Completed
Branch master (d54b6f)
by
unknown
17:38 queued 15:22
created
caffeinated/admin/new/pricing/Pricing_Admin_Page.core.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
         wp_enqueue_style('espresso-ui-theme');
342 342
         wp_register_style(
343 343
             'espresso_PRICING',
344
-            PRICING_ASSETS_URL . 'espresso_pricing_admin.css',
344
+            PRICING_ASSETS_URL.'espresso_pricing_admin.css',
345 345
             [],
346 346
             EVENT_ESPRESSO_VERSION
347 347
         );
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
         wp_enqueue_script('jquery-ui-widget');
354 354
         wp_register_script(
355 355
             'espresso_PRICING',
356
-            PRICING_ASSETS_URL . 'espresso_pricing_admin.js',
356
+            PRICING_ASSETS_URL.'espresso_pricing_admin.js',
357 357
             ['jquery'],
358 358
             EVENT_ESPRESSO_VERSION,
359 359
             true
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
      */
451 451
     protected function _price_overview_list_table()
452 452
     {
453
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
453
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
454 454
             'add_new_price',
455 455
             'add',
456 456
             [],
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
         // start with an empty array
478 478
         $event_pricing = [];
479 479
 
480
-        require_once(PRICING_ADMIN . 'Prices_List_Table.class.php');
480
+        require_once(PRICING_ADMIN.'Prices_List_Table.class.php');
481 481
 
482 482
         $orderby = $this->request->getRequestParam('orderby', '');
483 483
         $order   = $this->request->getRequestParam('order', 'ASC');
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
                 $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
556 556
         }
557 557
         // add PRC_ID to title if editing
558
-        $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title;
558
+        $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title.' # '.$PRC_ID : $this->_admin_page_title;
559 559
 
560 560
         if ($PRC_ID) {
561 561
             $price                    = EEM_Price::instance()->get_one_by_ID($PRC_ID);
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
             $this->_set_add_edit_form_tags('insert_price');
569 569
         }
570 570
 
571
-        if (! $price instanceof EE_Price) {
571
+        if ( ! $price instanceof EE_Price) {
572 572
             throw new RuntimeException(
573 573
                 sprintf(
574 574
                     esc_html__(
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
     public function _edit_price_details_meta_box(): string
627 627
     {
628 628
         return EEH_Template::display_template(
629
-            PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php',
629
+            PRICING_TEMPLATE_PATH.'pricing_details_main_meta_box.template.php',
630 630
             $this->_template_args,
631 631
             true
632 632
         );
@@ -789,19 +789,19 @@  discard block
 block discarded – undo
789 789
      */
790 790
     public function adjustTicketRelations(EEM_Base $entity_model, $entity_ID, string $action, int $result)
791 791
     {
792
-        if (! $entity_ID || (float) $result < 1) {
792
+        if ( ! $entity_ID || (float) $result < 1) {
793 793
             return;
794 794
         }
795 795
 
796 796
         $entity = $entity_model->get_one_by_ID($entity_ID);
797
-        if (! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) {
797
+        if ( ! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) {
798 798
             return;
799 799
         }
800 800
 
801 801
         // get default tickets for updating
802 802
         $default_tickets = EEM_Ticket::instance()->get_all_default_tickets();
803 803
         foreach ($default_tickets as $default_ticket) {
804
-            if (! $default_ticket instanceof EE_Ticket) {
804
+            if ( ! $default_ticket instanceof EE_Ticket) {
805 805
                 continue;
806 806
             }
807 807
             switch ($action) {
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
      */
877 877
     protected function _price_types_overview_list_table()
878 878
     {
879
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
879
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
880 880
             'add_new_price_type',
881 881
             'add_type',
882 882
             [],
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
     public function get_price_types_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false)
902 902
     {
903 903
         // start with an empty array
904
-        require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php');
904
+        require_once(PRICING_ADMIN.'Price_Types_List_Table.class.php');
905 905
 
906 906
         $orderby = $this->request->getRequestParam('orderby', '');
907 907
         $order   = $this->request->getRequestParam('order', 'ASC');
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
                 $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
963 963
         }
964 964
         // add PRT_ID to title if editing
965
-        $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title;
965
+        $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title.' # '.$PRT_ID : $this->_admin_page_title;
966 966
 
967 967
         if ($PRT_ID) {
968 968
             $price_type               = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
             $this->_set_add_edit_form_tags('insert_price_type');
974 974
         }
975 975
 
976
-        if (! $price_type instanceof EE_Price_Type) {
976
+        if ( ! $price_type instanceof EE_Price_Type) {
977 977
             throw new RuntimeException(
978 978
                 sprintf(
979 979
                     esc_html__(
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
     public function _edit_price_type_details_meta_box(): string
1024 1024
     {
1025 1025
         return EEH_Template::display_template(
1026
-            PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php',
1026
+            PRICING_TEMPLATE_PATH.'pricing_type_details_main_meta_box.template.php',
1027 1027
             $this->_template_args,
1028 1028
             true
1029 1029
         );
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
      */
1036 1036
     protected function set_price_type_column_values(): array
1037 1037
     {
1038
-        $base_type  = $this->request->getRequestParam(
1038
+        $base_type = $this->request->getRequestParam(
1039 1039
             'base_type',
1040 1040
             EEM_Price_Type::base_type_base_price,
1041 1041
             DataType::INTEGER
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
     {
1162 1162
         return '
1163 1163
             <a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >
1164
-                ' . esc_html__('learn more about how pricing works', 'event_espresso') . '
1164
+                ' . esc_html__('learn more about how pricing works', 'event_espresso').'
1165 1165
             </a>';
1166 1166
     }
1167 1167
 
@@ -1237,7 +1237,7 @@  discard block
 block discarded – undo
1237 1237
     public function _update_tax_settings()
1238 1238
     {
1239 1239
         $tax_settings = EE_Config::instance()->tax_settings;
1240
-        if (! $tax_settings instanceof EE_Tax_Config) {
1240
+        if ( ! $tax_settings instanceof EE_Tax_Config) {
1241 1241
             $tax_settings = new EE_Tax_Config();
1242 1242
         }
1243 1243
         try {
Please login to merge, or discard this patch.
Indentation   +1259 added lines, -1259 removed lines patch added patch discarded remove patch
@@ -12,1270 +12,1270 @@
 block discarded – undo
12 12
 class Pricing_Admin_Page extends EE_Admin_Page
13 13
 {
14 14
 
15
-    protected function _init_page_props()
16
-    {
17
-        $this->page_slug        = PRICING_PG_SLUG;
18
-        $this->page_label       = PRICING_LABEL;
19
-        $this->_admin_base_url  = PRICING_ADMIN_URL;
20
-        $this->_admin_base_path = PRICING_ADMIN;
21
-    }
22
-
23
-
24
-    protected function _ajax_hooks()
25
-    {
26
-        add_action('wp_ajax_espresso_update_prices_order', [$this, 'update_price_order']);
27
-    }
28
-
29
-
30
-    protected function _define_page_props()
31
-    {
32
-        $this->_admin_page_title = PRICING_LABEL;
33
-        $this->_labels           = [
34
-            'buttons' => [
35
-                'add'         => esc_html__('Add New Default Price', 'event_espresso'),
36
-                'edit'        => esc_html__('Edit Default Price', 'event_espresso'),
37
-                'delete'      => esc_html__('Delete Default Price', 'event_espresso'),
38
-                'add_type'    => esc_html__('Add New Default Price Type', 'event_espresso'),
39
-                'edit_type'   => esc_html__('Edit Price Type', 'event_espresso'),
40
-                'delete_type' => esc_html__('Delete Price Type', 'event_espresso'),
41
-            ],
42
-        ];
43
-    }
44
-
45
-
46
-    /**
47
-     * an array for storing request actions and their corresponding methods
48
-     *
49
-     * @return void
50
-     */
51
-    protected function _set_page_routes()
52
-    {
53
-        $PRC_ID             = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER);
54
-        $PRT_ID             = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
55
-        $this->_page_routes = [
56
-            'default'                     => [
57
-                'func'       => '_price_overview_list_table',
58
-                'capability' => 'ee_read_default_prices',
59
-            ],
60
-            'add_new_price'               => [
61
-                'func'       => '_edit_price_details',
62
-                'args'       => ['new_price' => true],
63
-                'capability' => 'ee_edit_default_prices',
64
-            ],
65
-            'edit_price'                  => [
66
-                'func'       => '_edit_price_details',
67
-                'args'       => ['new_price' => false],
68
-                'capability' => 'ee_edit_default_price',
69
-                'obj_id'     => $PRC_ID,
70
-            ],
71
-            'insert_price'                => [
72
-                'func'       => '_insert_or_update_price',
73
-                'args'       => ['new_price' => true],
74
-                'noheader'   => true,
75
-                'capability' => 'ee_edit_default_prices',
76
-            ],
77
-            'update_price'                => [
78
-                'func'       => '_insert_or_update_price',
79
-                'args'       => ['new_price' => false],
80
-                'noheader'   => true,
81
-                'capability' => 'ee_edit_default_price',
82
-                'obj_id'     => $PRC_ID,
83
-            ],
84
-            'trash_price'                 => [
85
-                'func'       => '_trash_or_restore_price',
86
-                'args'       => ['trash' => true],
87
-                'noheader'   => true,
88
-                'capability' => 'ee_delete_default_price',
89
-                'obj_id'     => $PRC_ID,
90
-            ],
91
-            'restore_price'               => [
92
-                'func'       => '_trash_or_restore_price',
93
-                'args'       => ['trash' => false],
94
-                'noheader'   => true,
95
-                'capability' => 'ee_delete_default_price',
96
-                'obj_id'     => $PRC_ID,
97
-            ],
98
-            'delete_price'                => [
99
-                'func'       => '_delete_price',
100
-                'noheader'   => true,
101
-                'capability' => 'ee_delete_default_price',
102
-                'obj_id'     => $PRC_ID,
103
-            ],
104
-            'espresso_update_price_order' => [
105
-                'func'       => 'update_price_order',
106
-                'noheader'   => true,
107
-                'capability' => 'ee_edit_default_prices',
108
-            ],
109
-            // price types
110
-            'price_types'                 => [
111
-                'func'       => '_price_types_overview_list_table',
112
-                'capability' => 'ee_read_default_price_types',
113
-            ],
114
-            'add_new_price_type'          => [
115
-                'func'       => '_edit_price_type_details',
116
-                'capability' => 'ee_edit_default_price_types',
117
-            ],
118
-            'edit_price_type'             => [
119
-                'func'       => '_edit_price_type_details',
120
-                'capability' => 'ee_edit_default_price_type',
121
-                'obj_id'     => $PRT_ID,
122
-            ],
123
-            'insert_price_type'           => [
124
-                'func'       => '_insert_or_update_price_type',
125
-                'args'       => ['new_price_type' => true],
126
-                'noheader'   => true,
127
-                'capability' => 'ee_edit_default_price_types',
128
-            ],
129
-            'update_price_type'           => [
130
-                'func'       => '_insert_or_update_price_type',
131
-                'args'       => ['new_price_type' => false],
132
-                'noheader'   => true,
133
-                'capability' => 'ee_edit_default_price_type',
134
-                'obj_id'     => $PRT_ID,
135
-            ],
136
-            'trash_price_type'            => [
137
-                'func'       => '_trash_or_restore_price_type',
138
-                'args'       => ['trash' => true],
139
-                'noheader'   => true,
140
-                'capability' => 'ee_delete_default_price_type',
141
-                'obj_id'     => $PRT_ID,
142
-            ],
143
-            'restore_price_type'          => [
144
-                'func'       => '_trash_or_restore_price_type',
145
-                'args'       => ['trash' => false],
146
-                'noheader'   => true,
147
-                'capability' => 'ee_delete_default_price_type',
148
-                'obj_id'     => $PRT_ID,
149
-            ],
150
-            'delete_price_type'           => [
151
-                'func'       => '_delete_price_type',
152
-                'noheader'   => true,
153
-                'capability' => 'ee_delete_default_price_type',
154
-                'obj_id'     => $PRT_ID,
155
-            ],
156
-            'tax_settings'                => [
157
-                'func'       => '_tax_settings',
158
-                'capability' => 'manage_options',
159
-            ],
160
-            'update_tax_settings'         => [
161
-                'func'       => '_update_tax_settings',
162
-                'capability' => 'manage_options',
163
-                'noheader'   => true,
164
-            ],
165
-        ];
166
-    }
167
-
168
-
169
-    protected function _set_page_config()
170
-    {
171
-        $PRC_ID             = $this->request->getRequestParam('id', 0, DataType::INTEGER);
172
-        $this->_page_config = [
173
-            'default'            => [
174
-                'nav'           => [
175
-                    'label' => esc_html__('Default Pricing', 'event_espresso'),
176
-                    'order' => 10,
177
-                ],
178
-                'list_table'    => 'Prices_List_Table',
179
-                'metaboxes'     => $this->_default_espresso_metaboxes,
180
-                'help_tabs'     => [
181
-                    'pricing_default_pricing_help_tab'                           => [
182
-                        'title'    => esc_html__('Default Pricing', 'event_espresso'),
183
-                        'filename' => 'pricing_default_pricing',
184
-                    ],
185
-                    'pricing_default_pricing_table_column_headings_help_tab'     => [
186
-                        'title'    => esc_html__('Default Pricing Table Column Headings', 'event_espresso'),
187
-                        'filename' => 'pricing_default_pricing_table_column_headings',
188
-                    ],
189
-                    'pricing_default_pricing_views_bulk_actions_search_help_tab' => [
190
-                        'title'    => esc_html__('Default Pricing Views & Bulk Actions & Search', 'event_espresso'),
191
-                        'filename' => 'pricing_default_pricing_views_bulk_actions_search',
192
-                    ],
193
-                ],
194
-                'require_nonce' => false,
195
-            ],
196
-            'add_new_price'      => [
197
-                'nav'           => [
198
-                    'label'      => esc_html__('Add New Default Price', 'event_espresso'),
199
-                    'order'      => 20,
200
-                    'persistent' => false,
201
-                ],
202
-                'help_tabs'     => [
203
-                    'add_new_default_price_help_tab' => [
204
-                        'title'    => esc_html__('Add New Default Price', 'event_espresso'),
205
-                        'filename' => 'pricing_add_new_default_price',
206
-                    ],
207
-                ],
208
-                'metaboxes'     => array_merge(
209
-                    ['_publish_post_box'],
210
-                    $this->_default_espresso_metaboxes
211
-                ),
212
-                'require_nonce' => false,
213
-            ],
214
-            'edit_price'         => [
215
-                'nav'           => [
216
-                    'label'      => esc_html__('Edit Default Price', 'event_espresso'),
217
-                    'order'      => 20,
218
-                    'url'        => $PRC_ID
219
-                        ? add_query_arg(['id' => $PRC_ID], $this->_current_page_view_url)
220
-                        : $this->_admin_base_url,
221
-                    'persistent' => false,
222
-                ],
223
-                'metaboxes'     => array_merge(
224
-                    ['_publish_post_box'],
225
-                    $this->_default_espresso_metaboxes
226
-                ),
227
-                'help_tabs'     => [
228
-                    'edit_default_price_help_tab' => [
229
-                        'title'    => esc_html__('Edit Default Price', 'event_espresso'),
230
-                        'filename' => 'pricing_edit_default_price',
231
-                    ],
232
-                ],
233
-                'require_nonce' => false,
234
-            ],
235
-            'price_types'        => [
236
-                'nav'           => [
237
-                    'label' => esc_html__('Price Types', 'event_espresso'),
238
-                    'order' => 30,
239
-                ],
240
-                'list_table'    => 'Price_Types_List_Table',
241
-                'help_tabs'     => [
242
-                    'pricing_price_types_help_tab'                           => [
243
-                        'title'    => esc_html__('Price Types', 'event_espresso'),
244
-                        'filename' => 'pricing_price_types',
245
-                    ],
246
-                    'pricing_price_types_table_column_headings_help_tab'     => [
247
-                        'title'    => esc_html__('Price Types Table Column Headings', 'event_espresso'),
248
-                        'filename' => 'pricing_price_types_table_column_headings',
249
-                    ],
250
-                    'pricing_price_types_views_bulk_actions_search_help_tab' => [
251
-                        'title'    => esc_html__('Price Types Views & Bulk Actions & Search', 'event_espresso'),
252
-                        'filename' => 'pricing_price_types_views_bulk_actions_search',
253
-                    ],
254
-                ],
255
-                'metaboxes'     => $this->_default_espresso_metaboxes,
256
-                'require_nonce' => false,
257
-            ],
258
-            'add_new_price_type' => [
259
-                'nav'           => [
260
-                    'label'      => esc_html__('Add New Price Type', 'event_espresso'),
261
-                    'order'      => 40,
262
-                    'persistent' => false,
263
-                ],
264
-                'help_tabs'     => [
265
-                    'add_new_price_type_help_tab' => [
266
-                        'title'    => esc_html__('Add New Price Type', 'event_espresso'),
267
-                        'filename' => 'pricing_add_new_price_type',
268
-                    ],
269
-                ],
270
-                'metaboxes'     => array_merge(
271
-                    ['_publish_post_box'],
272
-                    $this->_default_espresso_metaboxes
273
-                ),
274
-                'require_nonce' => false,
275
-            ],
276
-            'edit_price_type'    => [
277
-                'nav'           => [
278
-                    'label'      => esc_html__('Edit Price Type', 'event_espresso'),
279
-                    'order'      => 40,
280
-                    'persistent' => false,
281
-                ],
282
-                'help_tabs'     => [
283
-                    'edit_price_type_help_tab' => [
284
-                        'title'    => esc_html__('Edit Price Type', 'event_espresso'),
285
-                        'filename' => 'pricing_edit_price_type',
286
-                    ],
287
-                ],
288
-                'metaboxes'     => array_merge(
289
-                    ['_publish_post_box'],
290
-                    $this->_default_espresso_metaboxes
291
-                ),
292
-                'require_nonce' => false,
293
-            ],
294
-            'tax_settings'       => [
295
-                'nav'           => [
296
-                    'label' => esc_html__('Tax Settings', 'event_espresso'),
297
-                    'order' => 40,
298
-                ],
299
-                'labels'        => [
300
-                    'publishbox' => esc_html__('Update Tax Settings', 'event_espresso'),
301
-                ],
302
-                'metaboxes'     => array_merge(
303
-                    ['_publish_post_box'],
304
-                    $this->_default_espresso_metaboxes
305
-                ),
306
-                'require_nonce' => true,
307
-            ],
308
-        ];
309
-    }
310
-
311
-
312
-    protected function _add_screen_options()
313
-    {
314
-        // todo
315
-    }
316
-
317
-
318
-    protected function _add_screen_options_default()
319
-    {
320
-        $this->_per_page_screen_option();
321
-    }
322
-
323
-
324
-    protected function _add_screen_options_price_types()
325
-    {
326
-        $page_title              = $this->_admin_page_title;
327
-        $this->_admin_page_title = esc_html__('Price Types', 'event_espresso');
328
-        $this->_per_page_screen_option();
329
-        $this->_admin_page_title = $page_title;
330
-    }
331
-
332
-
333
-    protected function _add_feature_pointers()
334
-    {
335
-    }
336
-
337
-
338
-    public function load_scripts_styles()
339
-    {
340
-        // styles
341
-        wp_enqueue_style('espresso-ui-theme');
342
-        wp_register_style(
343
-            'espresso_PRICING',
344
-            PRICING_ASSETS_URL . 'espresso_pricing_admin.css',
345
-            [],
346
-            EVENT_ESPRESSO_VERSION
347
-        );
348
-        wp_enqueue_style('espresso_PRICING');
349
-
350
-        // scripts
351
-        wp_enqueue_script('ee_admin_js');
352
-        wp_enqueue_script('jquery-ui-position');
353
-        wp_enqueue_script('jquery-ui-widget');
354
-        wp_register_script(
355
-            'espresso_PRICING',
356
-            PRICING_ASSETS_URL . 'espresso_pricing_admin.js',
357
-            ['jquery'],
358
-            EVENT_ESPRESSO_VERSION,
359
-            true
360
-        );
361
-        wp_enqueue_script('espresso_PRICING');
362
-    }
363
-
364
-
365
-    public function load_scripts_styles_default()
366
-    {
367
-        wp_enqueue_script('espresso_ajax_table_sorting');
368
-    }
369
-
370
-
371
-    public function admin_footer_scripts()
372
-    {
373
-    }
374
-
375
-
376
-    public function admin_init()
377
-    {
378
-    }
379
-
380
-
381
-    public function admin_notices()
382
-    {
383
-    }
384
-
385
-
386
-    protected function _set_list_table_views_default()
387
-    {
388
-        $this->_views = [
389
-            'all' => [
390
-                'slug'        => 'all',
391
-                'label'       => esc_html__('View All Default Pricing', 'event_espresso'),
392
-                'count'       => 0,
393
-                'bulk_action' => [
394
-                    'trash_price' => esc_html__('Move to Trash', 'event_espresso'),
395
-                ],
396
-            ],
397
-        ];
398
-
399
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) {
400
-            $this->_views['trashed'] = [
401
-                'slug'        => 'trashed',
402
-                'label'       => esc_html__('Trash', 'event_espresso'),
403
-                'count'       => 0,
404
-                'bulk_action' => [
405
-                    'restore_price' => esc_html__('Restore from Trash', 'event_espresso'),
406
-                    'delete_price'  => esc_html__('Delete Permanently', 'event_espresso'),
407
-                ],
408
-            ];
409
-        }
410
-    }
411
-
412
-
413
-    protected function _set_list_table_views_price_types()
414
-    {
415
-        $this->_views = [
416
-            'all' => [
417
-                'slug'        => 'all',
418
-                'label'       => esc_html__('All', 'event_espresso'),
419
-                'count'       => 0,
420
-                'bulk_action' => [
421
-                    'trash_price_type' => esc_html__('Move to Trash', 'event_espresso'),
422
-                ],
423
-            ],
424
-        ];
425
-
426
-        if (
427
-            EE_Registry::instance()->CAP->current_user_can(
428
-                'ee_delete_default_price_types',
429
-                'pricing_trash_price_type'
430
-            )
431
-        ) {
432
-            $this->_views['trashed'] = [
433
-                'slug'        => 'trashed',
434
-                'label'       => esc_html__('Trash', 'event_espresso'),
435
-                'count'       => 0,
436
-                'bulk_action' => [
437
-                    'restore_price_type' => esc_html__('Restore from Trash', 'event_espresso'),
438
-                    'delete_price_type'  => esc_html__('Delete Permanently', 'event_espresso'),
439
-                ],
440
-            ];
441
-        }
442
-    }
443
-
444
-
445
-    /**
446
-     * generates HTML for main Prices Admin page
447
-     *
448
-     * @return void
449
-     * @throws EE_Error
450
-     */
451
-    protected function _price_overview_list_table()
452
-    {
453
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
454
-            'add_new_price',
455
-            'add',
456
-            [],
457
-            'add-new-h2'
458
-        );
459
-        $this->_admin_page_title .= $this->_learn_more_about_pricing_link();
460
-        $this->_search_btn_label = esc_html__('Default Prices', 'event_espresso');
461
-        $this->display_admin_list_table_page_with_sidebar();
462
-    }
463
-
464
-
465
-    /**
466
-     * retrieve data for Prices List table
467
-     *
468
-     * @param int  $per_page how many prices displayed per page
469
-     * @param bool $count    return the count or objects
470
-     * @param bool $trashed  whether the current view is of the trash can - eww yuck!
471
-     * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects
472
-     * @throws EE_Error
473
-     * @throws ReflectionException
474
-     */
475
-    public function get_prices_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false)
476
-    {
477
-        // start with an empty array
478
-        $event_pricing = [];
479
-
480
-        require_once(PRICING_ADMIN . 'Prices_List_Table.class.php');
481
-
482
-        $orderby = $this->request->getRequestParam('orderby', '');
483
-        $order   = $this->request->getRequestParam('order', 'ASC');
484
-
485
-        switch ($orderby) {
486
-            case 'name':
487
-                $orderby = ['PRC_name' => $order];
488
-                break;
489
-            case 'type':
490
-                $orderby = ['Price_Type.PRT_name' => $order];
491
-                break;
492
-            case 'amount':
493
-                $orderby = ['PRC_amount' => $order];
494
-                break;
495
-            default:
496
-                $orderby = ['PRC_order' => $order, 'Price_Type.PRT_order' => $order, 'PRC_ID' => $order];
497
-        }
498
-
499
-        $current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER);
500
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER);
501
-
502
-        $where = [
503
-            'PRC_is_default' => 1,
504
-            'PRC_deleted'    => $trashed,
505
-        ];
506
-
507
-        $offset = ($current_page - 1) * $per_page;
508
-        $limit  = [$offset, $per_page];
509
-
510
-        $search_term = $this->request->getRequestParam('s');
511
-        if ($search_term) {
512
-            $search_term = "%{$search_term}%";
513
-            $where['OR'] = [
514
-                'PRC_name'            => ['LIKE', $search_term],
515
-                'PRC_desc'            => ['LIKE', $search_term],
516
-                'PRC_amount'          => ['LIKE', $search_term],
517
-                'Price_Type.PRT_name' => ['LIKE', $search_term],
518
-            ];
519
-        }
520
-
521
-        $query_params = [
522
-            $where,
523
-            'order_by' => $orderby,
524
-            'limit'    => $limit,
525
-            'group_by' => 'PRC_ID',
526
-        ];
527
-
528
-        if ($count) {
529
-            return $trashed
530
-                ? EEM_Price::instance()->count([$where])
531
-                : EEM_Price::instance()->count_deleted_and_undeleted([$where]);
532
-        }
533
-        return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params);
534
-    }
535
-
536
-
537
-    /**
538
-     * @return void
539
-     * @throws EE_Error
540
-     * @throws ReflectionException
541
-     */
542
-    protected function _edit_price_details()
543
-    {
544
-        // grab price ID
545
-        $PRC_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER);
546
-        // change page title based on request action
547
-        switch ($this->_req_action) {
548
-            case 'add_new_price':
549
-                $this->_admin_page_title = esc_html__('Add New Price', 'event_espresso');
550
-                break;
551
-            case 'edit_price':
552
-                $this->_admin_page_title = esc_html__('Edit Price', 'event_espresso');
553
-                break;
554
-            default:
555
-                $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
556
-        }
557
-        // add PRC_ID to title if editing
558
-        $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title;
559
-
560
-        if ($PRC_ID) {
561
-            $price                    = EEM_Price::instance()->get_one_by_ID($PRC_ID);
562
-            $additional_hidden_fields = [
563
-                'PRC_ID' => ['type' => 'hidden', 'value' => $PRC_ID],
564
-            ];
565
-            $this->_set_add_edit_form_tags('update_price', $additional_hidden_fields);
566
-        } else {
567
-            $price = EEM_Price::instance()->get_new_price();
568
-            $this->_set_add_edit_form_tags('insert_price');
569
-        }
570
-
571
-        if (! $price instanceof EE_Price) {
572
-            throw new RuntimeException(
573
-                sprintf(
574
-                    esc_html__(
575
-                        'A valid Price could not be retrieved from the database with ID: %1$s',
576
-                        'event_espresso'
577
-                    ),
578
-                    $PRC_ID
579
-                )
580
-            );
581
-        }
582
-
583
-        $this->_template_args['PRC_ID'] = $PRC_ID;
584
-        $this->_template_args['price']  = $price;
585
-
586
-        $default_base_price = $price->type_obj() && $price->type_obj()->base_type() === 1;
587
-
588
-        $this->_template_args['default_base_price'] = $default_base_price;
589
-
590
-        // get price types
591
-        $price_types = EEM_Price_Type::instance()->get_all([['PBT_ID' => ['!=', 1]]]);
592
-        if (empty($price_types)) {
593
-            $msg = esc_html__(
594
-                'You have no price types defined. Please add a price type before adding a price.',
595
-                'event_espresso'
596
-            );
597
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
598
-            $this->display_admin_page_with_sidebar();
599
-        }
600
-        $attributes       = [];
601
-        $price_type_names = [];
602
-        $attributes[]     = 'id="PRT_ID"';
603
-        if ($default_base_price) {
604
-            $attributes[]       = 'disabled="disabled"';
605
-            $price_type_names[] = ['id' => 1, 'text' => esc_html__('Base Price', 'event_espresso')];
606
-        }
607
-        foreach ($price_types as $type) {
608
-            $price_type_names[] = ['id' => $type->ID(), 'text' => $type->name()];
609
-        }
610
-        $this->_template_args['attributes']  = implode(' ', $attributes);
611
-        $this->_template_args['price_types'] = $price_type_names;
612
-
613
-        $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
614
-        $this->_template_args['admin_page_content']            = $this->_edit_price_details_meta_box();
615
-
616
-        $this->_set_publish_post_box_vars('id', $PRC_ID);
617
-        // the details template wrapper
618
-        $this->display_admin_page_with_sidebar();
619
-    }
620
-
621
-
622
-    /**
623
-     *
624
-     * @return string
625
-     */
626
-    public function _edit_price_details_meta_box(): string
627
-    {
628
-        return EEH_Template::display_template(
629
-            PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php',
630
-            $this->_template_args,
631
-            true
632
-        );
633
-    }
634
-
635
-
636
-    /**
637
-     * @return array
638
-     * @throws EE_Error
639
-     * @throws ReflectionException
640
-     */
641
-    protected function set_price_column_values(): array
642
-    {
643
-        $PRC_order = 0;
644
-        $PRT_ID    = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
645
-        if ($PRT_ID) {
646
-            /** @var EE_Price_Type $price_type */
647
-            $price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
648
-            if ($price_type instanceof EE_Price_Type) {
649
-                $PRC_order = $price_type->order();
650
-            }
651
-        }
652
-        return [
653
-            'PRT_ID'         => $PRT_ID,
654
-            'PRC_amount'     => $this->request->getRequestParam('PRC_amount', 0, DataType::FLOAT),
655
-            'PRC_name'       => $this->request->getRequestParam('PRC_name'),
656
-            'PRC_desc'       => $this->request->getRequestParam('PRC_desc'),
657
-            'PRC_is_default' => 1,
658
-            'PRC_overrides'  => null,
659
-            'PRC_order'      => $PRC_order,
660
-            'PRC_deleted'    => 0,
661
-            'PRC_parent'     => 0,
662
-        ];
663
-    }
664
-
665
-
666
-    /**
667
-     * @param bool $insert - whether to insert or update
668
-     * @return void
669
-     * @throws EE_Error
670
-     * @throws ReflectionException
671
-     */
672
-    protected function _insert_or_update_price(bool $insert = false)
673
-    {
674
-        // why be so pessimistic ???  : (
675
-        $updated = 0;
676
-
677
-        $set_column_values = $this->set_price_column_values();
678
-        // is this a new Price ?
679
-        if ($insert) {
680
-            // run the insert
681
-            $PRC_ID = EEM_Price::instance()->insert($set_column_values);
682
-            if ($PRC_ID) {
683
-                // make sure this new price modifier is attached to the ticket but ONLY if it is not a tax type
684
-                $price = EEM_price::instance()->get_one_by_ID($PRC_ID);
685
-                if (
686
-                    $price instanceof EE_Price
687
-                    && $price->type_obj() instanceof EE_Price_type
688
-                    && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax
689
-                ) {
690
-                    $ticket = EEM_Ticket::instance()->get_one_by_ID(1);
691
-                    $ticket->_add_relation_to($price, 'Price');
692
-                    $ticket->save();
693
-                }
694
-                $updated = 1;
695
-            }
696
-            $action_desc = 'created';
697
-        } else {
698
-            $PRC_ID = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER);
699
-            // run the update
700
-            $where_cols_n_values = ['PRC_ID' => $PRC_ID];
701
-            $updated             = EEM_Price::instance()->update($set_column_values, [$where_cols_n_values]);
702
-
703
-            $price = EEM_Price::instance()->get_one_by_ID($PRC_ID);
704
-            if ($price instanceof EE_Price && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
705
-                // if this is $PRC_ID == 1,
706
-                // then we need to update the default ticket attached to this price so the TKT_price value is updated.
707
-                if ($PRC_ID === 1) {
708
-                    $ticket = $price->get_first_related('Ticket');
709
-                    if ($ticket) {
710
-                        $ticket->set('TKT_price', $price->get('PRC_amount'));
711
-                        $ticket->set('TKT_name', $price->get('PRC_name'));
712
-                        $ticket->set('TKT_description', $price->get('PRC_desc'));
713
-                        $ticket->save();
714
-                    }
715
-                } else {
716
-                    // we make sure this price is attached to base ticket. but ONLY if its not a tax ticket type.
717
-                    $ticket = EEM_Ticket::instance()->get_one_by_ID(1);
718
-                    $ticket->_add_relation_to($PRC_ID, 'Price');
719
-                    $ticket->save();
720
-                }
721
-            }
722
-
723
-            $action_desc = 'updated';
724
-        }
725
-
726
-        $query_args = ['action' => 'edit_price', 'id' => $PRC_ID];
727
-
728
-        $this->_redirect_after_action($updated, 'Prices', $action_desc, $query_args);
729
-    }
730
-
731
-
732
-    /**
733
-     * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE)
734
-     * @return void
735
-     * @throws EE_Error
736
-     * @throws ReflectionException
737
-     */
738
-    protected function _trash_or_restore_price(bool $trash = true)
739
-    {
740
-        $entity_model = EEM_Price::instance();
741
-        $action       = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE;
742
-        $result       = $this->trashRestoreDeleteEntities(
743
-            $entity_model,
744
-            'id',
745
-            $action,
746
-            'PRC_deleted',
747
-            [$this, 'adjustTicketRelations']
748
-        );
749
-
750
-        if ($result) {
751
-            $msg = $trash
752
-                ? esc_html(
753
-                    _n(
754
-                        'The Price has been trashed',
755
-                        'The Prices have been trashed',
756
-                        $result,
757
-                        'event_espresso'
758
-                    )
759
-                )
760
-                : esc_html(
761
-                    _n(
762
-                        'The Price has been restored',
763
-                        'The Prices have been restored',
764
-                        $result,
765
-                        'event_espresso'
766
-                    )
767
-                );
768
-            EE_Error::add_success($msg);
769
-        }
770
-
771
-        $this->_redirect_after_action(
772
-            $result,
773
-            _n('Price', 'Prices', $result, 'event_espresso'),
774
-            $trash ? 'trashed' : 'restored',
775
-            ['action' => 'default'],
776
-            true
777
-        );
778
-    }
779
-
780
-
781
-    /**
782
-     * @param EEM_Base   $entity_model
783
-     * @param int|string $entity_ID
784
-     * @param string     $action
785
-     * @param int        $result
786
-     * @throws EE_Error
787
-     * @throws ReflectionException
788
-     * @since $VID:$
789
-     */
790
-    public function adjustTicketRelations(EEM_Base $entity_model, $entity_ID, string $action, int $result)
791
-    {
792
-        if (! $entity_ID || (float) $result < 1) {
793
-            return;
794
-        }
795
-
796
-        $entity = $entity_model->get_one_by_ID($entity_ID);
797
-        if (! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) {
798
-            return;
799
-        }
800
-
801
-        // get default tickets for updating
802
-        $default_tickets = EEM_Ticket::instance()->get_all_default_tickets();
803
-        foreach ($default_tickets as $default_ticket) {
804
-            if (! $default_ticket instanceof EE_Ticket) {
805
-                continue;
806
-            }
807
-            switch ($action) {
808
-                case EE_Admin_List_Table::ACTION_DELETE:
809
-                case EE_Admin_List_Table::ACTION_TRASH:
810
-                    // if trashing then remove relations to base default ticket.
811
-                    $default_ticket->_remove_relation_to($entity_ID, 'Price');
812
-                    break;
813
-                case EE_Admin_List_Table::ACTION_RESTORE:
814
-                    // if restoring then add back to base default ticket
815
-                    $default_ticket->_add_relation_to($entity_ID, 'Price');
816
-                    break;
817
-            }
818
-            $default_ticket->save();
819
-        }
820
-    }
821
-
822
-
823
-    /**
824
-     * @return void
825
-     * @throws EE_Error
826
-     * @throws ReflectionException
827
-     */
828
-    protected function _delete_price()
829
-    {
830
-        $entity_model = EEM_Price::instance();
831
-        $deleted      = $this->trashRestoreDeleteEntities($entity_model, 'id');
832
-        $entity       = $entity_model->item_name($deleted);
833
-        $this->_redirect_after_action($deleted, $entity, 'deleted', ['action' => 'default']);
834
-    }
835
-
836
-
837
-    /**
838
-     * @throws EE_Error
839
-     * @throws ReflectionException
840
-     */
841
-    public function update_price_order()
842
-    {
843
-        // grab our row IDs
844
-        $row_ids = $this->request->getRequestParam('row_ids', '');
845
-        $row_ids = explode(',', rtrim($row_ids, ','));
846
-
847
-        $all_updated = true;
848
-        foreach ($row_ids as $i => $row_id) {
849
-            // Update the prices when re-ordering
850
-            $fields_n_values = ['PRC_order' => $i + 1];
851
-            $query_params    = [['PRC_ID' => absint($row_id)]];
852
-            // any failure will toggle $all_updated to false
853
-            $all_updated = $row_id && EEM_Price::instance()->update($fields_n_values, $query_params) !== false
854
-                ? $all_updated
855
-                : false;
856
-        }
857
-        $success = $all_updated ? esc_html__('Price order was updated successfully.', 'event_espresso') : false;
858
-        $errors  = ! $all_updated ? esc_html__('An error occurred. The price order was not updated.', 'event_espresso')
859
-            : false;
860
-
861
-        echo wp_json_encode(['return_data' => false, 'success' => $success, 'errors' => $errors]);
862
-        die();
863
-    }
864
-
865
-
866
-    /******************************************************************************************************************
15
+	protected function _init_page_props()
16
+	{
17
+		$this->page_slug        = PRICING_PG_SLUG;
18
+		$this->page_label       = PRICING_LABEL;
19
+		$this->_admin_base_url  = PRICING_ADMIN_URL;
20
+		$this->_admin_base_path = PRICING_ADMIN;
21
+	}
22
+
23
+
24
+	protected function _ajax_hooks()
25
+	{
26
+		add_action('wp_ajax_espresso_update_prices_order', [$this, 'update_price_order']);
27
+	}
28
+
29
+
30
+	protected function _define_page_props()
31
+	{
32
+		$this->_admin_page_title = PRICING_LABEL;
33
+		$this->_labels           = [
34
+			'buttons' => [
35
+				'add'         => esc_html__('Add New Default Price', 'event_espresso'),
36
+				'edit'        => esc_html__('Edit Default Price', 'event_espresso'),
37
+				'delete'      => esc_html__('Delete Default Price', 'event_espresso'),
38
+				'add_type'    => esc_html__('Add New Default Price Type', 'event_espresso'),
39
+				'edit_type'   => esc_html__('Edit Price Type', 'event_espresso'),
40
+				'delete_type' => esc_html__('Delete Price Type', 'event_espresso'),
41
+			],
42
+		];
43
+	}
44
+
45
+
46
+	/**
47
+	 * an array for storing request actions and their corresponding methods
48
+	 *
49
+	 * @return void
50
+	 */
51
+	protected function _set_page_routes()
52
+	{
53
+		$PRC_ID             = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER);
54
+		$PRT_ID             = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
55
+		$this->_page_routes = [
56
+			'default'                     => [
57
+				'func'       => '_price_overview_list_table',
58
+				'capability' => 'ee_read_default_prices',
59
+			],
60
+			'add_new_price'               => [
61
+				'func'       => '_edit_price_details',
62
+				'args'       => ['new_price' => true],
63
+				'capability' => 'ee_edit_default_prices',
64
+			],
65
+			'edit_price'                  => [
66
+				'func'       => '_edit_price_details',
67
+				'args'       => ['new_price' => false],
68
+				'capability' => 'ee_edit_default_price',
69
+				'obj_id'     => $PRC_ID,
70
+			],
71
+			'insert_price'                => [
72
+				'func'       => '_insert_or_update_price',
73
+				'args'       => ['new_price' => true],
74
+				'noheader'   => true,
75
+				'capability' => 'ee_edit_default_prices',
76
+			],
77
+			'update_price'                => [
78
+				'func'       => '_insert_or_update_price',
79
+				'args'       => ['new_price' => false],
80
+				'noheader'   => true,
81
+				'capability' => 'ee_edit_default_price',
82
+				'obj_id'     => $PRC_ID,
83
+			],
84
+			'trash_price'                 => [
85
+				'func'       => '_trash_or_restore_price',
86
+				'args'       => ['trash' => true],
87
+				'noheader'   => true,
88
+				'capability' => 'ee_delete_default_price',
89
+				'obj_id'     => $PRC_ID,
90
+			],
91
+			'restore_price'               => [
92
+				'func'       => '_trash_or_restore_price',
93
+				'args'       => ['trash' => false],
94
+				'noheader'   => true,
95
+				'capability' => 'ee_delete_default_price',
96
+				'obj_id'     => $PRC_ID,
97
+			],
98
+			'delete_price'                => [
99
+				'func'       => '_delete_price',
100
+				'noheader'   => true,
101
+				'capability' => 'ee_delete_default_price',
102
+				'obj_id'     => $PRC_ID,
103
+			],
104
+			'espresso_update_price_order' => [
105
+				'func'       => 'update_price_order',
106
+				'noheader'   => true,
107
+				'capability' => 'ee_edit_default_prices',
108
+			],
109
+			// price types
110
+			'price_types'                 => [
111
+				'func'       => '_price_types_overview_list_table',
112
+				'capability' => 'ee_read_default_price_types',
113
+			],
114
+			'add_new_price_type'          => [
115
+				'func'       => '_edit_price_type_details',
116
+				'capability' => 'ee_edit_default_price_types',
117
+			],
118
+			'edit_price_type'             => [
119
+				'func'       => '_edit_price_type_details',
120
+				'capability' => 'ee_edit_default_price_type',
121
+				'obj_id'     => $PRT_ID,
122
+			],
123
+			'insert_price_type'           => [
124
+				'func'       => '_insert_or_update_price_type',
125
+				'args'       => ['new_price_type' => true],
126
+				'noheader'   => true,
127
+				'capability' => 'ee_edit_default_price_types',
128
+			],
129
+			'update_price_type'           => [
130
+				'func'       => '_insert_or_update_price_type',
131
+				'args'       => ['new_price_type' => false],
132
+				'noheader'   => true,
133
+				'capability' => 'ee_edit_default_price_type',
134
+				'obj_id'     => $PRT_ID,
135
+			],
136
+			'trash_price_type'            => [
137
+				'func'       => '_trash_or_restore_price_type',
138
+				'args'       => ['trash' => true],
139
+				'noheader'   => true,
140
+				'capability' => 'ee_delete_default_price_type',
141
+				'obj_id'     => $PRT_ID,
142
+			],
143
+			'restore_price_type'          => [
144
+				'func'       => '_trash_or_restore_price_type',
145
+				'args'       => ['trash' => false],
146
+				'noheader'   => true,
147
+				'capability' => 'ee_delete_default_price_type',
148
+				'obj_id'     => $PRT_ID,
149
+			],
150
+			'delete_price_type'           => [
151
+				'func'       => '_delete_price_type',
152
+				'noheader'   => true,
153
+				'capability' => 'ee_delete_default_price_type',
154
+				'obj_id'     => $PRT_ID,
155
+			],
156
+			'tax_settings'                => [
157
+				'func'       => '_tax_settings',
158
+				'capability' => 'manage_options',
159
+			],
160
+			'update_tax_settings'         => [
161
+				'func'       => '_update_tax_settings',
162
+				'capability' => 'manage_options',
163
+				'noheader'   => true,
164
+			],
165
+		];
166
+	}
167
+
168
+
169
+	protected function _set_page_config()
170
+	{
171
+		$PRC_ID             = $this->request->getRequestParam('id', 0, DataType::INTEGER);
172
+		$this->_page_config = [
173
+			'default'            => [
174
+				'nav'           => [
175
+					'label' => esc_html__('Default Pricing', 'event_espresso'),
176
+					'order' => 10,
177
+				],
178
+				'list_table'    => 'Prices_List_Table',
179
+				'metaboxes'     => $this->_default_espresso_metaboxes,
180
+				'help_tabs'     => [
181
+					'pricing_default_pricing_help_tab'                           => [
182
+						'title'    => esc_html__('Default Pricing', 'event_espresso'),
183
+						'filename' => 'pricing_default_pricing',
184
+					],
185
+					'pricing_default_pricing_table_column_headings_help_tab'     => [
186
+						'title'    => esc_html__('Default Pricing Table Column Headings', 'event_espresso'),
187
+						'filename' => 'pricing_default_pricing_table_column_headings',
188
+					],
189
+					'pricing_default_pricing_views_bulk_actions_search_help_tab' => [
190
+						'title'    => esc_html__('Default Pricing Views & Bulk Actions & Search', 'event_espresso'),
191
+						'filename' => 'pricing_default_pricing_views_bulk_actions_search',
192
+					],
193
+				],
194
+				'require_nonce' => false,
195
+			],
196
+			'add_new_price'      => [
197
+				'nav'           => [
198
+					'label'      => esc_html__('Add New Default Price', 'event_espresso'),
199
+					'order'      => 20,
200
+					'persistent' => false,
201
+				],
202
+				'help_tabs'     => [
203
+					'add_new_default_price_help_tab' => [
204
+						'title'    => esc_html__('Add New Default Price', 'event_espresso'),
205
+						'filename' => 'pricing_add_new_default_price',
206
+					],
207
+				],
208
+				'metaboxes'     => array_merge(
209
+					['_publish_post_box'],
210
+					$this->_default_espresso_metaboxes
211
+				),
212
+				'require_nonce' => false,
213
+			],
214
+			'edit_price'         => [
215
+				'nav'           => [
216
+					'label'      => esc_html__('Edit Default Price', 'event_espresso'),
217
+					'order'      => 20,
218
+					'url'        => $PRC_ID
219
+						? add_query_arg(['id' => $PRC_ID], $this->_current_page_view_url)
220
+						: $this->_admin_base_url,
221
+					'persistent' => false,
222
+				],
223
+				'metaboxes'     => array_merge(
224
+					['_publish_post_box'],
225
+					$this->_default_espresso_metaboxes
226
+				),
227
+				'help_tabs'     => [
228
+					'edit_default_price_help_tab' => [
229
+						'title'    => esc_html__('Edit Default Price', 'event_espresso'),
230
+						'filename' => 'pricing_edit_default_price',
231
+					],
232
+				],
233
+				'require_nonce' => false,
234
+			],
235
+			'price_types'        => [
236
+				'nav'           => [
237
+					'label' => esc_html__('Price Types', 'event_espresso'),
238
+					'order' => 30,
239
+				],
240
+				'list_table'    => 'Price_Types_List_Table',
241
+				'help_tabs'     => [
242
+					'pricing_price_types_help_tab'                           => [
243
+						'title'    => esc_html__('Price Types', 'event_espresso'),
244
+						'filename' => 'pricing_price_types',
245
+					],
246
+					'pricing_price_types_table_column_headings_help_tab'     => [
247
+						'title'    => esc_html__('Price Types Table Column Headings', 'event_espresso'),
248
+						'filename' => 'pricing_price_types_table_column_headings',
249
+					],
250
+					'pricing_price_types_views_bulk_actions_search_help_tab' => [
251
+						'title'    => esc_html__('Price Types Views & Bulk Actions & Search', 'event_espresso'),
252
+						'filename' => 'pricing_price_types_views_bulk_actions_search',
253
+					],
254
+				],
255
+				'metaboxes'     => $this->_default_espresso_metaboxes,
256
+				'require_nonce' => false,
257
+			],
258
+			'add_new_price_type' => [
259
+				'nav'           => [
260
+					'label'      => esc_html__('Add New Price Type', 'event_espresso'),
261
+					'order'      => 40,
262
+					'persistent' => false,
263
+				],
264
+				'help_tabs'     => [
265
+					'add_new_price_type_help_tab' => [
266
+						'title'    => esc_html__('Add New Price Type', 'event_espresso'),
267
+						'filename' => 'pricing_add_new_price_type',
268
+					],
269
+				],
270
+				'metaboxes'     => array_merge(
271
+					['_publish_post_box'],
272
+					$this->_default_espresso_metaboxes
273
+				),
274
+				'require_nonce' => false,
275
+			],
276
+			'edit_price_type'    => [
277
+				'nav'           => [
278
+					'label'      => esc_html__('Edit Price Type', 'event_espresso'),
279
+					'order'      => 40,
280
+					'persistent' => false,
281
+				],
282
+				'help_tabs'     => [
283
+					'edit_price_type_help_tab' => [
284
+						'title'    => esc_html__('Edit Price Type', 'event_espresso'),
285
+						'filename' => 'pricing_edit_price_type',
286
+					],
287
+				],
288
+				'metaboxes'     => array_merge(
289
+					['_publish_post_box'],
290
+					$this->_default_espresso_metaboxes
291
+				),
292
+				'require_nonce' => false,
293
+			],
294
+			'tax_settings'       => [
295
+				'nav'           => [
296
+					'label' => esc_html__('Tax Settings', 'event_espresso'),
297
+					'order' => 40,
298
+				],
299
+				'labels'        => [
300
+					'publishbox' => esc_html__('Update Tax Settings', 'event_espresso'),
301
+				],
302
+				'metaboxes'     => array_merge(
303
+					['_publish_post_box'],
304
+					$this->_default_espresso_metaboxes
305
+				),
306
+				'require_nonce' => true,
307
+			],
308
+		];
309
+	}
310
+
311
+
312
+	protected function _add_screen_options()
313
+	{
314
+		// todo
315
+	}
316
+
317
+
318
+	protected function _add_screen_options_default()
319
+	{
320
+		$this->_per_page_screen_option();
321
+	}
322
+
323
+
324
+	protected function _add_screen_options_price_types()
325
+	{
326
+		$page_title              = $this->_admin_page_title;
327
+		$this->_admin_page_title = esc_html__('Price Types', 'event_espresso');
328
+		$this->_per_page_screen_option();
329
+		$this->_admin_page_title = $page_title;
330
+	}
331
+
332
+
333
+	protected function _add_feature_pointers()
334
+	{
335
+	}
336
+
337
+
338
+	public function load_scripts_styles()
339
+	{
340
+		// styles
341
+		wp_enqueue_style('espresso-ui-theme');
342
+		wp_register_style(
343
+			'espresso_PRICING',
344
+			PRICING_ASSETS_URL . 'espresso_pricing_admin.css',
345
+			[],
346
+			EVENT_ESPRESSO_VERSION
347
+		);
348
+		wp_enqueue_style('espresso_PRICING');
349
+
350
+		// scripts
351
+		wp_enqueue_script('ee_admin_js');
352
+		wp_enqueue_script('jquery-ui-position');
353
+		wp_enqueue_script('jquery-ui-widget');
354
+		wp_register_script(
355
+			'espresso_PRICING',
356
+			PRICING_ASSETS_URL . 'espresso_pricing_admin.js',
357
+			['jquery'],
358
+			EVENT_ESPRESSO_VERSION,
359
+			true
360
+		);
361
+		wp_enqueue_script('espresso_PRICING');
362
+	}
363
+
364
+
365
+	public function load_scripts_styles_default()
366
+	{
367
+		wp_enqueue_script('espresso_ajax_table_sorting');
368
+	}
369
+
370
+
371
+	public function admin_footer_scripts()
372
+	{
373
+	}
374
+
375
+
376
+	public function admin_init()
377
+	{
378
+	}
379
+
380
+
381
+	public function admin_notices()
382
+	{
383
+	}
384
+
385
+
386
+	protected function _set_list_table_views_default()
387
+	{
388
+		$this->_views = [
389
+			'all' => [
390
+				'slug'        => 'all',
391
+				'label'       => esc_html__('View All Default Pricing', 'event_espresso'),
392
+				'count'       => 0,
393
+				'bulk_action' => [
394
+					'trash_price' => esc_html__('Move to Trash', 'event_espresso'),
395
+				],
396
+			],
397
+		];
398
+
399
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) {
400
+			$this->_views['trashed'] = [
401
+				'slug'        => 'trashed',
402
+				'label'       => esc_html__('Trash', 'event_espresso'),
403
+				'count'       => 0,
404
+				'bulk_action' => [
405
+					'restore_price' => esc_html__('Restore from Trash', 'event_espresso'),
406
+					'delete_price'  => esc_html__('Delete Permanently', 'event_espresso'),
407
+				],
408
+			];
409
+		}
410
+	}
411
+
412
+
413
+	protected function _set_list_table_views_price_types()
414
+	{
415
+		$this->_views = [
416
+			'all' => [
417
+				'slug'        => 'all',
418
+				'label'       => esc_html__('All', 'event_espresso'),
419
+				'count'       => 0,
420
+				'bulk_action' => [
421
+					'trash_price_type' => esc_html__('Move to Trash', 'event_espresso'),
422
+				],
423
+			],
424
+		];
425
+
426
+		if (
427
+			EE_Registry::instance()->CAP->current_user_can(
428
+				'ee_delete_default_price_types',
429
+				'pricing_trash_price_type'
430
+			)
431
+		) {
432
+			$this->_views['trashed'] = [
433
+				'slug'        => 'trashed',
434
+				'label'       => esc_html__('Trash', 'event_espresso'),
435
+				'count'       => 0,
436
+				'bulk_action' => [
437
+					'restore_price_type' => esc_html__('Restore from Trash', 'event_espresso'),
438
+					'delete_price_type'  => esc_html__('Delete Permanently', 'event_espresso'),
439
+				],
440
+			];
441
+		}
442
+	}
443
+
444
+
445
+	/**
446
+	 * generates HTML for main Prices Admin page
447
+	 *
448
+	 * @return void
449
+	 * @throws EE_Error
450
+	 */
451
+	protected function _price_overview_list_table()
452
+	{
453
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
454
+			'add_new_price',
455
+			'add',
456
+			[],
457
+			'add-new-h2'
458
+		);
459
+		$this->_admin_page_title .= $this->_learn_more_about_pricing_link();
460
+		$this->_search_btn_label = esc_html__('Default Prices', 'event_espresso');
461
+		$this->display_admin_list_table_page_with_sidebar();
462
+	}
463
+
464
+
465
+	/**
466
+	 * retrieve data for Prices List table
467
+	 *
468
+	 * @param int  $per_page how many prices displayed per page
469
+	 * @param bool $count    return the count or objects
470
+	 * @param bool $trashed  whether the current view is of the trash can - eww yuck!
471
+	 * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects
472
+	 * @throws EE_Error
473
+	 * @throws ReflectionException
474
+	 */
475
+	public function get_prices_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false)
476
+	{
477
+		// start with an empty array
478
+		$event_pricing = [];
479
+
480
+		require_once(PRICING_ADMIN . 'Prices_List_Table.class.php');
481
+
482
+		$orderby = $this->request->getRequestParam('orderby', '');
483
+		$order   = $this->request->getRequestParam('order', 'ASC');
484
+
485
+		switch ($orderby) {
486
+			case 'name':
487
+				$orderby = ['PRC_name' => $order];
488
+				break;
489
+			case 'type':
490
+				$orderby = ['Price_Type.PRT_name' => $order];
491
+				break;
492
+			case 'amount':
493
+				$orderby = ['PRC_amount' => $order];
494
+				break;
495
+			default:
496
+				$orderby = ['PRC_order' => $order, 'Price_Type.PRT_order' => $order, 'PRC_ID' => $order];
497
+		}
498
+
499
+		$current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER);
500
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER);
501
+
502
+		$where = [
503
+			'PRC_is_default' => 1,
504
+			'PRC_deleted'    => $trashed,
505
+		];
506
+
507
+		$offset = ($current_page - 1) * $per_page;
508
+		$limit  = [$offset, $per_page];
509
+
510
+		$search_term = $this->request->getRequestParam('s');
511
+		if ($search_term) {
512
+			$search_term = "%{$search_term}%";
513
+			$where['OR'] = [
514
+				'PRC_name'            => ['LIKE', $search_term],
515
+				'PRC_desc'            => ['LIKE', $search_term],
516
+				'PRC_amount'          => ['LIKE', $search_term],
517
+				'Price_Type.PRT_name' => ['LIKE', $search_term],
518
+			];
519
+		}
520
+
521
+		$query_params = [
522
+			$where,
523
+			'order_by' => $orderby,
524
+			'limit'    => $limit,
525
+			'group_by' => 'PRC_ID',
526
+		];
527
+
528
+		if ($count) {
529
+			return $trashed
530
+				? EEM_Price::instance()->count([$where])
531
+				: EEM_Price::instance()->count_deleted_and_undeleted([$where]);
532
+		}
533
+		return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params);
534
+	}
535
+
536
+
537
+	/**
538
+	 * @return void
539
+	 * @throws EE_Error
540
+	 * @throws ReflectionException
541
+	 */
542
+	protected function _edit_price_details()
543
+	{
544
+		// grab price ID
545
+		$PRC_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER);
546
+		// change page title based on request action
547
+		switch ($this->_req_action) {
548
+			case 'add_new_price':
549
+				$this->_admin_page_title = esc_html__('Add New Price', 'event_espresso');
550
+				break;
551
+			case 'edit_price':
552
+				$this->_admin_page_title = esc_html__('Edit Price', 'event_espresso');
553
+				break;
554
+			default:
555
+				$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
556
+		}
557
+		// add PRC_ID to title if editing
558
+		$this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title;
559
+
560
+		if ($PRC_ID) {
561
+			$price                    = EEM_Price::instance()->get_one_by_ID($PRC_ID);
562
+			$additional_hidden_fields = [
563
+				'PRC_ID' => ['type' => 'hidden', 'value' => $PRC_ID],
564
+			];
565
+			$this->_set_add_edit_form_tags('update_price', $additional_hidden_fields);
566
+		} else {
567
+			$price = EEM_Price::instance()->get_new_price();
568
+			$this->_set_add_edit_form_tags('insert_price');
569
+		}
570
+
571
+		if (! $price instanceof EE_Price) {
572
+			throw new RuntimeException(
573
+				sprintf(
574
+					esc_html__(
575
+						'A valid Price could not be retrieved from the database with ID: %1$s',
576
+						'event_espresso'
577
+					),
578
+					$PRC_ID
579
+				)
580
+			);
581
+		}
582
+
583
+		$this->_template_args['PRC_ID'] = $PRC_ID;
584
+		$this->_template_args['price']  = $price;
585
+
586
+		$default_base_price = $price->type_obj() && $price->type_obj()->base_type() === 1;
587
+
588
+		$this->_template_args['default_base_price'] = $default_base_price;
589
+
590
+		// get price types
591
+		$price_types = EEM_Price_Type::instance()->get_all([['PBT_ID' => ['!=', 1]]]);
592
+		if (empty($price_types)) {
593
+			$msg = esc_html__(
594
+				'You have no price types defined. Please add a price type before adding a price.',
595
+				'event_espresso'
596
+			);
597
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
598
+			$this->display_admin_page_with_sidebar();
599
+		}
600
+		$attributes       = [];
601
+		$price_type_names = [];
602
+		$attributes[]     = 'id="PRT_ID"';
603
+		if ($default_base_price) {
604
+			$attributes[]       = 'disabled="disabled"';
605
+			$price_type_names[] = ['id' => 1, 'text' => esc_html__('Base Price', 'event_espresso')];
606
+		}
607
+		foreach ($price_types as $type) {
608
+			$price_type_names[] = ['id' => $type->ID(), 'text' => $type->name()];
609
+		}
610
+		$this->_template_args['attributes']  = implode(' ', $attributes);
611
+		$this->_template_args['price_types'] = $price_type_names;
612
+
613
+		$this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
614
+		$this->_template_args['admin_page_content']            = $this->_edit_price_details_meta_box();
615
+
616
+		$this->_set_publish_post_box_vars('id', $PRC_ID);
617
+		// the details template wrapper
618
+		$this->display_admin_page_with_sidebar();
619
+	}
620
+
621
+
622
+	/**
623
+	 *
624
+	 * @return string
625
+	 */
626
+	public function _edit_price_details_meta_box(): string
627
+	{
628
+		return EEH_Template::display_template(
629
+			PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php',
630
+			$this->_template_args,
631
+			true
632
+		);
633
+	}
634
+
635
+
636
+	/**
637
+	 * @return array
638
+	 * @throws EE_Error
639
+	 * @throws ReflectionException
640
+	 */
641
+	protected function set_price_column_values(): array
642
+	{
643
+		$PRC_order = 0;
644
+		$PRT_ID    = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
645
+		if ($PRT_ID) {
646
+			/** @var EE_Price_Type $price_type */
647
+			$price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
648
+			if ($price_type instanceof EE_Price_Type) {
649
+				$PRC_order = $price_type->order();
650
+			}
651
+		}
652
+		return [
653
+			'PRT_ID'         => $PRT_ID,
654
+			'PRC_amount'     => $this->request->getRequestParam('PRC_amount', 0, DataType::FLOAT),
655
+			'PRC_name'       => $this->request->getRequestParam('PRC_name'),
656
+			'PRC_desc'       => $this->request->getRequestParam('PRC_desc'),
657
+			'PRC_is_default' => 1,
658
+			'PRC_overrides'  => null,
659
+			'PRC_order'      => $PRC_order,
660
+			'PRC_deleted'    => 0,
661
+			'PRC_parent'     => 0,
662
+		];
663
+	}
664
+
665
+
666
+	/**
667
+	 * @param bool $insert - whether to insert or update
668
+	 * @return void
669
+	 * @throws EE_Error
670
+	 * @throws ReflectionException
671
+	 */
672
+	protected function _insert_or_update_price(bool $insert = false)
673
+	{
674
+		// why be so pessimistic ???  : (
675
+		$updated = 0;
676
+
677
+		$set_column_values = $this->set_price_column_values();
678
+		// is this a new Price ?
679
+		if ($insert) {
680
+			// run the insert
681
+			$PRC_ID = EEM_Price::instance()->insert($set_column_values);
682
+			if ($PRC_ID) {
683
+				// make sure this new price modifier is attached to the ticket but ONLY if it is not a tax type
684
+				$price = EEM_price::instance()->get_one_by_ID($PRC_ID);
685
+				if (
686
+					$price instanceof EE_Price
687
+					&& $price->type_obj() instanceof EE_Price_type
688
+					&& $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax
689
+				) {
690
+					$ticket = EEM_Ticket::instance()->get_one_by_ID(1);
691
+					$ticket->_add_relation_to($price, 'Price');
692
+					$ticket->save();
693
+				}
694
+				$updated = 1;
695
+			}
696
+			$action_desc = 'created';
697
+		} else {
698
+			$PRC_ID = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER);
699
+			// run the update
700
+			$where_cols_n_values = ['PRC_ID' => $PRC_ID];
701
+			$updated             = EEM_Price::instance()->update($set_column_values, [$where_cols_n_values]);
702
+
703
+			$price = EEM_Price::instance()->get_one_by_ID($PRC_ID);
704
+			if ($price instanceof EE_Price && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
705
+				// if this is $PRC_ID == 1,
706
+				// then we need to update the default ticket attached to this price so the TKT_price value is updated.
707
+				if ($PRC_ID === 1) {
708
+					$ticket = $price->get_first_related('Ticket');
709
+					if ($ticket) {
710
+						$ticket->set('TKT_price', $price->get('PRC_amount'));
711
+						$ticket->set('TKT_name', $price->get('PRC_name'));
712
+						$ticket->set('TKT_description', $price->get('PRC_desc'));
713
+						$ticket->save();
714
+					}
715
+				} else {
716
+					// we make sure this price is attached to base ticket. but ONLY if its not a tax ticket type.
717
+					$ticket = EEM_Ticket::instance()->get_one_by_ID(1);
718
+					$ticket->_add_relation_to($PRC_ID, 'Price');
719
+					$ticket->save();
720
+				}
721
+			}
722
+
723
+			$action_desc = 'updated';
724
+		}
725
+
726
+		$query_args = ['action' => 'edit_price', 'id' => $PRC_ID];
727
+
728
+		$this->_redirect_after_action($updated, 'Prices', $action_desc, $query_args);
729
+	}
730
+
731
+
732
+	/**
733
+	 * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE)
734
+	 * @return void
735
+	 * @throws EE_Error
736
+	 * @throws ReflectionException
737
+	 */
738
+	protected function _trash_or_restore_price(bool $trash = true)
739
+	{
740
+		$entity_model = EEM_Price::instance();
741
+		$action       = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE;
742
+		$result       = $this->trashRestoreDeleteEntities(
743
+			$entity_model,
744
+			'id',
745
+			$action,
746
+			'PRC_deleted',
747
+			[$this, 'adjustTicketRelations']
748
+		);
749
+
750
+		if ($result) {
751
+			$msg = $trash
752
+				? esc_html(
753
+					_n(
754
+						'The Price has been trashed',
755
+						'The Prices have been trashed',
756
+						$result,
757
+						'event_espresso'
758
+					)
759
+				)
760
+				: esc_html(
761
+					_n(
762
+						'The Price has been restored',
763
+						'The Prices have been restored',
764
+						$result,
765
+						'event_espresso'
766
+					)
767
+				);
768
+			EE_Error::add_success($msg);
769
+		}
770
+
771
+		$this->_redirect_after_action(
772
+			$result,
773
+			_n('Price', 'Prices', $result, 'event_espresso'),
774
+			$trash ? 'trashed' : 'restored',
775
+			['action' => 'default'],
776
+			true
777
+		);
778
+	}
779
+
780
+
781
+	/**
782
+	 * @param EEM_Base   $entity_model
783
+	 * @param int|string $entity_ID
784
+	 * @param string     $action
785
+	 * @param int        $result
786
+	 * @throws EE_Error
787
+	 * @throws ReflectionException
788
+	 * @since $VID:$
789
+	 */
790
+	public function adjustTicketRelations(EEM_Base $entity_model, $entity_ID, string $action, int $result)
791
+	{
792
+		if (! $entity_ID || (float) $result < 1) {
793
+			return;
794
+		}
795
+
796
+		$entity = $entity_model->get_one_by_ID($entity_ID);
797
+		if (! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) {
798
+			return;
799
+		}
800
+
801
+		// get default tickets for updating
802
+		$default_tickets = EEM_Ticket::instance()->get_all_default_tickets();
803
+		foreach ($default_tickets as $default_ticket) {
804
+			if (! $default_ticket instanceof EE_Ticket) {
805
+				continue;
806
+			}
807
+			switch ($action) {
808
+				case EE_Admin_List_Table::ACTION_DELETE:
809
+				case EE_Admin_List_Table::ACTION_TRASH:
810
+					// if trashing then remove relations to base default ticket.
811
+					$default_ticket->_remove_relation_to($entity_ID, 'Price');
812
+					break;
813
+				case EE_Admin_List_Table::ACTION_RESTORE:
814
+					// if restoring then add back to base default ticket
815
+					$default_ticket->_add_relation_to($entity_ID, 'Price');
816
+					break;
817
+			}
818
+			$default_ticket->save();
819
+		}
820
+	}
821
+
822
+
823
+	/**
824
+	 * @return void
825
+	 * @throws EE_Error
826
+	 * @throws ReflectionException
827
+	 */
828
+	protected function _delete_price()
829
+	{
830
+		$entity_model = EEM_Price::instance();
831
+		$deleted      = $this->trashRestoreDeleteEntities($entity_model, 'id');
832
+		$entity       = $entity_model->item_name($deleted);
833
+		$this->_redirect_after_action($deleted, $entity, 'deleted', ['action' => 'default']);
834
+	}
835
+
836
+
837
+	/**
838
+	 * @throws EE_Error
839
+	 * @throws ReflectionException
840
+	 */
841
+	public function update_price_order()
842
+	{
843
+		// grab our row IDs
844
+		$row_ids = $this->request->getRequestParam('row_ids', '');
845
+		$row_ids = explode(',', rtrim($row_ids, ','));
846
+
847
+		$all_updated = true;
848
+		foreach ($row_ids as $i => $row_id) {
849
+			// Update the prices when re-ordering
850
+			$fields_n_values = ['PRC_order' => $i + 1];
851
+			$query_params    = [['PRC_ID' => absint($row_id)]];
852
+			// any failure will toggle $all_updated to false
853
+			$all_updated = $row_id && EEM_Price::instance()->update($fields_n_values, $query_params) !== false
854
+				? $all_updated
855
+				: false;
856
+		}
857
+		$success = $all_updated ? esc_html__('Price order was updated successfully.', 'event_espresso') : false;
858
+		$errors  = ! $all_updated ? esc_html__('An error occurred. The price order was not updated.', 'event_espresso')
859
+			: false;
860
+
861
+		echo wp_json_encode(['return_data' => false, 'success' => $success, 'errors' => $errors]);
862
+		die();
863
+	}
864
+
865
+
866
+	/******************************************************************************************************************
867 867
      ***********************************************  TICKET PRICE TYPES  *********************************************
868 868
      ******************************************************************************************************************/
869 869
 
870 870
 
871
-    /**
872
-     * generates HTML for main Prices Admin page
873
-     *
874
-     * @return void
875
-     * @throws EE_Error
876
-     */
877
-    protected function _price_types_overview_list_table()
878
-    {
879
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
880
-            'add_new_price_type',
881
-            'add_type',
882
-            [],
883
-            'add-new-h2'
884
-        );
885
-        $this->_admin_page_title .= $this->_learn_more_about_pricing_link();
886
-        $this->_search_btn_label = esc_html__('Price Types', 'event_espresso');
887
-        $this->display_admin_list_table_page_with_sidebar();
888
-    }
889
-
890
-
891
-    /**
892
-     * retrieve data for Price Types List table
893
-     *
894
-     * @param int  $per_page how many prices displayed per page
895
-     * @param bool $count    return the count or objects
896
-     * @param bool $trashed  whether the current view is of the trash can - eww yuck!
897
-     * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects
898
-     * @throws EE_Error
899
-     * @throws ReflectionException
900
-     */
901
-    public function get_price_types_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false)
902
-    {
903
-        // start with an empty array
904
-        require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php');
905
-
906
-        $orderby = $this->request->getRequestParam('orderby', '');
907
-        $order   = $this->request->getRequestParam('order', 'ASC');
908
-
909
-        switch ($orderby) {
910
-            case 'name':
911
-                $orderby = ['PRT_name' => $order];
912
-                break;
913
-            default:
914
-                $orderby = ['PRT_order' => $order];
915
-        }
916
-
917
-        $current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER);
918
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER);
919
-
920
-        $offset = ($current_page - 1) * $per_page;
921
-        $limit  = [$offset, $per_page];
922
-
923
-        $where = ['PRT_deleted' => $trashed, 'PBT_ID' => ['!=', 1]];
924
-
925
-        $search_term = $this->request->getRequestParam('s');
926
-        if ($search_term) {
927
-            $where['OR'] = [
928
-                'PRT_name' => ['LIKE', "%{$search_term}%"],
929
-            ];
930
-        }
931
-        $query_params = [
932
-            $where,
933
-            'order_by' => $orderby,
934
-            'limit'    => $limit,
935
-        ];
936
-        return $count
937
-            ? EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params)
938
-            : EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params);
939
-    }
940
-
941
-
942
-    /**
943
-     * _edit_price_type_details
944
-     *
945
-     * @return void
946
-     * @throws EE_Error
947
-     * @throws ReflectionException
948
-     */
949
-    protected function _edit_price_type_details()
950
-    {
951
-        // grab price type ID
952
-        $PRT_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER);
953
-        // change page title based on request action
954
-        switch ($this->_req_action) {
955
-            case 'add_new_price_type':
956
-                $this->_admin_page_title = esc_html__('Add New Price Type', 'event_espresso');
957
-                break;
958
-            case 'edit_price_type':
959
-                $this->_admin_page_title = esc_html__('Edit Price Type', 'event_espresso');
960
-                break;
961
-            default:
962
-                $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
963
-        }
964
-        // add PRT_ID to title if editing
965
-        $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title;
966
-
967
-        if ($PRT_ID) {
968
-            $price_type               = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
969
-            $additional_hidden_fields = ['PRT_ID' => ['type' => 'hidden', 'value' => $PRT_ID]];
970
-            $this->_set_add_edit_form_tags('update_price_type', $additional_hidden_fields);
971
-        } else {
972
-            $price_type = EEM_Price_Type::instance()->get_new_price_type();
973
-            $this->_set_add_edit_form_tags('insert_price_type');
974
-        }
975
-
976
-        if (! $price_type instanceof EE_Price_Type) {
977
-            throw new RuntimeException(
978
-                sprintf(
979
-                    esc_html__(
980
-                        'A valid Price Type could not be retrieved from the database with ID: %1$s',
981
-                        'event_espresso'
982
-                    ),
983
-                    $PRT_ID
984
-                )
985
-            );
986
-        }
987
-
988
-        $this->_template_args['PRT_ID']     = $PRT_ID;
989
-        $this->_template_args['price_type'] = $price_type;
990
-
991
-        $base_types    = EEM_Price_Type::instance()->get_base_types();
992
-        $select_values = [];
993
-        foreach ($base_types as $ref => $text) {
994
-            if ($ref == EEM_Price_Type::base_type_base_price) {
995
-                // do not allow creation of base_type_base_prices because that's a system only base type.
996
-                continue;
997
-            }
998
-            $select_values[] = ['id' => $ref, 'text' => $text];
999
-        }
1000
-
1001
-        $this->_template_args['base_type_select'] = EEH_Form_Fields::select_input(
1002
-            'base_type',
1003
-            $select_values,
1004
-            $price_type->base_type(),
1005
-            'id="price-type-base-type-slct"'
1006
-        );
1007
-
1008
-        $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
1009
-        $this->_template_args['admin_page_content']            = $this->_edit_price_type_details_meta_box();
1010
-
1011
-        $redirect_URL = add_query_arg(['action' => 'price_types'], $this->_admin_base_url);
1012
-        $this->_set_publish_post_box_vars('id', $PRT_ID, false, $redirect_URL);
1013
-        // the details template wrapper
1014
-        $this->display_admin_page_with_sidebar();
1015
-    }
1016
-
1017
-
1018
-    /**
1019
-     * _edit_price_type_details_meta_box
1020
-     *
1021
-     * @return string
1022
-     */
1023
-    public function _edit_price_type_details_meta_box(): string
1024
-    {
1025
-        return EEH_Template::display_template(
1026
-            PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php',
1027
-            $this->_template_args,
1028
-            true
1029
-        );
1030
-    }
1031
-
1032
-
1033
-    /**
1034
-     * @return array
1035
-     */
1036
-    protected function set_price_type_column_values(): array
1037
-    {
1038
-        $base_type  = $this->request->getRequestParam(
1039
-            'base_type',
1040
-            EEM_Price_Type::base_type_base_price,
1041
-            DataType::INTEGER
1042
-        );
1043
-        $is_percent = $this->request->getRequestParam('PRT_is_percent', 0, DataType::INTEGER);
1044
-        $order      = $this->request->getRequestParam('PRT_order', 0, DataType::INTEGER);
1045
-        switch ($base_type) {
1046
-            case EEM_Price_Type::base_type_base_price:
1047
-                $is_percent = 0;
1048
-                $order      = 0;
1049
-                break;
1050
-
1051
-            case EEM_Price_Type::base_type_discount:
1052
-            case EEM_Price_Type::base_type_surcharge:
1053
-                break;
1054
-
1055
-            case EEM_Price_Type::base_type_tax:
1056
-                $is_percent = 1;
1057
-                break;
1058
-        }
1059
-
1060
-        return [
1061
-            'PBT_ID'         => $base_type,
1062
-            'PRT_name'       => $this->request->getRequestParam('PRT_name', ''),
1063
-            'PRT_is_percent' => $is_percent,
1064
-            'PRT_order'      => $order,
1065
-            'PRT_deleted'    => 0,
1066
-        ];
1067
-    }
1068
-
1069
-
1070
-    /**
1071
-     * @param bool $new_price_type - whether to insert or update
1072
-     * @return void
1073
-     * @throws EE_Error
1074
-     * @throws ReflectionException
1075
-     */
1076
-    protected function _insert_or_update_price_type(bool $new_price_type = false)
1077
-    {
1078
-        // why be so pessimistic ???  : (
1079
-        $success = 0;
1080
-
1081
-        $set_column_values = $this->set_price_type_column_values();
1082
-        // is this a new Price ?
1083
-        if ($new_price_type) {
1084
-            // run the insert
1085
-            if ($PRT_ID = EEM_Price_Type::instance()->insert($set_column_values)) {
1086
-                $success = 1;
1087
-            }
1088
-            $action_desc = 'created';
1089
-        } else {
1090
-            $PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
1091
-            // run the update
1092
-            $where_cols_n_values = ['PRT_ID' => $PRT_ID];
1093
-            if (EEM_Price_Type::instance()->update($set_column_values, [$where_cols_n_values])) {
1094
-                $success = 1;
1095
-            }
1096
-            $action_desc = 'updated';
1097
-        }
1098
-
1099
-        $query_args = ['action' => 'edit_price_type', 'id' => $PRT_ID];
1100
-        $this->_redirect_after_action($success, 'Price Type', $action_desc, $query_args);
1101
-    }
1102
-
1103
-
1104
-    /**
1105
-     * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE)
1106
-     * @return void
1107
-     * @throws EE_Error
1108
-     * @throws ReflectionException
1109
-     */
1110
-    protected function _trash_or_restore_price_type(bool $trash = true)
1111
-    {
1112
-        $entity_model = EEM_Price_Type::instance();
1113
-        $action       = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE;
1114
-        $success      = $this->trashRestoreDeleteEntities($entity_model, 'id', $action, 'PRT_deleted');
1115
-        if ($success) {
1116
-            $msg = $trash
1117
-                ? esc_html(
1118
-                    _n(
1119
-                        'The Price Type has been trashed',
1120
-                        'The Price Types have been trashed',
1121
-                        $success,
1122
-                        'event_espresso'
1123
-                    )
1124
-                )
1125
-                : esc_html(
1126
-                    _n(
1127
-                        'The Price Type has been restored',
1128
-                        'The Price Types have been restored',
1129
-                        $success,
1130
-                        'event_espresso'
1131
-                    )
1132
-                );
1133
-            EE_Error::add_success($msg);
1134
-        }
1135
-        $this->_redirect_after_action('', '', '', ['action' => 'price_types'], true);
1136
-    }
1137
-
1138
-
1139
-    /**
1140
-     * @return void
1141
-     * @throws EE_Error
1142
-     * @throws ReflectionException
1143
-     */
1144
-    protected function _delete_price_type()
1145
-    {
1146
-        $entity_model = EEM_Price_Type::instance();
1147
-        $deleted      = $this->trashRestoreDeleteEntities($entity_model, 'id');
1148
-        $this->_redirect_after_action(
1149
-            $deleted,
1150
-            $entity_model->item_name($deleted),
1151
-            'deleted',
1152
-            ['action' => 'price_types']
1153
-        );
1154
-    }
1155
-
1156
-
1157
-    /**
1158
-     * @return string
1159
-     */
1160
-    protected function _learn_more_about_pricing_link(): string
1161
-    {
1162
-        return '
871
+	/**
872
+	 * generates HTML for main Prices Admin page
873
+	 *
874
+	 * @return void
875
+	 * @throws EE_Error
876
+	 */
877
+	protected function _price_types_overview_list_table()
878
+	{
879
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
880
+			'add_new_price_type',
881
+			'add_type',
882
+			[],
883
+			'add-new-h2'
884
+		);
885
+		$this->_admin_page_title .= $this->_learn_more_about_pricing_link();
886
+		$this->_search_btn_label = esc_html__('Price Types', 'event_espresso');
887
+		$this->display_admin_list_table_page_with_sidebar();
888
+	}
889
+
890
+
891
+	/**
892
+	 * retrieve data for Price Types List table
893
+	 *
894
+	 * @param int  $per_page how many prices displayed per page
895
+	 * @param bool $count    return the count or objects
896
+	 * @param bool $trashed  whether the current view is of the trash can - eww yuck!
897
+	 * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects
898
+	 * @throws EE_Error
899
+	 * @throws ReflectionException
900
+	 */
901
+	public function get_price_types_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false)
902
+	{
903
+		// start with an empty array
904
+		require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php');
905
+
906
+		$orderby = $this->request->getRequestParam('orderby', '');
907
+		$order   = $this->request->getRequestParam('order', 'ASC');
908
+
909
+		switch ($orderby) {
910
+			case 'name':
911
+				$orderby = ['PRT_name' => $order];
912
+				break;
913
+			default:
914
+				$orderby = ['PRT_order' => $order];
915
+		}
916
+
917
+		$current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER);
918
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER);
919
+
920
+		$offset = ($current_page - 1) * $per_page;
921
+		$limit  = [$offset, $per_page];
922
+
923
+		$where = ['PRT_deleted' => $trashed, 'PBT_ID' => ['!=', 1]];
924
+
925
+		$search_term = $this->request->getRequestParam('s');
926
+		if ($search_term) {
927
+			$where['OR'] = [
928
+				'PRT_name' => ['LIKE', "%{$search_term}%"],
929
+			];
930
+		}
931
+		$query_params = [
932
+			$where,
933
+			'order_by' => $orderby,
934
+			'limit'    => $limit,
935
+		];
936
+		return $count
937
+			? EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params)
938
+			: EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params);
939
+	}
940
+
941
+
942
+	/**
943
+	 * _edit_price_type_details
944
+	 *
945
+	 * @return void
946
+	 * @throws EE_Error
947
+	 * @throws ReflectionException
948
+	 */
949
+	protected function _edit_price_type_details()
950
+	{
951
+		// grab price type ID
952
+		$PRT_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER);
953
+		// change page title based on request action
954
+		switch ($this->_req_action) {
955
+			case 'add_new_price_type':
956
+				$this->_admin_page_title = esc_html__('Add New Price Type', 'event_espresso');
957
+				break;
958
+			case 'edit_price_type':
959
+				$this->_admin_page_title = esc_html__('Edit Price Type', 'event_espresso');
960
+				break;
961
+			default:
962
+				$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
963
+		}
964
+		// add PRT_ID to title if editing
965
+		$this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title;
966
+
967
+		if ($PRT_ID) {
968
+			$price_type               = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
969
+			$additional_hidden_fields = ['PRT_ID' => ['type' => 'hidden', 'value' => $PRT_ID]];
970
+			$this->_set_add_edit_form_tags('update_price_type', $additional_hidden_fields);
971
+		} else {
972
+			$price_type = EEM_Price_Type::instance()->get_new_price_type();
973
+			$this->_set_add_edit_form_tags('insert_price_type');
974
+		}
975
+
976
+		if (! $price_type instanceof EE_Price_Type) {
977
+			throw new RuntimeException(
978
+				sprintf(
979
+					esc_html__(
980
+						'A valid Price Type could not be retrieved from the database with ID: %1$s',
981
+						'event_espresso'
982
+					),
983
+					$PRT_ID
984
+				)
985
+			);
986
+		}
987
+
988
+		$this->_template_args['PRT_ID']     = $PRT_ID;
989
+		$this->_template_args['price_type'] = $price_type;
990
+
991
+		$base_types    = EEM_Price_Type::instance()->get_base_types();
992
+		$select_values = [];
993
+		foreach ($base_types as $ref => $text) {
994
+			if ($ref == EEM_Price_Type::base_type_base_price) {
995
+				// do not allow creation of base_type_base_prices because that's a system only base type.
996
+				continue;
997
+			}
998
+			$select_values[] = ['id' => $ref, 'text' => $text];
999
+		}
1000
+
1001
+		$this->_template_args['base_type_select'] = EEH_Form_Fields::select_input(
1002
+			'base_type',
1003
+			$select_values,
1004
+			$price_type->base_type(),
1005
+			'id="price-type-base-type-slct"'
1006
+		);
1007
+
1008
+		$this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
1009
+		$this->_template_args['admin_page_content']            = $this->_edit_price_type_details_meta_box();
1010
+
1011
+		$redirect_URL = add_query_arg(['action' => 'price_types'], $this->_admin_base_url);
1012
+		$this->_set_publish_post_box_vars('id', $PRT_ID, false, $redirect_URL);
1013
+		// the details template wrapper
1014
+		$this->display_admin_page_with_sidebar();
1015
+	}
1016
+
1017
+
1018
+	/**
1019
+	 * _edit_price_type_details_meta_box
1020
+	 *
1021
+	 * @return string
1022
+	 */
1023
+	public function _edit_price_type_details_meta_box(): string
1024
+	{
1025
+		return EEH_Template::display_template(
1026
+			PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php',
1027
+			$this->_template_args,
1028
+			true
1029
+		);
1030
+	}
1031
+
1032
+
1033
+	/**
1034
+	 * @return array
1035
+	 */
1036
+	protected function set_price_type_column_values(): array
1037
+	{
1038
+		$base_type  = $this->request->getRequestParam(
1039
+			'base_type',
1040
+			EEM_Price_Type::base_type_base_price,
1041
+			DataType::INTEGER
1042
+		);
1043
+		$is_percent = $this->request->getRequestParam('PRT_is_percent', 0, DataType::INTEGER);
1044
+		$order      = $this->request->getRequestParam('PRT_order', 0, DataType::INTEGER);
1045
+		switch ($base_type) {
1046
+			case EEM_Price_Type::base_type_base_price:
1047
+				$is_percent = 0;
1048
+				$order      = 0;
1049
+				break;
1050
+
1051
+			case EEM_Price_Type::base_type_discount:
1052
+			case EEM_Price_Type::base_type_surcharge:
1053
+				break;
1054
+
1055
+			case EEM_Price_Type::base_type_tax:
1056
+				$is_percent = 1;
1057
+				break;
1058
+		}
1059
+
1060
+		return [
1061
+			'PBT_ID'         => $base_type,
1062
+			'PRT_name'       => $this->request->getRequestParam('PRT_name', ''),
1063
+			'PRT_is_percent' => $is_percent,
1064
+			'PRT_order'      => $order,
1065
+			'PRT_deleted'    => 0,
1066
+		];
1067
+	}
1068
+
1069
+
1070
+	/**
1071
+	 * @param bool $new_price_type - whether to insert or update
1072
+	 * @return void
1073
+	 * @throws EE_Error
1074
+	 * @throws ReflectionException
1075
+	 */
1076
+	protected function _insert_or_update_price_type(bool $new_price_type = false)
1077
+	{
1078
+		// why be so pessimistic ???  : (
1079
+		$success = 0;
1080
+
1081
+		$set_column_values = $this->set_price_type_column_values();
1082
+		// is this a new Price ?
1083
+		if ($new_price_type) {
1084
+			// run the insert
1085
+			if ($PRT_ID = EEM_Price_Type::instance()->insert($set_column_values)) {
1086
+				$success = 1;
1087
+			}
1088
+			$action_desc = 'created';
1089
+		} else {
1090
+			$PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
1091
+			// run the update
1092
+			$where_cols_n_values = ['PRT_ID' => $PRT_ID];
1093
+			if (EEM_Price_Type::instance()->update($set_column_values, [$where_cols_n_values])) {
1094
+				$success = 1;
1095
+			}
1096
+			$action_desc = 'updated';
1097
+		}
1098
+
1099
+		$query_args = ['action' => 'edit_price_type', 'id' => $PRT_ID];
1100
+		$this->_redirect_after_action($success, 'Price Type', $action_desc, $query_args);
1101
+	}
1102
+
1103
+
1104
+	/**
1105
+	 * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE)
1106
+	 * @return void
1107
+	 * @throws EE_Error
1108
+	 * @throws ReflectionException
1109
+	 */
1110
+	protected function _trash_or_restore_price_type(bool $trash = true)
1111
+	{
1112
+		$entity_model = EEM_Price_Type::instance();
1113
+		$action       = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE;
1114
+		$success      = $this->trashRestoreDeleteEntities($entity_model, 'id', $action, 'PRT_deleted');
1115
+		if ($success) {
1116
+			$msg = $trash
1117
+				? esc_html(
1118
+					_n(
1119
+						'The Price Type has been trashed',
1120
+						'The Price Types have been trashed',
1121
+						$success,
1122
+						'event_espresso'
1123
+					)
1124
+				)
1125
+				: esc_html(
1126
+					_n(
1127
+						'The Price Type has been restored',
1128
+						'The Price Types have been restored',
1129
+						$success,
1130
+						'event_espresso'
1131
+					)
1132
+				);
1133
+			EE_Error::add_success($msg);
1134
+		}
1135
+		$this->_redirect_after_action('', '', '', ['action' => 'price_types'], true);
1136
+	}
1137
+
1138
+
1139
+	/**
1140
+	 * @return void
1141
+	 * @throws EE_Error
1142
+	 * @throws ReflectionException
1143
+	 */
1144
+	protected function _delete_price_type()
1145
+	{
1146
+		$entity_model = EEM_Price_Type::instance();
1147
+		$deleted      = $this->trashRestoreDeleteEntities($entity_model, 'id');
1148
+		$this->_redirect_after_action(
1149
+			$deleted,
1150
+			$entity_model->item_name($deleted),
1151
+			'deleted',
1152
+			['action' => 'price_types']
1153
+		);
1154
+	}
1155
+
1156
+
1157
+	/**
1158
+	 * @return string
1159
+	 */
1160
+	protected function _learn_more_about_pricing_link(): string
1161
+	{
1162
+		return '
1163 1163
             <a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >
1164 1164
                 ' . esc_html__('learn more about how pricing works', 'event_espresso') . '
1165 1165
             </a>';
1166
-    }
1167
-
1168
-
1169
-    /**
1170
-     * @throws EE_Error
1171
-     */
1172
-    protected function _tax_settings()
1173
-    {
1174
-        $this->_set_add_edit_form_tags('update_tax_settings');
1175
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1176
-        $this->_template_args['admin_page_content'] = $this->tax_settings_form()->get_html();
1177
-        $this->display_admin_page_with_sidebar();
1178
-    }
1179
-
1180
-
1181
-    /**
1182
-     * @return EE_Form_Section_Proper
1183
-     * @throws EE_Error
1184
-     */
1185
-    protected function tax_settings_form(): EE_Form_Section_Proper
1186
-    {
1187
-        $tax_settings = EE_Config::instance()->tax_settings;
1188
-        return new EE_Form_Section_Proper(
1189
-            [
1190
-                'name'            => 'tax_settings_form',
1191
-                'html_id'         => 'tax_settings_form',
1192
-                'html_class'      => 'padding',
1193
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
1194
-                'subsections'     => apply_filters(
1195
-                    'FHEE__Pricing_Admin_Page__tax_settings_form__form_subsections',
1196
-                    [
1197
-                        'tax_settings' => new EE_Form_Section_Proper(
1198
-                            [
1199
-                                'name'            => 'tax_settings_tbl',
1200
-                                'html_id'         => 'tax_settings_tbl',
1201
-                                'html_class'      => 'form-table',
1202
-                                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1203
-                                'subsections'     => [
1204
-                                    'prices_displayed_including_taxes' => new EE_Yes_No_Input(
1205
-                                        [
1206
-                                            'html_label_text'         => esc_html__(
1207
-                                                'Show Prices With Taxes Included?',
1208
-                                                'event_espresso'
1209
-                                            ),
1210
-                                            'html_help_text'          => esc_html__(
1211
-                                                'Indicates whether or not to display prices with the taxes included',
1212
-                                                'event_espresso'
1213
-                                            ),
1214
-                                            'default'                 => $tax_settings->prices_displayed_including_taxes
1215
-                                                                         ?? true,
1216
-                                            'display_html_label_text' => false,
1217
-                                        ]
1218
-                                    ),
1219
-                                ],
1220
-                            ]
1221
-                        ),
1222
-                    ]
1223
-                ),
1224
-            ]
1225
-        );
1226
-    }
1227
-
1228
-
1229
-    /**
1230
-     * _update_tax_settings
1231
-     *
1232
-     * @return void
1233
-     * @throws EE_Error
1234
-     * @throws ReflectionException
1235
-     * @since 4.9.13
1236
-     */
1237
-    public function _update_tax_settings()
1238
-    {
1239
-        $tax_settings = EE_Config::instance()->tax_settings;
1240
-        if (! $tax_settings instanceof EE_Tax_Config) {
1241
-            $tax_settings = new EE_Tax_Config();
1242
-        }
1243
-        try {
1244
-            $tax_form = $this->tax_settings_form();
1245
-            // check for form submission
1246
-            if ($tax_form->was_submitted()) {
1247
-                // capture form data
1248
-                $tax_form->receive_form_submission();
1249
-                // validate form data
1250
-                if ($tax_form->is_valid()) {
1251
-                    // grab validated data from form
1252
-                    $valid_data = $tax_form->valid_data();
1253
-                    // set data on config
1254
-                    $tax_settings->prices_displayed_including_taxes =
1255
-                        $valid_data['tax_settings']['prices_displayed_including_taxes'];
1256
-                } else {
1257
-                    if ($tax_form->submission_error_message() !== '') {
1258
-                        EE_Error::add_error(
1259
-                            $tax_form->submission_error_message(),
1260
-                            __FILE__,
1261
-                            __FUNCTION__,
1262
-                            __LINE__
1263
-                        );
1264
-                    }
1265
-                }
1266
-            }
1267
-        } catch (EE_Error $e) {
1268
-            EE_Error::add_error($e->get_error(), __FILE__, __FUNCTION__, __LINE__);
1269
-        }
1270
-
1271
-        $what    = 'Tax Settings';
1272
-        $success = $this->_update_espresso_configuration(
1273
-            $what,
1274
-            $tax_settings,
1275
-            __FILE__,
1276
-            __FUNCTION__,
1277
-            __LINE__
1278
-        );
1279
-        $this->_redirect_after_action($success, $what, 'updated', ['action' => 'tax_settings']);
1280
-    }
1166
+	}
1167
+
1168
+
1169
+	/**
1170
+	 * @throws EE_Error
1171
+	 */
1172
+	protected function _tax_settings()
1173
+	{
1174
+		$this->_set_add_edit_form_tags('update_tax_settings');
1175
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1176
+		$this->_template_args['admin_page_content'] = $this->tax_settings_form()->get_html();
1177
+		$this->display_admin_page_with_sidebar();
1178
+	}
1179
+
1180
+
1181
+	/**
1182
+	 * @return EE_Form_Section_Proper
1183
+	 * @throws EE_Error
1184
+	 */
1185
+	protected function tax_settings_form(): EE_Form_Section_Proper
1186
+	{
1187
+		$tax_settings = EE_Config::instance()->tax_settings;
1188
+		return new EE_Form_Section_Proper(
1189
+			[
1190
+				'name'            => 'tax_settings_form',
1191
+				'html_id'         => 'tax_settings_form',
1192
+				'html_class'      => 'padding',
1193
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
1194
+				'subsections'     => apply_filters(
1195
+					'FHEE__Pricing_Admin_Page__tax_settings_form__form_subsections',
1196
+					[
1197
+						'tax_settings' => new EE_Form_Section_Proper(
1198
+							[
1199
+								'name'            => 'tax_settings_tbl',
1200
+								'html_id'         => 'tax_settings_tbl',
1201
+								'html_class'      => 'form-table',
1202
+								'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1203
+								'subsections'     => [
1204
+									'prices_displayed_including_taxes' => new EE_Yes_No_Input(
1205
+										[
1206
+											'html_label_text'         => esc_html__(
1207
+												'Show Prices With Taxes Included?',
1208
+												'event_espresso'
1209
+											),
1210
+											'html_help_text'          => esc_html__(
1211
+												'Indicates whether or not to display prices with the taxes included',
1212
+												'event_espresso'
1213
+											),
1214
+											'default'                 => $tax_settings->prices_displayed_including_taxes
1215
+																		 ?? true,
1216
+											'display_html_label_text' => false,
1217
+										]
1218
+									),
1219
+								],
1220
+							]
1221
+						),
1222
+					]
1223
+				),
1224
+			]
1225
+		);
1226
+	}
1227
+
1228
+
1229
+	/**
1230
+	 * _update_tax_settings
1231
+	 *
1232
+	 * @return void
1233
+	 * @throws EE_Error
1234
+	 * @throws ReflectionException
1235
+	 * @since 4.9.13
1236
+	 */
1237
+	public function _update_tax_settings()
1238
+	{
1239
+		$tax_settings = EE_Config::instance()->tax_settings;
1240
+		if (! $tax_settings instanceof EE_Tax_Config) {
1241
+			$tax_settings = new EE_Tax_Config();
1242
+		}
1243
+		try {
1244
+			$tax_form = $this->tax_settings_form();
1245
+			// check for form submission
1246
+			if ($tax_form->was_submitted()) {
1247
+				// capture form data
1248
+				$tax_form->receive_form_submission();
1249
+				// validate form data
1250
+				if ($tax_form->is_valid()) {
1251
+					// grab validated data from form
1252
+					$valid_data = $tax_form->valid_data();
1253
+					// set data on config
1254
+					$tax_settings->prices_displayed_including_taxes =
1255
+						$valid_data['tax_settings']['prices_displayed_including_taxes'];
1256
+				} else {
1257
+					if ($tax_form->submission_error_message() !== '') {
1258
+						EE_Error::add_error(
1259
+							$tax_form->submission_error_message(),
1260
+							__FILE__,
1261
+							__FUNCTION__,
1262
+							__LINE__
1263
+						);
1264
+					}
1265
+				}
1266
+			}
1267
+		} catch (EE_Error $e) {
1268
+			EE_Error::add_error($e->get_error(), __FILE__, __FUNCTION__, __LINE__);
1269
+		}
1270
+
1271
+		$what    = 'Tax Settings';
1272
+		$success = $this->_update_espresso_configuration(
1273
+			$what,
1274
+			$tax_settings,
1275
+			__FILE__,
1276
+			__FUNCTION__,
1277
+			__LINE__
1278
+		);
1279
+		$this->_redirect_after_action($success, $what, 'updated', ['action' => 'tax_settings']);
1280
+	}
1281 1281
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Country.class.php 1 patch
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -10,207 +10,207 @@
 block discarded – undo
10 10
 class EE_Country extends EE_Base_Class
11 11
 {
12 12
 
13
-    /**
14
-     * @param array $props_n_values
15
-     * @return EE_Country|mixed
16
-     * @throws EE_Error
17
-     * @throws ReflectionException
18
-     */
19
-    public static function new_instance($props_n_values = [])
20
-    {
21
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
22
-        return $has_object ? $has_object : new self($props_n_values);
23
-    }
24
-
25
-
26
-    /**
27
-     * @param array $props_n_values
28
-     * @return EE_Country
29
-     * @throws EE_Error
30
-     * @throws ReflectionException
31
-     */
32
-    public static function new_instance_from_db($props_n_values = [])
33
-    {
34
-        return new self($props_n_values, true);
35
-    }
36
-
37
-
38
-    /**
39
-     * Gets the country name
40
-     *
41
-     * @return string
42
-     * @throws EE_Error
43
-     * @throws ReflectionException
44
-     */
45
-    public function name()
46
-    {
47
-        return $this->get('CNT_name');
48
-    }
49
-
50
-
51
-    /**
52
-     * Whether the country is active/enabled
53
-     *
54
-     * @return bool
55
-     * @throws EE_Error
56
-     * @throws ReflectionException
57
-     */
58
-    public function isActive()
59
-    {
60
-        return (bool) $this->get('CNT_active');
61
-    }
62
-
63
-
64
-    /**
65
-     * Gets the country ISO3
66
-     *
67
-     * @return string
68
-     * @throws EE_Error
69
-     * @throws ReflectionException
70
-     */
71
-    public function ISO3()
72
-    {
73
-        return $this->get('CNT_ISO3');
74
-    }
75
-
76
-
77
-    /**
78
-     * gets the country's currency code
79
-     *
80
-     * @return string
81
-     * @throws EE_Error
82
-     * @throws ReflectionException
83
-     */
84
-    public function currency_code()
85
-    {
86
-        return $this->get('CNT_cur_code');
87
-    }
88
-
89
-
90
-    /**
91
-     * gets the country's currency sign/symbol
92
-     *
93
-     * @return string
94
-     * @throws EE_Error
95
-     * @throws ReflectionException
96
-     */
97
-    public function currency_sign()
98
-    {
99
-        $CNT_cur_sign = $this->get('CNT_cur_sign');
100
-        return $CNT_cur_sign ? $CNT_cur_sign : '';
101
-    }
102
-
103
-
104
-    /**
105
-     * Currency name singular
106
-     *
107
-     * @return string
108
-     * @throws EE_Error
109
-     * @throws ReflectionException
110
-     */
111
-    public function currency_name_single()
112
-    {
113
-        return $this->get('CNT_cur_single');
114
-    }
115
-
116
-
117
-    /**
118
-     * Currency name plural
119
-     *
120
-     * @return string
121
-     * @throws EE_Error
122
-     * @throws ReflectionException
123
-     */
124
-    public function currency_name_plural()
125
-    {
126
-        return $this->get('CNT_cur_plural');
127
-    }
128
-
129
-
130
-    /**
131
-     * currency_sign_before - ie: $TRUE  or  FALSE$
132
-     *
133
-     * @return boolean
134
-     * @throws EE_Error
135
-     * @throws ReflectionException
136
-     */
137
-    public function currency_sign_before()
138
-    {
139
-        return (bool) $this->get('CNT_cur_sign_b4');
140
-    }
141
-
142
-
143
-    /**
144
-     * currency_decimal_places : 2 = 0.00   3 = 0.000
145
-     *
146
-     * @return integer
147
-     * @throws EE_Error
148
-     * @throws ReflectionException
149
-     */
150
-    public function currency_decimal_places()
151
-    {
152
-        return $this->get('CNT_cur_dec_plc');
153
-    }
154
-
155
-
156
-    /**
157
-     * currency_decimal_mark :   (comma) ',' = 0,01   or   (decimal) '.' = 0.01
158
-     *
159
-     * @return string
160
-     * @throws EE_Error
161
-     * @throws ReflectionException
162
-     */
163
-    public function currency_decimal_mark()
164
-    {
165
-        return $this->get('CNT_cur_dec_mrk');
166
-    }
167
-
168
-
169
-    /**
170
-     * currency thousands separator:   (comma) ',' = 1,000   or   (decimal) '.' = 1.000
171
-     *
172
-     * @return string
173
-     * @throws EE_Error
174
-     * @throws ReflectionException
175
-     */
176
-    public function currency_thousands_separator()
177
-    {
178
-        return $this->get('CNT_cur_thsnds');
179
-    }
180
-
181
-
182
-    /**
183
-     * @return bool
184
-     * @throws EE_Error
185
-     * @throws ReflectionException
186
-     * @since $VID:$
187
-     */
188
-    public function isEU()
189
-    {
190
-        return (bool) $this->get('CNT_is_EU');
191
-    }
192
-
193
-
194
-    /**
195
-     * Country Telephone Code: +1
196
-     *
197
-     * @return string
198
-     * @throws EE_Error
199
-     * @throws ReflectionException
200
-     * @since $VID:$
201
-     */
202
-    public function telephoneCode()
203
-    {
204
-        return $this->get('CNT_tel_code');
205
-    }
206
-
207
-
208
-    /**
209
-     * @deprecated $VID:$
210
-     * @return bool
211
-     */
212
-    public function is_active()
213
-    {
214
-        return $this->isActive();
215
-    }
13
+	/**
14
+	 * @param array $props_n_values
15
+	 * @return EE_Country|mixed
16
+	 * @throws EE_Error
17
+	 * @throws ReflectionException
18
+	 */
19
+	public static function new_instance($props_n_values = [])
20
+	{
21
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
22
+		return $has_object ? $has_object : new self($props_n_values);
23
+	}
24
+
25
+
26
+	/**
27
+	 * @param array $props_n_values
28
+	 * @return EE_Country
29
+	 * @throws EE_Error
30
+	 * @throws ReflectionException
31
+	 */
32
+	public static function new_instance_from_db($props_n_values = [])
33
+	{
34
+		return new self($props_n_values, true);
35
+	}
36
+
37
+
38
+	/**
39
+	 * Gets the country name
40
+	 *
41
+	 * @return string
42
+	 * @throws EE_Error
43
+	 * @throws ReflectionException
44
+	 */
45
+	public function name()
46
+	{
47
+		return $this->get('CNT_name');
48
+	}
49
+
50
+
51
+	/**
52
+	 * Whether the country is active/enabled
53
+	 *
54
+	 * @return bool
55
+	 * @throws EE_Error
56
+	 * @throws ReflectionException
57
+	 */
58
+	public function isActive()
59
+	{
60
+		return (bool) $this->get('CNT_active');
61
+	}
62
+
63
+
64
+	/**
65
+	 * Gets the country ISO3
66
+	 *
67
+	 * @return string
68
+	 * @throws EE_Error
69
+	 * @throws ReflectionException
70
+	 */
71
+	public function ISO3()
72
+	{
73
+		return $this->get('CNT_ISO3');
74
+	}
75
+
76
+
77
+	/**
78
+	 * gets the country's currency code
79
+	 *
80
+	 * @return string
81
+	 * @throws EE_Error
82
+	 * @throws ReflectionException
83
+	 */
84
+	public function currency_code()
85
+	{
86
+		return $this->get('CNT_cur_code');
87
+	}
88
+
89
+
90
+	/**
91
+	 * gets the country's currency sign/symbol
92
+	 *
93
+	 * @return string
94
+	 * @throws EE_Error
95
+	 * @throws ReflectionException
96
+	 */
97
+	public function currency_sign()
98
+	{
99
+		$CNT_cur_sign = $this->get('CNT_cur_sign');
100
+		return $CNT_cur_sign ? $CNT_cur_sign : '';
101
+	}
102
+
103
+
104
+	/**
105
+	 * Currency name singular
106
+	 *
107
+	 * @return string
108
+	 * @throws EE_Error
109
+	 * @throws ReflectionException
110
+	 */
111
+	public function currency_name_single()
112
+	{
113
+		return $this->get('CNT_cur_single');
114
+	}
115
+
116
+
117
+	/**
118
+	 * Currency name plural
119
+	 *
120
+	 * @return string
121
+	 * @throws EE_Error
122
+	 * @throws ReflectionException
123
+	 */
124
+	public function currency_name_plural()
125
+	{
126
+		return $this->get('CNT_cur_plural');
127
+	}
128
+
129
+
130
+	/**
131
+	 * currency_sign_before - ie: $TRUE  or  FALSE$
132
+	 *
133
+	 * @return boolean
134
+	 * @throws EE_Error
135
+	 * @throws ReflectionException
136
+	 */
137
+	public function currency_sign_before()
138
+	{
139
+		return (bool) $this->get('CNT_cur_sign_b4');
140
+	}
141
+
142
+
143
+	/**
144
+	 * currency_decimal_places : 2 = 0.00   3 = 0.000
145
+	 *
146
+	 * @return integer
147
+	 * @throws EE_Error
148
+	 * @throws ReflectionException
149
+	 */
150
+	public function currency_decimal_places()
151
+	{
152
+		return $this->get('CNT_cur_dec_plc');
153
+	}
154
+
155
+
156
+	/**
157
+	 * currency_decimal_mark :   (comma) ',' = 0,01   or   (decimal) '.' = 0.01
158
+	 *
159
+	 * @return string
160
+	 * @throws EE_Error
161
+	 * @throws ReflectionException
162
+	 */
163
+	public function currency_decimal_mark()
164
+	{
165
+		return $this->get('CNT_cur_dec_mrk');
166
+	}
167
+
168
+
169
+	/**
170
+	 * currency thousands separator:   (comma) ',' = 1,000   or   (decimal) '.' = 1.000
171
+	 *
172
+	 * @return string
173
+	 * @throws EE_Error
174
+	 * @throws ReflectionException
175
+	 */
176
+	public function currency_thousands_separator()
177
+	{
178
+		return $this->get('CNT_cur_thsnds');
179
+	}
180
+
181
+
182
+	/**
183
+	 * @return bool
184
+	 * @throws EE_Error
185
+	 * @throws ReflectionException
186
+	 * @since $VID:$
187
+	 */
188
+	public function isEU()
189
+	{
190
+		return (bool) $this->get('CNT_is_EU');
191
+	}
192
+
193
+
194
+	/**
195
+	 * Country Telephone Code: +1
196
+	 *
197
+	 * @return string
198
+	 * @throws EE_Error
199
+	 * @throws ReflectionException
200
+	 * @since $VID:$
201
+	 */
202
+	public function telephoneCode()
203
+	{
204
+		return $this->get('CNT_tel_code');
205
+	}
206
+
207
+
208
+	/**
209
+	 * @deprecated $VID:$
210
+	 * @return bool
211
+	 */
212
+	public function is_active()
213
+	{
214
+		return $this->isActive();
215
+	}
216 216
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/AdminOptionsSettings.php 1 patch
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -26,191 +26,191 @@
 block discarded – undo
26 26
 class AdminOptionsSettings extends FormHandler
27 27
 {
28 28
 
29
-    protected $template_args = array();
29
+	protected $template_args = array();
30 30
 
31
-    /**
32
-     * Form constructor.
33
-     *
34
-     * @param \EE_Registry $registry
35
-     */
36
-    public function __construct(\EE_Registry $registry)
37
-    {
38
-        parent::__construct(
39
-            esc_html__('Admin Options', 'event_espresso'),
40
-            esc_html__('Admin Options', 'event_espresso'),
41
-            'admin_option_settings',
42
-            '',
43
-            FormHandler::DO_NOT_SETUP_FORM,
44
-            $registry
45
-        );
46
-    }
31
+	/**
32
+	 * Form constructor.
33
+	 *
34
+	 * @param \EE_Registry $registry
35
+	 */
36
+	public function __construct(\EE_Registry $registry)
37
+	{
38
+		parent::__construct(
39
+			esc_html__('Admin Options', 'event_espresso'),
40
+			esc_html__('Admin Options', 'event_espresso'),
41
+			'admin_option_settings',
42
+			'',
43
+			FormHandler::DO_NOT_SETUP_FORM,
44
+			$registry
45
+		);
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * @param array $template_args
51
-     */
52
-    public function setTemplateArgs(array $template_args)
53
-    {
54
-        $this->template_args = $template_args;
55
-    }
49
+	/**
50
+	 * @param array $template_args
51
+	 */
52
+	public function setTemplateArgs(array $template_args)
53
+	{
54
+		$this->template_args = $template_args;
55
+	}
56 56
 
57 57
 
58
-    /**
59
-     * creates and returns the actual form
60
-     *
61
-     * @return EE_Form_Section_Proper
62
-     * @throws EE_Error
63
-     */
64
-    public function generate()
65
-    {
66
-        $form = new EE_Form_Section_Proper(
67
-            array(
68
-                'name'            => 'admin_option_settings',
69
-                'html_id'         => 'admin_option_settings',
70
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
71
-                'subsections'     => array(
72
-                    'compatibility_hdr'        => new EE_Form_Section_HTML(
73
-                        EEH_HTML::h2(
74
-                            esc_html__('Compatibility Settings', 'event_espresso'),
75
-                            '',
76
-                            'ee-admin-settings-hdr'
77
-                        )
78
-                    ),
79
-                    'encode_session_data'      => new EE_Yes_No_Input(
80
-                        array(
81
-                            'html_label_text' => esc_html__('Encode Session Data?', 'event_espresso'),
82
-                            'html_help_text'  => sprintf(
83
-                                esc_html__(
84
-                                    'Some servers and database configurations can cause problems when saving the Event Espresso session data. Setting this option to "Yes" adds an extra layer of encoding to session data to prevent serialization errors, but can be incompatible with some server configurations.%1$sIf you receive "500 internal server" type errors during registration, try turning this option on.%1$sIf you get fatal PHP errors regarding missing base64 functions, then turn this option off.',
85
-                                    'event_espresso'
86
-                                ),
87
-                                '<br>'
88
-                            ),
89
-                            'default'         => $this->registry->CFG->admin->encode_session_data(),
90
-                            'required'        => false,
91
-                        )
92
-                    ),
93
-                ),
94
-            )
95
-        );
96
-        if (
97
-            $this->registry->CAP->current_user_can(
98
-                'manage_options',
99
-                'display_admin_settings_options_promote_and_affiliate'
100
-            )
101
-        ) {
102
-            $form->add_subsections(
103
-                array(
104
-                    'promote_ee_hdr'  => new EE_Form_Section_HTML(
105
-                        EEH_HTML::h2(
106
-                            esc_html__('Promote Event Espresso', 'event_espresso')
107
-                            . ' '
108
-                            . EEH_HTML::span(
109
-                                EEH_Template::get_help_tab_link('affiliate_info'),
110
-                                'affiliate_info'
111
-                            ),
112
-                            '',
113
-                            'ee-admin-settings-hdr'
114
-                        )
115
-                    ),
116
-                    'show_reg_footer' => new EE_Yes_No_Input(
117
-                        array(
118
-                            'html_label_text' => esc_html__(
119
-                                'Link to Event Espresso in your Registration Page?',
120
-                                'event_espresso'
121
-                            )
122
-                            . EEH_Template::get_help_tab_link('email_validation_info'),
123
-                            'html_help_text'  => esc_html__(
124
-                                'adds an unobtrusive link to Event Espresso\'s website in the footer of your registration form. Get an affiliate link (see below) and make money if people click the link and purchase Event Espresso.',
125
-                                'event_espresso'
126
-                            ),
127
-                            'default'         => filter_var($this->registry->CFG->admin->show_reg_footer, FILTER_VALIDATE_BOOLEAN),
128
-                            'required'        => false,
129
-                        )
130
-                    ),
131
-                    'affiliate_id'    => new EE_Text_Input(
132
-                        array(
133
-                            'html_label_text' => sprintf(
134
-                                esc_html__('Event Espresso %1$sAffiliate%2$s ID', 'event_espresso'),
135
-                                '<a href="https://eventespresso.com/affiliates/" target="_blank">',
136
-                                '</a>'
137
-                            ),
138
-                            'html_help_text'  => esc_html__(
139
-                                'Earn cash for promoting Event Espresso.',
140
-                                'event_espresso'
141
-                            ),
142
-                            'html_class'      => 'regular-text',
143
-                            'default'         => isset($this->registry->CFG->admin->affiliate_id)
144
-                                ? $this->registry->CFG->admin->get_pretty('affiliate_id')
145
-                                : '',
146
-                            'required'        => false,
147
-                        )
148
-                    ),
149
-                ),
150
-                'compatibility_hdr'
151
-            );
152
-        }
153
-        return $form;
154
-    }
58
+	/**
59
+	 * creates and returns the actual form
60
+	 *
61
+	 * @return EE_Form_Section_Proper
62
+	 * @throws EE_Error
63
+	 */
64
+	public function generate()
65
+	{
66
+		$form = new EE_Form_Section_Proper(
67
+			array(
68
+				'name'            => 'admin_option_settings',
69
+				'html_id'         => 'admin_option_settings',
70
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
71
+				'subsections'     => array(
72
+					'compatibility_hdr'        => new EE_Form_Section_HTML(
73
+						EEH_HTML::h2(
74
+							esc_html__('Compatibility Settings', 'event_espresso'),
75
+							'',
76
+							'ee-admin-settings-hdr'
77
+						)
78
+					),
79
+					'encode_session_data'      => new EE_Yes_No_Input(
80
+						array(
81
+							'html_label_text' => esc_html__('Encode Session Data?', 'event_espresso'),
82
+							'html_help_text'  => sprintf(
83
+								esc_html__(
84
+									'Some servers and database configurations can cause problems when saving the Event Espresso session data. Setting this option to "Yes" adds an extra layer of encoding to session data to prevent serialization errors, but can be incompatible with some server configurations.%1$sIf you receive "500 internal server" type errors during registration, try turning this option on.%1$sIf you get fatal PHP errors regarding missing base64 functions, then turn this option off.',
85
+									'event_espresso'
86
+								),
87
+								'<br>'
88
+							),
89
+							'default'         => $this->registry->CFG->admin->encode_session_data(),
90
+							'required'        => false,
91
+						)
92
+					),
93
+				),
94
+			)
95
+		);
96
+		if (
97
+			$this->registry->CAP->current_user_can(
98
+				'manage_options',
99
+				'display_admin_settings_options_promote_and_affiliate'
100
+			)
101
+		) {
102
+			$form->add_subsections(
103
+				array(
104
+					'promote_ee_hdr'  => new EE_Form_Section_HTML(
105
+						EEH_HTML::h2(
106
+							esc_html__('Promote Event Espresso', 'event_espresso')
107
+							. ' '
108
+							. EEH_HTML::span(
109
+								EEH_Template::get_help_tab_link('affiliate_info'),
110
+								'affiliate_info'
111
+							),
112
+							'',
113
+							'ee-admin-settings-hdr'
114
+						)
115
+					),
116
+					'show_reg_footer' => new EE_Yes_No_Input(
117
+						array(
118
+							'html_label_text' => esc_html__(
119
+								'Link to Event Espresso in your Registration Page?',
120
+								'event_espresso'
121
+							)
122
+							. EEH_Template::get_help_tab_link('email_validation_info'),
123
+							'html_help_text'  => esc_html__(
124
+								'adds an unobtrusive link to Event Espresso\'s website in the footer of your registration form. Get an affiliate link (see below) and make money if people click the link and purchase Event Espresso.',
125
+								'event_espresso'
126
+							),
127
+							'default'         => filter_var($this->registry->CFG->admin->show_reg_footer, FILTER_VALIDATE_BOOLEAN),
128
+							'required'        => false,
129
+						)
130
+					),
131
+					'affiliate_id'    => new EE_Text_Input(
132
+						array(
133
+							'html_label_text' => sprintf(
134
+								esc_html__('Event Espresso %1$sAffiliate%2$s ID', 'event_espresso'),
135
+								'<a href="https://eventespresso.com/affiliates/" target="_blank">',
136
+								'</a>'
137
+							),
138
+							'html_help_text'  => esc_html__(
139
+								'Earn cash for promoting Event Espresso.',
140
+								'event_espresso'
141
+							),
142
+							'html_class'      => 'regular-text',
143
+							'default'         => isset($this->registry->CFG->admin->affiliate_id)
144
+								? $this->registry->CFG->admin->get_pretty('affiliate_id')
145
+								: '',
146
+							'required'        => false,
147
+						)
148
+					),
149
+				),
150
+				'compatibility_hdr'
151
+			);
152
+		}
153
+		return $form;
154
+	}
155 155
 
156 156
 
157
-    /**
158
-     * takes the generated form and displays it along with ony other non-form HTML that may be required
159
-     * returns a string of HTML that can be directly echoed in a template
160
-     *
161
-     * @return string
162
-     * @throws LogicException
163
-     * @throws EE_Error
164
-     */
165
-    public function display()
166
-    {
167
-        add_filter(
168
-            'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__display__before_form',
169
-            array($this, 'handleOldAdminOptionsSettingsAction')
170
-        );
171
-        return parent::display();
172
-    }
157
+	/**
158
+	 * takes the generated form and displays it along with ony other non-form HTML that may be required
159
+	 * returns a string of HTML that can be directly echoed in a template
160
+	 *
161
+	 * @return string
162
+	 * @throws LogicException
163
+	 * @throws EE_Error
164
+	 */
165
+	public function display()
166
+	{
167
+		add_filter(
168
+			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__display__before_form',
169
+			array($this, 'handleOldAdminOptionsSettingsAction')
170
+		);
171
+		return parent::display();
172
+	}
173 173
 
174 174
 
175
-    /**
176
-     * @return string
177
-     */
178
-    public function handleOldAdminOptionsSettingsAction()
179
-    {
180
-        ob_start();
181
-        do_action('AHEE__admin_option_settings__template__before', $this->template_args);
182
-        return ob_get_clean();
183
-    }
175
+	/**
176
+	 * @return string
177
+	 */
178
+	public function handleOldAdminOptionsSettingsAction()
179
+	{
180
+		ob_start();
181
+		do_action('AHEE__admin_option_settings__template__before', $this->template_args);
182
+		return ob_get_clean();
183
+	}
184 184
 
185 185
 
186
-    /**
187
-     * handles processing the form submission
188
-     * returns true or false depending on whether the form was processed successfully or not
189
-     *
190
-     * @param array $form_data
191
-     * @return bool
192
-     * @throws InvalidFormSubmissionException
193
-     * @throws EE_Error
194
-     * @throws LogicException
195
-     * @throws InvalidArgumentException
196
-     * @throws InvalidDataTypeException
197
-     */
198
-    public function process($form_data = array())
199
-    {
200
-        // process form
201
-        $valid_data = (array) parent::process($form_data);
202
-        if (empty($valid_data)) {
203
-            return false;
204
-        }
205
-        $this->registry->CFG->admin->show_reg_footer = isset($form_data['show_reg_footer'])
206
-            ? absint($form_data['show_reg_footer'])
207
-            : $this->registry->CFG->admin->show_reg_footer;
208
-        $this->registry->CFG->admin->affiliate_id = isset($form_data['affiliate_id'])
209
-            ? sanitize_text_field($form_data['affiliate_id'])
210
-            : $this->registry->CFG->admin->affiliate_id;
211
-        if (isset($form_data['encode_session_data'])) {
212
-            $this->registry->CFG->admin->set_encode_session_data($form_data['encode_session_data']);
213
-        }
214
-        return false;
215
-    }
186
+	/**
187
+	 * handles processing the form submission
188
+	 * returns true or false depending on whether the form was processed successfully or not
189
+	 *
190
+	 * @param array $form_data
191
+	 * @return bool
192
+	 * @throws InvalidFormSubmissionException
193
+	 * @throws EE_Error
194
+	 * @throws LogicException
195
+	 * @throws InvalidArgumentException
196
+	 * @throws InvalidDataTypeException
197
+	 */
198
+	public function process($form_data = array())
199
+	{
200
+		// process form
201
+		$valid_data = (array) parent::process($form_data);
202
+		if (empty($valid_data)) {
203
+			return false;
204
+		}
205
+		$this->registry->CFG->admin->show_reg_footer = isset($form_data['show_reg_footer'])
206
+			? absint($form_data['show_reg_footer'])
207
+			: $this->registry->CFG->admin->show_reg_footer;
208
+		$this->registry->CFG->admin->affiliate_id = isset($form_data['affiliate_id'])
209
+			? sanitize_text_field($form_data['affiliate_id'])
210
+			: $this->registry->CFG->admin->affiliate_id;
211
+		if (isset($form_data['encode_session_data'])) {
212
+			$this->registry->CFG->admin->set_encode_session_data($form_data['encode_session_data']);
213
+		}
214
+		return false;
215
+	}
216 216
 }
Please login to merge, or discard this patch.
core/services/shortcodes/ShortcodesManager.php 1 patch
Indentation   +206 added lines, -206 removed lines patch added patch discarded remove patch
@@ -29,210 +29,210 @@
 block discarded – undo
29 29
  */
30 30
 class ShortcodesManager
31 31
 {
32
-    /**
33
-     * @type CurrentPage
34
-     */
35
-    protected $current_page;
36
-
37
-    /**
38
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
39
-     */
40
-    private $legacy_shortcodes_manager;
41
-
42
-    /**
43
-     * @var ShortcodeInterface[] $shortcodes
44
-     */
45
-    private $shortcodes;
46
-
47
-
48
-    /**
49
-     * ShortcodesManager constructor
50
-     *
51
-     * @param LegacyShortcodesManager $legacy_shortcodes_manager
52
-     * @param CurrentPage             $current_page
53
-     */
54
-    public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager, CurrentPage $current_page)
55
-    {
56
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
57
-        $this->current_page              = $current_page;
58
-        // assemble a list of installed and active shortcodes
59
-        add_action(
60
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
61
-            [$this, 'registerShortcodes'],
62
-            999
63
-        );
64
-        //  call add_shortcode() for all installed shortcodes
65
-        add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'addShortcodes']);
66
-        // check content for shortcodes the old way
67
-        add_action('parse_query', [$this->legacy_shortcodes_manager, 'initializeShortcodes'], 5);
68
-        // check content for shortcodes the NEW more efficient way
69
-        add_action('template_redirect', [$this, 'templateRedirect'], 999);
70
-    }
71
-
72
-
73
-    /**
74
-     * @return CollectionInterface|ShortcodeInterface[]
75
-     * @throws InvalidIdentifierException
76
-     * @throws InvalidInterfaceException
77
-     * @throws InvalidFilePathException
78
-     * @throws InvalidEntityException
79
-     * @throws InvalidDataTypeException
80
-     * @throws InvalidClassException
81
-     */
82
-    public function getShortcodes()
83
-    {
84
-        if (! $this->shortcodes instanceof CollectionInterface) {
85
-            $this->shortcodes = $this->loadShortcodesCollection();
86
-        }
87
-        return $this->shortcodes;
88
-    }
89
-
90
-
91
-    /**
92
-     * @return CollectionInterface|ShortcodeInterface[]
93
-     * @throws InvalidIdentifierException
94
-     * @throws InvalidInterfaceException
95
-     * @throws InvalidFilePathException
96
-     * @throws InvalidEntityException
97
-     * @throws InvalidDataTypeException
98
-     * @throws InvalidClassException
99
-     */
100
-    protected function loadShortcodesCollection()
101
-    {
102
-        $loader = new CollectionLoader(
103
-            new CollectionDetails(
104
-            // collection name
105
-                'shortcodes',
106
-                // collection interface
107
-                'EventEspresso\core\services\shortcodes\ShortcodeInterface',
108
-                // FQCNs for classes to add (all classes within that namespace will be loaded)
109
-                ['EventEspresso\core\domain\entities\shortcodes'],
110
-                // filepaths to classes to add
111
-                [],
112
-                // file mask to use if parsing folder for files to add
113
-                '',
114
-                // what to use as identifier for collection entities
115
-                // using CLASS NAME prevents duplicates (works like a singleton)
116
-                CollectionDetails::ID_CLASS_NAME
117
-            )
118
-        );
119
-        return $loader->getCollection();
120
-    }
121
-
122
-
123
-    /**
124
-     * @return void
125
-     * @throws DomainException
126
-     * @throws InvalidInterfaceException
127
-     * @throws InvalidIdentifierException
128
-     * @throws InvalidFilePathException
129
-     * @throws InvalidEntityException
130
-     * @throws InvalidDataTypeException
131
-     * @throws InvalidClassException
132
-     * @throws Exception
133
-     */
134
-    public function registerShortcodes()
135
-    {
136
-        try {
137
-            $this->shortcodes = apply_filters(
138
-                'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
139
-                $this->getShortcodes()
140
-            );
141
-            if (! $this->shortcodes instanceof CollectionInterface) {
142
-                throw new InvalidEntityException(
143
-                    $this->shortcodes,
144
-                    'CollectionInterface',
145
-                    sprintf(
146
-                        esc_html__(
147
-                            'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.',
148
-                            'event_espresso'
149
-                        ),
150
-                        is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes)
151
-                    )
152
-                );
153
-            }
154
-            $this->legacy_shortcodes_manager->registerShortcodes();
155
-        } catch (Exception $exception) {
156
-            new ExceptionStackTraceDisplay($exception);
157
-        }
158
-    }
159
-
160
-
161
-    /**
162
-     * @return void
163
-     * @throws Exception
164
-     */
165
-    public function addShortcodes()
166
-    {
167
-        try {
168
-            // cycle thru shortcode folders
169
-            foreach ($this->shortcodes as $shortcode) {
170
-                if ($shortcode instanceof EnqueueAssetsInterface) {
171
-                    add_action('wp_enqueue_scripts', [$shortcode, 'registerScriptsAndStylesheets'], 10);
172
-                    add_action('wp_enqueue_scripts', [$shortcode, 'enqueueStylesheets'], 11);
173
-                }
174
-                // add_shortcode() if it has not already been added
175
-                if (! shortcode_exists($shortcode->getTag())) {
176
-                    add_shortcode($shortcode->getTag(), [$shortcode, 'processShortcodeCallback']);
177
-                }
178
-            }
179
-            $this->legacy_shortcodes_manager->addShortcodes();
180
-        } catch (Exception $exception) {
181
-            new ExceptionStackTraceDisplay($exception);
182
-        }
183
-    }
184
-
185
-
186
-    /**
187
-     * callback for the "template_redirect" hook point
188
-     * checks posts for EE shortcodes, and initializes them,
189
-     * then toggles filter switch that loads core default assets
190
-     *
191
-     * @return void
192
-     */
193
-    public function templateRedirect()
194
-    {
195
-        global $wp_query;
196
-        if (empty($wp_query->posts)) {
197
-            return;
198
-        }
199
-        $load_assets = false;
200
-        // array of posts displayed in current request
201
-        $posts = is_array($wp_query->posts) ? $wp_query->posts : [$wp_query->posts];
202
-        foreach ($posts as $post) {
203
-            // now check post content and excerpt for EE shortcodes
204
-            $load_assets = $this->parseContentForShortcodes($post->post_content)
205
-                ? true
206
-                : $load_assets;
207
-        }
208
-        if ($load_assets) {
209
-            $this->current_page->setEspressoPage(true);
210
-            add_filter('FHEE_load_css', '__return_true');
211
-            add_filter('FHEE_load_js', '__return_true');
212
-        }
213
-    }
214
-
215
-
216
-    /**
217
-     * checks supplied content against list of shortcodes,
218
-     * then initializes any found shortcodes, and returns true.
219
-     * returns false if no shortcodes found.
220
-     *
221
-     * @param string $content
222
-     * @return bool
223
-     */
224
-    public function parseContentForShortcodes($content)
225
-    {
226
-        if (empty($this->shortcodes)) {
227
-            return false;
228
-        }
229
-        $has_shortcode = false;
230
-        foreach ($this->shortcodes as $shortcode) {
231
-            if (has_shortcode($content, $shortcode->getTag())) {
232
-                $shortcode->initializeShortcode();
233
-                $has_shortcode = true;
234
-            }
235
-        }
236
-        return $has_shortcode;
237
-    }
32
+	/**
33
+	 * @type CurrentPage
34
+	 */
35
+	protected $current_page;
36
+
37
+	/**
38
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
39
+	 */
40
+	private $legacy_shortcodes_manager;
41
+
42
+	/**
43
+	 * @var ShortcodeInterface[] $shortcodes
44
+	 */
45
+	private $shortcodes;
46
+
47
+
48
+	/**
49
+	 * ShortcodesManager constructor
50
+	 *
51
+	 * @param LegacyShortcodesManager $legacy_shortcodes_manager
52
+	 * @param CurrentPage             $current_page
53
+	 */
54
+	public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager, CurrentPage $current_page)
55
+	{
56
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
57
+		$this->current_page              = $current_page;
58
+		// assemble a list of installed and active shortcodes
59
+		add_action(
60
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
61
+			[$this, 'registerShortcodes'],
62
+			999
63
+		);
64
+		//  call add_shortcode() for all installed shortcodes
65
+		add_action('AHEE__EE_System__core_loaded_and_ready', [$this, 'addShortcodes']);
66
+		// check content for shortcodes the old way
67
+		add_action('parse_query', [$this->legacy_shortcodes_manager, 'initializeShortcodes'], 5);
68
+		// check content for shortcodes the NEW more efficient way
69
+		add_action('template_redirect', [$this, 'templateRedirect'], 999);
70
+	}
71
+
72
+
73
+	/**
74
+	 * @return CollectionInterface|ShortcodeInterface[]
75
+	 * @throws InvalidIdentifierException
76
+	 * @throws InvalidInterfaceException
77
+	 * @throws InvalidFilePathException
78
+	 * @throws InvalidEntityException
79
+	 * @throws InvalidDataTypeException
80
+	 * @throws InvalidClassException
81
+	 */
82
+	public function getShortcodes()
83
+	{
84
+		if (! $this->shortcodes instanceof CollectionInterface) {
85
+			$this->shortcodes = $this->loadShortcodesCollection();
86
+		}
87
+		return $this->shortcodes;
88
+	}
89
+
90
+
91
+	/**
92
+	 * @return CollectionInterface|ShortcodeInterface[]
93
+	 * @throws InvalidIdentifierException
94
+	 * @throws InvalidInterfaceException
95
+	 * @throws InvalidFilePathException
96
+	 * @throws InvalidEntityException
97
+	 * @throws InvalidDataTypeException
98
+	 * @throws InvalidClassException
99
+	 */
100
+	protected function loadShortcodesCollection()
101
+	{
102
+		$loader = new CollectionLoader(
103
+			new CollectionDetails(
104
+			// collection name
105
+				'shortcodes',
106
+				// collection interface
107
+				'EventEspresso\core\services\shortcodes\ShortcodeInterface',
108
+				// FQCNs for classes to add (all classes within that namespace will be loaded)
109
+				['EventEspresso\core\domain\entities\shortcodes'],
110
+				// filepaths to classes to add
111
+				[],
112
+				// file mask to use if parsing folder for files to add
113
+				'',
114
+				// what to use as identifier for collection entities
115
+				// using CLASS NAME prevents duplicates (works like a singleton)
116
+				CollectionDetails::ID_CLASS_NAME
117
+			)
118
+		);
119
+		return $loader->getCollection();
120
+	}
121
+
122
+
123
+	/**
124
+	 * @return void
125
+	 * @throws DomainException
126
+	 * @throws InvalidInterfaceException
127
+	 * @throws InvalidIdentifierException
128
+	 * @throws InvalidFilePathException
129
+	 * @throws InvalidEntityException
130
+	 * @throws InvalidDataTypeException
131
+	 * @throws InvalidClassException
132
+	 * @throws Exception
133
+	 */
134
+	public function registerShortcodes()
135
+	{
136
+		try {
137
+			$this->shortcodes = apply_filters(
138
+				'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
139
+				$this->getShortcodes()
140
+			);
141
+			if (! $this->shortcodes instanceof CollectionInterface) {
142
+				throw new InvalidEntityException(
143
+					$this->shortcodes,
144
+					'CollectionInterface',
145
+					sprintf(
146
+						esc_html__(
147
+							'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.',
148
+							'event_espresso'
149
+						),
150
+						is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes)
151
+					)
152
+				);
153
+			}
154
+			$this->legacy_shortcodes_manager->registerShortcodes();
155
+		} catch (Exception $exception) {
156
+			new ExceptionStackTraceDisplay($exception);
157
+		}
158
+	}
159
+
160
+
161
+	/**
162
+	 * @return void
163
+	 * @throws Exception
164
+	 */
165
+	public function addShortcodes()
166
+	{
167
+		try {
168
+			// cycle thru shortcode folders
169
+			foreach ($this->shortcodes as $shortcode) {
170
+				if ($shortcode instanceof EnqueueAssetsInterface) {
171
+					add_action('wp_enqueue_scripts', [$shortcode, 'registerScriptsAndStylesheets'], 10);
172
+					add_action('wp_enqueue_scripts', [$shortcode, 'enqueueStylesheets'], 11);
173
+				}
174
+				// add_shortcode() if it has not already been added
175
+				if (! shortcode_exists($shortcode->getTag())) {
176
+					add_shortcode($shortcode->getTag(), [$shortcode, 'processShortcodeCallback']);
177
+				}
178
+			}
179
+			$this->legacy_shortcodes_manager->addShortcodes();
180
+		} catch (Exception $exception) {
181
+			new ExceptionStackTraceDisplay($exception);
182
+		}
183
+	}
184
+
185
+
186
+	/**
187
+	 * callback for the "template_redirect" hook point
188
+	 * checks posts for EE shortcodes, and initializes them,
189
+	 * then toggles filter switch that loads core default assets
190
+	 *
191
+	 * @return void
192
+	 */
193
+	public function templateRedirect()
194
+	{
195
+		global $wp_query;
196
+		if (empty($wp_query->posts)) {
197
+			return;
198
+		}
199
+		$load_assets = false;
200
+		// array of posts displayed in current request
201
+		$posts = is_array($wp_query->posts) ? $wp_query->posts : [$wp_query->posts];
202
+		foreach ($posts as $post) {
203
+			// now check post content and excerpt for EE shortcodes
204
+			$load_assets = $this->parseContentForShortcodes($post->post_content)
205
+				? true
206
+				: $load_assets;
207
+		}
208
+		if ($load_assets) {
209
+			$this->current_page->setEspressoPage(true);
210
+			add_filter('FHEE_load_css', '__return_true');
211
+			add_filter('FHEE_load_js', '__return_true');
212
+		}
213
+	}
214
+
215
+
216
+	/**
217
+	 * checks supplied content against list of shortcodes,
218
+	 * then initializes any found shortcodes, and returns true.
219
+	 * returns false if no shortcodes found.
220
+	 *
221
+	 * @param string $content
222
+	 * @return bool
223
+	 */
224
+	public function parseContentForShortcodes($content)
225
+	{
226
+		if (empty($this->shortcodes)) {
227
+			return false;
228
+		}
229
+		$has_shortcode = false;
230
+		foreach ($this->shortcodes as $shortcode) {
231
+			if (has_shortcode($content, $shortcode->getTag())) {
232
+				$shortcode->initializeShortcode();
233
+				$has_shortcode = true;
234
+			}
235
+		}
236
+		return $has_shortcode;
237
+	}
238 238
 }
Please login to merge, or discard this patch.
core/EE_Front_Controller.core.php 2 patches
Indentation   +509 added lines, -509 removed lines patch added patch discarded remove patch
@@ -18,513 +18,513 @@
 block discarded – undo
18 18
 final class EE_Front_Controller
19 19
 {
20 20
 
21
-    /**
22
-     * @var string
23
-     */
24
-    private $_template_path;
25
-
26
-    /**
27
-     * @var string
28
-     */
29
-    private $_template;
30
-
31
-    /**
32
-     * @type EE_Registry
33
-     */
34
-    protected $Registry;
35
-
36
-    /**
37
-     * @type EE_Request_Handler
38
-     */
39
-    protected $Request_Handler;
40
-
41
-    /**
42
-     * @type EE_Module_Request_Router
43
-     */
44
-    protected $Module_Request_Router;
45
-
46
-    /**
47
-     * @type CurrentPage
48
-     */
49
-    protected $current_page;
50
-
51
-
52
-    /**
53
-     *    class constructor
54
-     *    should fire after shortcode, module, addon, or other plugin's default priority init phases have run
55
-     *
56
-     * @access    public
57
-     * @param EE_Registry              $Registry
58
-     * @param CurrentPage              $EspressoPage
59
-     * @param EE_Module_Request_Router $Module_Request_Router
60
-     */
61
-    public function __construct(
62
-        EE_Registry $Registry,
63
-        CurrentPage $EspressoPage,
64
-        EE_Module_Request_Router $Module_Request_Router
65
-    ) {
66
-        $this->Registry              = $Registry;
67
-        $this->current_page          = $EspressoPage;
68
-        $this->Module_Request_Router = $Module_Request_Router;
69
-        // load other resources and begin to actually run shortcodes and modules
70
-        // analyse the incoming WP request
71
-        add_action('parse_request', array($this, 'get_request'), 1, 1);
72
-        // process request with module factory
73
-        add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1);
74
-        // before headers sent
75
-        add_action('wp', array($this, 'wp'), 5);
76
-        // primarily used to process any content shortcodes
77
-        add_action('template_redirect', array($this, 'templateRedirect'), 999);
78
-        // header
79
-        add_action('wp_head', array($this, 'header_meta_tag'), 5);
80
-        add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10);
81
-        add_filter('template_include', array($this, 'template_include'), 1);
82
-        // display errors
83
-        add_action('loop_start', array($this, 'display_errors'), 2);
84
-        // the content
85
-        // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 );
86
-        // exclude our private cpt comments
87
-        add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1);
88
-        // make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://)
89
-        add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1);
90
-        // action hook EE
91
-        do_action('AHEE__EE_Front_Controller__construct__done', $this);
92
-    }
93
-
94
-
95
-    /**
96
-     * @return EE_Request_Handler
97
-     * @deprecated 4.10.14.p
98
-     */
99
-    public function Request_Handler()
100
-    {
101
-        if (! $this->Request_Handler instanceof EE_Request_Handler) {
102
-            $this->Request_Handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler');
103
-        }
104
-        return $this->Request_Handler;
105
-    }
106
-
107
-
108
-    /**
109
-     * @return EE_Module_Request_Router
110
-     */
111
-    public function Module_Request_Router()
112
-    {
113
-        return $this->Module_Request_Router;
114
-    }
115
-
116
-
117
-    /**
118
-     * @return LegacyShortcodesManager
119
-     * @deprecated 4.10.14.p
120
-     */
121
-    public function getLegacyShortcodesManager()
122
-    {
123
-        return EE_Config::getLegacyShortcodesManager();
124
-    }
125
-
126
-
127
-
128
-
129
-
130
-    /***********************************************        INIT ACTION HOOK         ***********************************************/
131
-    /**
132
-     * filter_wp_comments
133
-     * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment
134
-     * widgets/queries done on frontend
135
-     *
136
-     * @param  array $clauses array of comment clauses setup by WP_Comment_Query
137
-     * @return array array of comment clauses with modifications.
138
-     * @throws InvalidArgumentException
139
-     * @throws InvalidDataTypeException
140
-     * @throws InvalidInterfaceException
141
-     */
142
-    public function filter_wp_comments($clauses)
143
-    {
144
-        global $wpdb;
145
-        if (strpos($clauses['join'], $wpdb->posts) !== false) {
146
-            /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
147
-            $custom_post_types = LoaderFactory::getLoader()->getShared(
148
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
149
-            );
150
-            $cpts = $custom_post_types->getPrivateCustomPostTypes();
151
-            foreach ($cpts as $cpt => $details) {
152
-                $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt);
153
-            }
154
-        }
155
-        return $clauses;
156
-    }
157
-
158
-
159
-    /**
160
-     * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend
161
-     *
162
-     * @param  string $url incoming url
163
-     * @return string         final assembled url
164
-     */
165
-    public function maybe_force_admin_ajax_ssl($url)
166
-    {
167
-        if (is_ssl() && preg_match('/admin-ajax.php/', $url)) {
168
-            $url = str_replace('http://', 'https://', $url);
169
-        }
170
-        return $url;
171
-    }
172
-
173
-
174
-
175
-
176
-
177
-
178
-    /***********************************************        WP_LOADED ACTION HOOK         ***********************************************/
179
-
180
-
181
-    /**
182
-     *    wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their
183
-     *    default priority init phases have run
184
-     *
185
-     * @access    public
186
-     * @return    void
187
-     */
188
-    public function wp_loaded()
189
-    {
190
-    }
191
-
192
-
193
-
194
-
195
-
196
-    /***********************************************        PARSE_REQUEST HOOK         ***********************************************/
197
-    /**
198
-     *    _get_request
199
-     *
200
-     * @access public
201
-     * @param WP $WP
202
-     * @return void
203
-     */
204
-    public function get_request(WP $WP)
205
-    {
206
-        do_action('AHEE__EE_Front_Controller__get_request__start');
207
-        $this->current_page->parseQueryVars($WP);
208
-        do_action('AHEE__EE_Front_Controller__get_request__complete');
209
-        remove_action('parse_request', [$this, 'get_request'], 1);
210
-    }
211
-
212
-
213
-    /**
214
-     *    pre_get_posts - basically a module factory for instantiating modules and selecting the final view template
215
-     *
216
-     * @access    public
217
-     * @param WP_Query $WP_Query
218
-     * @return    void
219
-     * @throws EE_Error
220
-     * @throws ReflectionException
221
-     */
222
-    public function pre_get_posts($WP_Query)
223
-    {
224
-        // only load Module_Request_Router if this is the main query
225
-        if (
226
-            $this->Module_Request_Router instanceof EE_Module_Request_Router
227
-            && $WP_Query->is_main_query()
228
-        ) {
229
-            // cycle thru module routes
230
-            while ($route = $this->Module_Request_Router->get_route($WP_Query)) {
231
-                // determine module and method for route
232
-                $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]);
233
-                if ($module instanceof EED_Module) {
234
-                    // get registered view for route
235
-                    $this->_template_path = $this->Module_Request_Router->get_view($route);
236
-                    // grab module name
237
-                    $module_name = $module->module_name();
238
-                    // map the module to the module objects
239
-                    $this->Registry->modules->{$module_name} = $module;
240
-                }
241
-            }
242
-        }
243
-    }
244
-
245
-
246
-
247
-
248
-
249
-    /***********************************************        WP HOOK         ***********************************************/
250
-
251
-
252
-    /**
253
-     *    wp - basically last chance to do stuff before headers sent
254
-     *
255
-     * @access    public
256
-     * @return    void
257
-     */
258
-    public function wp()
259
-    {
260
-    }
261
-
262
-
263
-
264
-    /***********************     GET_HEADER && WP_HEAD HOOK     ***********************/
265
-
266
-
267
-    /**
268
-     * callback for the "template_redirect" hook point
269
-     * checks sidebars for EE widgets
270
-     * loads resources and assets accordingly
271
-     *
272
-     * @return void
273
-     */
274
-    public function templateRedirect()
275
-    {
276
-        global $wp_query;
277
-        if (empty($wp_query->posts)) {
278
-            return;
279
-        }
280
-        // if we already know this is an espresso page, then load assets
281
-        $load_assets = $this->current_page->isEspressoPage();
282
-        // if we are already loading assets then just move along, otherwise check for widgets
283
-        $load_assets = $load_assets || $this->espresso_widgets_in_active_sidebars();
284
-        if ($load_assets) {
285
-            add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10);
286
-            add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10);
287
-        }
288
-    }
289
-
290
-
291
-    /**
292
-     * builds list of active widgets then scans active sidebars looking for them
293
-     * returns true is an EE widget is found in an active sidebar
294
-     * Please Note: this does NOT mean that the sidebar or widget
295
-     * is actually in use in a given template, as that is unfortunately not known
296
-     * until a sidebar and it's widgets are actually loaded
297
-     *
298
-     * @return boolean
299
-     */
300
-    private function espresso_widgets_in_active_sidebars()
301
-    {
302
-        $espresso_widgets = array();
303
-        foreach ($this->Registry->widgets as $widget_class => $widget) {
304
-            $id_base = EspressoWidget::getIdBase($widget_class);
305
-            if (is_active_widget(false, false, $id_base)) {
306
-                $espresso_widgets[] = $id_base;
307
-            }
308
-        }
309
-        $all_sidebar_widgets = wp_get_sidebars_widgets();
310
-        foreach ($all_sidebar_widgets as $sidebar_widgets) {
311
-            if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) {
312
-                foreach ($sidebar_widgets as $sidebar_widget) {
313
-                    foreach ($espresso_widgets as $espresso_widget) {
314
-                        if (strpos($sidebar_widget, $espresso_widget) !== false) {
315
-                            return true;
316
-                        }
317
-                    }
318
-                }
319
-            }
320
-        }
321
-        return false;
322
-    }
323
-
324
-
325
-    /**
326
-     *    header_meta_tag
327
-     *
328
-     * @access    public
329
-     * @return    void
330
-     */
331
-    public function header_meta_tag()
332
-    {
333
-        print(
334
-        apply_filters(
335
-            'FHEE__EE_Front_Controller__header_meta_tag',
336
-            '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n"
337
-        )
338
-        );
339
-
340
-        // let's exclude all event type taxonomy term archive pages from search engine indexing
341
-        // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249
342
-        // also exclude all critical pages from indexing
343
-        if (
344
-            (
345
-                is_tax('espresso_event_type')
346
-                && get_option('blog_public') !== '0'
347
-            )
348
-            || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array())
349
-        ) {
350
-            print(
351
-            apply_filters(
352
-                'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type',
353
-                '<meta name="robots" content="noindex,follow" />' . "\n"
354
-            )
355
-            );
356
-        }
357
-    }
358
-
359
-
360
-    /**
361
-     * wp_print_scripts
362
-     *
363
-     * @return void
364
-     * @throws EE_Error
365
-     */
366
-    public function wp_print_scripts()
367
-    {
368
-        global $post;
369
-        if (
370
-            isset($post->EE_Event)
371
-            && $post->EE_Event instanceof EE_Event
372
-            && get_post_type() === 'espresso_events'
373
-            && is_singular()
374
-        ) {
375
-            EEH_Schema::add_json_linked_data_for_event($post->EE_Event);
376
-        }
377
-    }
378
-
379
-
380
-    public function enqueueStyle()
381
-    {
382
-        wp_enqueue_style('espresso_default');
383
-        wp_enqueue_style('espresso_custom_css');
384
-    }
385
-
386
-
387
-
388
-    /***********************************************        WP_FOOTER         ***********************************************/
389
-
390
-
391
-    public function enqueueScripts()
392
-    {
393
-        wp_enqueue_script('espresso_core');
394
-    }
395
-
396
-
397
-    /**
398
-     * display_errors
399
-     *
400
-     * @access public
401
-     * @return void
402
-     * @throws DomainException
403
-     */
404
-    public function display_errors()
405
-    {
406
-        static $shown_already = false;
407
-        do_action('AHEE__EE_Front_Controller__display_errors__begin');
408
-        if (
409
-            ! $shown_already
410
-            && apply_filters('FHEE__EE_Front_Controller__display_errors', true)
411
-            && is_main_query()
412
-            && ! is_feed()
413
-            && in_the_loop()
414
-            && $this->current_page->isEspressoPage()
415
-        ) {
416
-            $shown_already = true;
417
-            if (did_action('wp_head')) {
418
-                $this->printNotices();
419
-            } else {
420
-                // block enabled themes run their query loop before headers are sent
421
-                // so we need to add our notices onto the beginning of the content
422
-                add_filter('the_content', [$this, 'prependNotices'], 1, 1);
423
-            }
424
-        }
425
-        do_action('AHEE__EE_Front_Controller__display_errors__end');
426
-    }
427
-
428
-
429
-    /**
430
-     * @param string $the_content
431
-     * @return string
432
-     * @since $VID:$
433
-     */
434
-    public function prependNotices($the_content)
435
-    {
436
-        $notices = $this->printNotices();
437
-        return $notices ? $notices . $the_content : $the_content;
438
-    }
439
-
440
-
441
-    /**
442
-     * @return false|string
443
-     * @since $VID:$
444
-     */
445
-    public function printNotices()
446
-    {
447
-        ob_start();
448
-        echo wp_kses(EE_Error::get_notices(), AllowedTags::getWithFormTags());
449
-        EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php');
450
-        return ob_get_clean();
451
-    }
452
-
453
-
454
-
455
-    /***********************************************        UTILITIES         ***********************************************/
456
-
457
-
458
-    /**
459
-     * @param string $template_include_path
460
-     * @return string
461
-     * @throws EE_Error
462
-     * @throws ReflectionException
463
-     */
464
-    public function template_include($template_include_path = null)
465
-    {
466
-        if ($this->current_page->isEspressoPage()) {
467
-            // despite all helpers having autoloaders set, we need to manually load the template loader
468
-            // because there are some side effects in that class for triggering template tag functions
469
-            $this->Registry->load_helper('EEH_Template');
470
-            $this->_template_path = ! empty($this->_template_path)
471
-                ? basename($this->_template_path)
472
-                : basename(
473
-                    $template_include_path
474
-                );
475
-            $template_path = EEH_Template::locate_template($this->_template_path, array(), false);
476
-            $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path;
477
-            $this->_template = basename($this->_template_path);
478
-            return $this->_template_path;
479
-        }
480
-        return $template_include_path;
481
-    }
482
-
483
-
484
-    /**
485
-     * @param bool $with_path
486
-     * @return    string
487
-     */
488
-    public function get_selected_template($with_path = false)
489
-    {
490
-        return $with_path ? $this->_template_path : $this->_template;
491
-    }
492
-
493
-
494
-    /**
495
-     * @param string $shortcode_class
496
-     * @param WP     $wp
497
-     * @throws ReflectionException
498
-     * @deprecated 4.9.26
499
-     */
500
-    public function initialize_shortcode($shortcode_class = '', WP $wp = null)
501
-    {
502
-        EE_Error::doing_it_wrong(
503
-            __METHOD__,
504
-            esc_html__(
505
-                'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.',
506
-                'event_espresso'
507
-            ),
508
-            '4.9.26'
509
-        );
510
-        $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp);
511
-    }
512
-
513
-
514
-    /**
515
-     * @return void
516
-     * @deprecated 4.9.57.p
517
-     */
518
-    public function loadPersistentAdminNoticeManager()
519
-    {
520
-    }
521
-
522
-
523
-    /**
524
-     * @return void
525
-     * @deprecated 4.9.64.p
526
-     */
527
-    public function employ_CPT_Strategy()
528
-    {
529
-    }
21
+	/**
22
+	 * @var string
23
+	 */
24
+	private $_template_path;
25
+
26
+	/**
27
+	 * @var string
28
+	 */
29
+	private $_template;
30
+
31
+	/**
32
+	 * @type EE_Registry
33
+	 */
34
+	protected $Registry;
35
+
36
+	/**
37
+	 * @type EE_Request_Handler
38
+	 */
39
+	protected $Request_Handler;
40
+
41
+	/**
42
+	 * @type EE_Module_Request_Router
43
+	 */
44
+	protected $Module_Request_Router;
45
+
46
+	/**
47
+	 * @type CurrentPage
48
+	 */
49
+	protected $current_page;
50
+
51
+
52
+	/**
53
+	 *    class constructor
54
+	 *    should fire after shortcode, module, addon, or other plugin's default priority init phases have run
55
+	 *
56
+	 * @access    public
57
+	 * @param EE_Registry              $Registry
58
+	 * @param CurrentPage              $EspressoPage
59
+	 * @param EE_Module_Request_Router $Module_Request_Router
60
+	 */
61
+	public function __construct(
62
+		EE_Registry $Registry,
63
+		CurrentPage $EspressoPage,
64
+		EE_Module_Request_Router $Module_Request_Router
65
+	) {
66
+		$this->Registry              = $Registry;
67
+		$this->current_page          = $EspressoPage;
68
+		$this->Module_Request_Router = $Module_Request_Router;
69
+		// load other resources and begin to actually run shortcodes and modules
70
+		// analyse the incoming WP request
71
+		add_action('parse_request', array($this, 'get_request'), 1, 1);
72
+		// process request with module factory
73
+		add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1);
74
+		// before headers sent
75
+		add_action('wp', array($this, 'wp'), 5);
76
+		// primarily used to process any content shortcodes
77
+		add_action('template_redirect', array($this, 'templateRedirect'), 999);
78
+		// header
79
+		add_action('wp_head', array($this, 'header_meta_tag'), 5);
80
+		add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10);
81
+		add_filter('template_include', array($this, 'template_include'), 1);
82
+		// display errors
83
+		add_action('loop_start', array($this, 'display_errors'), 2);
84
+		// the content
85
+		// add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 );
86
+		// exclude our private cpt comments
87
+		add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1);
88
+		// make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://)
89
+		add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1);
90
+		// action hook EE
91
+		do_action('AHEE__EE_Front_Controller__construct__done', $this);
92
+	}
93
+
94
+
95
+	/**
96
+	 * @return EE_Request_Handler
97
+	 * @deprecated 4.10.14.p
98
+	 */
99
+	public function Request_Handler()
100
+	{
101
+		if (! $this->Request_Handler instanceof EE_Request_Handler) {
102
+			$this->Request_Handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler');
103
+		}
104
+		return $this->Request_Handler;
105
+	}
106
+
107
+
108
+	/**
109
+	 * @return EE_Module_Request_Router
110
+	 */
111
+	public function Module_Request_Router()
112
+	{
113
+		return $this->Module_Request_Router;
114
+	}
115
+
116
+
117
+	/**
118
+	 * @return LegacyShortcodesManager
119
+	 * @deprecated 4.10.14.p
120
+	 */
121
+	public function getLegacyShortcodesManager()
122
+	{
123
+		return EE_Config::getLegacyShortcodesManager();
124
+	}
125
+
126
+
127
+
128
+
129
+
130
+	/***********************************************        INIT ACTION HOOK         ***********************************************/
131
+	/**
132
+	 * filter_wp_comments
133
+	 * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment
134
+	 * widgets/queries done on frontend
135
+	 *
136
+	 * @param  array $clauses array of comment clauses setup by WP_Comment_Query
137
+	 * @return array array of comment clauses with modifications.
138
+	 * @throws InvalidArgumentException
139
+	 * @throws InvalidDataTypeException
140
+	 * @throws InvalidInterfaceException
141
+	 */
142
+	public function filter_wp_comments($clauses)
143
+	{
144
+		global $wpdb;
145
+		if (strpos($clauses['join'], $wpdb->posts) !== false) {
146
+			/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
147
+			$custom_post_types = LoaderFactory::getLoader()->getShared(
148
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
149
+			);
150
+			$cpts = $custom_post_types->getPrivateCustomPostTypes();
151
+			foreach ($cpts as $cpt => $details) {
152
+				$clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt);
153
+			}
154
+		}
155
+		return $clauses;
156
+	}
157
+
158
+
159
+	/**
160
+	 * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend
161
+	 *
162
+	 * @param  string $url incoming url
163
+	 * @return string         final assembled url
164
+	 */
165
+	public function maybe_force_admin_ajax_ssl($url)
166
+	{
167
+		if (is_ssl() && preg_match('/admin-ajax.php/', $url)) {
168
+			$url = str_replace('http://', 'https://', $url);
169
+		}
170
+		return $url;
171
+	}
172
+
173
+
174
+
175
+
176
+
177
+
178
+	/***********************************************        WP_LOADED ACTION HOOK         ***********************************************/
179
+
180
+
181
+	/**
182
+	 *    wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their
183
+	 *    default priority init phases have run
184
+	 *
185
+	 * @access    public
186
+	 * @return    void
187
+	 */
188
+	public function wp_loaded()
189
+	{
190
+	}
191
+
192
+
193
+
194
+
195
+
196
+	/***********************************************        PARSE_REQUEST HOOK         ***********************************************/
197
+	/**
198
+	 *    _get_request
199
+	 *
200
+	 * @access public
201
+	 * @param WP $WP
202
+	 * @return void
203
+	 */
204
+	public function get_request(WP $WP)
205
+	{
206
+		do_action('AHEE__EE_Front_Controller__get_request__start');
207
+		$this->current_page->parseQueryVars($WP);
208
+		do_action('AHEE__EE_Front_Controller__get_request__complete');
209
+		remove_action('parse_request', [$this, 'get_request'], 1);
210
+	}
211
+
212
+
213
+	/**
214
+	 *    pre_get_posts - basically a module factory for instantiating modules and selecting the final view template
215
+	 *
216
+	 * @access    public
217
+	 * @param WP_Query $WP_Query
218
+	 * @return    void
219
+	 * @throws EE_Error
220
+	 * @throws ReflectionException
221
+	 */
222
+	public function pre_get_posts($WP_Query)
223
+	{
224
+		// only load Module_Request_Router if this is the main query
225
+		if (
226
+			$this->Module_Request_Router instanceof EE_Module_Request_Router
227
+			&& $WP_Query->is_main_query()
228
+		) {
229
+			// cycle thru module routes
230
+			while ($route = $this->Module_Request_Router->get_route($WP_Query)) {
231
+				// determine module and method for route
232
+				$module = $this->Module_Request_Router->resolve_route($route[0], $route[1]);
233
+				if ($module instanceof EED_Module) {
234
+					// get registered view for route
235
+					$this->_template_path = $this->Module_Request_Router->get_view($route);
236
+					// grab module name
237
+					$module_name = $module->module_name();
238
+					// map the module to the module objects
239
+					$this->Registry->modules->{$module_name} = $module;
240
+				}
241
+			}
242
+		}
243
+	}
244
+
245
+
246
+
247
+
248
+
249
+	/***********************************************        WP HOOK         ***********************************************/
250
+
251
+
252
+	/**
253
+	 *    wp - basically last chance to do stuff before headers sent
254
+	 *
255
+	 * @access    public
256
+	 * @return    void
257
+	 */
258
+	public function wp()
259
+	{
260
+	}
261
+
262
+
263
+
264
+	/***********************     GET_HEADER && WP_HEAD HOOK     ***********************/
265
+
266
+
267
+	/**
268
+	 * callback for the "template_redirect" hook point
269
+	 * checks sidebars for EE widgets
270
+	 * loads resources and assets accordingly
271
+	 *
272
+	 * @return void
273
+	 */
274
+	public function templateRedirect()
275
+	{
276
+		global $wp_query;
277
+		if (empty($wp_query->posts)) {
278
+			return;
279
+		}
280
+		// if we already know this is an espresso page, then load assets
281
+		$load_assets = $this->current_page->isEspressoPage();
282
+		// if we are already loading assets then just move along, otherwise check for widgets
283
+		$load_assets = $load_assets || $this->espresso_widgets_in_active_sidebars();
284
+		if ($load_assets) {
285
+			add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10);
286
+			add_action('wp_print_footer_scripts', array($this, 'enqueueScripts'), 10);
287
+		}
288
+	}
289
+
290
+
291
+	/**
292
+	 * builds list of active widgets then scans active sidebars looking for them
293
+	 * returns true is an EE widget is found in an active sidebar
294
+	 * Please Note: this does NOT mean that the sidebar or widget
295
+	 * is actually in use in a given template, as that is unfortunately not known
296
+	 * until a sidebar and it's widgets are actually loaded
297
+	 *
298
+	 * @return boolean
299
+	 */
300
+	private function espresso_widgets_in_active_sidebars()
301
+	{
302
+		$espresso_widgets = array();
303
+		foreach ($this->Registry->widgets as $widget_class => $widget) {
304
+			$id_base = EspressoWidget::getIdBase($widget_class);
305
+			if (is_active_widget(false, false, $id_base)) {
306
+				$espresso_widgets[] = $id_base;
307
+			}
308
+		}
309
+		$all_sidebar_widgets = wp_get_sidebars_widgets();
310
+		foreach ($all_sidebar_widgets as $sidebar_widgets) {
311
+			if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) {
312
+				foreach ($sidebar_widgets as $sidebar_widget) {
313
+					foreach ($espresso_widgets as $espresso_widget) {
314
+						if (strpos($sidebar_widget, $espresso_widget) !== false) {
315
+							return true;
316
+						}
317
+					}
318
+				}
319
+			}
320
+		}
321
+		return false;
322
+	}
323
+
324
+
325
+	/**
326
+	 *    header_meta_tag
327
+	 *
328
+	 * @access    public
329
+	 * @return    void
330
+	 */
331
+	public function header_meta_tag()
332
+	{
333
+		print(
334
+		apply_filters(
335
+			'FHEE__EE_Front_Controller__header_meta_tag',
336
+			'<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n"
337
+		)
338
+		);
339
+
340
+		// let's exclude all event type taxonomy term archive pages from search engine indexing
341
+		// @see https://events.codebasehq.com/projects/event-espresso/tickets/10249
342
+		// also exclude all critical pages from indexing
343
+		if (
344
+			(
345
+				is_tax('espresso_event_type')
346
+				&& get_option('blog_public') !== '0'
347
+			)
348
+			|| is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array())
349
+		) {
350
+			print(
351
+			apply_filters(
352
+				'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type',
353
+				'<meta name="robots" content="noindex,follow" />' . "\n"
354
+			)
355
+			);
356
+		}
357
+	}
358
+
359
+
360
+	/**
361
+	 * wp_print_scripts
362
+	 *
363
+	 * @return void
364
+	 * @throws EE_Error
365
+	 */
366
+	public function wp_print_scripts()
367
+	{
368
+		global $post;
369
+		if (
370
+			isset($post->EE_Event)
371
+			&& $post->EE_Event instanceof EE_Event
372
+			&& get_post_type() === 'espresso_events'
373
+			&& is_singular()
374
+		) {
375
+			EEH_Schema::add_json_linked_data_for_event($post->EE_Event);
376
+		}
377
+	}
378
+
379
+
380
+	public function enqueueStyle()
381
+	{
382
+		wp_enqueue_style('espresso_default');
383
+		wp_enqueue_style('espresso_custom_css');
384
+	}
385
+
386
+
387
+
388
+	/***********************************************        WP_FOOTER         ***********************************************/
389
+
390
+
391
+	public function enqueueScripts()
392
+	{
393
+		wp_enqueue_script('espresso_core');
394
+	}
395
+
396
+
397
+	/**
398
+	 * display_errors
399
+	 *
400
+	 * @access public
401
+	 * @return void
402
+	 * @throws DomainException
403
+	 */
404
+	public function display_errors()
405
+	{
406
+		static $shown_already = false;
407
+		do_action('AHEE__EE_Front_Controller__display_errors__begin');
408
+		if (
409
+			! $shown_already
410
+			&& apply_filters('FHEE__EE_Front_Controller__display_errors', true)
411
+			&& is_main_query()
412
+			&& ! is_feed()
413
+			&& in_the_loop()
414
+			&& $this->current_page->isEspressoPage()
415
+		) {
416
+			$shown_already = true;
417
+			if (did_action('wp_head')) {
418
+				$this->printNotices();
419
+			} else {
420
+				// block enabled themes run their query loop before headers are sent
421
+				// so we need to add our notices onto the beginning of the content
422
+				add_filter('the_content', [$this, 'prependNotices'], 1, 1);
423
+			}
424
+		}
425
+		do_action('AHEE__EE_Front_Controller__display_errors__end');
426
+	}
427
+
428
+
429
+	/**
430
+	 * @param string $the_content
431
+	 * @return string
432
+	 * @since $VID:$
433
+	 */
434
+	public function prependNotices($the_content)
435
+	{
436
+		$notices = $this->printNotices();
437
+		return $notices ? $notices . $the_content : $the_content;
438
+	}
439
+
440
+
441
+	/**
442
+	 * @return false|string
443
+	 * @since $VID:$
444
+	 */
445
+	public function printNotices()
446
+	{
447
+		ob_start();
448
+		echo wp_kses(EE_Error::get_notices(), AllowedTags::getWithFormTags());
449
+		EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php');
450
+		return ob_get_clean();
451
+	}
452
+
453
+
454
+
455
+	/***********************************************        UTILITIES         ***********************************************/
456
+
457
+
458
+	/**
459
+	 * @param string $template_include_path
460
+	 * @return string
461
+	 * @throws EE_Error
462
+	 * @throws ReflectionException
463
+	 */
464
+	public function template_include($template_include_path = null)
465
+	{
466
+		if ($this->current_page->isEspressoPage()) {
467
+			// despite all helpers having autoloaders set, we need to manually load the template loader
468
+			// because there are some side effects in that class for triggering template tag functions
469
+			$this->Registry->load_helper('EEH_Template');
470
+			$this->_template_path = ! empty($this->_template_path)
471
+				? basename($this->_template_path)
472
+				: basename(
473
+					$template_include_path
474
+				);
475
+			$template_path = EEH_Template::locate_template($this->_template_path, array(), false);
476
+			$this->_template_path = ! empty($template_path) ? $template_path : $template_include_path;
477
+			$this->_template = basename($this->_template_path);
478
+			return $this->_template_path;
479
+		}
480
+		return $template_include_path;
481
+	}
482
+
483
+
484
+	/**
485
+	 * @param bool $with_path
486
+	 * @return    string
487
+	 */
488
+	public function get_selected_template($with_path = false)
489
+	{
490
+		return $with_path ? $this->_template_path : $this->_template;
491
+	}
492
+
493
+
494
+	/**
495
+	 * @param string $shortcode_class
496
+	 * @param WP     $wp
497
+	 * @throws ReflectionException
498
+	 * @deprecated 4.9.26
499
+	 */
500
+	public function initialize_shortcode($shortcode_class = '', WP $wp = null)
501
+	{
502
+		EE_Error::doing_it_wrong(
503
+			__METHOD__,
504
+			esc_html__(
505
+				'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.',
506
+				'event_espresso'
507
+			),
508
+			'4.9.26'
509
+		);
510
+		$this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp);
511
+	}
512
+
513
+
514
+	/**
515
+	 * @return void
516
+	 * @deprecated 4.9.57.p
517
+	 */
518
+	public function loadPersistentAdminNoticeManager()
519
+	{
520
+	}
521
+
522
+
523
+	/**
524
+	 * @return void
525
+	 * @deprecated 4.9.64.p
526
+	 */
527
+	public function employ_CPT_Strategy()
528
+	{
529
+	}
530 530
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      */
99 99
     public function Request_Handler()
100 100
     {
101
-        if (! $this->Request_Handler instanceof EE_Request_Handler) {
101
+        if ( ! $this->Request_Handler instanceof EE_Request_Handler) {
102 102
             $this->Request_Handler = LoaderFactory::getLoader()->getShared('EE_Request_Handler');
103 103
         }
104 104
         return $this->Request_Handler;
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
         print(
334 334
         apply_filters(
335 335
             'FHEE__EE_Front_Controller__header_meta_tag',
336
-            '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n"
336
+            '<meta name="generator" content="Event Espresso Version '.EVENT_ESPRESSO_VERSION."\" />\n"
337 337
         )
338 338
         );
339 339
 
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
             print(
351 351
             apply_filters(
352 352
                 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type',
353
-                '<meta name="robots" content="noindex,follow" />' . "\n"
353
+                '<meta name="robots" content="noindex,follow" />'."\n"
354 354
             )
355 355
             );
356 356
         }
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
     public function prependNotices($the_content)
435 435
     {
436 436
         $notices = $this->printNotices();
437
-        return $notices ? $notices . $the_content : $the_content;
437
+        return $notices ? $notices.$the_content : $the_content;
438 438
     }
439 439
 
440 440
 
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
     {
447 447
         ob_start();
448 448
         echo wp_kses(EE_Error::get_notices(), AllowedTags::getWithFormTags());
449
-        EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php');
449
+        EEH_Template::display_template(EE_TEMPLATES.'espresso-ajax-notices.template.php');
450 450
         return ob_get_clean();
451 451
     }
452 452
 
Please login to merge, or discard this patch.
core/admin/EE_Admin_List_Table.core.php 1 patch
Indentation   +878 added lines, -878 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\services\request\sanitizers\AllowedTags;
4 4
 
5 5
 if (! class_exists('WP_List_Table')) {
6
-    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
6
+	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
7 7
 }
8 8
 
9 9
 
@@ -21,891 +21,891 @@  discard block
 block discarded – undo
21 21
  */
22 22
 abstract class EE_Admin_List_Table extends WP_List_Table
23 23
 {
24
-    const ACTION_COPY    = 'duplicate';
25
-
26
-    const ACTION_DELETE  = 'delete';
27
-
28
-    const ACTION_EDIT    = 'edit';
29
-
30
-    const ACTION_RESTORE = 'restore';
31
-
32
-    const ACTION_TRASH   = 'trash';
33
-
34
-    protected static $actions = [
35
-        self::ACTION_COPY,
36
-        self::ACTION_DELETE,
37
-        self::ACTION_EDIT,
38
-        self::ACTION_RESTORE,
39
-        self::ACTION_TRASH,
40
-    ];
41
-
42
-    /**
43
-     * holds the data that will be processed for the table
44
-     *
45
-     * @var array $_data
46
-     */
47
-    protected $_data;
48
-
49
-
50
-    /**
51
-     * This holds the value of all the data available for the given view (for all pages).
52
-     *
53
-     * @var int $_all_data_count
54
-     */
55
-    protected $_all_data_count;
56
-
57
-
58
-    /**
59
-     * Will contain the count of trashed items for the view label.
60
-     *
61
-     * @var int $_trashed_count
62
-     */
63
-    protected $_trashed_count;
64
-
65
-
66
-    /**
67
-     * This is what will be referenced as the slug for the current screen
68
-     *
69
-     * @var string $_screen
70
-     */
71
-    protected $_screen;
72
-
73
-
74
-    /**
75
-     * this is the EE_Admin_Page object
76
-     *
77
-     * @var EE_Admin_Page $_admin_page
78
-     */
79
-    protected $_admin_page;
80
-
81
-
82
-    /**
83
-     * The current view
84
-     *
85
-     * @var string $_view
86
-     */
87
-    protected $_view;
88
-
89
-
90
-    /**
91
-     * array of possible views for this table
92
-     *
93
-     * @var array $_views
94
-     */
95
-    protected $_views;
96
-
97
-
98
-    /**
99
-     * An array of key => value pairs containing information about the current table
100
-     * array(
101
-     *        'plural' => 'plural label',
102
-     *        'singular' => 'singular label',
103
-     *        'ajax' => false, //whether to use ajax or not
104
-     *        'screen' => null, //string used to reference what screen this is
105
-     *        (WP_List_table converts to screen object)
106
-     * )
107
-     *
108
-     * @var array $_wp_list_args
109
-     */
110
-    protected $_wp_list_args;
111
-
112
-    /**
113
-     * an array of column names
114
-     * array(
115
-     *    'internal-name' => 'Title'
116
-     * )
117
-     *
118
-     * @var array $_columns
119
-     */
120
-    protected $_columns;
121
-
122
-    /**
123
-     * An array of sortable columns
124
-     * array(
125
-     *    'internal-name' => 'orderby' //or
126
-     *    'internal-name' => array( 'orderby', true )
127
-     * )
128
-     *
129
-     * @var array $_sortable_columns
130
-     */
131
-    protected $_sortable_columns;
132
-
133
-    /**
134
-     * callback method used to perform AJAX row reordering
135
-     *
136
-     * @var string $_ajax_sorting_callback
137
-     */
138
-    protected $_ajax_sorting_callback;
139
-
140
-    /**
141
-     * An array of hidden columns (if needed)
142
-     * array('internal-name', 'internal-name')
143
-     *
144
-     * @var array $_hidden_columns
145
-     */
146
-    protected $_hidden_columns;
147
-
148
-    /**
149
-     * holds the per_page value
150
-     *
151
-     * @var int $_per_page
152
-     */
153
-    protected $_per_page;
154
-
155
-    /**
156
-     * holds what page number is currently being viewed
157
-     *
158
-     * @var int $_current_page
159
-     */
160
-    protected $_current_page;
161
-
162
-    /**
163
-     * the reference string for the nonce_action
164
-     *
165
-     * @var string $_nonce_action_ref
166
-     */
167
-    protected $_nonce_action_ref;
168
-
169
-    /**
170
-     * property to hold incoming request data (as set by the admin_page_core)
171
-     *
172
-     * @var array $_req_data
173
-     */
174
-    protected $_req_data;
175
-
176
-
177
-    /**
178
-     * yes / no array for admin form fields
179
-     *
180
-     * @var array $_yes_no
181
-     */
182
-    protected $_yes_no = [];
183
-
184
-    /**
185
-     * Array describing buttons that should appear at the bottom of the page
186
-     * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
187
-     * and the values are another array with the following keys
188
-     * array(
189
-     *    'route' => 'page_route',
190
-     *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
191
-     * )
192
-     *
193
-     * @var array $_bottom_buttons
194
-     */
195
-    protected $_bottom_buttons = [];
196
-
197
-
198
-    /**
199
-     * Used to indicate what should be the primary column for the list table.
200
-     * If not present then falls back to what WP calculates
201
-     * as the primary column.
202
-     *
203
-     * @type string $_primary_column
204
-     */
205
-    protected $_primary_column = '';
206
-
207
-
208
-    /**
209
-     * Used to indicate whether the table has a checkbox column or not.
210
-     *
211
-     * @type bool $_has_checkbox_column
212
-     */
213
-    protected $_has_checkbox_column = false;
214
-
215
-
216
-    /**
217
-     * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
218
-     */
219
-    public function __construct(EE_Admin_Page $admin_page)
220
-    {
221
-        $this->_admin_page   = $admin_page;
222
-        $this->_req_data     = $this->_admin_page->get_request_data();
223
-        $this->_view         = $this->_admin_page->get_view();
224
-        $this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
225
-        $this->_current_page = $this->get_pagenum();
226
-        $this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
227
-        $this->_yes_no       = [
228
-            esc_html__('No', 'event_espresso'),
229
-            esc_html__('Yes', 'event_espresso')
230
-        ];
231
-
232
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
233
-
234
-        $this->_setup_data();
235
-        $this->_add_view_counts();
236
-
237
-        $this->_nonce_action_ref = $this->_view;
238
-
239
-        $this->_set_properties();
240
-
241
-        // set primary column
242
-        add_filter('list_table_primary_column', [$this, 'set_primary_column']);
243
-
244
-        // set parent defaults
245
-        parent::__construct($this->_wp_list_args);
246
-
247
-        $this->prepare_items();
248
-    }
249
-
250
-
251
-    /**
252
-     * _setup_data
253
-     * this method is used to setup the $_data, $_all_data_count, and _per_page properties
254
-     *
255
-     * @return void
256
-     * @uses $this->_admin_page
257
-     */
258
-    abstract protected function _setup_data();
259
-
260
-
261
-    /**
262
-     * set the properties that this class needs to be able to execute wp_list_table properly
263
-     * properties set:
264
-     * _wp_list_args = what the arguments required for the parent _wp_list_table.
265
-     * _columns = set the columns in an array.
266
-     * _sortable_columns = columns that are sortable (array).
267
-     * _hidden_columns = columns that are hidden (array)
268
-     * _default_orderby = the default orderby for sorting.
269
-     *
270
-     * @abstract
271
-     * @access protected
272
-     * @return void
273
-     */
274
-    abstract protected function _set_properties();
275
-
276
-
277
-    /**
278
-     * _get_table_filters
279
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
280
-     * gets shown in the table.
281
-     *
282
-     * @abstract
283
-     * @access protected
284
-     * @return string
285
-     */
286
-    abstract protected function _get_table_filters();
287
-
288
-
289
-    /**
290
-     * this is a method that child class will do to add counts to the views array so when views are displayed the
291
-     * counts of the views is accurate.
292
-     *
293
-     * @abstract
294
-     * @access protected
295
-     * @return void
296
-     */
297
-    abstract protected function _add_view_counts();
298
-
299
-
300
-    /**
301
-     * _get_hidden_fields
302
-     * returns a html string of hidden fields so if any table filters are used the current view will be respected.
303
-     *
304
-     * @return string
305
-     */
306
-    protected function _get_hidden_fields()
307
-    {
308
-        $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
309
-        $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
310
-        // if action is STILL empty, then we set it to default
311
-        $action = empty($action) ? 'default' : $action;
312
-        $field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
313
-        $field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
314
-        $field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
315
-
316
-        $bulk_actions = $this->_get_bulk_actions();
317
-        foreach ($bulk_actions as $bulk_action => $label) {
318
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
319
-                      . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
320
-        }
321
-
322
-        return $field;
323
-    }
324
-
325
-
326
-    /**
327
-     * _set_column_info
328
-     * we're using this to set the column headers property.
329
-     *
330
-     * @access protected
331
-     * @return void
332
-     */
333
-    protected function _set_column_info()
334
-    {
335
-        $columns   = $this->get_columns();
336
-        $hidden    = $this->get_hidden_columns();
337
-        $_sortable = $this->get_sortable_columns();
338
-
339
-        /**
340
-         * Dynamic hook allowing for adding sortable columns in this list table.
341
-         * Note that $this->screen->id is in the format
342
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
343
-         * table it is: event-espresso_page_espresso_messages.
344
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
345
-         * hook prefix ("event-espresso") will be different.
346
-         *
347
-         * @var array
348
-         */
349
-        $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
350
-
351
-        $sortable = [];
352
-        foreach ($_sortable as $id => $data) {
353
-            if (empty($data)) {
354
-                continue;
355
-            }
356
-            // fix for offset errors with WP_List_Table default get_columninfo()
357
-            if (is_array($data)) {
358
-                $_data[0] = key($data);
359
-                $_data[1] = isset($data[1]) ? $data[1] : false;
360
-            } else {
361
-                $_data[0] = $data;
362
-            }
363
-
364
-            $data = (array) $data;
365
-
366
-            if (! isset($data[1])) {
367
-                $_data[1] = false;
368
-            }
369
-
370
-            $sortable[ $id ] = $_data;
371
-        }
372
-        $primary               = $this->get_primary_column_name();
373
-        $this->_column_headers = [$columns, $hidden, $sortable, $primary];
374
-    }
375
-
376
-
377
-    /**
378
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
379
-     *
380
-     * @return string
381
-     */
382
-    protected function get_primary_column_name()
383
-    {
384
-        foreach (class_parents($this) as $parent) {
385
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
386
-                return parent::get_primary_column_name();
387
-            }
388
-        }
389
-        return $this->_primary_column;
390
-    }
391
-
392
-
393
-    /**
394
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
395
-     *
396
-     * @param EE_Base_Class $item
397
-     * @param string        $column_name
398
-     * @param string        $primary
399
-     * @return string
400
-     */
401
-    protected function handle_row_actions($item, $column_name, $primary)
402
-    {
403
-        foreach (class_parents($this) as $parent) {
404
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
405
-                return parent::handle_row_actions($item, $column_name, $primary);
406
-            }
407
-        }
408
-        return '';
409
-    }
410
-
411
-
412
-    /**
413
-     * _get_bulk_actions
414
-     * This is a wrapper called by WP_List_Table::get_bulk_actions()
415
-     *
416
-     * @access protected
417
-     * @return array bulk_actions
418
-     */
419
-    protected function _get_bulk_actions()
420
-    {
421
-        $actions = [];
422
-        // the _views property should have the bulk_actions, so let's go through and extract them into a properly
423
-        // formatted array for the wp_list_table();
424
-        foreach ($this->_views as $view => $args) {
425
-            if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
426
-                // each bulk action will correspond with a admin page route, so we can check whatever the capability is
427
-                // for that page route and skip adding the bulk action if no access for the current logged in user.
428
-                foreach ($args['bulk_action'] as $route => $label) {
429
-                    if ($this->_admin_page->check_user_access($route, true)) {
430
-                        $actions[ $route ] = $label;
431
-                    }
432
-                }
433
-            }
434
-        }
435
-        return $actions;
436
-    }
437
-
438
-
439
-    /**
440
-     * Generate the table navigation above or below the table.
441
-     * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
442
-     *
443
-     * @throws EE_Error
444
-     * @since 4.9.44.rc.001
445
-     */
446
-    public function display_tablenav($which)
447
-    {
448
-        if ('top' === $which) {
449
-            wp_nonce_field('bulk-' . $this->_args['plural']);
450
-        }
451
-        ?>
24
+	const ACTION_COPY    = 'duplicate';
25
+
26
+	const ACTION_DELETE  = 'delete';
27
+
28
+	const ACTION_EDIT    = 'edit';
29
+
30
+	const ACTION_RESTORE = 'restore';
31
+
32
+	const ACTION_TRASH   = 'trash';
33
+
34
+	protected static $actions = [
35
+		self::ACTION_COPY,
36
+		self::ACTION_DELETE,
37
+		self::ACTION_EDIT,
38
+		self::ACTION_RESTORE,
39
+		self::ACTION_TRASH,
40
+	];
41
+
42
+	/**
43
+	 * holds the data that will be processed for the table
44
+	 *
45
+	 * @var array $_data
46
+	 */
47
+	protected $_data;
48
+
49
+
50
+	/**
51
+	 * This holds the value of all the data available for the given view (for all pages).
52
+	 *
53
+	 * @var int $_all_data_count
54
+	 */
55
+	protected $_all_data_count;
56
+
57
+
58
+	/**
59
+	 * Will contain the count of trashed items for the view label.
60
+	 *
61
+	 * @var int $_trashed_count
62
+	 */
63
+	protected $_trashed_count;
64
+
65
+
66
+	/**
67
+	 * This is what will be referenced as the slug for the current screen
68
+	 *
69
+	 * @var string $_screen
70
+	 */
71
+	protected $_screen;
72
+
73
+
74
+	/**
75
+	 * this is the EE_Admin_Page object
76
+	 *
77
+	 * @var EE_Admin_Page $_admin_page
78
+	 */
79
+	protected $_admin_page;
80
+
81
+
82
+	/**
83
+	 * The current view
84
+	 *
85
+	 * @var string $_view
86
+	 */
87
+	protected $_view;
88
+
89
+
90
+	/**
91
+	 * array of possible views for this table
92
+	 *
93
+	 * @var array $_views
94
+	 */
95
+	protected $_views;
96
+
97
+
98
+	/**
99
+	 * An array of key => value pairs containing information about the current table
100
+	 * array(
101
+	 *        'plural' => 'plural label',
102
+	 *        'singular' => 'singular label',
103
+	 *        'ajax' => false, //whether to use ajax or not
104
+	 *        'screen' => null, //string used to reference what screen this is
105
+	 *        (WP_List_table converts to screen object)
106
+	 * )
107
+	 *
108
+	 * @var array $_wp_list_args
109
+	 */
110
+	protected $_wp_list_args;
111
+
112
+	/**
113
+	 * an array of column names
114
+	 * array(
115
+	 *    'internal-name' => 'Title'
116
+	 * )
117
+	 *
118
+	 * @var array $_columns
119
+	 */
120
+	protected $_columns;
121
+
122
+	/**
123
+	 * An array of sortable columns
124
+	 * array(
125
+	 *    'internal-name' => 'orderby' //or
126
+	 *    'internal-name' => array( 'orderby', true )
127
+	 * )
128
+	 *
129
+	 * @var array $_sortable_columns
130
+	 */
131
+	protected $_sortable_columns;
132
+
133
+	/**
134
+	 * callback method used to perform AJAX row reordering
135
+	 *
136
+	 * @var string $_ajax_sorting_callback
137
+	 */
138
+	protected $_ajax_sorting_callback;
139
+
140
+	/**
141
+	 * An array of hidden columns (if needed)
142
+	 * array('internal-name', 'internal-name')
143
+	 *
144
+	 * @var array $_hidden_columns
145
+	 */
146
+	protected $_hidden_columns;
147
+
148
+	/**
149
+	 * holds the per_page value
150
+	 *
151
+	 * @var int $_per_page
152
+	 */
153
+	protected $_per_page;
154
+
155
+	/**
156
+	 * holds what page number is currently being viewed
157
+	 *
158
+	 * @var int $_current_page
159
+	 */
160
+	protected $_current_page;
161
+
162
+	/**
163
+	 * the reference string for the nonce_action
164
+	 *
165
+	 * @var string $_nonce_action_ref
166
+	 */
167
+	protected $_nonce_action_ref;
168
+
169
+	/**
170
+	 * property to hold incoming request data (as set by the admin_page_core)
171
+	 *
172
+	 * @var array $_req_data
173
+	 */
174
+	protected $_req_data;
175
+
176
+
177
+	/**
178
+	 * yes / no array for admin form fields
179
+	 *
180
+	 * @var array $_yes_no
181
+	 */
182
+	protected $_yes_no = [];
183
+
184
+	/**
185
+	 * Array describing buttons that should appear at the bottom of the page
186
+	 * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
187
+	 * and the values are another array with the following keys
188
+	 * array(
189
+	 *    'route' => 'page_route',
190
+	 *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
191
+	 * )
192
+	 *
193
+	 * @var array $_bottom_buttons
194
+	 */
195
+	protected $_bottom_buttons = [];
196
+
197
+
198
+	/**
199
+	 * Used to indicate what should be the primary column for the list table.
200
+	 * If not present then falls back to what WP calculates
201
+	 * as the primary column.
202
+	 *
203
+	 * @type string $_primary_column
204
+	 */
205
+	protected $_primary_column = '';
206
+
207
+
208
+	/**
209
+	 * Used to indicate whether the table has a checkbox column or not.
210
+	 *
211
+	 * @type bool $_has_checkbox_column
212
+	 */
213
+	protected $_has_checkbox_column = false;
214
+
215
+
216
+	/**
217
+	 * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
218
+	 */
219
+	public function __construct(EE_Admin_Page $admin_page)
220
+	{
221
+		$this->_admin_page   = $admin_page;
222
+		$this->_req_data     = $this->_admin_page->get_request_data();
223
+		$this->_view         = $this->_admin_page->get_view();
224
+		$this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
225
+		$this->_current_page = $this->get_pagenum();
226
+		$this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
227
+		$this->_yes_no       = [
228
+			esc_html__('No', 'event_espresso'),
229
+			esc_html__('Yes', 'event_espresso')
230
+		];
231
+
232
+		$this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
233
+
234
+		$this->_setup_data();
235
+		$this->_add_view_counts();
236
+
237
+		$this->_nonce_action_ref = $this->_view;
238
+
239
+		$this->_set_properties();
240
+
241
+		// set primary column
242
+		add_filter('list_table_primary_column', [$this, 'set_primary_column']);
243
+
244
+		// set parent defaults
245
+		parent::__construct($this->_wp_list_args);
246
+
247
+		$this->prepare_items();
248
+	}
249
+
250
+
251
+	/**
252
+	 * _setup_data
253
+	 * this method is used to setup the $_data, $_all_data_count, and _per_page properties
254
+	 *
255
+	 * @return void
256
+	 * @uses $this->_admin_page
257
+	 */
258
+	abstract protected function _setup_data();
259
+
260
+
261
+	/**
262
+	 * set the properties that this class needs to be able to execute wp_list_table properly
263
+	 * properties set:
264
+	 * _wp_list_args = what the arguments required for the parent _wp_list_table.
265
+	 * _columns = set the columns in an array.
266
+	 * _sortable_columns = columns that are sortable (array).
267
+	 * _hidden_columns = columns that are hidden (array)
268
+	 * _default_orderby = the default orderby for sorting.
269
+	 *
270
+	 * @abstract
271
+	 * @access protected
272
+	 * @return void
273
+	 */
274
+	abstract protected function _set_properties();
275
+
276
+
277
+	/**
278
+	 * _get_table_filters
279
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
280
+	 * gets shown in the table.
281
+	 *
282
+	 * @abstract
283
+	 * @access protected
284
+	 * @return string
285
+	 */
286
+	abstract protected function _get_table_filters();
287
+
288
+
289
+	/**
290
+	 * this is a method that child class will do to add counts to the views array so when views are displayed the
291
+	 * counts of the views is accurate.
292
+	 *
293
+	 * @abstract
294
+	 * @access protected
295
+	 * @return void
296
+	 */
297
+	abstract protected function _add_view_counts();
298
+
299
+
300
+	/**
301
+	 * _get_hidden_fields
302
+	 * returns a html string of hidden fields so if any table filters are used the current view will be respected.
303
+	 *
304
+	 * @return string
305
+	 */
306
+	protected function _get_hidden_fields()
307
+	{
308
+		$action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
309
+		$action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
310
+		// if action is STILL empty, then we set it to default
311
+		$action = empty($action) ? 'default' : $action;
312
+		$field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
313
+		$field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
314
+		$field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
315
+
316
+		$bulk_actions = $this->_get_bulk_actions();
317
+		foreach ($bulk_actions as $bulk_action => $label) {
318
+			$field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
319
+					  . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
320
+		}
321
+
322
+		return $field;
323
+	}
324
+
325
+
326
+	/**
327
+	 * _set_column_info
328
+	 * we're using this to set the column headers property.
329
+	 *
330
+	 * @access protected
331
+	 * @return void
332
+	 */
333
+	protected function _set_column_info()
334
+	{
335
+		$columns   = $this->get_columns();
336
+		$hidden    = $this->get_hidden_columns();
337
+		$_sortable = $this->get_sortable_columns();
338
+
339
+		/**
340
+		 * Dynamic hook allowing for adding sortable columns in this list table.
341
+		 * Note that $this->screen->id is in the format
342
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
343
+		 * table it is: event-espresso_page_espresso_messages.
344
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
345
+		 * hook prefix ("event-espresso") will be different.
346
+		 *
347
+		 * @var array
348
+		 */
349
+		$_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
350
+
351
+		$sortable = [];
352
+		foreach ($_sortable as $id => $data) {
353
+			if (empty($data)) {
354
+				continue;
355
+			}
356
+			// fix for offset errors with WP_List_Table default get_columninfo()
357
+			if (is_array($data)) {
358
+				$_data[0] = key($data);
359
+				$_data[1] = isset($data[1]) ? $data[1] : false;
360
+			} else {
361
+				$_data[0] = $data;
362
+			}
363
+
364
+			$data = (array) $data;
365
+
366
+			if (! isset($data[1])) {
367
+				$_data[1] = false;
368
+			}
369
+
370
+			$sortable[ $id ] = $_data;
371
+		}
372
+		$primary               = $this->get_primary_column_name();
373
+		$this->_column_headers = [$columns, $hidden, $sortable, $primary];
374
+	}
375
+
376
+
377
+	/**
378
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
379
+	 *
380
+	 * @return string
381
+	 */
382
+	protected function get_primary_column_name()
383
+	{
384
+		foreach (class_parents($this) as $parent) {
385
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
386
+				return parent::get_primary_column_name();
387
+			}
388
+		}
389
+		return $this->_primary_column;
390
+	}
391
+
392
+
393
+	/**
394
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
395
+	 *
396
+	 * @param EE_Base_Class $item
397
+	 * @param string        $column_name
398
+	 * @param string        $primary
399
+	 * @return string
400
+	 */
401
+	protected function handle_row_actions($item, $column_name, $primary)
402
+	{
403
+		foreach (class_parents($this) as $parent) {
404
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
405
+				return parent::handle_row_actions($item, $column_name, $primary);
406
+			}
407
+		}
408
+		return '';
409
+	}
410
+
411
+
412
+	/**
413
+	 * _get_bulk_actions
414
+	 * This is a wrapper called by WP_List_Table::get_bulk_actions()
415
+	 *
416
+	 * @access protected
417
+	 * @return array bulk_actions
418
+	 */
419
+	protected function _get_bulk_actions()
420
+	{
421
+		$actions = [];
422
+		// the _views property should have the bulk_actions, so let's go through and extract them into a properly
423
+		// formatted array for the wp_list_table();
424
+		foreach ($this->_views as $view => $args) {
425
+			if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
426
+				// each bulk action will correspond with a admin page route, so we can check whatever the capability is
427
+				// for that page route and skip adding the bulk action if no access for the current logged in user.
428
+				foreach ($args['bulk_action'] as $route => $label) {
429
+					if ($this->_admin_page->check_user_access($route, true)) {
430
+						$actions[ $route ] = $label;
431
+					}
432
+				}
433
+			}
434
+		}
435
+		return $actions;
436
+	}
437
+
438
+
439
+	/**
440
+	 * Generate the table navigation above or below the table.
441
+	 * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
442
+	 *
443
+	 * @throws EE_Error
444
+	 * @since 4.9.44.rc.001
445
+	 */
446
+	public function display_tablenav($which)
447
+	{
448
+		if ('top' === $which) {
449
+			wp_nonce_field('bulk-' . $this->_args['plural']);
450
+		}
451
+		?>
452 452
         <div class="tablenav <?php echo esc_attr($which); ?>">
453 453
             <?php if ($this->_get_bulk_actions()) { ?>
454 454
                 <div class="alignleft actions bulkactions">
455 455
                     <?php $this->bulk_actions(); ?>
456 456
                 </div>
457 457
             <?php }
458
-            $this->extra_tablenav($which);
459
-            $this->pagination($which);
460
-            ?>
458
+			$this->extra_tablenav($which);
459
+			$this->pagination($which);
460
+			?>
461 461
 
462 462
             <br class="clear" />
463 463
         </div>
464 464
         <?php
465
-    }
466
-
467
-
468
-    /**
469
-     * _filters
470
-     * This receives the filters array from children _get_table_filters() and assembles the string including the filter
471
-     * button.
472
-     *
473
-     * @access private
474
-     * @return void  echos html showing filters
475
-     */
476
-    private function _filters()
477
-    {
478
-        $classname = get_class($this);
479
-        $filters   = apply_filters(
480
-            "FHEE__{$classname}__filters",
481
-            (array) $this->_get_table_filters(),
482
-            $this,
483
-            $this->_screen
484
-        );
485
-
486
-        if (empty($filters)) {
487
-            return;
488
-        }
489
-        foreach ($filters as $filter) {
490
-            echo wp_kses($filter, AllowedTags::getWithFormTags());
491
-        }
492
-        // add filter button at end
493
-        echo '<input type="submit" class="button-secondary" value="'
494
-             . esc_html__('Filter', 'event_espresso')
495
-             . '" id="post-query-submit" />';
496
-        // add reset filters button at end
497
-        echo '<a class="button button-secondary"  href="'
498
-             . esc_url_raw($this->_admin_page->get_current_page_view_url())
499
-             . '" style="display:inline-block">'
500
-             . esc_html__('Reset Filters', 'event_espresso')
501
-             . '</a>';
502
-    }
503
-
504
-
505
-    /**
506
-     * Callback for 'list_table_primary_column' WordPress filter
507
-     * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
508
-     * column when class is instantiated.
509
-     *
510
-     * @param string $column_name
511
-     * @return string
512
-     * @see WP_List_Table::get_primary_column_name
513
-     */
514
-    public function set_primary_column($column_name)
515
-    {
516
-        return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
517
-    }
518
-
519
-
520
-    /**
521
-     *
522
-     */
523
-    public function prepare_items()
524
-    {
525
-
526
-        $this->_set_column_info();
527
-        // $this->_column_headers = $this->get_column_info();
528
-        $total_items = $this->_all_data_count;
529
-        $this->process_bulk_action();
530
-
531
-        $this->items = $this->_data;
532
-        $this->set_pagination_args(
533
-            [
534
-                'total_items' => $total_items,
535
-                'per_page'    => $this->_per_page,
536
-                'total_pages' => ceil($total_items / $this->_per_page),
537
-            ]
538
-        );
539
-    }
540
-
541
-
542
-    /**
543
-     * @param object|array $item
544
-     * @return string html content for the column
545
-     */
546
-    protected function column_cb($item)
547
-    {
548
-        return '';
549
-    }
550
-
551
-
552
-    /**
553
-     * This column is the default for when there is no defined column method for a registered column.
554
-     * This can be overridden by child classes, but allows for hooking in for custom columns.
555
-     *
556
-     * @param EE_Base_Class $item
557
-     * @param string        $column_name The column being called.
558
-     * @return string html content for the column
559
-     */
560
-    public function column_default($item, $column_name)
561
-    {
562
-        /**
563
-         * Dynamic hook allowing for adding additional column content in this list table.
564
-         * Note that $this->screen->id is in the format
565
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
566
-         * table it is: event-espresso_page_espresso_messages.
567
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
568
-         * hook prefix ("event-espresso") will be different.
569
-         */
570
-        ob_start();
571
-        do_action(
572
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
573
-            $item,
574
-            $this->_screen
575
-        );
576
-        return ob_get_clean();
577
-    }
578
-
579
-
580
-    /**
581
-     * Get a list of columns. The format is:
582
-     * 'internal-name' => 'Title'
583
-     *
584
-     * @return array
585
-     * @since  3.1.0
586
-     * @access public
587
-     * @abstract
588
-     */
589
-    public function get_columns()
590
-    {
591
-        /**
592
-         * Dynamic hook allowing for adding additional columns in this list table.
593
-         * Note that $this->screen->id is in the format
594
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
595
-         * table it is: event-espresso_page_espresso_messages.
596
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
597
-         * hook prefix ("event-espresso") will be different.
598
-         *
599
-         * @var array
600
-         */
601
-        return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
602
-    }
603
-
604
-
605
-    /**
606
-     * Get an associative array ( id => link ) with the list
607
-     * of views available on this table.
608
-     *
609
-     * @return array
610
-     * @since  3.1.0
611
-     * @access protected
612
-     */
613
-    public function get_views()
614
-    {
615
-        return $this->_views;
616
-    }
617
-
618
-
619
-    /**
620
-     * Generate the views html.
621
-     */
622
-    public function display_views()
623
-    {
624
-        $views           = $this->get_views();
625
-        $assembled_views = [];
626
-
627
-        if (empty($views)) {
628
-            return;
629
-        }
630
-        echo "<ul class='subsubsub'>\n";
631
-        foreach ($views as $view) {
632
-            $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
633
-            if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
634
-                $filter = "<li";
635
-                $filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
636
-                $filter .= ">";
637
-                $filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
638
-                $filter .= '<span class="count">(' . $count . ')</span>';
639
-                $filter .= '</li>';
640
-                $assembled_views[ $view['slug'] ] = $filter;
641
-            }
642
-        }
643
-
644
-        echo ! empty($assembled_views)
645
-            ? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views)
646
-            : '';
647
-        echo "</ul>";
648
-    }
649
-
650
-
651
-    /**
652
-     * Generates content for a single row of the table
653
-     *
654
-     * @param EE_Base_Class $item The current item
655
-     * @since  4.1
656
-     * @access public
657
-     */
658
-    public function single_row($item)
659
-    {
660
-        $row_class = $this->_get_row_class($item);
661
-        echo '<tr class="' . esc_attr($row_class) . '">';
662
-        $this->single_row_columns($item); // already escaped
663
-        echo '</tr>';
664
-    }
665
-
666
-
667
-    /**
668
-     * This simply sets up the row class for the table rows.
669
-     * Allows for easier overriding of child methods for setting up sorting.
670
-     *
671
-     * @param EE_Base_Class $item the current item
672
-     * @return string
673
-     */
674
-    protected function _get_row_class($item)
675
-    {
676
-        static $row_class = '';
677
-        $row_class = ($row_class === '' ? 'alternate' : '');
678
-
679
-        $new_row_class = $row_class;
680
-
681
-        if (! empty($this->_ajax_sorting_callback)) {
682
-            $new_row_class .= ' rowsortable';
683
-        }
684
-
685
-        return $new_row_class;
686
-    }
687
-
688
-
689
-    /**
690
-     * @return array
691
-     */
692
-    public function get_sortable_columns()
693
-    {
694
-        return (array) $this->_sortable_columns;
695
-    }
696
-
697
-
698
-    /**
699
-     * @return string
700
-     */
701
-    public function get_ajax_sorting_callback()
702
-    {
703
-        return $this->_ajax_sorting_callback;
704
-    }
705
-
706
-
707
-    /**
708
-     * @return array
709
-     */
710
-    public function get_hidden_columns()
711
-    {
712
-        $user_id     = get_current_user_id();
713
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
714
-        if (empty($has_default) && ! empty($this->_hidden_columns)) {
715
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
716
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
717
-        }
718
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
719
-        return (array) get_user_option($ref, $user_id);
720
-    }
721
-
722
-
723
-    /**
724
-     * Generates the columns for a single row of the table.
725
-     * Overridden from wp_list_table so as to allow us to filter the column content for a given
726
-     * column.
727
-     *
728
-     * @param EE_Base_Class $item The current item
729
-     * @since 3.1.0
730
-     */
731
-    public function single_row_columns($item)
732
-    {
733
-        [$columns, $hidden, $sortable, $primary] = $this->get_column_info();
734
-
735
-        foreach ($columns as $column_name => $column_display_name) {
736
-
737
-            /**
738
-             * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
739
-             * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
740
-             */
741
-            $hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
742
-
743
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
744
-            if ($primary === $column_name) {
745
-                $classes .= ' has-row-actions column-primary';
746
-            }
747
-
748
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
749
-
750
-            $class = 'class="' . esc_attr($classes) . '"';
751
-
752
-            $attributes = "{$class}{$data}";
753
-
754
-            if ($column_name === 'cb') {
755
-                echo '<th scope="row" class="check-column">';
756
-                echo apply_filters(
757
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
758
-                    $this->column_cb($item), // already escaped
759
-                    $item,
760
-                    $this
761
-                );
762
-                echo '</th>';
763
-            } elseif (method_exists($this, 'column_' . $column_name)) {
764
-                echo "<td $attributes>"; // already escaped
765
-                echo apply_filters(
766
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
767
-                    call_user_func([$this, 'column_' . $column_name], $item),
768
-                    $item,
769
-                    $this
770
-                );
771
-                echo wp_kses($this->handle_row_actions($item, $column_name, $primary), AllowedTags::getWithFormTags());
772
-                echo "</td>";
773
-            } else {
774
-                echo "<td $attributes>"; // already escaped
775
-                echo apply_filters(
776
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
777
-                    $this->column_default($item, $column_name),
778
-                    $item,
779
-                    $column_name,
780
-                    $this
781
-                );
782
-                echo wp_kses($this->handle_row_actions($item, $column_name, $primary), AllowedTags::getWithFormTags());
783
-                echo "</td>";
784
-            }
785
-        }
786
-    }
787
-
788
-
789
-    /**
790
-     * Extra controls to be displayed between bulk actions and pagination
791
-     *
792
-     * @access public
793
-     * @param string $which
794
-     * @throws EE_Error
795
-     */
796
-    public function extra_tablenav($which)
797
-    {
798
-        if ($which === 'top') {
799
-            $this->_filters();
800
-            echo wp_kses($this->_get_hidden_fields(), AllowedTags::getWithFormTags());
801
-        } else {
802
-            echo '<div class="list-table-bottom-buttons alignleft actions">';
803
-            foreach ($this->_bottom_buttons as $type => $action) {
804
-                $route         = isset($action['route']) ? $action['route'] : '';
805
-                $extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
806
-                // already escaped
807
-                echo wp_kses($this->_admin_page->get_action_link_or_button(
808
-                    $route,
809
-                    $type,
810
-                    $extra_request,
811
-                    'button button-secondary'
812
-                ), AllowedTags::getWithFormTags());
813
-            }
814
-            do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
815
-            echo '</div>';
816
-        }
817
-    }
818
-
819
-
820
-    /**
821
-     * Get an associative array ( option_name => option_title ) with the list
822
-     * of bulk actions available on this table.
823
-     *
824
-     * @return array
825
-     * @since  3.1.0
826
-     * @access protected
827
-     */
828
-    public function get_bulk_actions()
829
-    {
830
-        return (array) $this->_get_bulk_actions();
831
-    }
832
-
833
-
834
-    /**
835
-     * Processing bulk actions.
836
-     */
837
-    public function process_bulk_action()
838
-    {
839
-        // this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
840
-        // reference in case there is a case where it gets used.
841
-    }
842
-
843
-
844
-    /**
845
-     * returns the EE admin page this list table is associated with
846
-     *
847
-     * @return EE_Admin_Page
848
-     */
849
-    public function get_admin_page()
850
-    {
851
-        return $this->_admin_page;
852
-    }
853
-
854
-
855
-    /**
856
-     * A "helper" function for all children to provide an html string of
857
-     * actions to output in their content.  It is preferable for child classes
858
-     * to use this method for generating their actions content so that it's
859
-     * filterable by plugins
860
-     *
861
-     * @param string        $action_container           what are the html container
862
-     *                                                  elements for this actions string?
863
-     * @param string        $action_class               What class is for the container
864
-     *                                                  element.
865
-     * @param string        $action_items               The contents for the action items
866
-     *                                                  container.  This is filtered before
867
-     *                                                  returned.
868
-     * @param string        $action_id                  What id (optional) is used for the
869
-     *                                                  container element.
870
-     * @param EE_Base_Class $item                       The object for the column displaying
871
-     *                                                  the actions.
872
-     * @return string The assembled action elements container.
873
-     */
874
-    protected function _action_string(
875
-        $action_items,
876
-        $item,
877
-        $action_container = 'ul',
878
-        $action_class = '',
879
-        $action_id = ''
880
-    ) {
881
-        $action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
882
-        $action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
883
-        $open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
884
-        $close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
885
-        try {
886
-            $content = apply_filters(
887
-                'FHEE__EE_Admin_List_Table___action_string__action_items',
888
-                $action_items,
889
-                $item,
890
-                $this
891
-            );
892
-        } catch (Exception $e) {
893
-            if (WP_DEBUG) {
894
-                EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
895
-            }
896
-            $content = $action_items;
897
-        }
898
-        return "{$open_tag}{$content}{$close_tag}";
899
-    }
900
-
901
-
902
-    /**
903
-     * @return string
904
-     */
905
-    protected function getReturnUrl()
906
-    {
907
-        $host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
908
-        $uri  = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
909
-        return urlencode(esc_url_raw("//{$host}{$uri}"));
910
-    }
465
+	}
466
+
467
+
468
+	/**
469
+	 * _filters
470
+	 * This receives the filters array from children _get_table_filters() and assembles the string including the filter
471
+	 * button.
472
+	 *
473
+	 * @access private
474
+	 * @return void  echos html showing filters
475
+	 */
476
+	private function _filters()
477
+	{
478
+		$classname = get_class($this);
479
+		$filters   = apply_filters(
480
+			"FHEE__{$classname}__filters",
481
+			(array) $this->_get_table_filters(),
482
+			$this,
483
+			$this->_screen
484
+		);
485
+
486
+		if (empty($filters)) {
487
+			return;
488
+		}
489
+		foreach ($filters as $filter) {
490
+			echo wp_kses($filter, AllowedTags::getWithFormTags());
491
+		}
492
+		// add filter button at end
493
+		echo '<input type="submit" class="button-secondary" value="'
494
+			 . esc_html__('Filter', 'event_espresso')
495
+			 . '" id="post-query-submit" />';
496
+		// add reset filters button at end
497
+		echo '<a class="button button-secondary"  href="'
498
+			 . esc_url_raw($this->_admin_page->get_current_page_view_url())
499
+			 . '" style="display:inline-block">'
500
+			 . esc_html__('Reset Filters', 'event_espresso')
501
+			 . '</a>';
502
+	}
503
+
504
+
505
+	/**
506
+	 * Callback for 'list_table_primary_column' WordPress filter
507
+	 * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
508
+	 * column when class is instantiated.
509
+	 *
510
+	 * @param string $column_name
511
+	 * @return string
512
+	 * @see WP_List_Table::get_primary_column_name
513
+	 */
514
+	public function set_primary_column($column_name)
515
+	{
516
+		return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
517
+	}
518
+
519
+
520
+	/**
521
+	 *
522
+	 */
523
+	public function prepare_items()
524
+	{
525
+
526
+		$this->_set_column_info();
527
+		// $this->_column_headers = $this->get_column_info();
528
+		$total_items = $this->_all_data_count;
529
+		$this->process_bulk_action();
530
+
531
+		$this->items = $this->_data;
532
+		$this->set_pagination_args(
533
+			[
534
+				'total_items' => $total_items,
535
+				'per_page'    => $this->_per_page,
536
+				'total_pages' => ceil($total_items / $this->_per_page),
537
+			]
538
+		);
539
+	}
540
+
541
+
542
+	/**
543
+	 * @param object|array $item
544
+	 * @return string html content for the column
545
+	 */
546
+	protected function column_cb($item)
547
+	{
548
+		return '';
549
+	}
550
+
551
+
552
+	/**
553
+	 * This column is the default for when there is no defined column method for a registered column.
554
+	 * This can be overridden by child classes, but allows for hooking in for custom columns.
555
+	 *
556
+	 * @param EE_Base_Class $item
557
+	 * @param string        $column_name The column being called.
558
+	 * @return string html content for the column
559
+	 */
560
+	public function column_default($item, $column_name)
561
+	{
562
+		/**
563
+		 * Dynamic hook allowing for adding additional column content in this list table.
564
+		 * Note that $this->screen->id is in the format
565
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
566
+		 * table it is: event-espresso_page_espresso_messages.
567
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
568
+		 * hook prefix ("event-espresso") will be different.
569
+		 */
570
+		ob_start();
571
+		do_action(
572
+			'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
573
+			$item,
574
+			$this->_screen
575
+		);
576
+		return ob_get_clean();
577
+	}
578
+
579
+
580
+	/**
581
+	 * Get a list of columns. The format is:
582
+	 * 'internal-name' => 'Title'
583
+	 *
584
+	 * @return array
585
+	 * @since  3.1.0
586
+	 * @access public
587
+	 * @abstract
588
+	 */
589
+	public function get_columns()
590
+	{
591
+		/**
592
+		 * Dynamic hook allowing for adding additional columns in this list table.
593
+		 * Note that $this->screen->id is in the format
594
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
595
+		 * table it is: event-espresso_page_espresso_messages.
596
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
597
+		 * hook prefix ("event-espresso") will be different.
598
+		 *
599
+		 * @var array
600
+		 */
601
+		return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
602
+	}
603
+
604
+
605
+	/**
606
+	 * Get an associative array ( id => link ) with the list
607
+	 * of views available on this table.
608
+	 *
609
+	 * @return array
610
+	 * @since  3.1.0
611
+	 * @access protected
612
+	 */
613
+	public function get_views()
614
+	{
615
+		return $this->_views;
616
+	}
617
+
618
+
619
+	/**
620
+	 * Generate the views html.
621
+	 */
622
+	public function display_views()
623
+	{
624
+		$views           = $this->get_views();
625
+		$assembled_views = [];
626
+
627
+		if (empty($views)) {
628
+			return;
629
+		}
630
+		echo "<ul class='subsubsub'>\n";
631
+		foreach ($views as $view) {
632
+			$count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
633
+			if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
634
+				$filter = "<li";
635
+				$filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
636
+				$filter .= ">";
637
+				$filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
638
+				$filter .= '<span class="count">(' . $count . ')</span>';
639
+				$filter .= '</li>';
640
+				$assembled_views[ $view['slug'] ] = $filter;
641
+			}
642
+		}
643
+
644
+		echo ! empty($assembled_views)
645
+			? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views)
646
+			: '';
647
+		echo "</ul>";
648
+	}
649
+
650
+
651
+	/**
652
+	 * Generates content for a single row of the table
653
+	 *
654
+	 * @param EE_Base_Class $item The current item
655
+	 * @since  4.1
656
+	 * @access public
657
+	 */
658
+	public function single_row($item)
659
+	{
660
+		$row_class = $this->_get_row_class($item);
661
+		echo '<tr class="' . esc_attr($row_class) . '">';
662
+		$this->single_row_columns($item); // already escaped
663
+		echo '</tr>';
664
+	}
665
+
666
+
667
+	/**
668
+	 * This simply sets up the row class for the table rows.
669
+	 * Allows for easier overriding of child methods for setting up sorting.
670
+	 *
671
+	 * @param EE_Base_Class $item the current item
672
+	 * @return string
673
+	 */
674
+	protected function _get_row_class($item)
675
+	{
676
+		static $row_class = '';
677
+		$row_class = ($row_class === '' ? 'alternate' : '');
678
+
679
+		$new_row_class = $row_class;
680
+
681
+		if (! empty($this->_ajax_sorting_callback)) {
682
+			$new_row_class .= ' rowsortable';
683
+		}
684
+
685
+		return $new_row_class;
686
+	}
687
+
688
+
689
+	/**
690
+	 * @return array
691
+	 */
692
+	public function get_sortable_columns()
693
+	{
694
+		return (array) $this->_sortable_columns;
695
+	}
696
+
697
+
698
+	/**
699
+	 * @return string
700
+	 */
701
+	public function get_ajax_sorting_callback()
702
+	{
703
+		return $this->_ajax_sorting_callback;
704
+	}
705
+
706
+
707
+	/**
708
+	 * @return array
709
+	 */
710
+	public function get_hidden_columns()
711
+	{
712
+		$user_id     = get_current_user_id();
713
+		$has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
714
+		if (empty($has_default) && ! empty($this->_hidden_columns)) {
715
+			update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
716
+			update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
717
+		}
718
+		$ref = 'manage' . $this->screen->id . 'columnshidden';
719
+		return (array) get_user_option($ref, $user_id);
720
+	}
721
+
722
+
723
+	/**
724
+	 * Generates the columns for a single row of the table.
725
+	 * Overridden from wp_list_table so as to allow us to filter the column content for a given
726
+	 * column.
727
+	 *
728
+	 * @param EE_Base_Class $item The current item
729
+	 * @since 3.1.0
730
+	 */
731
+	public function single_row_columns($item)
732
+	{
733
+		[$columns, $hidden, $sortable, $primary] = $this->get_column_info();
734
+
735
+		foreach ($columns as $column_name => $column_display_name) {
736
+
737
+			/**
738
+			 * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
739
+			 * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
740
+			 */
741
+			$hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
742
+
743
+			$classes = $column_name . ' column-' . $column_name . $hidden_class;
744
+			if ($primary === $column_name) {
745
+				$classes .= ' has-row-actions column-primary';
746
+			}
747
+
748
+			$data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
749
+
750
+			$class = 'class="' . esc_attr($classes) . '"';
751
+
752
+			$attributes = "{$class}{$data}";
753
+
754
+			if ($column_name === 'cb') {
755
+				echo '<th scope="row" class="check-column">';
756
+				echo apply_filters(
757
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
758
+					$this->column_cb($item), // already escaped
759
+					$item,
760
+					$this
761
+				);
762
+				echo '</th>';
763
+			} elseif (method_exists($this, 'column_' . $column_name)) {
764
+				echo "<td $attributes>"; // already escaped
765
+				echo apply_filters(
766
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
767
+					call_user_func([$this, 'column_' . $column_name], $item),
768
+					$item,
769
+					$this
770
+				);
771
+				echo wp_kses($this->handle_row_actions($item, $column_name, $primary), AllowedTags::getWithFormTags());
772
+				echo "</td>";
773
+			} else {
774
+				echo "<td $attributes>"; // already escaped
775
+				echo apply_filters(
776
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
777
+					$this->column_default($item, $column_name),
778
+					$item,
779
+					$column_name,
780
+					$this
781
+				);
782
+				echo wp_kses($this->handle_row_actions($item, $column_name, $primary), AllowedTags::getWithFormTags());
783
+				echo "</td>";
784
+			}
785
+		}
786
+	}
787
+
788
+
789
+	/**
790
+	 * Extra controls to be displayed between bulk actions and pagination
791
+	 *
792
+	 * @access public
793
+	 * @param string $which
794
+	 * @throws EE_Error
795
+	 */
796
+	public function extra_tablenav($which)
797
+	{
798
+		if ($which === 'top') {
799
+			$this->_filters();
800
+			echo wp_kses($this->_get_hidden_fields(), AllowedTags::getWithFormTags());
801
+		} else {
802
+			echo '<div class="list-table-bottom-buttons alignleft actions">';
803
+			foreach ($this->_bottom_buttons as $type => $action) {
804
+				$route         = isset($action['route']) ? $action['route'] : '';
805
+				$extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
806
+				// already escaped
807
+				echo wp_kses($this->_admin_page->get_action_link_or_button(
808
+					$route,
809
+					$type,
810
+					$extra_request,
811
+					'button button-secondary'
812
+				), AllowedTags::getWithFormTags());
813
+			}
814
+			do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
815
+			echo '</div>';
816
+		}
817
+	}
818
+
819
+
820
+	/**
821
+	 * Get an associative array ( option_name => option_title ) with the list
822
+	 * of bulk actions available on this table.
823
+	 *
824
+	 * @return array
825
+	 * @since  3.1.0
826
+	 * @access protected
827
+	 */
828
+	public function get_bulk_actions()
829
+	{
830
+		return (array) $this->_get_bulk_actions();
831
+	}
832
+
833
+
834
+	/**
835
+	 * Processing bulk actions.
836
+	 */
837
+	public function process_bulk_action()
838
+	{
839
+		// this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
840
+		// reference in case there is a case where it gets used.
841
+	}
842
+
843
+
844
+	/**
845
+	 * returns the EE admin page this list table is associated with
846
+	 *
847
+	 * @return EE_Admin_Page
848
+	 */
849
+	public function get_admin_page()
850
+	{
851
+		return $this->_admin_page;
852
+	}
853
+
854
+
855
+	/**
856
+	 * A "helper" function for all children to provide an html string of
857
+	 * actions to output in their content.  It is preferable for child classes
858
+	 * to use this method for generating their actions content so that it's
859
+	 * filterable by plugins
860
+	 *
861
+	 * @param string        $action_container           what are the html container
862
+	 *                                                  elements for this actions string?
863
+	 * @param string        $action_class               What class is for the container
864
+	 *                                                  element.
865
+	 * @param string        $action_items               The contents for the action items
866
+	 *                                                  container.  This is filtered before
867
+	 *                                                  returned.
868
+	 * @param string        $action_id                  What id (optional) is used for the
869
+	 *                                                  container element.
870
+	 * @param EE_Base_Class $item                       The object for the column displaying
871
+	 *                                                  the actions.
872
+	 * @return string The assembled action elements container.
873
+	 */
874
+	protected function _action_string(
875
+		$action_items,
876
+		$item,
877
+		$action_container = 'ul',
878
+		$action_class = '',
879
+		$action_id = ''
880
+	) {
881
+		$action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
882
+		$action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
883
+		$open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
884
+		$close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
885
+		try {
886
+			$content = apply_filters(
887
+				'FHEE__EE_Admin_List_Table___action_string__action_items',
888
+				$action_items,
889
+				$item,
890
+				$this
891
+			);
892
+		} catch (Exception $e) {
893
+			if (WP_DEBUG) {
894
+				EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
895
+			}
896
+			$content = $action_items;
897
+		}
898
+		return "{$open_tag}{$content}{$close_tag}";
899
+	}
900
+
901
+
902
+	/**
903
+	 * @return string
904
+	 */
905
+	protected function getReturnUrl()
906
+	{
907
+		$host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
908
+		$uri  = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
909
+		return urlencode(esc_url_raw("//{$host}{$uri}"));
910
+	}
911 911
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Indentation   +4093 added lines, -4093 removed lines patch added patch discarded remove patch
@@ -19,4167 +19,4167 @@
 block discarded – undo
19 19
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
20 20
 {
21 21
 
22
-    /**
23
-     * @var LoaderInterface
24
-     */
25
-    protected $loader;
22
+	/**
23
+	 * @var LoaderInterface
24
+	 */
25
+	protected $loader;
26 26
 
27
-    /**
28
-     * @var RequestInterface
29
-     */
30
-    protected $request;
27
+	/**
28
+	 * @var RequestInterface
29
+	 */
30
+	protected $request;
31 31
 
32
-    // set in _init_page_props()
33
-    public $page_slug;
32
+	// set in _init_page_props()
33
+	public $page_slug;
34 34
 
35
-    public $page_label;
35
+	public $page_label;
36 36
 
37
-    public $page_folder;
37
+	public $page_folder;
38 38
 
39
-    // set in define_page_props()
40
-    protected $_admin_base_url;
39
+	// set in define_page_props()
40
+	protected $_admin_base_url;
41 41
 
42
-    protected $_admin_base_path;
42
+	protected $_admin_base_path;
43 43
 
44
-    protected $_admin_page_title;
44
+	protected $_admin_page_title;
45 45
 
46
-    protected $_labels;
46
+	protected $_labels;
47 47
 
48 48
 
49
-    // set early within EE_Admin_Init
50
-    protected $_wp_page_slug;
49
+	// set early within EE_Admin_Init
50
+	protected $_wp_page_slug;
51 51
 
52
-    // navtabs
53
-    protected $_nav_tabs;
52
+	// navtabs
53
+	protected $_nav_tabs;
54 54
 
55
-    protected $_default_nav_tab_name;
55
+	protected $_default_nav_tab_name;
56 56
 
57 57
 
58
-    // template variables (used by templates)
59
-    protected $_template_path;
58
+	// template variables (used by templates)
59
+	protected $_template_path;
60 60
 
61
-    protected $_column_template_path;
61
+	protected $_column_template_path;
62 62
 
63
-    /**
64
-     * @var array $_template_args
65
-     */
66
-    protected $_template_args = [];
63
+	/**
64
+	 * @var array $_template_args
65
+	 */
66
+	protected $_template_args = [];
67 67
 
68
-    /**
69
-     * this will hold the list table object for a given view.
70
-     *
71
-     * @var EE_Admin_List_Table $_list_table_object
72
-     */
73
-    protected $_list_table_object;
68
+	/**
69
+	 * this will hold the list table object for a given view.
70
+	 *
71
+	 * @var EE_Admin_List_Table $_list_table_object
72
+	 */
73
+	protected $_list_table_object;
74 74
 
75
-    // bools
76
-    protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
75
+	// bools
76
+	protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
77 77
 
78
-    protected $_routing;
78
+	protected $_routing;
79 79
 
80
-    // list table args
81
-    protected $_view;
80
+	// list table args
81
+	protected $_view;
82 82
 
83
-    protected $_views;
83
+	protected $_views;
84 84
 
85 85
 
86
-    // action => method pairs used for routing incoming requests
87
-    protected $_page_routes;
86
+	// action => method pairs used for routing incoming requests
87
+	protected $_page_routes;
88 88
 
89
-    /**
90
-     * @var array $_page_config
91
-     */
92
-    protected $_page_config;
89
+	/**
90
+	 * @var array $_page_config
91
+	 */
92
+	protected $_page_config;
93 93
 
94
-    /**
95
-     * the current page route and route config
96
-     *
97
-     * @var string $_route
98
-     */
99
-    protected $_route;
94
+	/**
95
+	 * the current page route and route config
96
+	 *
97
+	 * @var string $_route
98
+	 */
99
+	protected $_route;
100 100
 
101
-    /**
102
-     * @var string $_cpt_route
103
-     */
104
-    protected $_cpt_route;
101
+	/**
102
+	 * @var string $_cpt_route
103
+	 */
104
+	protected $_cpt_route;
105 105
 
106
-    /**
107
-     * @var array $_route_config
108
-     */
109
-    protected $_route_config;
106
+	/**
107
+	 * @var array $_route_config
108
+	 */
109
+	protected $_route_config;
110 110
 
111
-    /**
112
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
113
-     * actions.
114
-     *
115
-     * @since 4.6.x
116
-     * @var array.
117
-     */
118
-    protected $_default_route_query_args;
119
-
120
-    // set via request page and action args.
121
-    protected $_current_page;
122
-
123
-    protected $_current_view;
124
-
125
-    protected $_current_page_view_url;
126
-
127
-    /**
128
-     * unprocessed value for the 'action' request param (default '')
129
-     *
130
-     * @var string
131
-     */
132
-    protected $raw_req_action = '';
133
-
134
-    /**
135
-     * unprocessed value for the 'page' request param (default '')
136
-     *
137
-     * @var string
138
-     */
139
-    protected $raw_req_page = '';
140
-
141
-    /**
142
-     * sanitized request action (and nonce)
143
-     *
144
-     * @var string
145
-     */
146
-    protected $_req_action = '';
147
-
148
-    /**
149
-     * sanitized request action nonce
150
-     *
151
-     * @var string
152
-     */
153
-    protected $_req_nonce = '';
154
-
155
-    /**
156
-     * @var string
157
-     */
158
-    protected $_search_btn_label = '';
159
-
160
-    /**
161
-     * @var string
162
-     */
163
-    protected $_search_box_callback = '';
164
-
165
-    /**
166
-     * @var WP_Screen
167
-     */
168
-    protected $_current_screen;
169
-
170
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
171
-    protected $_hook_obj;
172
-
173
-    // for holding incoming request data
174
-    protected $_req_data = [];
175
-
176
-    // yes / no array for admin form fields
177
-    protected $_yes_no_values = [];
178
-
179
-    // some default things shared by all child classes
180
-    protected $_default_espresso_metaboxes;
181
-
182
-    /**
183
-     * @var EE_Registry
184
-     */
185
-    protected $EE = null;
186
-
187
-
188
-    /**
189
-     * This is just a property that flags whether the given route is a caffeinated route or not.
190
-     *
191
-     * @var boolean
192
-     */
193
-    protected $_is_caf = false;
194
-
195
-
196
-    /**
197
-     * @Constructor
198
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
199
-     * @throws EE_Error
200
-     * @throws InvalidArgumentException
201
-     * @throws ReflectionException
202
-     * @throws InvalidDataTypeException
203
-     * @throws InvalidInterfaceException
204
-     */
205
-    public function __construct($routing = true)
206
-    {
207
-        $this->loader  = LoaderFactory::getLoader();
208
-        $this->request = $this->loader->getShared(RequestInterface::class);
209
-        $this->_routing = $routing;
210
-
211
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
212
-            $this->_is_caf = true;
213
-        }
214
-        $this->_yes_no_values = [
215
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
216
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
217
-        ];
218
-        // set the _req_data property.
219
-        $this->_req_data = $this->request->requestParams();
220
-        // set initial page props (child method)
221
-        $this->_init_page_props();
222
-        // set global defaults
223
-        $this->_set_defaults();
224
-        // set early because incoming requests could be ajax related and we need to register those hooks.
225
-        $this->_global_ajax_hooks();
226
-        $this->_ajax_hooks();
227
-        // other_page_hooks have to be early too.
228
-        $this->_do_other_page_hooks();
229
-        // set up page dependencies
230
-        $this->_before_page_setup();
231
-        $this->_page_setup();
232
-        // die();
233
-    }
234
-
235
-
236
-    /**
237
-     * _init_page_props
238
-     * Child classes use to set at least the following properties:
239
-     * $page_slug.
240
-     * $page_label.
241
-     *
242
-     * @abstract
243
-     * @return void
244
-     */
245
-    abstract protected function _init_page_props();
246
-
247
-
248
-    /**
249
-     * _ajax_hooks
250
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
251
-     * Note: within the ajax callback methods.
252
-     *
253
-     * @abstract
254
-     * @return void
255
-     */
256
-    abstract protected function _ajax_hooks();
257
-
258
-
259
-    /**
260
-     * _define_page_props
261
-     * child classes define page properties in here.  Must include at least:
262
-     * $_admin_base_url = base_url for all admin pages
263
-     * $_admin_page_title = default admin_page_title for admin pages
264
-     * $_labels = array of default labels for various automatically generated elements:
265
-     *    array(
266
-     *        'buttons' => array(
267
-     *            'add' => esc_html__('label for add new button'),
268
-     *            'edit' => esc_html__('label for edit button'),
269
-     *            'delete' => esc_html__('label for delete button')
270
-     *            )
271
-     *        )
272
-     *
273
-     * @abstract
274
-     * @return void
275
-     */
276
-    abstract protected function _define_page_props();
277
-
278
-
279
-    /**
280
-     * _set_page_routes
281
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
282
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
283
-     * have a 'default' route. Here's the format
284
-     * $this->_page_routes = array(
285
-     *        'default' => array(
286
-     *            'func' => '_default_method_handling_route',
287
-     *            'args' => array('array','of','args'),
288
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
289
-     *            ajax request, backend processing)
290
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
291
-     *            headers route after.  The string you enter here should match the defined route reference for a
292
-     *            headers sent route.
293
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
294
-     *            this route.
295
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
296
-     *            checks).
297
-     *        ),
298
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
299
-     *        handling method.
300
-     *        )
301
-     * )
302
-     *
303
-     * @abstract
304
-     * @return void
305
-     */
306
-    abstract protected function _set_page_routes();
307
-
308
-
309
-    /**
310
-     * _set_page_config
311
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
312
-     * array corresponds to the page_route for the loaded page. Format:
313
-     * $this->_page_config = array(
314
-     *        'default' => array(
315
-     *            'labels' => array(
316
-     *                'buttons' => array(
317
-     *                    'add' => esc_html__('label for adding item'),
318
-     *                    'edit' => esc_html__('label for editing item'),
319
-     *                    'delete' => esc_html__('label for deleting item')
320
-     *                ),
321
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
322
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
323
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
324
-     *            _define_page_props() method
325
-     *            'nav' => array(
326
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
327
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
328
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
329
-     *                'order' => 10, //required to indicate tab position.
330
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
331
-     *                displayed then add this parameter.
332
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
333
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
334
-     *            metaboxes set for eventespresso admin pages.
335
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
336
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
337
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
338
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
339
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
340
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
341
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
342
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
343
-     *            want to display.
344
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
345
-     *                'tab_id' => array(
346
-     *                    'title' => 'tab_title',
347
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
348
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
349
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
350
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
351
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
352
-     *                    attempt to use the callback which should match the name of a method in the class
353
-     *                    ),
354
-     *                'tab2_id' => array(
355
-     *                    'title' => 'tab2 title',
356
-     *                    'filename' => 'file_name_2'
357
-     *                    'callback' => 'callback_method_for_content',
358
-     *                 ),
359
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
360
-     *            help tab area on an admin page. @return void
361
-     *
362
-     * @abstract
363
-     */
364
-    abstract protected function _set_page_config();
365
-
366
-
367
-    /**
368
-     * _add_screen_options
369
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
370
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
371
-     * to a particular view.
372
-     *
373
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
374
-     *         see also WP_Screen object documents...
375
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
376
-     * @abstract
377
-     * @return void
378
-     */
379
-    abstract protected function _add_screen_options();
380
-
381
-
382
-    /**
383
-     * _add_feature_pointers
384
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
385
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
386
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
387
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
388
-     * extended) also see:
389
-     *
390
-     * @link   http://eamann.com/tech/wordpress-portland/
391
-     * @abstract
392
-     * @return void
393
-     */
394
-    abstract protected function _add_feature_pointers();
395
-
396
-
397
-    /**
398
-     * load_scripts_styles
399
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
400
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
401
-     * scripts/styles per view by putting them in a dynamic function in this format
402
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
403
-     *
404
-     * @abstract
405
-     * @return void
406
-     */
407
-    abstract public function load_scripts_styles();
408
-
409
-
410
-    /**
411
-     * admin_init
412
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
413
-     * all pages/views loaded by child class.
414
-     *
415
-     * @abstract
416
-     * @return void
417
-     */
418
-    abstract public function admin_init();
419
-
420
-
421
-    /**
422
-     * admin_notices
423
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
424
-     * all pages/views loaded by child class.
425
-     *
426
-     * @abstract
427
-     * @return void
428
-     */
429
-    abstract public function admin_notices();
430
-
431
-
432
-    /**
433
-     * admin_footer_scripts
434
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
435
-     * will apply to all pages/views loaded by child class.
436
-     *
437
-     * @return void
438
-     */
439
-    abstract public function admin_footer_scripts();
440
-
441
-
442
-    /**
443
-     * admin_footer
444
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
445
-     * apply to all pages/views loaded by child class.
446
-     *
447
-     * @return void
448
-     */
449
-    public function admin_footer()
450
-    {
451
-    }
452
-
453
-
454
-    /**
455
-     * _global_ajax_hooks
456
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
457
-     * Note: within the ajax callback methods.
458
-     *
459
-     * @abstract
460
-     * @return void
461
-     */
462
-    protected function _global_ajax_hooks()
463
-    {
464
-        // for lazy loading of metabox content
465
-        add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
466
-    }
467
-
468
-
469
-    public function ajax_metabox_content()
470
-    {
471
-        $content_id  = $this->request->getRequestParam('contentid', '');
472
-        $content_url = $this->request->getRequestParam('contenturl', '', 'url');
473
-        self::cached_rss_display($content_id, $content_url);
474
-        wp_die();
475
-    }
476
-
477
-
478
-    /**
479
-     * allows extending classes do something specific before the parent constructor runs _page_setup().
480
-     *
481
-     * @return void
482
-     */
483
-    protected function _before_page_setup()
484
-    {
485
-        // default is to do nothing
486
-    }
487
-
488
-
489
-    /**
490
-     * Makes sure any things that need to be loaded early get handled.
491
-     * We also escape early here if the page requested doesn't match the object.
492
-     *
493
-     * @final
494
-     * @return void
495
-     * @throws EE_Error
496
-     * @throws InvalidArgumentException
497
-     * @throws ReflectionException
498
-     * @throws InvalidDataTypeException
499
-     * @throws InvalidInterfaceException
500
-     */
501
-    final protected function _page_setup()
502
-    {
503
-        // requires?
504
-        // admin_init stuff - global - we're setting this REALLY early
505
-        // so if EE_Admin pages have to hook into other WP pages they can.
506
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
507
-        add_action('admin_init', [$this, 'admin_init_global'], 5);
508
-        // next verify if we need to load anything...
509
-        $this->_current_page = $this->request->getRequestParam('page', '', 'key');
510
-        $this->page_folder   = strtolower(
511
-            str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
512
-        );
513
-        global $ee_menu_slugs;
514
-        $ee_menu_slugs = (array) $ee_menu_slugs;
515
-        if (
516
-            ! $this->request->isAjax()
517
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
518
-        ) {
519
-            return;
520
-        }
521
-        // because WP List tables have two duplicate select inputs for choosing bulk actions,
522
-        // we need to copy the action from the second to the first
523
-        $action     = $this->request->getRequestParam('action', '-1', 'key');
524
-        $action2    = $this->request->getRequestParam('action2', '-1', 'key');
525
-        $action     = $action !== '-1' ? $action : $action2;
526
-        $req_action = $action !== '-1' ? $action : 'default';
527
-
528
-        // if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
529
-        // then let's use the route as the action.
530
-        // This covers cases where we're coming in from a list table that isn't on the default route.
531
-        $route = $this->request->getRequestParam('route');
532
-        $this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
533
-            ? $route
534
-            : $req_action;
535
-
536
-        $this->_current_view = $this->_req_action;
537
-        $this->_req_nonce    = $this->_req_action . '_nonce';
538
-        $this->_define_page_props();
539
-        $this->_current_page_view_url = add_query_arg(
540
-            ['page' => $this->_current_page, 'action' => $this->_current_view],
541
-            $this->_admin_base_url
542
-        );
543
-        // default things
544
-        $this->_default_espresso_metaboxes = [
545
-            '_espresso_news_post_box',
546
-            '_espresso_links_post_box',
547
-            '_espresso_ratings_request',
548
-            '_espresso_sponsors_post_box',
549
-        ];
550
-        // set page configs
551
-        $this->_set_page_routes();
552
-        $this->_set_page_config();
553
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
554
-        if ($this->request->requestParamIsSet('wp_referer')) {
555
-            $wp_referer = $this->request->getRequestParam('wp_referer');
556
-            if ($wp_referer) {
557
-                $this->_default_route_query_args['wp_referer'] = $wp_referer;
558
-            }
559
-        }
560
-        // for caffeinated and other extended functionality.
561
-        //  If there is a _extend_page_config method
562
-        // then let's run that to modify the all the various page configuration arrays
563
-        if (method_exists($this, '_extend_page_config')) {
564
-            $this->_extend_page_config();
565
-        }
566
-        // for CPT and other extended functionality.
567
-        // If there is an _extend_page_config_for_cpt
568
-        // then let's run that to modify all the various page configuration arrays.
569
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
570
-            $this->_extend_page_config_for_cpt();
571
-        }
572
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
573
-        $this->_page_routes = apply_filters(
574
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
575
-            $this->_page_routes,
576
-            $this
577
-        );
578
-        $this->_page_config = apply_filters(
579
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
580
-            $this->_page_config,
581
-            $this
582
-        );
583
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
584
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
585
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
586
-            add_action(
587
-                'AHEE__EE_Admin_Page__route_admin_request',
588
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
589
-                10,
590
-                2
591
-            );
592
-        }
593
-        // next route only if routing enabled
594
-        if ($this->_routing && ! $this->request->isAjax()) {
595
-            $this->_verify_routes();
596
-            // next let's just check user_access and kill if no access
597
-            $this->check_user_access();
598
-            if ($this->_is_UI_request) {
599
-                // admin_init stuff - global, all views for this page class, specific view
600
-                add_action('admin_init', [$this, 'admin_init'], 10);
601
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
602
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
603
-                }
604
-            } else {
605
-                // hijack regular WP loading and route admin request immediately
606
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
607
-                $this->route_admin_request();
608
-            }
609
-        }
610
-    }
611
-
612
-
613
-    /**
614
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
615
-     *
616
-     * @return void
617
-     * @throws EE_Error
618
-     */
619
-    private function _do_other_page_hooks()
620
-    {
621
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
622
-        foreach ($registered_pages as $page) {
623
-            // now let's setup the file name and class that should be present
624
-            $classname = str_replace('.class.php', '', $page);
625
-            // autoloaders should take care of loading file
626
-            if (! class_exists($classname)) {
627
-                $error_msg[] = sprintf(
628
-                    esc_html__(
629
-                        'Something went wrong with loading the %s admin hooks page.',
630
-                        'event_espresso'
631
-                    ),
632
-                    $page
633
-                );
634
-                $error_msg[] = $error_msg[0]
635
-                               . "\r\n"
636
-                               . sprintf(
637
-                                   esc_html__(
638
-                                       'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
639
-                                       'event_espresso'
640
-                                   ),
641
-                                   $page,
642
-                                   '<br />',
643
-                                   '<strong>' . $classname . '</strong>'
644
-                               );
645
-                throw new EE_Error(implode('||', $error_msg));
646
-            }
647
-            // notice we are passing the instance of this class to the hook object.
648
-            $this->loader->getShared($classname, [$this]);
649
-        }
650
-    }
651
-
652
-
653
-    /**
654
-     * @throws ReflectionException
655
-     * @throws EE_Error
656
-     */
657
-    public function load_page_dependencies()
658
-    {
659
-        try {
660
-            $this->_load_page_dependencies();
661
-        } catch (EE_Error $e) {
662
-            $e->get_error();
663
-        }
664
-    }
665
-
666
-
667
-    /**
668
-     * load_page_dependencies
669
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
670
-     *
671
-     * @return void
672
-     * @throws DomainException
673
-     * @throws EE_Error
674
-     * @throws InvalidArgumentException
675
-     * @throws InvalidDataTypeException
676
-     * @throws InvalidInterfaceException
677
-     */
678
-    protected function _load_page_dependencies()
679
-    {
680
-        // let's set the current_screen and screen options to override what WP set
681
-        $this->_current_screen = get_current_screen();
682
-        // load admin_notices - global, page class, and view specific
683
-        add_action('admin_notices', [$this, 'admin_notices_global'], 5);
684
-        add_action('admin_notices', [$this, 'admin_notices'], 10);
685
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
686
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
687
-        }
688
-        // load network admin_notices - global, page class, and view specific
689
-        add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
690
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
691
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
692
-        }
693
-        // this will save any per_page screen options if they are present
694
-        $this->_set_per_page_screen_options();
695
-        // setup list table properties
696
-        $this->_set_list_table();
697
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
698
-        // However in some cases the metaboxes will need to be added within a route handling callback.
699
-        $this->_add_registered_meta_boxes();
700
-        $this->_add_screen_columns();
701
-        // add screen options - global, page child class, and view specific
702
-        $this->_add_global_screen_options();
703
-        $this->_add_screen_options();
704
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
705
-        if (method_exists($this, $add_screen_options)) {
706
-            $this->{$add_screen_options}();
707
-        }
708
-        // add help tab(s) - set via page_config and qtips.
709
-        $this->_add_help_tabs();
710
-        $this->_add_qtips();
711
-        // add feature_pointers - global, page child class, and view specific
712
-        $this->_add_feature_pointers();
713
-        $this->_add_global_feature_pointers();
714
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
715
-        if (method_exists($this, $add_feature_pointer)) {
716
-            $this->{$add_feature_pointer}();
717
-        }
718
-        // enqueue scripts/styles - global, page class, and view specific
719
-        add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
720
-        add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
721
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
722
-            add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
723
-        }
724
-        add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
725
-        // admin_print_footer_scripts - global, page child class, and view specific.
726
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
727
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
728
-        // is a good use case. Notice the late priority we're giving these
729
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
730
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
731
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
732
-            add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
733
-        }
734
-        // admin footer scripts
735
-        add_action('admin_footer', [$this, 'admin_footer_global'], 99);
736
-        add_action('admin_footer', [$this, 'admin_footer'], 100);
737
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
738
-            add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
739
-        }
740
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
741
-        // targeted hook
742
-        do_action(
743
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
744
-        );
745
-    }
746
-
747
-
748
-    /**
749
-     * _set_defaults
750
-     * This sets some global defaults for class properties.
751
-     */
752
-    private function _set_defaults()
753
-    {
754
-        $this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
755
-        $this->_event                = $this->_template_path = $this->_column_template_path = null;
756
-        $this->_nav_tabs             = $this->_views = $this->_page_routes = [];
757
-        $this->_page_config          = $this->_default_route_query_args = [];
758
-        $this->_default_nav_tab_name = 'overview';
759
-        // init template args
760
-        $this->_template_args = [
761
-            'admin_page_header'  => '',
762
-            'admin_page_content' => '',
763
-            'post_body_content'  => '',
764
-            'before_list_table'  => '',
765
-            'after_list_table'   => '',
766
-        ];
767
-    }
768
-
769
-
770
-    /**
771
-     * route_admin_request
772
-     *
773
-     * @return void
774
-     * @throws InvalidArgumentException
775
-     * @throws InvalidInterfaceException
776
-     * @throws InvalidDataTypeException
777
-     * @throws EE_Error
778
-     * @throws ReflectionException
779
-     * @see    _route_admin_request()
780
-     */
781
-    public function route_admin_request()
782
-    {
783
-        try {
784
-            $this->_route_admin_request();
785
-        } catch (EE_Error $e) {
786
-            $e->get_error();
787
-        }
788
-    }
789
-
790
-
791
-    public function set_wp_page_slug($wp_page_slug)
792
-    {
793
-        $this->_wp_page_slug = $wp_page_slug;
794
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
795
-        if (is_network_admin()) {
796
-            $this->_wp_page_slug .= '-network';
797
-        }
798
-    }
799
-
800
-
801
-    /**
802
-     * _verify_routes
803
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
804
-     * we know if we need to drop out.
805
-     *
806
-     * @return bool
807
-     * @throws EE_Error
808
-     */
809
-    protected function _verify_routes()
810
-    {
811
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
812
-        if (! $this->_current_page && ! $this->request->isAjax()) {
813
-            return false;
814
-        }
815
-        $this->_route = false;
816
-        // check that the page_routes array is not empty
817
-        if (empty($this->_page_routes)) {
818
-            // user error msg
819
-            $error_msg = sprintf(
820
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
821
-                $this->_admin_page_title
822
-            );
823
-            // developer error msg
824
-            $error_msg .= '||' . $error_msg
825
-                          . esc_html__(
826
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
827
-                              'event_espresso'
828
-                          );
829
-            throw new EE_Error($error_msg);
830
-        }
831
-        // and that the requested page route exists
832
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
833
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
834
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
835
-                ? $this->_page_config[ $this->_req_action ]
836
-                : [];
837
-        } else {
838
-            // user error msg
839
-            $error_msg = sprintf(
840
-                esc_html__(
841
-                    'The requested page route does not exist for the %s admin page.',
842
-                    'event_espresso'
843
-                ),
844
-                $this->_admin_page_title
845
-            );
846
-            // developer error msg
847
-            $error_msg .= '||' . $error_msg
848
-                          . sprintf(
849
-                              esc_html__(
850
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
851
-                                  'event_espresso'
852
-                              ),
853
-                              $this->_req_action
854
-                          );
855
-            throw new EE_Error($error_msg);
856
-        }
857
-        // and that a default route exists
858
-        if (! array_key_exists('default', $this->_page_routes)) {
859
-            // user error msg
860
-            $error_msg = sprintf(
861
-                esc_html__(
862
-                    'A default page route has not been set for the % admin page.',
863
-                    'event_espresso'
864
-                ),
865
-                $this->_admin_page_title
866
-            );
867
-            // developer error msg
868
-            $error_msg .= '||' . $error_msg
869
-                          . esc_html__(
870
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
871
-                              'event_espresso'
872
-                          );
873
-            throw new EE_Error($error_msg);
874
-        }
875
-        // first lets' catch if the UI request has EVER been set.
876
-        if ($this->_is_UI_request === null) {
877
-            // lets set if this is a UI request or not.
878
-            $this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
879
-            // wait a minute... we might have a noheader in the route array
880
-            $this->_is_UI_request = ! (
881
-                is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
882
-            )
883
-                ? $this->_is_UI_request
884
-                : false;
885
-        }
886
-        $this->_set_current_labels();
887
-        return true;
888
-    }
889
-
890
-
891
-    /**
892
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
893
-     *
894
-     * @param string $route the route name we're verifying
895
-     * @return bool we'll throw an exception if this isn't a valid route.
896
-     * @throws EE_Error
897
-     */
898
-    protected function _verify_route($route)
899
-    {
900
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
901
-            return true;
902
-        }
903
-        // user error msg
904
-        $error_msg = sprintf(
905
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
906
-            $this->_admin_page_title
907
-        );
908
-        // developer error msg
909
-        $error_msg .= '||' . $error_msg
910
-                      . sprintf(
911
-                          esc_html__(
912
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
913
-                              'event_espresso'
914
-                          ),
915
-                          $route
916
-                      );
917
-        throw new EE_Error($error_msg);
918
-    }
919
-
920
-
921
-    /**
922
-     * perform nonce verification
923
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
924
-     * using this method (and save retyping!)
925
-     *
926
-     * @param string $nonce     The nonce sent
927
-     * @param string $nonce_ref The nonce reference string (name0)
928
-     * @return void
929
-     * @throws EE_Error
930
-     */
931
-    protected function _verify_nonce($nonce, $nonce_ref)
932
-    {
933
-        // verify nonce against expected value
934
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
935
-            // these are not the droids you are looking for !!!
936
-            $msg = sprintf(
937
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
938
-                '<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
939
-                '</a>'
940
-            );
941
-            if (WP_DEBUG) {
942
-                $msg .= "\n  ";
943
-                $msg .= sprintf(
944
-                    esc_html__(
945
-                        'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
946
-                        'event_espresso'
947
-                    ),
948
-                    __CLASS__
949
-                );
950
-            }
951
-            if (! $this->request->isAjax()) {
952
-                wp_die($msg);
953
-            }
954
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
955
-            $this->_return_json();
956
-        }
957
-    }
958
-
959
-
960
-    /**
961
-     * _route_admin_request()
962
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
963
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
964
-     * in the page routes and then will try to load the corresponding method.
965
-     *
966
-     * @return void
967
-     * @throws EE_Error
968
-     * @throws InvalidArgumentException
969
-     * @throws InvalidDataTypeException
970
-     * @throws InvalidInterfaceException
971
-     * @throws ReflectionException
972
-     */
973
-    protected function _route_admin_request()
974
-    {
975
-        if (! $this->_is_UI_request) {
976
-            $this->_verify_routes();
977
-        }
978
-        $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
979
-        if ($this->_req_action !== 'default' && $nonce_check) {
980
-            // set nonce from post data
981
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
982
-            $this->_verify_nonce($nonce, $this->_req_nonce);
983
-        }
984
-        // set the nav_tabs array but ONLY if this is  UI_request
985
-        if ($this->_is_UI_request) {
986
-            $this->_set_nav_tabs();
987
-        }
988
-        // grab callback function
989
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
990
-        // check if callback has args
991
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
992
-        $error_msg = '';
993
-        // action right before calling route
994
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
995
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
996
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
997
-        }
998
-        // right before calling the route, let's clean the _wp_http_referer
999
-        $this->request->setServerParam(
1000
-            'REQUEST_URI',
1001
-            remove_query_arg(
1002
-                '_wp_http_referer',
1003
-                wp_unslash($this->request->getServerParam('REQUEST_URI'))
1004
-            )
1005
-        );
1006
-        if (! empty($func)) {
1007
-            if (is_array($func)) {
1008
-                list($class, $method) = $func;
1009
-            } elseif (strpos($func, '::') !== false) {
1010
-                list($class, $method) = explode('::', $func);
1011
-            } else {
1012
-                $class  = $this;
1013
-                $method = $func;
1014
-            }
1015
-            if (! (is_object($class) && $class === $this)) {
1016
-                // send along this admin page object for access by addons.
1017
-                $args['admin_page_object'] = $this;
1018
-            }
1019
-            if (
1020
-                // is it a method on a class that doesn't work?
1021
-                (
1022
-                    (
1023
-                        method_exists($class, $method)
1024
-                        && call_user_func_array([$class, $method], $args) === false
1025
-                    )
1026
-                    && (
1027
-                        // is it a standalone function that doesn't work?
1028
-                        function_exists($method)
1029
-                        && call_user_func_array(
1030
-                            $func,
1031
-                            array_merge(['admin_page_object' => $this], $args)
1032
-                        ) === false
1033
-                    )
1034
-                )
1035
-                || (
1036
-                    // is it neither a class method NOR a standalone function?
1037
-                    ! method_exists($class, $method)
1038
-                    && ! function_exists($method)
1039
-                )
1040
-            ) {
1041
-                // user error msg
1042
-                $error_msg = esc_html__(
1043
-                    'An error occurred. The  requested page route could not be found.',
1044
-                    'event_espresso'
1045
-                );
1046
-                // developer error msg
1047
-                $error_msg .= '||';
1048
-                $error_msg .= sprintf(
1049
-                    esc_html__(
1050
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1051
-                        'event_espresso'
1052
-                    ),
1053
-                    $method
1054
-                );
1055
-            }
1056
-            if (! empty($error_msg)) {
1057
-                throw new EE_Error($error_msg);
1058
-            }
1059
-        }
1060
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1061
-        // then we need to reset the routing properties to the new route.
1062
-        // 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.
1063
-        if (
1064
-            $this->_is_UI_request === false
1065
-            && is_array($this->_route)
1066
-            && ! empty($this->_route['headers_sent_route'])
1067
-        ) {
1068
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1069
-        }
1070
-    }
1071
-
1072
-
1073
-    /**
1074
-     * This method just allows the resetting of page properties in the case where a no headers
1075
-     * route redirects to a headers route in its route config.
1076
-     *
1077
-     * @param string $new_route New (non header) route to redirect to.
1078
-     * @return   void
1079
-     * @throws ReflectionException
1080
-     * @throws InvalidArgumentException
1081
-     * @throws InvalidInterfaceException
1082
-     * @throws InvalidDataTypeException
1083
-     * @throws EE_Error
1084
-     * @since   4.3.0
1085
-     */
1086
-    protected function _reset_routing_properties($new_route)
1087
-    {
1088
-        $this->_is_UI_request = true;
1089
-        // now we set the current route to whatever the headers_sent_route is set at
1090
-        $this->request->setRequestParam('action', $new_route);
1091
-        // rerun page setup
1092
-        $this->_page_setup();
1093
-    }
1094
-
1095
-
1096
-    /**
1097
-     * _add_query_arg
1098
-     * adds nonce to array of arguments then calls WP add_query_arg function
1099
-     *(internally just uses EEH_URL's function with the same name)
1100
-     *
1101
-     * @param array  $args
1102
-     * @param string $url
1103
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1104
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1105
-     *                                        Example usage: If the current page is:
1106
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1107
-     *                                        &action=default&event_id=20&month_range=March%202015
1108
-     *                                        &_wpnonce=5467821
1109
-     *                                        and you call:
1110
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1111
-     *                                        array(
1112
-     *                                        'action' => 'resend_something',
1113
-     *                                        'page=>espresso_registrations'
1114
-     *                                        ),
1115
-     *                                        $some_url,
1116
-     *                                        true
1117
-     *                                        );
1118
-     *                                        It will produce a url in this structure:
1119
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1120
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1121
-     *                                        month_range]=March%202015
1122
-     * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1123
-     * @return string
1124
-     */
1125
-    public static function add_query_args_and_nonce(
1126
-        $args = [],
1127
-        $url = false,
1128
-        $sticky = false,
1129
-        $exclude_nonce = false
1130
-    ) {
1131
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1132
-        if ($sticky) {
1133
-            /** @var RequestInterface $request */
1134
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1135
-            $request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1136
-            foreach ($request->requestParams() as $key => $value) {
1137
-                // do not add nonces
1138
-                if (strpos($key, 'nonce') !== false) {
1139
-                    continue;
1140
-                }
1141
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1142
-            }
1143
-        }
1144
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1145
-    }
1146
-
1147
-
1148
-    /**
1149
-     * This returns a generated link that will load the related help tab.
1150
-     *
1151
-     * @param string $help_tab_id the id for the connected help tab
1152
-     * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1153
-     * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1154
-     * @return string              generated link
1155
-     * @uses EEH_Template::get_help_tab_link()
1156
-     */
1157
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1158
-    {
1159
-        return EEH_Template::get_help_tab_link(
1160
-            $help_tab_id,
1161
-            $this->page_slug,
1162
-            $this->_req_action,
1163
-            $icon_style,
1164
-            $help_text
1165
-        );
1166
-    }
1167
-
1168
-
1169
-    /**
1170
-     * _add_help_tabs
1171
-     * Note child classes define their help tabs within the page_config array.
1172
-     *
1173
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1174
-     * @return void
1175
-     * @throws DomainException
1176
-     * @throws EE_Error
1177
-     */
1178
-    protected function _add_help_tabs()
1179
-    {
1180
-        if (isset($this->_page_config[ $this->_req_action ])) {
1181
-            $config = $this->_page_config[ $this->_req_action ];
1182
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1183
-            if (is_array($config) && isset($config['help_sidebar'])) {
1184
-                // check that the callback given is valid
1185
-                if (! method_exists($this, $config['help_sidebar'])) {
1186
-                    throw new EE_Error(
1187
-                        sprintf(
1188
-                            esc_html__(
1189
-                                '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',
1190
-                                'event_espresso'
1191
-                            ),
1192
-                            $config['help_sidebar'],
1193
-                            get_class($this)
1194
-                        )
1195
-                    );
1196
-                }
1197
-                $content = apply_filters(
1198
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1199
-                    $this->{$config['help_sidebar']}()
1200
-                );
1201
-                $this->_current_screen->set_help_sidebar($content);
1202
-            }
1203
-            if (! isset($config['help_tabs'])) {
1204
-                return;
1205
-            } //no help tabs for this route
1206
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1207
-                // we're here so there ARE help tabs!
1208
-                // make sure we've got what we need
1209
-                if (! isset($cfg['title'])) {
1210
-                    throw new EE_Error(
1211
-                        esc_html__(
1212
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1213
-                            'event_espresso'
1214
-                        )
1215
-                    );
1216
-                }
1217
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1218
-                    throw new EE_Error(
1219
-                        esc_html__(
1220
-                            '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',
1221
-                            'event_espresso'
1222
-                        )
1223
-                    );
1224
-                }
1225
-                // first priority goes to content.
1226
-                if (! empty($cfg['content'])) {
1227
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1228
-                    // second priority goes to filename
1229
-                } elseif (! empty($cfg['filename'])) {
1230
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1231
-                    // 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)
1232
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1233
-                                                             . basename($this->_get_dir())
1234
-                                                             . '/help_tabs/'
1235
-                                                             . $cfg['filename']
1236
-                                                             . '.help_tab.php' : $file_path;
1237
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1238
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1239
-                        EE_Error::add_error(
1240
-                            sprintf(
1241
-                                esc_html__(
1242
-                                    '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',
1243
-                                    'event_espresso'
1244
-                                ),
1245
-                                $tab_id,
1246
-                                key($config),
1247
-                                $file_path
1248
-                            ),
1249
-                            __FILE__,
1250
-                            __FUNCTION__,
1251
-                            __LINE__
1252
-                        );
1253
-                        return;
1254
-                    }
1255
-                    $template_args['admin_page_obj'] = $this;
1256
-                    $content                         = EEH_Template::display_template(
1257
-                        $file_path,
1258
-                        $template_args,
1259
-                        true
1260
-                    );
1261
-                } else {
1262
-                    $content = '';
1263
-                }
1264
-                // check if callback is valid
1265
-                if (
1266
-                    empty($content)
1267
-                    && (
1268
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1269
-                    )
1270
-                ) {
1271
-                    EE_Error::add_error(
1272
-                        sprintf(
1273
-                            esc_html__(
1274
-                                '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.',
1275
-                                'event_espresso'
1276
-                            ),
1277
-                            $cfg['title']
1278
-                        ),
1279
-                        __FILE__,
1280
-                        __FUNCTION__,
1281
-                        __LINE__
1282
-                    );
1283
-                    return;
1284
-                }
1285
-                // setup config array for help tab method
1286
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1287
-                $_ht = [
1288
-                    'id'       => $id,
1289
-                    'title'    => $cfg['title'],
1290
-                    'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1291
-                    'content'  => $content,
1292
-                ];
1293
-                $this->_current_screen->add_help_tab($_ht);
1294
-            }
1295
-        }
1296
-    }
1297
-
1298
-
1299
-    /**
1300
-     * This simply sets up any qtips that have been defined in the page config
1301
-     *
1302
-     * @return void
1303
-     */
1304
-    protected function _add_qtips()
1305
-    {
1306
-        if (isset($this->_route_config['qtips'])) {
1307
-            $qtips = (array) $this->_route_config['qtips'];
1308
-            // load qtip loader
1309
-            $path = [
1310
-                $this->_get_dir() . '/qtips/',
1311
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1312
-            ];
1313
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1314
-        }
1315
-    }
1316
-
1317
-
1318
-    /**
1319
-     * _set_nav_tabs
1320
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1321
-     * wish to add additional tabs or modify accordingly.
1322
-     *
1323
-     * @return void
1324
-     * @throws InvalidArgumentException
1325
-     * @throws InvalidInterfaceException
1326
-     * @throws InvalidDataTypeException
1327
-     */
1328
-    protected function _set_nav_tabs()
1329
-    {
1330
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1331
-        $i = 0;
1332
-        foreach ($this->_page_config as $slug => $config) {
1333
-            if (! is_array($config) || empty($config['nav'])) {
1334
-                continue;
1335
-            }
1336
-            // no nav tab for this config
1337
-            // check for persistent flag
1338
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1339
-                // nav tab is only to appear when route requested.
1340
-                continue;
1341
-            }
1342
-            if (! $this->check_user_access($slug, true)) {
1343
-                // no nav tab because current user does not have access.
1344
-                continue;
1345
-            }
1346
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1347
-            $this->_nav_tabs[ $slug ] = [
1348
-                'url'       => isset($config['nav']['url'])
1349
-                    ? $config['nav']['url']
1350
-                    : self::add_query_args_and_nonce(
1351
-                        ['action' => $slug],
1352
-                        $this->_admin_base_url
1353
-                    ),
1354
-                'link_text' => isset($config['nav']['label'])
1355
-                    ? $config['nav']['label']
1356
-                    : ucwords(
1357
-                        str_replace('_', ' ', $slug)
1358
-                    ),
1359
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1360
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1361
-            ];
1362
-            $i++;
1363
-        }
1364
-        // if $this->_nav_tabs is empty then lets set the default
1365
-        if (empty($this->_nav_tabs)) {
1366
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1367
-                'url'       => $this->_admin_base_url,
1368
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1369
-                'css_class' => 'nav-tab-active',
1370
-                'order'     => 10,
1371
-            ];
1372
-        }
1373
-        // now let's sort the tabs according to order
1374
-        usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1375
-    }
1376
-
1377
-
1378
-    /**
1379
-     * _set_current_labels
1380
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1381
-     * property array
1382
-     *
1383
-     * @return void
1384
-     */
1385
-    private function _set_current_labels()
1386
-    {
1387
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1388
-            foreach ($this->_route_config['labels'] as $label => $text) {
1389
-                if (is_array($text)) {
1390
-                    foreach ($text as $sublabel => $subtext) {
1391
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1392
-                    }
1393
-                } else {
1394
-                    $this->_labels[ $label ] = $text;
1395
-                }
1396
-            }
1397
-        }
1398
-    }
1399
-
1400
-
1401
-    /**
1402
-     *        verifies user access for this admin page
1403
-     *
1404
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1405
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1406
-     *                               return false if verify fail.
1407
-     * @return bool
1408
-     * @throws InvalidArgumentException
1409
-     * @throws InvalidDataTypeException
1410
-     * @throws InvalidInterfaceException
1411
-     */
1412
-    public function check_user_access($route_to_check = '', $verify_only = false)
1413
-    {
1414
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1415
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1416
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1417
-                          && is_array(
1418
-                              $this->_page_routes[ $route_to_check ]
1419
-                          )
1420
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1421
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1422
-        if (empty($capability) && empty($route_to_check)) {
1423
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1424
-                : $this->_route['capability'];
1425
-        } else {
1426
-            $capability = empty($capability) ? 'manage_options' : $capability;
1427
-        }
1428
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1429
-        if (
1430
-            ! $this->request->isAjax()
1431
-            && (
1432
-                ! function_exists('is_admin')
1433
-                || ! EE_Registry::instance()->CAP->current_user_can(
1434
-                    $capability,
1435
-                    $this->page_slug
1436
-                    . '_'
1437
-                    . $route_to_check,
1438
-                    $id
1439
-                )
1440
-            )
1441
-        ) {
1442
-            if ($verify_only) {
1443
-                return false;
1444
-            }
1445
-            if (is_user_logged_in()) {
1446
-                wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1447
-            } else {
1448
-                return false;
1449
-            }
1450
-        }
1451
-        return true;
1452
-    }
1453
-
1454
-
1455
-    /**
1456
-     * admin_init_global
1457
-     * This runs all the code that we want executed within the WP admin_init hook.
1458
-     * This method executes for ALL EE Admin pages.
1459
-     *
1460
-     * @return void
1461
-     */
1462
-    public function admin_init_global()
1463
-    {
1464
-    }
1465
-
1466
-
1467
-    /**
1468
-     * wp_loaded_global
1469
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1470
-     * EE_Admin page and will execute on every EE Admin Page load
1471
-     *
1472
-     * @return void
1473
-     */
1474
-    public function wp_loaded()
1475
-    {
1476
-    }
1477
-
1478
-
1479
-    /**
1480
-     * admin_notices
1481
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1482
-     * ALL EE_Admin pages.
1483
-     *
1484
-     * @return void
1485
-     */
1486
-    public function admin_notices_global()
1487
-    {
1488
-        $this->_display_no_javascript_warning();
1489
-        $this->_display_espresso_notices();
1490
-    }
1491
-
1492
-
1493
-    public function network_admin_notices_global()
1494
-    {
1495
-        $this->_display_no_javascript_warning();
1496
-        $this->_display_espresso_notices();
1497
-    }
1498
-
1499
-
1500
-    /**
1501
-     * admin_footer_scripts_global
1502
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1503
-     * will apply on ALL EE_Admin pages.
1504
-     *
1505
-     * @return void
1506
-     */
1507
-    public function admin_footer_scripts_global()
1508
-    {
1509
-        $this->_add_admin_page_ajax_loading_img();
1510
-        $this->_add_admin_page_overlay();
1511
-        // if metaboxes are present we need to add the nonce field
1512
-        if (
1513
-            isset($this->_route_config['metaboxes'])
1514
-            || isset($this->_route_config['list_table'])
1515
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1516
-        ) {
1517
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1518
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1519
-        }
1520
-    }
1521
-
1522
-
1523
-    /**
1524
-     * admin_footer_global
1525
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1526
-     * ALL EE_Admin Pages.
1527
-     *
1528
-     * @return void
1529
-     */
1530
-    public function admin_footer_global()
1531
-    {
1532
-        // dialog container for dialog helper
1533
-        echo '
111
+	/**
112
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
113
+	 * actions.
114
+	 *
115
+	 * @since 4.6.x
116
+	 * @var array.
117
+	 */
118
+	protected $_default_route_query_args;
119
+
120
+	// set via request page and action args.
121
+	protected $_current_page;
122
+
123
+	protected $_current_view;
124
+
125
+	protected $_current_page_view_url;
126
+
127
+	/**
128
+	 * unprocessed value for the 'action' request param (default '')
129
+	 *
130
+	 * @var string
131
+	 */
132
+	protected $raw_req_action = '';
133
+
134
+	/**
135
+	 * unprocessed value for the 'page' request param (default '')
136
+	 *
137
+	 * @var string
138
+	 */
139
+	protected $raw_req_page = '';
140
+
141
+	/**
142
+	 * sanitized request action (and nonce)
143
+	 *
144
+	 * @var string
145
+	 */
146
+	protected $_req_action = '';
147
+
148
+	/**
149
+	 * sanitized request action nonce
150
+	 *
151
+	 * @var string
152
+	 */
153
+	protected $_req_nonce = '';
154
+
155
+	/**
156
+	 * @var string
157
+	 */
158
+	protected $_search_btn_label = '';
159
+
160
+	/**
161
+	 * @var string
162
+	 */
163
+	protected $_search_box_callback = '';
164
+
165
+	/**
166
+	 * @var WP_Screen
167
+	 */
168
+	protected $_current_screen;
169
+
170
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
171
+	protected $_hook_obj;
172
+
173
+	// for holding incoming request data
174
+	protected $_req_data = [];
175
+
176
+	// yes / no array for admin form fields
177
+	protected $_yes_no_values = [];
178
+
179
+	// some default things shared by all child classes
180
+	protected $_default_espresso_metaboxes;
181
+
182
+	/**
183
+	 * @var EE_Registry
184
+	 */
185
+	protected $EE = null;
186
+
187
+
188
+	/**
189
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
190
+	 *
191
+	 * @var boolean
192
+	 */
193
+	protected $_is_caf = false;
194
+
195
+
196
+	/**
197
+	 * @Constructor
198
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
199
+	 * @throws EE_Error
200
+	 * @throws InvalidArgumentException
201
+	 * @throws ReflectionException
202
+	 * @throws InvalidDataTypeException
203
+	 * @throws InvalidInterfaceException
204
+	 */
205
+	public function __construct($routing = true)
206
+	{
207
+		$this->loader  = LoaderFactory::getLoader();
208
+		$this->request = $this->loader->getShared(RequestInterface::class);
209
+		$this->_routing = $routing;
210
+
211
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
212
+			$this->_is_caf = true;
213
+		}
214
+		$this->_yes_no_values = [
215
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
216
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
217
+		];
218
+		// set the _req_data property.
219
+		$this->_req_data = $this->request->requestParams();
220
+		// set initial page props (child method)
221
+		$this->_init_page_props();
222
+		// set global defaults
223
+		$this->_set_defaults();
224
+		// set early because incoming requests could be ajax related and we need to register those hooks.
225
+		$this->_global_ajax_hooks();
226
+		$this->_ajax_hooks();
227
+		// other_page_hooks have to be early too.
228
+		$this->_do_other_page_hooks();
229
+		// set up page dependencies
230
+		$this->_before_page_setup();
231
+		$this->_page_setup();
232
+		// die();
233
+	}
234
+
235
+
236
+	/**
237
+	 * _init_page_props
238
+	 * Child classes use to set at least the following properties:
239
+	 * $page_slug.
240
+	 * $page_label.
241
+	 *
242
+	 * @abstract
243
+	 * @return void
244
+	 */
245
+	abstract protected function _init_page_props();
246
+
247
+
248
+	/**
249
+	 * _ajax_hooks
250
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
251
+	 * Note: within the ajax callback methods.
252
+	 *
253
+	 * @abstract
254
+	 * @return void
255
+	 */
256
+	abstract protected function _ajax_hooks();
257
+
258
+
259
+	/**
260
+	 * _define_page_props
261
+	 * child classes define page properties in here.  Must include at least:
262
+	 * $_admin_base_url = base_url for all admin pages
263
+	 * $_admin_page_title = default admin_page_title for admin pages
264
+	 * $_labels = array of default labels for various automatically generated elements:
265
+	 *    array(
266
+	 *        'buttons' => array(
267
+	 *            'add' => esc_html__('label for add new button'),
268
+	 *            'edit' => esc_html__('label for edit button'),
269
+	 *            'delete' => esc_html__('label for delete button')
270
+	 *            )
271
+	 *        )
272
+	 *
273
+	 * @abstract
274
+	 * @return void
275
+	 */
276
+	abstract protected function _define_page_props();
277
+
278
+
279
+	/**
280
+	 * _set_page_routes
281
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
282
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
283
+	 * have a 'default' route. Here's the format
284
+	 * $this->_page_routes = array(
285
+	 *        'default' => array(
286
+	 *            'func' => '_default_method_handling_route',
287
+	 *            'args' => array('array','of','args'),
288
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
289
+	 *            ajax request, backend processing)
290
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
291
+	 *            headers route after.  The string you enter here should match the defined route reference for a
292
+	 *            headers sent route.
293
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
294
+	 *            this route.
295
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
296
+	 *            checks).
297
+	 *        ),
298
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
299
+	 *        handling method.
300
+	 *        )
301
+	 * )
302
+	 *
303
+	 * @abstract
304
+	 * @return void
305
+	 */
306
+	abstract protected function _set_page_routes();
307
+
308
+
309
+	/**
310
+	 * _set_page_config
311
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
312
+	 * array corresponds to the page_route for the loaded page. Format:
313
+	 * $this->_page_config = array(
314
+	 *        'default' => array(
315
+	 *            'labels' => array(
316
+	 *                'buttons' => array(
317
+	 *                    'add' => esc_html__('label for adding item'),
318
+	 *                    'edit' => esc_html__('label for editing item'),
319
+	 *                    'delete' => esc_html__('label for deleting item')
320
+	 *                ),
321
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
322
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
323
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
324
+	 *            _define_page_props() method
325
+	 *            'nav' => array(
326
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
327
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
328
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
329
+	 *                'order' => 10, //required to indicate tab position.
330
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
331
+	 *                displayed then add this parameter.
332
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
333
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
334
+	 *            metaboxes set for eventespresso admin pages.
335
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
336
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
337
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
338
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
339
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
340
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
341
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
342
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
343
+	 *            want to display.
344
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
345
+	 *                'tab_id' => array(
346
+	 *                    'title' => 'tab_title',
347
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
348
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
349
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
350
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
351
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
352
+	 *                    attempt to use the callback which should match the name of a method in the class
353
+	 *                    ),
354
+	 *                'tab2_id' => array(
355
+	 *                    'title' => 'tab2 title',
356
+	 *                    'filename' => 'file_name_2'
357
+	 *                    'callback' => 'callback_method_for_content',
358
+	 *                 ),
359
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
360
+	 *            help tab area on an admin page. @return void
361
+	 *
362
+	 * @abstract
363
+	 */
364
+	abstract protected function _set_page_config();
365
+
366
+
367
+	/**
368
+	 * _add_screen_options
369
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
370
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
371
+	 * to a particular view.
372
+	 *
373
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
374
+	 *         see also WP_Screen object documents...
375
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
376
+	 * @abstract
377
+	 * @return void
378
+	 */
379
+	abstract protected function _add_screen_options();
380
+
381
+
382
+	/**
383
+	 * _add_feature_pointers
384
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
385
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
386
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
387
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
388
+	 * extended) also see:
389
+	 *
390
+	 * @link   http://eamann.com/tech/wordpress-portland/
391
+	 * @abstract
392
+	 * @return void
393
+	 */
394
+	abstract protected function _add_feature_pointers();
395
+
396
+
397
+	/**
398
+	 * load_scripts_styles
399
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
400
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
401
+	 * scripts/styles per view by putting them in a dynamic function in this format
402
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
403
+	 *
404
+	 * @abstract
405
+	 * @return void
406
+	 */
407
+	abstract public function load_scripts_styles();
408
+
409
+
410
+	/**
411
+	 * admin_init
412
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
413
+	 * all pages/views loaded by child class.
414
+	 *
415
+	 * @abstract
416
+	 * @return void
417
+	 */
418
+	abstract public function admin_init();
419
+
420
+
421
+	/**
422
+	 * admin_notices
423
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
424
+	 * all pages/views loaded by child class.
425
+	 *
426
+	 * @abstract
427
+	 * @return void
428
+	 */
429
+	abstract public function admin_notices();
430
+
431
+
432
+	/**
433
+	 * admin_footer_scripts
434
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
435
+	 * will apply to all pages/views loaded by child class.
436
+	 *
437
+	 * @return void
438
+	 */
439
+	abstract public function admin_footer_scripts();
440
+
441
+
442
+	/**
443
+	 * admin_footer
444
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
445
+	 * apply to all pages/views loaded by child class.
446
+	 *
447
+	 * @return void
448
+	 */
449
+	public function admin_footer()
450
+	{
451
+	}
452
+
453
+
454
+	/**
455
+	 * _global_ajax_hooks
456
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
457
+	 * Note: within the ajax callback methods.
458
+	 *
459
+	 * @abstract
460
+	 * @return void
461
+	 */
462
+	protected function _global_ajax_hooks()
463
+	{
464
+		// for lazy loading of metabox content
465
+		add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
466
+	}
467
+
468
+
469
+	public function ajax_metabox_content()
470
+	{
471
+		$content_id  = $this->request->getRequestParam('contentid', '');
472
+		$content_url = $this->request->getRequestParam('contenturl', '', 'url');
473
+		self::cached_rss_display($content_id, $content_url);
474
+		wp_die();
475
+	}
476
+
477
+
478
+	/**
479
+	 * allows extending classes do something specific before the parent constructor runs _page_setup().
480
+	 *
481
+	 * @return void
482
+	 */
483
+	protected function _before_page_setup()
484
+	{
485
+		// default is to do nothing
486
+	}
487
+
488
+
489
+	/**
490
+	 * Makes sure any things that need to be loaded early get handled.
491
+	 * We also escape early here if the page requested doesn't match the object.
492
+	 *
493
+	 * @final
494
+	 * @return void
495
+	 * @throws EE_Error
496
+	 * @throws InvalidArgumentException
497
+	 * @throws ReflectionException
498
+	 * @throws InvalidDataTypeException
499
+	 * @throws InvalidInterfaceException
500
+	 */
501
+	final protected function _page_setup()
502
+	{
503
+		// requires?
504
+		// admin_init stuff - global - we're setting this REALLY early
505
+		// so if EE_Admin pages have to hook into other WP pages they can.
506
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
507
+		add_action('admin_init', [$this, 'admin_init_global'], 5);
508
+		// next verify if we need to load anything...
509
+		$this->_current_page = $this->request->getRequestParam('page', '', 'key');
510
+		$this->page_folder   = strtolower(
511
+			str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
512
+		);
513
+		global $ee_menu_slugs;
514
+		$ee_menu_slugs = (array) $ee_menu_slugs;
515
+		if (
516
+			! $this->request->isAjax()
517
+			&& (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
518
+		) {
519
+			return;
520
+		}
521
+		// because WP List tables have two duplicate select inputs for choosing bulk actions,
522
+		// we need to copy the action from the second to the first
523
+		$action     = $this->request->getRequestParam('action', '-1', 'key');
524
+		$action2    = $this->request->getRequestParam('action2', '-1', 'key');
525
+		$action     = $action !== '-1' ? $action : $action2;
526
+		$req_action = $action !== '-1' ? $action : 'default';
527
+
528
+		// if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
529
+		// then let's use the route as the action.
530
+		// This covers cases where we're coming in from a list table that isn't on the default route.
531
+		$route = $this->request->getRequestParam('route');
532
+		$this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
533
+			? $route
534
+			: $req_action;
535
+
536
+		$this->_current_view = $this->_req_action;
537
+		$this->_req_nonce    = $this->_req_action . '_nonce';
538
+		$this->_define_page_props();
539
+		$this->_current_page_view_url = add_query_arg(
540
+			['page' => $this->_current_page, 'action' => $this->_current_view],
541
+			$this->_admin_base_url
542
+		);
543
+		// default things
544
+		$this->_default_espresso_metaboxes = [
545
+			'_espresso_news_post_box',
546
+			'_espresso_links_post_box',
547
+			'_espresso_ratings_request',
548
+			'_espresso_sponsors_post_box',
549
+		];
550
+		// set page configs
551
+		$this->_set_page_routes();
552
+		$this->_set_page_config();
553
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
554
+		if ($this->request->requestParamIsSet('wp_referer')) {
555
+			$wp_referer = $this->request->getRequestParam('wp_referer');
556
+			if ($wp_referer) {
557
+				$this->_default_route_query_args['wp_referer'] = $wp_referer;
558
+			}
559
+		}
560
+		// for caffeinated and other extended functionality.
561
+		//  If there is a _extend_page_config method
562
+		// then let's run that to modify the all the various page configuration arrays
563
+		if (method_exists($this, '_extend_page_config')) {
564
+			$this->_extend_page_config();
565
+		}
566
+		// for CPT and other extended functionality.
567
+		// If there is an _extend_page_config_for_cpt
568
+		// then let's run that to modify all the various page configuration arrays.
569
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
570
+			$this->_extend_page_config_for_cpt();
571
+		}
572
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
573
+		$this->_page_routes = apply_filters(
574
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
575
+			$this->_page_routes,
576
+			$this
577
+		);
578
+		$this->_page_config = apply_filters(
579
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
580
+			$this->_page_config,
581
+			$this
582
+		);
583
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
584
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
585
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
586
+			add_action(
587
+				'AHEE__EE_Admin_Page__route_admin_request',
588
+				[$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
589
+				10,
590
+				2
591
+			);
592
+		}
593
+		// next route only if routing enabled
594
+		if ($this->_routing && ! $this->request->isAjax()) {
595
+			$this->_verify_routes();
596
+			// next let's just check user_access and kill if no access
597
+			$this->check_user_access();
598
+			if ($this->_is_UI_request) {
599
+				// admin_init stuff - global, all views for this page class, specific view
600
+				add_action('admin_init', [$this, 'admin_init'], 10);
601
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
602
+					add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
603
+				}
604
+			} else {
605
+				// hijack regular WP loading and route admin request immediately
606
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
607
+				$this->route_admin_request();
608
+			}
609
+		}
610
+	}
611
+
612
+
613
+	/**
614
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
615
+	 *
616
+	 * @return void
617
+	 * @throws EE_Error
618
+	 */
619
+	private function _do_other_page_hooks()
620
+	{
621
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
622
+		foreach ($registered_pages as $page) {
623
+			// now let's setup the file name and class that should be present
624
+			$classname = str_replace('.class.php', '', $page);
625
+			// autoloaders should take care of loading file
626
+			if (! class_exists($classname)) {
627
+				$error_msg[] = sprintf(
628
+					esc_html__(
629
+						'Something went wrong with loading the %s admin hooks page.',
630
+						'event_espresso'
631
+					),
632
+					$page
633
+				);
634
+				$error_msg[] = $error_msg[0]
635
+							   . "\r\n"
636
+							   . sprintf(
637
+								   esc_html__(
638
+									   'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
639
+									   'event_espresso'
640
+								   ),
641
+								   $page,
642
+								   '<br />',
643
+								   '<strong>' . $classname . '</strong>'
644
+							   );
645
+				throw new EE_Error(implode('||', $error_msg));
646
+			}
647
+			// notice we are passing the instance of this class to the hook object.
648
+			$this->loader->getShared($classname, [$this]);
649
+		}
650
+	}
651
+
652
+
653
+	/**
654
+	 * @throws ReflectionException
655
+	 * @throws EE_Error
656
+	 */
657
+	public function load_page_dependencies()
658
+	{
659
+		try {
660
+			$this->_load_page_dependencies();
661
+		} catch (EE_Error $e) {
662
+			$e->get_error();
663
+		}
664
+	}
665
+
666
+
667
+	/**
668
+	 * load_page_dependencies
669
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
670
+	 *
671
+	 * @return void
672
+	 * @throws DomainException
673
+	 * @throws EE_Error
674
+	 * @throws InvalidArgumentException
675
+	 * @throws InvalidDataTypeException
676
+	 * @throws InvalidInterfaceException
677
+	 */
678
+	protected function _load_page_dependencies()
679
+	{
680
+		// let's set the current_screen and screen options to override what WP set
681
+		$this->_current_screen = get_current_screen();
682
+		// load admin_notices - global, page class, and view specific
683
+		add_action('admin_notices', [$this, 'admin_notices_global'], 5);
684
+		add_action('admin_notices', [$this, 'admin_notices'], 10);
685
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
686
+			add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
687
+		}
688
+		// load network admin_notices - global, page class, and view specific
689
+		add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
690
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
691
+			add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
692
+		}
693
+		// this will save any per_page screen options if they are present
694
+		$this->_set_per_page_screen_options();
695
+		// setup list table properties
696
+		$this->_set_list_table();
697
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
698
+		// However in some cases the metaboxes will need to be added within a route handling callback.
699
+		$this->_add_registered_meta_boxes();
700
+		$this->_add_screen_columns();
701
+		// add screen options - global, page child class, and view specific
702
+		$this->_add_global_screen_options();
703
+		$this->_add_screen_options();
704
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
705
+		if (method_exists($this, $add_screen_options)) {
706
+			$this->{$add_screen_options}();
707
+		}
708
+		// add help tab(s) - set via page_config and qtips.
709
+		$this->_add_help_tabs();
710
+		$this->_add_qtips();
711
+		// add feature_pointers - global, page child class, and view specific
712
+		$this->_add_feature_pointers();
713
+		$this->_add_global_feature_pointers();
714
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
715
+		if (method_exists($this, $add_feature_pointer)) {
716
+			$this->{$add_feature_pointer}();
717
+		}
718
+		// enqueue scripts/styles - global, page class, and view specific
719
+		add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
720
+		add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
721
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
722
+			add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
723
+		}
724
+		add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
725
+		// admin_print_footer_scripts - global, page child class, and view specific.
726
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
727
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
728
+		// is a good use case. Notice the late priority we're giving these
729
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
730
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
731
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
732
+			add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
733
+		}
734
+		// admin footer scripts
735
+		add_action('admin_footer', [$this, 'admin_footer_global'], 99);
736
+		add_action('admin_footer', [$this, 'admin_footer'], 100);
737
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
738
+			add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
739
+		}
740
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
741
+		// targeted hook
742
+		do_action(
743
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
744
+		);
745
+	}
746
+
747
+
748
+	/**
749
+	 * _set_defaults
750
+	 * This sets some global defaults for class properties.
751
+	 */
752
+	private function _set_defaults()
753
+	{
754
+		$this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
755
+		$this->_event                = $this->_template_path = $this->_column_template_path = null;
756
+		$this->_nav_tabs             = $this->_views = $this->_page_routes = [];
757
+		$this->_page_config          = $this->_default_route_query_args = [];
758
+		$this->_default_nav_tab_name = 'overview';
759
+		// init template args
760
+		$this->_template_args = [
761
+			'admin_page_header'  => '',
762
+			'admin_page_content' => '',
763
+			'post_body_content'  => '',
764
+			'before_list_table'  => '',
765
+			'after_list_table'   => '',
766
+		];
767
+	}
768
+
769
+
770
+	/**
771
+	 * route_admin_request
772
+	 *
773
+	 * @return void
774
+	 * @throws InvalidArgumentException
775
+	 * @throws InvalidInterfaceException
776
+	 * @throws InvalidDataTypeException
777
+	 * @throws EE_Error
778
+	 * @throws ReflectionException
779
+	 * @see    _route_admin_request()
780
+	 */
781
+	public function route_admin_request()
782
+	{
783
+		try {
784
+			$this->_route_admin_request();
785
+		} catch (EE_Error $e) {
786
+			$e->get_error();
787
+		}
788
+	}
789
+
790
+
791
+	public function set_wp_page_slug($wp_page_slug)
792
+	{
793
+		$this->_wp_page_slug = $wp_page_slug;
794
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
795
+		if (is_network_admin()) {
796
+			$this->_wp_page_slug .= '-network';
797
+		}
798
+	}
799
+
800
+
801
+	/**
802
+	 * _verify_routes
803
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
804
+	 * we know if we need to drop out.
805
+	 *
806
+	 * @return bool
807
+	 * @throws EE_Error
808
+	 */
809
+	protected function _verify_routes()
810
+	{
811
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
812
+		if (! $this->_current_page && ! $this->request->isAjax()) {
813
+			return false;
814
+		}
815
+		$this->_route = false;
816
+		// check that the page_routes array is not empty
817
+		if (empty($this->_page_routes)) {
818
+			// user error msg
819
+			$error_msg = sprintf(
820
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
821
+				$this->_admin_page_title
822
+			);
823
+			// developer error msg
824
+			$error_msg .= '||' . $error_msg
825
+						  . esc_html__(
826
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
827
+							  'event_espresso'
828
+						  );
829
+			throw new EE_Error($error_msg);
830
+		}
831
+		// and that the requested page route exists
832
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
833
+			$this->_route        = $this->_page_routes[ $this->_req_action ];
834
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
835
+				? $this->_page_config[ $this->_req_action ]
836
+				: [];
837
+		} else {
838
+			// user error msg
839
+			$error_msg = sprintf(
840
+				esc_html__(
841
+					'The requested page route does not exist for the %s admin page.',
842
+					'event_espresso'
843
+				),
844
+				$this->_admin_page_title
845
+			);
846
+			// developer error msg
847
+			$error_msg .= '||' . $error_msg
848
+						  . sprintf(
849
+							  esc_html__(
850
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
851
+								  'event_espresso'
852
+							  ),
853
+							  $this->_req_action
854
+						  );
855
+			throw new EE_Error($error_msg);
856
+		}
857
+		// and that a default route exists
858
+		if (! array_key_exists('default', $this->_page_routes)) {
859
+			// user error msg
860
+			$error_msg = sprintf(
861
+				esc_html__(
862
+					'A default page route has not been set for the % admin page.',
863
+					'event_espresso'
864
+				),
865
+				$this->_admin_page_title
866
+			);
867
+			// developer error msg
868
+			$error_msg .= '||' . $error_msg
869
+						  . esc_html__(
870
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
871
+							  'event_espresso'
872
+						  );
873
+			throw new EE_Error($error_msg);
874
+		}
875
+		// first lets' catch if the UI request has EVER been set.
876
+		if ($this->_is_UI_request === null) {
877
+			// lets set if this is a UI request or not.
878
+			$this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
879
+			// wait a minute... we might have a noheader in the route array
880
+			$this->_is_UI_request = ! (
881
+				is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
882
+			)
883
+				? $this->_is_UI_request
884
+				: false;
885
+		}
886
+		$this->_set_current_labels();
887
+		return true;
888
+	}
889
+
890
+
891
+	/**
892
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
893
+	 *
894
+	 * @param string $route the route name we're verifying
895
+	 * @return bool we'll throw an exception if this isn't a valid route.
896
+	 * @throws EE_Error
897
+	 */
898
+	protected function _verify_route($route)
899
+	{
900
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
901
+			return true;
902
+		}
903
+		// user error msg
904
+		$error_msg = sprintf(
905
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
906
+			$this->_admin_page_title
907
+		);
908
+		// developer error msg
909
+		$error_msg .= '||' . $error_msg
910
+					  . sprintf(
911
+						  esc_html__(
912
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
913
+							  'event_espresso'
914
+						  ),
915
+						  $route
916
+					  );
917
+		throw new EE_Error($error_msg);
918
+	}
919
+
920
+
921
+	/**
922
+	 * perform nonce verification
923
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
924
+	 * using this method (and save retyping!)
925
+	 *
926
+	 * @param string $nonce     The nonce sent
927
+	 * @param string $nonce_ref The nonce reference string (name0)
928
+	 * @return void
929
+	 * @throws EE_Error
930
+	 */
931
+	protected function _verify_nonce($nonce, $nonce_ref)
932
+	{
933
+		// verify nonce against expected value
934
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
935
+			// these are not the droids you are looking for !!!
936
+			$msg = sprintf(
937
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
938
+				'<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
939
+				'</a>'
940
+			);
941
+			if (WP_DEBUG) {
942
+				$msg .= "\n  ";
943
+				$msg .= sprintf(
944
+					esc_html__(
945
+						'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
946
+						'event_espresso'
947
+					),
948
+					__CLASS__
949
+				);
950
+			}
951
+			if (! $this->request->isAjax()) {
952
+				wp_die($msg);
953
+			}
954
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
955
+			$this->_return_json();
956
+		}
957
+	}
958
+
959
+
960
+	/**
961
+	 * _route_admin_request()
962
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
963
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
964
+	 * in the page routes and then will try to load the corresponding method.
965
+	 *
966
+	 * @return void
967
+	 * @throws EE_Error
968
+	 * @throws InvalidArgumentException
969
+	 * @throws InvalidDataTypeException
970
+	 * @throws InvalidInterfaceException
971
+	 * @throws ReflectionException
972
+	 */
973
+	protected function _route_admin_request()
974
+	{
975
+		if (! $this->_is_UI_request) {
976
+			$this->_verify_routes();
977
+		}
978
+		$nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
979
+		if ($this->_req_action !== 'default' && $nonce_check) {
980
+			// set nonce from post data
981
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
982
+			$this->_verify_nonce($nonce, $this->_req_nonce);
983
+		}
984
+		// set the nav_tabs array but ONLY if this is  UI_request
985
+		if ($this->_is_UI_request) {
986
+			$this->_set_nav_tabs();
987
+		}
988
+		// grab callback function
989
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
990
+		// check if callback has args
991
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
992
+		$error_msg = '';
993
+		// action right before calling route
994
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
995
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
996
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
997
+		}
998
+		// right before calling the route, let's clean the _wp_http_referer
999
+		$this->request->setServerParam(
1000
+			'REQUEST_URI',
1001
+			remove_query_arg(
1002
+				'_wp_http_referer',
1003
+				wp_unslash($this->request->getServerParam('REQUEST_URI'))
1004
+			)
1005
+		);
1006
+		if (! empty($func)) {
1007
+			if (is_array($func)) {
1008
+				list($class, $method) = $func;
1009
+			} elseif (strpos($func, '::') !== false) {
1010
+				list($class, $method) = explode('::', $func);
1011
+			} else {
1012
+				$class  = $this;
1013
+				$method = $func;
1014
+			}
1015
+			if (! (is_object($class) && $class === $this)) {
1016
+				// send along this admin page object for access by addons.
1017
+				$args['admin_page_object'] = $this;
1018
+			}
1019
+			if (
1020
+				// is it a method on a class that doesn't work?
1021
+				(
1022
+					(
1023
+						method_exists($class, $method)
1024
+						&& call_user_func_array([$class, $method], $args) === false
1025
+					)
1026
+					&& (
1027
+						// is it a standalone function that doesn't work?
1028
+						function_exists($method)
1029
+						&& call_user_func_array(
1030
+							$func,
1031
+							array_merge(['admin_page_object' => $this], $args)
1032
+						) === false
1033
+					)
1034
+				)
1035
+				|| (
1036
+					// is it neither a class method NOR a standalone function?
1037
+					! method_exists($class, $method)
1038
+					&& ! function_exists($method)
1039
+				)
1040
+			) {
1041
+				// user error msg
1042
+				$error_msg = esc_html__(
1043
+					'An error occurred. The  requested page route could not be found.',
1044
+					'event_espresso'
1045
+				);
1046
+				// developer error msg
1047
+				$error_msg .= '||';
1048
+				$error_msg .= sprintf(
1049
+					esc_html__(
1050
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1051
+						'event_espresso'
1052
+					),
1053
+					$method
1054
+				);
1055
+			}
1056
+			if (! empty($error_msg)) {
1057
+				throw new EE_Error($error_msg);
1058
+			}
1059
+		}
1060
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1061
+		// then we need to reset the routing properties to the new route.
1062
+		// 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.
1063
+		if (
1064
+			$this->_is_UI_request === false
1065
+			&& is_array($this->_route)
1066
+			&& ! empty($this->_route['headers_sent_route'])
1067
+		) {
1068
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1069
+		}
1070
+	}
1071
+
1072
+
1073
+	/**
1074
+	 * This method just allows the resetting of page properties in the case where a no headers
1075
+	 * route redirects to a headers route in its route config.
1076
+	 *
1077
+	 * @param string $new_route New (non header) route to redirect to.
1078
+	 * @return   void
1079
+	 * @throws ReflectionException
1080
+	 * @throws InvalidArgumentException
1081
+	 * @throws InvalidInterfaceException
1082
+	 * @throws InvalidDataTypeException
1083
+	 * @throws EE_Error
1084
+	 * @since   4.3.0
1085
+	 */
1086
+	protected function _reset_routing_properties($new_route)
1087
+	{
1088
+		$this->_is_UI_request = true;
1089
+		// now we set the current route to whatever the headers_sent_route is set at
1090
+		$this->request->setRequestParam('action', $new_route);
1091
+		// rerun page setup
1092
+		$this->_page_setup();
1093
+	}
1094
+
1095
+
1096
+	/**
1097
+	 * _add_query_arg
1098
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1099
+	 *(internally just uses EEH_URL's function with the same name)
1100
+	 *
1101
+	 * @param array  $args
1102
+	 * @param string $url
1103
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1104
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1105
+	 *                                        Example usage: If the current page is:
1106
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1107
+	 *                                        &action=default&event_id=20&month_range=March%202015
1108
+	 *                                        &_wpnonce=5467821
1109
+	 *                                        and you call:
1110
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1111
+	 *                                        array(
1112
+	 *                                        'action' => 'resend_something',
1113
+	 *                                        'page=>espresso_registrations'
1114
+	 *                                        ),
1115
+	 *                                        $some_url,
1116
+	 *                                        true
1117
+	 *                                        );
1118
+	 *                                        It will produce a url in this structure:
1119
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1120
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1121
+	 *                                        month_range]=March%202015
1122
+	 * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1123
+	 * @return string
1124
+	 */
1125
+	public static function add_query_args_and_nonce(
1126
+		$args = [],
1127
+		$url = false,
1128
+		$sticky = false,
1129
+		$exclude_nonce = false
1130
+	) {
1131
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1132
+		if ($sticky) {
1133
+			/** @var RequestInterface $request */
1134
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1135
+			$request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1136
+			foreach ($request->requestParams() as $key => $value) {
1137
+				// do not add nonces
1138
+				if (strpos($key, 'nonce') !== false) {
1139
+					continue;
1140
+				}
1141
+				$args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1142
+			}
1143
+		}
1144
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1145
+	}
1146
+
1147
+
1148
+	/**
1149
+	 * This returns a generated link that will load the related help tab.
1150
+	 *
1151
+	 * @param string $help_tab_id the id for the connected help tab
1152
+	 * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1153
+	 * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1154
+	 * @return string              generated link
1155
+	 * @uses EEH_Template::get_help_tab_link()
1156
+	 */
1157
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1158
+	{
1159
+		return EEH_Template::get_help_tab_link(
1160
+			$help_tab_id,
1161
+			$this->page_slug,
1162
+			$this->_req_action,
1163
+			$icon_style,
1164
+			$help_text
1165
+		);
1166
+	}
1167
+
1168
+
1169
+	/**
1170
+	 * _add_help_tabs
1171
+	 * Note child classes define their help tabs within the page_config array.
1172
+	 *
1173
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1174
+	 * @return void
1175
+	 * @throws DomainException
1176
+	 * @throws EE_Error
1177
+	 */
1178
+	protected function _add_help_tabs()
1179
+	{
1180
+		if (isset($this->_page_config[ $this->_req_action ])) {
1181
+			$config = $this->_page_config[ $this->_req_action ];
1182
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1183
+			if (is_array($config) && isset($config['help_sidebar'])) {
1184
+				// check that the callback given is valid
1185
+				if (! method_exists($this, $config['help_sidebar'])) {
1186
+					throw new EE_Error(
1187
+						sprintf(
1188
+							esc_html__(
1189
+								'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',
1190
+								'event_espresso'
1191
+							),
1192
+							$config['help_sidebar'],
1193
+							get_class($this)
1194
+						)
1195
+					);
1196
+				}
1197
+				$content = apply_filters(
1198
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1199
+					$this->{$config['help_sidebar']}()
1200
+				);
1201
+				$this->_current_screen->set_help_sidebar($content);
1202
+			}
1203
+			if (! isset($config['help_tabs'])) {
1204
+				return;
1205
+			} //no help tabs for this route
1206
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1207
+				// we're here so there ARE help tabs!
1208
+				// make sure we've got what we need
1209
+				if (! isset($cfg['title'])) {
1210
+					throw new EE_Error(
1211
+						esc_html__(
1212
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1213
+							'event_espresso'
1214
+						)
1215
+					);
1216
+				}
1217
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1218
+					throw new EE_Error(
1219
+						esc_html__(
1220
+							'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',
1221
+							'event_espresso'
1222
+						)
1223
+					);
1224
+				}
1225
+				// first priority goes to content.
1226
+				if (! empty($cfg['content'])) {
1227
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1228
+					// second priority goes to filename
1229
+				} elseif (! empty($cfg['filename'])) {
1230
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1231
+					// 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)
1232
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1233
+															 . basename($this->_get_dir())
1234
+															 . '/help_tabs/'
1235
+															 . $cfg['filename']
1236
+															 . '.help_tab.php' : $file_path;
1237
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1238
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1239
+						EE_Error::add_error(
1240
+							sprintf(
1241
+								esc_html__(
1242
+									'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',
1243
+									'event_espresso'
1244
+								),
1245
+								$tab_id,
1246
+								key($config),
1247
+								$file_path
1248
+							),
1249
+							__FILE__,
1250
+							__FUNCTION__,
1251
+							__LINE__
1252
+						);
1253
+						return;
1254
+					}
1255
+					$template_args['admin_page_obj'] = $this;
1256
+					$content                         = EEH_Template::display_template(
1257
+						$file_path,
1258
+						$template_args,
1259
+						true
1260
+					);
1261
+				} else {
1262
+					$content = '';
1263
+				}
1264
+				// check if callback is valid
1265
+				if (
1266
+					empty($content)
1267
+					&& (
1268
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1269
+					)
1270
+				) {
1271
+					EE_Error::add_error(
1272
+						sprintf(
1273
+							esc_html__(
1274
+								'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.',
1275
+								'event_espresso'
1276
+							),
1277
+							$cfg['title']
1278
+						),
1279
+						__FILE__,
1280
+						__FUNCTION__,
1281
+						__LINE__
1282
+					);
1283
+					return;
1284
+				}
1285
+				// setup config array for help tab method
1286
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1287
+				$_ht = [
1288
+					'id'       => $id,
1289
+					'title'    => $cfg['title'],
1290
+					'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1291
+					'content'  => $content,
1292
+				];
1293
+				$this->_current_screen->add_help_tab($_ht);
1294
+			}
1295
+		}
1296
+	}
1297
+
1298
+
1299
+	/**
1300
+	 * This simply sets up any qtips that have been defined in the page config
1301
+	 *
1302
+	 * @return void
1303
+	 */
1304
+	protected function _add_qtips()
1305
+	{
1306
+		if (isset($this->_route_config['qtips'])) {
1307
+			$qtips = (array) $this->_route_config['qtips'];
1308
+			// load qtip loader
1309
+			$path = [
1310
+				$this->_get_dir() . '/qtips/',
1311
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1312
+			];
1313
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1314
+		}
1315
+	}
1316
+
1317
+
1318
+	/**
1319
+	 * _set_nav_tabs
1320
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1321
+	 * wish to add additional tabs or modify accordingly.
1322
+	 *
1323
+	 * @return void
1324
+	 * @throws InvalidArgumentException
1325
+	 * @throws InvalidInterfaceException
1326
+	 * @throws InvalidDataTypeException
1327
+	 */
1328
+	protected function _set_nav_tabs()
1329
+	{
1330
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1331
+		$i = 0;
1332
+		foreach ($this->_page_config as $slug => $config) {
1333
+			if (! is_array($config) || empty($config['nav'])) {
1334
+				continue;
1335
+			}
1336
+			// no nav tab for this config
1337
+			// check for persistent flag
1338
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1339
+				// nav tab is only to appear when route requested.
1340
+				continue;
1341
+			}
1342
+			if (! $this->check_user_access($slug, true)) {
1343
+				// no nav tab because current user does not have access.
1344
+				continue;
1345
+			}
1346
+			$css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1347
+			$this->_nav_tabs[ $slug ] = [
1348
+				'url'       => isset($config['nav']['url'])
1349
+					? $config['nav']['url']
1350
+					: self::add_query_args_and_nonce(
1351
+						['action' => $slug],
1352
+						$this->_admin_base_url
1353
+					),
1354
+				'link_text' => isset($config['nav']['label'])
1355
+					? $config['nav']['label']
1356
+					: ucwords(
1357
+						str_replace('_', ' ', $slug)
1358
+					),
1359
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1360
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1361
+			];
1362
+			$i++;
1363
+		}
1364
+		// if $this->_nav_tabs is empty then lets set the default
1365
+		if (empty($this->_nav_tabs)) {
1366
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1367
+				'url'       => $this->_admin_base_url,
1368
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1369
+				'css_class' => 'nav-tab-active',
1370
+				'order'     => 10,
1371
+			];
1372
+		}
1373
+		// now let's sort the tabs according to order
1374
+		usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1375
+	}
1376
+
1377
+
1378
+	/**
1379
+	 * _set_current_labels
1380
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1381
+	 * property array
1382
+	 *
1383
+	 * @return void
1384
+	 */
1385
+	private function _set_current_labels()
1386
+	{
1387
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1388
+			foreach ($this->_route_config['labels'] as $label => $text) {
1389
+				if (is_array($text)) {
1390
+					foreach ($text as $sublabel => $subtext) {
1391
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1392
+					}
1393
+				} else {
1394
+					$this->_labels[ $label ] = $text;
1395
+				}
1396
+			}
1397
+		}
1398
+	}
1399
+
1400
+
1401
+	/**
1402
+	 *        verifies user access for this admin page
1403
+	 *
1404
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1405
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1406
+	 *                               return false if verify fail.
1407
+	 * @return bool
1408
+	 * @throws InvalidArgumentException
1409
+	 * @throws InvalidDataTypeException
1410
+	 * @throws InvalidInterfaceException
1411
+	 */
1412
+	public function check_user_access($route_to_check = '', $verify_only = false)
1413
+	{
1414
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1415
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1416
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1417
+						  && is_array(
1418
+							  $this->_page_routes[ $route_to_check ]
1419
+						  )
1420
+						  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1421
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1422
+		if (empty($capability) && empty($route_to_check)) {
1423
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1424
+				: $this->_route['capability'];
1425
+		} else {
1426
+			$capability = empty($capability) ? 'manage_options' : $capability;
1427
+		}
1428
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1429
+		if (
1430
+			! $this->request->isAjax()
1431
+			&& (
1432
+				! function_exists('is_admin')
1433
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1434
+					$capability,
1435
+					$this->page_slug
1436
+					. '_'
1437
+					. $route_to_check,
1438
+					$id
1439
+				)
1440
+			)
1441
+		) {
1442
+			if ($verify_only) {
1443
+				return false;
1444
+			}
1445
+			if (is_user_logged_in()) {
1446
+				wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1447
+			} else {
1448
+				return false;
1449
+			}
1450
+		}
1451
+		return true;
1452
+	}
1453
+
1454
+
1455
+	/**
1456
+	 * admin_init_global
1457
+	 * This runs all the code that we want executed within the WP admin_init hook.
1458
+	 * This method executes for ALL EE Admin pages.
1459
+	 *
1460
+	 * @return void
1461
+	 */
1462
+	public function admin_init_global()
1463
+	{
1464
+	}
1465
+
1466
+
1467
+	/**
1468
+	 * wp_loaded_global
1469
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1470
+	 * EE_Admin page and will execute on every EE Admin Page load
1471
+	 *
1472
+	 * @return void
1473
+	 */
1474
+	public function wp_loaded()
1475
+	{
1476
+	}
1477
+
1478
+
1479
+	/**
1480
+	 * admin_notices
1481
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1482
+	 * ALL EE_Admin pages.
1483
+	 *
1484
+	 * @return void
1485
+	 */
1486
+	public function admin_notices_global()
1487
+	{
1488
+		$this->_display_no_javascript_warning();
1489
+		$this->_display_espresso_notices();
1490
+	}
1491
+
1492
+
1493
+	public function network_admin_notices_global()
1494
+	{
1495
+		$this->_display_no_javascript_warning();
1496
+		$this->_display_espresso_notices();
1497
+	}
1498
+
1499
+
1500
+	/**
1501
+	 * admin_footer_scripts_global
1502
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1503
+	 * will apply on ALL EE_Admin pages.
1504
+	 *
1505
+	 * @return void
1506
+	 */
1507
+	public function admin_footer_scripts_global()
1508
+	{
1509
+		$this->_add_admin_page_ajax_loading_img();
1510
+		$this->_add_admin_page_overlay();
1511
+		// if metaboxes are present we need to add the nonce field
1512
+		if (
1513
+			isset($this->_route_config['metaboxes'])
1514
+			|| isset($this->_route_config['list_table'])
1515
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1516
+		) {
1517
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1518
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1519
+		}
1520
+	}
1521
+
1522
+
1523
+	/**
1524
+	 * admin_footer_global
1525
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1526
+	 * ALL EE_Admin Pages.
1527
+	 *
1528
+	 * @return void
1529
+	 */
1530
+	public function admin_footer_global()
1531
+	{
1532
+		// dialog container for dialog helper
1533
+		echo '
1534 1534
         <div class="ee-admin-dialog-container auto-hide hidden">
1535 1535
             <div class="ee-notices"></div>
1536 1536
             <div class="ee-admin-dialog-container-inner-content"></div>
1537 1537
         </div>
1538 1538
         ';
1539 1539
 
1540
-        // current set timezone for timezone js
1541
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1542
-    }
1543
-
1544
-
1545
-    /**
1546
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1547
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1548
-     * help popups then in your templates or your content you set "triggers" for the content using the
1549
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1550
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1551
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1552
-     * for the
1553
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1554
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1555
-     *    'help_trigger_id' => array(
1556
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1557
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1558
-     *    )
1559
-     * );
1560
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1561
-     *
1562
-     * @param array $help_array
1563
-     * @param bool  $display
1564
-     * @return string content
1565
-     * @throws DomainException
1566
-     * @throws EE_Error
1567
-     */
1568
-    protected function _set_help_popup_content($help_array = [], $display = false)
1569
-    {
1570
-        $content    = '';
1571
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1572
-        // loop through the array and setup content
1573
-        foreach ($help_array as $trigger => $help) {
1574
-            // make sure the array is setup properly
1575
-            if (! isset($help['title']) || ! isset($help['content'])) {
1576
-                throw new EE_Error(
1577
-                    esc_html__(
1578
-                        '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',
1579
-                        'event_espresso'
1580
-                    )
1581
-                );
1582
-            }
1583
-            // we're good so let's setup the template vars and then assign parsed template content to our content.
1584
-            $template_args = [
1585
-                'help_popup_id'      => $trigger,
1586
-                'help_popup_title'   => $help['title'],
1587
-                'help_popup_content' => $help['content'],
1588
-            ];
1589
-            $content       .= EEH_Template::display_template(
1590
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1591
-                $template_args,
1592
-                true
1593
-            );
1594
-        }
1595
-        if ($display) {
1596
-            echo wp_kses($content, AllowedTags::getWithFormTags());
1597
-            return '';
1598
-        }
1599
-        return $content;
1600
-    }
1601
-
1602
-
1603
-    /**
1604
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1605
-     *
1606
-     * @return array properly formatted array for help popup content
1607
-     * @throws EE_Error
1608
-     */
1609
-    private function _get_help_content()
1610
-    {
1611
-        // what is the method we're looking for?
1612
-        $method_name = '_help_popup_content_' . $this->_req_action;
1613
-        // if method doesn't exist let's get out.
1614
-        if (! method_exists($this, $method_name)) {
1615
-            return [];
1616
-        }
1617
-        // k we're good to go let's retrieve the help array
1618
-        $help_array = call_user_func([$this, $method_name]);
1619
-        // make sure we've got an array!
1620
-        if (! is_array($help_array)) {
1621
-            throw new EE_Error(
1622
-                esc_html__(
1623
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1624
-                    'event_espresso'
1625
-                )
1626
-            );
1627
-        }
1628
-        return $help_array;
1629
-    }
1630
-
1631
-
1632
-    /**
1633
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1634
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1635
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1636
-     *
1637
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1638
-     * @param boolean $display    if false then we return the trigger string
1639
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1640
-     * @return string
1641
-     * @throws DomainException
1642
-     * @throws EE_Error
1643
-     */
1644
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1645
-    {
1646
-        if ($this->request->isAjax()) {
1647
-            return '';
1648
-        }
1649
-        // 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
1650
-        $help_array   = $this->_get_help_content();
1651
-        $help_content = '';
1652
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1653
-            $help_array[ $trigger_id ] = [
1654
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1655
-                'content' => esc_html__(
1656
-                    '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.)',
1657
-                    'event_espresso'
1658
-                ),
1659
-            ];
1660
-            $help_content              = $this->_set_help_popup_content($help_array);
1661
-        }
1662
-        // let's setup the trigger
1663
-        $content = '<a class="ee-dialog" href="?height='
1664
-                   . esc_attr($dimensions[0])
1665
-                   . '&width='
1666
-                   . esc_attr($dimensions[1])
1667
-                   . '&inlineId='
1668
-                   . esc_attr($trigger_id)
1669
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1670
-        $content .= $help_content;
1671
-        if ($display) {
1672
-            echo wp_kses($content, AllowedTags::getWithFormTags());
1673
-            return '';
1674
-        }
1675
-        return $content;
1676
-    }
1677
-
1678
-
1679
-    /**
1680
-     * _add_global_screen_options
1681
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1682
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1683
-     *
1684
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1685
-     *         see also WP_Screen object documents...
1686
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1687
-     * @abstract
1688
-     * @return void
1689
-     */
1690
-    private function _add_global_screen_options()
1691
-    {
1692
-    }
1693
-
1694
-
1695
-    /**
1696
-     * _add_global_feature_pointers
1697
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1698
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1699
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1700
-     *
1701
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1702
-     *         extended) also see:
1703
-     * @link   http://eamann.com/tech/wordpress-portland/
1704
-     * @abstract
1705
-     * @return void
1706
-     */
1707
-    private function _add_global_feature_pointers()
1708
-    {
1709
-    }
1710
-
1711
-
1712
-    /**
1713
-     * load_global_scripts_styles
1714
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1715
-     *
1716
-     * @return void
1717
-     */
1718
-    public function load_global_scripts_styles()
1719
-    {
1720
-        /** STYLES **/
1721
-        // add debugging styles
1722
-        if (WP_DEBUG) {
1723
-            add_action('admin_head', [$this, 'add_xdebug_style']);
1724
-        }
1725
-        // register all styles
1726
-        wp_register_style(
1727
-            'espresso-ui-theme',
1728
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1729
-            [],
1730
-            EVENT_ESPRESSO_VERSION
1731
-        );
1732
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1733
-        // helpers styles
1734
-        wp_register_style(
1735
-            'ee-text-links',
1736
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1737
-            [],
1738
-            EVENT_ESPRESSO_VERSION
1739
-        );
1740
-        /** SCRIPTS **/
1741
-        // register all scripts
1742
-        wp_register_script(
1743
-            'ee-dialog',
1744
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1745
-            ['jquery', 'jquery-ui-draggable'],
1746
-            EVENT_ESPRESSO_VERSION,
1747
-            true
1748
-        );
1749
-        wp_register_script(
1750
-            'ee_admin_js',
1751
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1752
-            ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1753
-            EVENT_ESPRESSO_VERSION,
1754
-            true
1755
-        );
1756
-        wp_register_script(
1757
-            'jquery-ui-timepicker-addon',
1758
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1759
-            ['jquery-ui-datepicker', 'jquery-ui-slider'],
1760
-            EVENT_ESPRESSO_VERSION,
1761
-            true
1762
-        );
1763
-        // script for sorting tables
1764
-        wp_register_script(
1765
-            'espresso_ajax_table_sorting',
1766
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1767
-            ['ee_admin_js', 'jquery-ui-sortable'],
1768
-            EVENT_ESPRESSO_VERSION,
1769
-            true
1770
-        );
1771
-        // script for parsing uri's
1772
-        wp_register_script(
1773
-            'ee-parse-uri',
1774
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1775
-            [],
1776
-            EVENT_ESPRESSO_VERSION,
1777
-            true
1778
-        );
1779
-        // and parsing associative serialized form elements
1780
-        wp_register_script(
1781
-            'ee-serialize-full-array',
1782
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1783
-            ['jquery'],
1784
-            EVENT_ESPRESSO_VERSION,
1785
-            true
1786
-        );
1787
-        // helpers scripts
1788
-        wp_register_script(
1789
-            'ee-text-links',
1790
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1791
-            ['jquery'],
1792
-            EVENT_ESPRESSO_VERSION,
1793
-            true
1794
-        );
1795
-        wp_register_script(
1796
-            'ee-moment-core',
1797
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1798
-            [],
1799
-            EVENT_ESPRESSO_VERSION,
1800
-            true
1801
-        );
1802
-        wp_register_script(
1803
-            'ee-moment',
1804
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1805
-            ['ee-moment-core'],
1806
-            EVENT_ESPRESSO_VERSION,
1807
-            true
1808
-        );
1809
-        wp_register_script(
1810
-            'ee-datepicker',
1811
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1812
-            ['jquery-ui-timepicker-addon', 'ee-moment'],
1813
-            EVENT_ESPRESSO_VERSION,
1814
-            true
1815
-        );
1816
-        // google charts
1817
-        wp_register_script(
1818
-            'google-charts',
1819
-            'https://www.gstatic.com/charts/loader.js',
1820
-            [],
1821
-            EVENT_ESPRESSO_VERSION
1822
-        );
1823
-        // ENQUEUE ALL BASICS BY DEFAULT
1824
-        wp_enqueue_style('ee-admin-css');
1825
-        wp_enqueue_script('ee_admin_js');
1826
-        wp_enqueue_script('ee-accounting');
1827
-        wp_enqueue_script('jquery-validate');
1828
-        // taking care of metaboxes
1829
-        if (
1830
-            empty($this->_cpt_route)
1831
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1832
-        ) {
1833
-            wp_enqueue_script('dashboard');
1834
-        }
1835
-        // LOCALIZED DATA
1836
-        // localize script for ajax lazy loading
1837
-        $lazy_loader_container_ids = apply_filters(
1838
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1839
-            ['espresso_news_post_box_content']
1840
-        );
1841
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1842
-        add_filter(
1843
-            'admin_body_class',
1844
-            function ($classes) {
1845
-                if (strpos($classes, 'espresso-admin') === false) {
1846
-                    $classes .= ' espresso-admin';
1847
-                }
1848
-                return $classes;
1849
-            }
1850
-        );
1851
-    }
1852
-
1853
-
1854
-    /**
1855
-     *        admin_footer_scripts_eei18n_js_strings
1856
-     *
1857
-     * @return        void
1858
-     */
1859
-    public function admin_footer_scripts_eei18n_js_strings()
1860
-    {
1861
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1862
-        EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1863
-            __(
1864
-                '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!!!',
1865
-                'event_espresso'
1866
-            )
1867
-        );
1868
-        EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1869
-        EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1870
-        EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1871
-        EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1872
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1873
-        EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1874
-        EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1875
-        EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1876
-        EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1877
-        EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1878
-        EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1879
-        EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1880
-        EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1881
-        EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1882
-        EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1883
-        EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1884
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1885
-        EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1886
-        EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1887
-        EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1888
-        EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1889
-        EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1890
-        EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1891
-        EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1892
-        EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1893
-        EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1894
-        EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1895
-        EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1896
-        EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1897
-        EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1898
-        EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1899
-        EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1900
-        EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1901
-        EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1902
-        EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1903
-        EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1904
-        EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
1905
-        EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
1906
-    }
1907
-
1908
-
1909
-    /**
1910
-     *        load enhanced xdebug styles for ppl with failing eyesight
1911
-     *
1912
-     * @return        void
1913
-     */
1914
-    public function add_xdebug_style()
1915
-    {
1916
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1917
-    }
1918
-
1919
-
1920
-    /************************/
1921
-    /** LIST TABLE METHODS **/
1922
-    /************************/
1923
-    /**
1924
-     * this sets up the list table if the current view requires it.
1925
-     *
1926
-     * @return void
1927
-     * @throws EE_Error
1928
-     */
1929
-    protected function _set_list_table()
1930
-    {
1931
-        // first is this a list_table view?
1932
-        if (! isset($this->_route_config['list_table'])) {
1933
-            return;
1934
-        } //not a list_table view so get out.
1935
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
1936
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
1937
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1938
-            // user error msg
1939
-            $error_msg = esc_html__(
1940
-                'An error occurred. The requested list table views could not be found.',
1941
-                'event_espresso'
1942
-            );
1943
-            // developer error msg
1944
-            $error_msg .= '||'
1945
-                          . sprintf(
1946
-                              esc_html__(
1947
-                                  '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.',
1948
-                                  'event_espresso'
1949
-                              ),
1950
-                              $this->_req_action,
1951
-                              $list_table_view
1952
-                          );
1953
-            throw new EE_Error($error_msg);
1954
-        }
1955
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1956
-        $this->_views = apply_filters(
1957
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1958
-            $this->_views
1959
-        );
1960
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1961
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1962
-        $this->_set_list_table_view();
1963
-        $this->_set_list_table_object();
1964
-    }
1965
-
1966
-
1967
-    /**
1968
-     * set current view for List Table
1969
-     *
1970
-     * @return void
1971
-     */
1972
-    protected function _set_list_table_view()
1973
-    {
1974
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1975
-        $status = $this->request->getRequestParam('status', null, 'key');
1976
-        $this->_view = $status && array_key_exists($status, $this->_views)
1977
-            ? $status
1978
-            : $this->_view;
1979
-    }
1980
-
1981
-
1982
-    /**
1983
-     * _set_list_table_object
1984
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1985
-     *
1986
-     * @throws InvalidInterfaceException
1987
-     * @throws InvalidArgumentException
1988
-     * @throws InvalidDataTypeException
1989
-     * @throws EE_Error
1990
-     * @throws InvalidInterfaceException
1991
-     */
1992
-    protected function _set_list_table_object()
1993
-    {
1994
-        if (isset($this->_route_config['list_table'])) {
1995
-            if (! class_exists($this->_route_config['list_table'])) {
1996
-                throw new EE_Error(
1997
-                    sprintf(
1998
-                        esc_html__(
1999
-                            '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.',
2000
-                            'event_espresso'
2001
-                        ),
2002
-                        $this->_route_config['list_table'],
2003
-                        get_class($this)
2004
-                    )
2005
-                );
2006
-            }
2007
-            $this->_list_table_object = $this->loader->getShared(
2008
-                $this->_route_config['list_table'],
2009
-                [$this]
2010
-            );
2011
-        }
2012
-    }
2013
-
2014
-
2015
-    /**
2016
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2017
-     *
2018
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2019
-     *                                                    urls.  The array should be indexed by the view it is being
2020
-     *                                                    added to.
2021
-     * @return array
2022
-     */
2023
-    public function get_list_table_view_RLs($extra_query_args = [])
2024
-    {
2025
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2026
-        if (empty($this->_views)) {
2027
-            $this->_views = [];
2028
-        }
2029
-        // cycle thru views
2030
-        foreach ($this->_views as $key => $view) {
2031
-            $query_args = [];
2032
-            // check for current view
2033
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2034
-            $query_args['action']                        = $this->_req_action;
2035
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2036
-            $query_args['status']                        = $view['slug'];
2037
-            // merge any other arguments sent in.
2038
-            if (isset($extra_query_args[ $view['slug'] ])) {
2039
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2040
-            }
2041
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2042
-        }
2043
-        return $this->_views;
2044
-    }
2045
-
2046
-
2047
-    /**
2048
-     * _entries_per_page_dropdown
2049
-     * generates a dropdown box for selecting the number of visible rows in an admin page list table
2050
-     *
2051
-     * @param int $max_entries total number of rows in the table
2052
-     * @return string
2053
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2054
-     *         WP does it.
2055
-     */
2056
-    protected function _entries_per_page_dropdown($max_entries = 0)
2057
-    {
2058
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2059
-        $values   = [10, 25, 50, 100];
2060
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2061
-        if ($max_entries) {
2062
-            $values[] = $max_entries;
2063
-            sort($values);
2064
-        }
2065
-        $entries_per_page_dropdown = '
1540
+		// current set timezone for timezone js
1541
+		echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1542
+	}
1543
+
1544
+
1545
+	/**
1546
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1547
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1548
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1549
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1550
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1551
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1552
+	 * for the
1553
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1554
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1555
+	 *    'help_trigger_id' => array(
1556
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1557
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1558
+	 *    )
1559
+	 * );
1560
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1561
+	 *
1562
+	 * @param array $help_array
1563
+	 * @param bool  $display
1564
+	 * @return string content
1565
+	 * @throws DomainException
1566
+	 * @throws EE_Error
1567
+	 */
1568
+	protected function _set_help_popup_content($help_array = [], $display = false)
1569
+	{
1570
+		$content    = '';
1571
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1572
+		// loop through the array and setup content
1573
+		foreach ($help_array as $trigger => $help) {
1574
+			// make sure the array is setup properly
1575
+			if (! isset($help['title']) || ! isset($help['content'])) {
1576
+				throw new EE_Error(
1577
+					esc_html__(
1578
+						'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',
1579
+						'event_espresso'
1580
+					)
1581
+				);
1582
+			}
1583
+			// we're good so let's setup the template vars and then assign parsed template content to our content.
1584
+			$template_args = [
1585
+				'help_popup_id'      => $trigger,
1586
+				'help_popup_title'   => $help['title'],
1587
+				'help_popup_content' => $help['content'],
1588
+			];
1589
+			$content       .= EEH_Template::display_template(
1590
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1591
+				$template_args,
1592
+				true
1593
+			);
1594
+		}
1595
+		if ($display) {
1596
+			echo wp_kses($content, AllowedTags::getWithFormTags());
1597
+			return '';
1598
+		}
1599
+		return $content;
1600
+	}
1601
+
1602
+
1603
+	/**
1604
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1605
+	 *
1606
+	 * @return array properly formatted array for help popup content
1607
+	 * @throws EE_Error
1608
+	 */
1609
+	private function _get_help_content()
1610
+	{
1611
+		// what is the method we're looking for?
1612
+		$method_name = '_help_popup_content_' . $this->_req_action;
1613
+		// if method doesn't exist let's get out.
1614
+		if (! method_exists($this, $method_name)) {
1615
+			return [];
1616
+		}
1617
+		// k we're good to go let's retrieve the help array
1618
+		$help_array = call_user_func([$this, $method_name]);
1619
+		// make sure we've got an array!
1620
+		if (! is_array($help_array)) {
1621
+			throw new EE_Error(
1622
+				esc_html__(
1623
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1624
+					'event_espresso'
1625
+				)
1626
+			);
1627
+		}
1628
+		return $help_array;
1629
+	}
1630
+
1631
+
1632
+	/**
1633
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1634
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1635
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1636
+	 *
1637
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1638
+	 * @param boolean $display    if false then we return the trigger string
1639
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1640
+	 * @return string
1641
+	 * @throws DomainException
1642
+	 * @throws EE_Error
1643
+	 */
1644
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1645
+	{
1646
+		if ($this->request->isAjax()) {
1647
+			return '';
1648
+		}
1649
+		// 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
1650
+		$help_array   = $this->_get_help_content();
1651
+		$help_content = '';
1652
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1653
+			$help_array[ $trigger_id ] = [
1654
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1655
+				'content' => esc_html__(
1656
+					'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.)',
1657
+					'event_espresso'
1658
+				),
1659
+			];
1660
+			$help_content              = $this->_set_help_popup_content($help_array);
1661
+		}
1662
+		// let's setup the trigger
1663
+		$content = '<a class="ee-dialog" href="?height='
1664
+				   . esc_attr($dimensions[0])
1665
+				   . '&width='
1666
+				   . esc_attr($dimensions[1])
1667
+				   . '&inlineId='
1668
+				   . esc_attr($trigger_id)
1669
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1670
+		$content .= $help_content;
1671
+		if ($display) {
1672
+			echo wp_kses($content, AllowedTags::getWithFormTags());
1673
+			return '';
1674
+		}
1675
+		return $content;
1676
+	}
1677
+
1678
+
1679
+	/**
1680
+	 * _add_global_screen_options
1681
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1682
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1683
+	 *
1684
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1685
+	 *         see also WP_Screen object documents...
1686
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1687
+	 * @abstract
1688
+	 * @return void
1689
+	 */
1690
+	private function _add_global_screen_options()
1691
+	{
1692
+	}
1693
+
1694
+
1695
+	/**
1696
+	 * _add_global_feature_pointers
1697
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1698
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1699
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1700
+	 *
1701
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1702
+	 *         extended) also see:
1703
+	 * @link   http://eamann.com/tech/wordpress-portland/
1704
+	 * @abstract
1705
+	 * @return void
1706
+	 */
1707
+	private function _add_global_feature_pointers()
1708
+	{
1709
+	}
1710
+
1711
+
1712
+	/**
1713
+	 * load_global_scripts_styles
1714
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1715
+	 *
1716
+	 * @return void
1717
+	 */
1718
+	public function load_global_scripts_styles()
1719
+	{
1720
+		/** STYLES **/
1721
+		// add debugging styles
1722
+		if (WP_DEBUG) {
1723
+			add_action('admin_head', [$this, 'add_xdebug_style']);
1724
+		}
1725
+		// register all styles
1726
+		wp_register_style(
1727
+			'espresso-ui-theme',
1728
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1729
+			[],
1730
+			EVENT_ESPRESSO_VERSION
1731
+		);
1732
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1733
+		// helpers styles
1734
+		wp_register_style(
1735
+			'ee-text-links',
1736
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1737
+			[],
1738
+			EVENT_ESPRESSO_VERSION
1739
+		);
1740
+		/** SCRIPTS **/
1741
+		// register all scripts
1742
+		wp_register_script(
1743
+			'ee-dialog',
1744
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1745
+			['jquery', 'jquery-ui-draggable'],
1746
+			EVENT_ESPRESSO_VERSION,
1747
+			true
1748
+		);
1749
+		wp_register_script(
1750
+			'ee_admin_js',
1751
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1752
+			['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1753
+			EVENT_ESPRESSO_VERSION,
1754
+			true
1755
+		);
1756
+		wp_register_script(
1757
+			'jquery-ui-timepicker-addon',
1758
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1759
+			['jquery-ui-datepicker', 'jquery-ui-slider'],
1760
+			EVENT_ESPRESSO_VERSION,
1761
+			true
1762
+		);
1763
+		// script for sorting tables
1764
+		wp_register_script(
1765
+			'espresso_ajax_table_sorting',
1766
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1767
+			['ee_admin_js', 'jquery-ui-sortable'],
1768
+			EVENT_ESPRESSO_VERSION,
1769
+			true
1770
+		);
1771
+		// script for parsing uri's
1772
+		wp_register_script(
1773
+			'ee-parse-uri',
1774
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1775
+			[],
1776
+			EVENT_ESPRESSO_VERSION,
1777
+			true
1778
+		);
1779
+		// and parsing associative serialized form elements
1780
+		wp_register_script(
1781
+			'ee-serialize-full-array',
1782
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1783
+			['jquery'],
1784
+			EVENT_ESPRESSO_VERSION,
1785
+			true
1786
+		);
1787
+		// helpers scripts
1788
+		wp_register_script(
1789
+			'ee-text-links',
1790
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1791
+			['jquery'],
1792
+			EVENT_ESPRESSO_VERSION,
1793
+			true
1794
+		);
1795
+		wp_register_script(
1796
+			'ee-moment-core',
1797
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1798
+			[],
1799
+			EVENT_ESPRESSO_VERSION,
1800
+			true
1801
+		);
1802
+		wp_register_script(
1803
+			'ee-moment',
1804
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1805
+			['ee-moment-core'],
1806
+			EVENT_ESPRESSO_VERSION,
1807
+			true
1808
+		);
1809
+		wp_register_script(
1810
+			'ee-datepicker',
1811
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1812
+			['jquery-ui-timepicker-addon', 'ee-moment'],
1813
+			EVENT_ESPRESSO_VERSION,
1814
+			true
1815
+		);
1816
+		// google charts
1817
+		wp_register_script(
1818
+			'google-charts',
1819
+			'https://www.gstatic.com/charts/loader.js',
1820
+			[],
1821
+			EVENT_ESPRESSO_VERSION
1822
+		);
1823
+		// ENQUEUE ALL BASICS BY DEFAULT
1824
+		wp_enqueue_style('ee-admin-css');
1825
+		wp_enqueue_script('ee_admin_js');
1826
+		wp_enqueue_script('ee-accounting');
1827
+		wp_enqueue_script('jquery-validate');
1828
+		// taking care of metaboxes
1829
+		if (
1830
+			empty($this->_cpt_route)
1831
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1832
+		) {
1833
+			wp_enqueue_script('dashboard');
1834
+		}
1835
+		// LOCALIZED DATA
1836
+		// localize script for ajax lazy loading
1837
+		$lazy_loader_container_ids = apply_filters(
1838
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1839
+			['espresso_news_post_box_content']
1840
+		);
1841
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1842
+		add_filter(
1843
+			'admin_body_class',
1844
+			function ($classes) {
1845
+				if (strpos($classes, 'espresso-admin') === false) {
1846
+					$classes .= ' espresso-admin';
1847
+				}
1848
+				return $classes;
1849
+			}
1850
+		);
1851
+	}
1852
+
1853
+
1854
+	/**
1855
+	 *        admin_footer_scripts_eei18n_js_strings
1856
+	 *
1857
+	 * @return        void
1858
+	 */
1859
+	public function admin_footer_scripts_eei18n_js_strings()
1860
+	{
1861
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1862
+		EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1863
+			__(
1864
+				'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!!!',
1865
+				'event_espresso'
1866
+			)
1867
+		);
1868
+		EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1869
+		EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1870
+		EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1871
+		EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1872
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1873
+		EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1874
+		EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1875
+		EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1876
+		EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1877
+		EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1878
+		EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1879
+		EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1880
+		EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1881
+		EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1882
+		EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1883
+		EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1884
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1885
+		EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1886
+		EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1887
+		EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1888
+		EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1889
+		EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1890
+		EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1891
+		EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1892
+		EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1893
+		EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1894
+		EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1895
+		EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1896
+		EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1897
+		EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1898
+		EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1899
+		EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1900
+		EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1901
+		EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1902
+		EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1903
+		EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1904
+		EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
1905
+		EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
1906
+	}
1907
+
1908
+
1909
+	/**
1910
+	 *        load enhanced xdebug styles for ppl with failing eyesight
1911
+	 *
1912
+	 * @return        void
1913
+	 */
1914
+	public function add_xdebug_style()
1915
+	{
1916
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1917
+	}
1918
+
1919
+
1920
+	/************************/
1921
+	/** LIST TABLE METHODS **/
1922
+	/************************/
1923
+	/**
1924
+	 * this sets up the list table if the current view requires it.
1925
+	 *
1926
+	 * @return void
1927
+	 * @throws EE_Error
1928
+	 */
1929
+	protected function _set_list_table()
1930
+	{
1931
+		// first is this a list_table view?
1932
+		if (! isset($this->_route_config['list_table'])) {
1933
+			return;
1934
+		} //not a list_table view so get out.
1935
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
1936
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
1937
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1938
+			// user error msg
1939
+			$error_msg = esc_html__(
1940
+				'An error occurred. The requested list table views could not be found.',
1941
+				'event_espresso'
1942
+			);
1943
+			// developer error msg
1944
+			$error_msg .= '||'
1945
+						  . sprintf(
1946
+							  esc_html__(
1947
+								  '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.',
1948
+								  'event_espresso'
1949
+							  ),
1950
+							  $this->_req_action,
1951
+							  $list_table_view
1952
+						  );
1953
+			throw new EE_Error($error_msg);
1954
+		}
1955
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1956
+		$this->_views = apply_filters(
1957
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1958
+			$this->_views
1959
+		);
1960
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1961
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1962
+		$this->_set_list_table_view();
1963
+		$this->_set_list_table_object();
1964
+	}
1965
+
1966
+
1967
+	/**
1968
+	 * set current view for List Table
1969
+	 *
1970
+	 * @return void
1971
+	 */
1972
+	protected function _set_list_table_view()
1973
+	{
1974
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1975
+		$status = $this->request->getRequestParam('status', null, 'key');
1976
+		$this->_view = $status && array_key_exists($status, $this->_views)
1977
+			? $status
1978
+			: $this->_view;
1979
+	}
1980
+
1981
+
1982
+	/**
1983
+	 * _set_list_table_object
1984
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1985
+	 *
1986
+	 * @throws InvalidInterfaceException
1987
+	 * @throws InvalidArgumentException
1988
+	 * @throws InvalidDataTypeException
1989
+	 * @throws EE_Error
1990
+	 * @throws InvalidInterfaceException
1991
+	 */
1992
+	protected function _set_list_table_object()
1993
+	{
1994
+		if (isset($this->_route_config['list_table'])) {
1995
+			if (! class_exists($this->_route_config['list_table'])) {
1996
+				throw new EE_Error(
1997
+					sprintf(
1998
+						esc_html__(
1999
+							'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.',
2000
+							'event_espresso'
2001
+						),
2002
+						$this->_route_config['list_table'],
2003
+						get_class($this)
2004
+					)
2005
+				);
2006
+			}
2007
+			$this->_list_table_object = $this->loader->getShared(
2008
+				$this->_route_config['list_table'],
2009
+				[$this]
2010
+			);
2011
+		}
2012
+	}
2013
+
2014
+
2015
+	/**
2016
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2017
+	 *
2018
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2019
+	 *                                                    urls.  The array should be indexed by the view it is being
2020
+	 *                                                    added to.
2021
+	 * @return array
2022
+	 */
2023
+	public function get_list_table_view_RLs($extra_query_args = [])
2024
+	{
2025
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2026
+		if (empty($this->_views)) {
2027
+			$this->_views = [];
2028
+		}
2029
+		// cycle thru views
2030
+		foreach ($this->_views as $key => $view) {
2031
+			$query_args = [];
2032
+			// check for current view
2033
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2034
+			$query_args['action']                        = $this->_req_action;
2035
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2036
+			$query_args['status']                        = $view['slug'];
2037
+			// merge any other arguments sent in.
2038
+			if (isset($extra_query_args[ $view['slug'] ])) {
2039
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2040
+			}
2041
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2042
+		}
2043
+		return $this->_views;
2044
+	}
2045
+
2046
+
2047
+	/**
2048
+	 * _entries_per_page_dropdown
2049
+	 * generates a dropdown box for selecting the number of visible rows in an admin page list table
2050
+	 *
2051
+	 * @param int $max_entries total number of rows in the table
2052
+	 * @return string
2053
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2054
+	 *         WP does it.
2055
+	 */
2056
+	protected function _entries_per_page_dropdown($max_entries = 0)
2057
+	{
2058
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2059
+		$values   = [10, 25, 50, 100];
2060
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2061
+		if ($max_entries) {
2062
+			$values[] = $max_entries;
2063
+			sort($values);
2064
+		}
2065
+		$entries_per_page_dropdown = '
2066 2066
 			<div id="entries-per-page-dv" class="alignleft actions">
2067 2067
 				<label class="hide-if-no-js">
2068 2068
 					Show
2069 2069
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2070
-        foreach ($values as $value) {
2071
-            if ($value < $max_entries) {
2072
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2073
-                $entries_per_page_dropdown .= '
2070
+		foreach ($values as $value) {
2071
+			if ($value < $max_entries) {
2072
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2073
+				$entries_per_page_dropdown .= '
2074 2074
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2075
-            }
2076
-        }
2077
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2078
-        $entries_per_page_dropdown .= '
2075
+			}
2076
+		}
2077
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2078
+		$entries_per_page_dropdown .= '
2079 2079
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2080
-        $entries_per_page_dropdown .= '
2080
+		$entries_per_page_dropdown .= '
2081 2081
 					</select>
2082 2082
 					entries
2083 2083
 				</label>
2084 2084
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2085 2085
 			</div>
2086 2086
 		';
2087
-        return $entries_per_page_dropdown;
2088
-    }
2089
-
2090
-
2091
-    /**
2092
-     *        _set_search_attributes
2093
-     *
2094
-     * @return        void
2095
-     */
2096
-    public function _set_search_attributes()
2097
-    {
2098
-        $this->_template_args['search']['btn_label'] = sprintf(
2099
-            esc_html__('Search %s', 'event_espresso'),
2100
-            empty($this->_search_btn_label) ? $this->page_label
2101
-                : $this->_search_btn_label
2102
-        );
2103
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2104
-    }
2105
-
2106
-
2107
-
2108
-    /*** END LIST TABLE METHODS **/
2109
-
2110
-
2111
-    /**
2112
-     * _add_registered_metaboxes
2113
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2114
-     *
2115
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2116
-     * @return void
2117
-     * @throws EE_Error
2118
-     */
2119
-    private function _add_registered_meta_boxes()
2120
-    {
2121
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2122
-        // we only add meta boxes if the page_route calls for it
2123
-        if (
2124
-            is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2125
-            && is_array(
2126
-                $this->_route_config['metaboxes']
2127
-            )
2128
-        ) {
2129
-            // this simply loops through the callbacks provided
2130
-            // and checks if there is a corresponding callback registered by the child
2131
-            // if there is then we go ahead and process the metabox loader.
2132
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2133
-                // first check for Closures
2134
-                if ($metabox_callback instanceof Closure) {
2135
-                    $result = $metabox_callback();
2136
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2137
-                    $result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2138
-                } else {
2139
-                    $result = call_user_func([$this, &$metabox_callback]);
2140
-                }
2141
-                if ($result === false) {
2142
-                    // user error msg
2143
-                    $error_msg = esc_html__(
2144
-                        'An error occurred. The  requested metabox could not be found.',
2145
-                        'event_espresso'
2146
-                    );
2147
-                    // developer error msg
2148
-                    $error_msg .= '||'
2149
-                                  . sprintf(
2150
-                                      esc_html__(
2151
-                                          '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.',
2152
-                                          'event_espresso'
2153
-                                      ),
2154
-                                      $metabox_callback
2155
-                                  );
2156
-                    throw new EE_Error($error_msg);
2157
-                }
2158
-            }
2159
-        }
2160
-    }
2161
-
2162
-
2163
-    /**
2164
-     * _add_screen_columns
2165
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2166
-     * the dynamic column template and we'll setup the column options for the page.
2167
-     *
2168
-     * @return void
2169
-     */
2170
-    private function _add_screen_columns()
2171
-    {
2172
-        if (
2173
-            is_array($this->_route_config)
2174
-            && isset($this->_route_config['columns'])
2175
-            && is_array($this->_route_config['columns'])
2176
-            && count($this->_route_config['columns']) === 2
2177
-        ) {
2178
-            add_screen_option(
2179
-                'layout_columns',
2180
-                [
2181
-                    'max'     => (int) $this->_route_config['columns'][0],
2182
-                    'default' => (int) $this->_route_config['columns'][1],
2183
-                ]
2184
-            );
2185
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2186
-            $screen_id                                           = $this->_current_screen->id;
2187
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2188
-            $total_columns                                       = ! empty($screen_columns)
2189
-                ? $screen_columns
2190
-                : $this->_route_config['columns'][1];
2191
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2192
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2193
-            $this->_template_args['screen']                      = $this->_current_screen;
2194
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2195
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2196
-            // finally if we don't have has_metaboxes set in the route config
2197
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2198
-            $this->_route_config['has_metaboxes'] = true;
2199
-        }
2200
-    }
2201
-
2202
-
2203
-
2204
-    /** GLOBALLY AVAILABLE METABOXES **/
2205
-
2206
-
2207
-    /**
2208
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2209
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2210
-     * these get loaded on.
2211
-     */
2212
-    private function _espresso_news_post_box()
2213
-    {
2214
-        $news_box_title = apply_filters(
2215
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2216
-            esc_html__('New @ Event Espresso', 'event_espresso')
2217
-        );
2218
-        add_meta_box(
2219
-            'espresso_news_post_box',
2220
-            $news_box_title,
2221
-            [
2222
-                $this,
2223
-                'espresso_news_post_box',
2224
-            ],
2225
-            $this->_wp_page_slug,
2226
-            'side'
2227
-        );
2228
-    }
2229
-
2230
-
2231
-    /**
2232
-     * Code for setting up espresso ratings request metabox.
2233
-     */
2234
-    protected function _espresso_ratings_request()
2235
-    {
2236
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2237
-            return;
2238
-        }
2239
-        $ratings_box_title = apply_filters(
2240
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2241
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2242
-        );
2243
-        add_meta_box(
2244
-            'espresso_ratings_request',
2245
-            $ratings_box_title,
2246
-            [
2247
-                $this,
2248
-                'espresso_ratings_request',
2249
-            ],
2250
-            $this->_wp_page_slug,
2251
-            'side'
2252
-        );
2253
-    }
2254
-
2255
-
2256
-    /**
2257
-     * Code for setting up espresso ratings request metabox content.
2258
-     *
2259
-     * @throws DomainException
2260
-     */
2261
-    public function espresso_ratings_request()
2262
-    {
2263
-        EEH_Template::display_template(
2264
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2265
-            []
2266
-        );
2267
-    }
2268
-
2269
-
2270
-    public static function cached_rss_display($rss_id, $url)
2271
-    {
2272
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2273
-                     . esc_html__('Loading&#8230;', 'event_espresso')
2274
-                     . '</p><p class="hide-if-js">'
2275
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2276
-                     . '</p>';
2277
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2278
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2279
-        $post      = '</div>' . "\n";
2280
-        $cache_key = 'ee_rss_' . md5($rss_id);
2281
-        $output    = get_transient($cache_key);
2282
-        if ($output !== false) {
2283
-            echo wp_kses($pre . $output . $post, AllowedTags::getWithFormTags());
2284
-            return true;
2285
-        }
2286
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2287
-            echo wp_kses($pre . $loading . $post, AllowedTags::getWithFormTags());
2288
-            return false;
2289
-        }
2290
-        ob_start();
2291
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2292
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2293
-        return true;
2294
-    }
2295
-
2296
-
2297
-    public function espresso_news_post_box()
2298
-    {
2299
-        ?>
2087
+		return $entries_per_page_dropdown;
2088
+	}
2089
+
2090
+
2091
+	/**
2092
+	 *        _set_search_attributes
2093
+	 *
2094
+	 * @return        void
2095
+	 */
2096
+	public function _set_search_attributes()
2097
+	{
2098
+		$this->_template_args['search']['btn_label'] = sprintf(
2099
+			esc_html__('Search %s', 'event_espresso'),
2100
+			empty($this->_search_btn_label) ? $this->page_label
2101
+				: $this->_search_btn_label
2102
+		);
2103
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2104
+	}
2105
+
2106
+
2107
+
2108
+	/*** END LIST TABLE METHODS **/
2109
+
2110
+
2111
+	/**
2112
+	 * _add_registered_metaboxes
2113
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2114
+	 *
2115
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2116
+	 * @return void
2117
+	 * @throws EE_Error
2118
+	 */
2119
+	private function _add_registered_meta_boxes()
2120
+	{
2121
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2122
+		// we only add meta boxes if the page_route calls for it
2123
+		if (
2124
+			is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2125
+			&& is_array(
2126
+				$this->_route_config['metaboxes']
2127
+			)
2128
+		) {
2129
+			// this simply loops through the callbacks provided
2130
+			// and checks if there is a corresponding callback registered by the child
2131
+			// if there is then we go ahead and process the metabox loader.
2132
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2133
+				// first check for Closures
2134
+				if ($metabox_callback instanceof Closure) {
2135
+					$result = $metabox_callback();
2136
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2137
+					$result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2138
+				} else {
2139
+					$result = call_user_func([$this, &$metabox_callback]);
2140
+				}
2141
+				if ($result === false) {
2142
+					// user error msg
2143
+					$error_msg = esc_html__(
2144
+						'An error occurred. The  requested metabox could not be found.',
2145
+						'event_espresso'
2146
+					);
2147
+					// developer error msg
2148
+					$error_msg .= '||'
2149
+								  . sprintf(
2150
+									  esc_html__(
2151
+										  '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.',
2152
+										  'event_espresso'
2153
+									  ),
2154
+									  $metabox_callback
2155
+								  );
2156
+					throw new EE_Error($error_msg);
2157
+				}
2158
+			}
2159
+		}
2160
+	}
2161
+
2162
+
2163
+	/**
2164
+	 * _add_screen_columns
2165
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2166
+	 * the dynamic column template and we'll setup the column options for the page.
2167
+	 *
2168
+	 * @return void
2169
+	 */
2170
+	private function _add_screen_columns()
2171
+	{
2172
+		if (
2173
+			is_array($this->_route_config)
2174
+			&& isset($this->_route_config['columns'])
2175
+			&& is_array($this->_route_config['columns'])
2176
+			&& count($this->_route_config['columns']) === 2
2177
+		) {
2178
+			add_screen_option(
2179
+				'layout_columns',
2180
+				[
2181
+					'max'     => (int) $this->_route_config['columns'][0],
2182
+					'default' => (int) $this->_route_config['columns'][1],
2183
+				]
2184
+			);
2185
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2186
+			$screen_id                                           = $this->_current_screen->id;
2187
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2188
+			$total_columns                                       = ! empty($screen_columns)
2189
+				? $screen_columns
2190
+				: $this->_route_config['columns'][1];
2191
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2192
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2193
+			$this->_template_args['screen']                      = $this->_current_screen;
2194
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2195
+																   . 'admin_details_metabox_column_wrapper.template.php';
2196
+			// finally if we don't have has_metaboxes set in the route config
2197
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2198
+			$this->_route_config['has_metaboxes'] = true;
2199
+		}
2200
+	}
2201
+
2202
+
2203
+
2204
+	/** GLOBALLY AVAILABLE METABOXES **/
2205
+
2206
+
2207
+	/**
2208
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2209
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2210
+	 * these get loaded on.
2211
+	 */
2212
+	private function _espresso_news_post_box()
2213
+	{
2214
+		$news_box_title = apply_filters(
2215
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2216
+			esc_html__('New @ Event Espresso', 'event_espresso')
2217
+		);
2218
+		add_meta_box(
2219
+			'espresso_news_post_box',
2220
+			$news_box_title,
2221
+			[
2222
+				$this,
2223
+				'espresso_news_post_box',
2224
+			],
2225
+			$this->_wp_page_slug,
2226
+			'side'
2227
+		);
2228
+	}
2229
+
2230
+
2231
+	/**
2232
+	 * Code for setting up espresso ratings request metabox.
2233
+	 */
2234
+	protected function _espresso_ratings_request()
2235
+	{
2236
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2237
+			return;
2238
+		}
2239
+		$ratings_box_title = apply_filters(
2240
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2241
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2242
+		);
2243
+		add_meta_box(
2244
+			'espresso_ratings_request',
2245
+			$ratings_box_title,
2246
+			[
2247
+				$this,
2248
+				'espresso_ratings_request',
2249
+			],
2250
+			$this->_wp_page_slug,
2251
+			'side'
2252
+		);
2253
+	}
2254
+
2255
+
2256
+	/**
2257
+	 * Code for setting up espresso ratings request metabox content.
2258
+	 *
2259
+	 * @throws DomainException
2260
+	 */
2261
+	public function espresso_ratings_request()
2262
+	{
2263
+		EEH_Template::display_template(
2264
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2265
+			[]
2266
+		);
2267
+	}
2268
+
2269
+
2270
+	public static function cached_rss_display($rss_id, $url)
2271
+	{
2272
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2273
+					 . esc_html__('Loading&#8230;', 'event_espresso')
2274
+					 . '</p><p class="hide-if-js">'
2275
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2276
+					 . '</p>';
2277
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2278
+		$pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2279
+		$post      = '</div>' . "\n";
2280
+		$cache_key = 'ee_rss_' . md5($rss_id);
2281
+		$output    = get_transient($cache_key);
2282
+		if ($output !== false) {
2283
+			echo wp_kses($pre . $output . $post, AllowedTags::getWithFormTags());
2284
+			return true;
2285
+		}
2286
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2287
+			echo wp_kses($pre . $loading . $post, AllowedTags::getWithFormTags());
2288
+			return false;
2289
+		}
2290
+		ob_start();
2291
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2292
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2293
+		return true;
2294
+	}
2295
+
2296
+
2297
+	public function espresso_news_post_box()
2298
+	{
2299
+		?>
2300 2300
         <div class="padding">
2301 2301
             <div id="espresso_news_post_box_content" class="infolinks">
2302 2302
                 <?php
2303
-                // Get RSS Feed(s)
2304
-                self::cached_rss_display(
2305
-                    'espresso_news_post_box_content',
2306
-                    esc_url_raw(
2307
-                        apply_filters(
2308
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2309
-                            'https://eventespresso.com/feed/'
2310
-                        )
2311
-                    )
2312
-                );
2313
-                ?>
2303
+				// Get RSS Feed(s)
2304
+				self::cached_rss_display(
2305
+					'espresso_news_post_box_content',
2306
+					esc_url_raw(
2307
+						apply_filters(
2308
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2309
+							'https://eventespresso.com/feed/'
2310
+						)
2311
+					)
2312
+				);
2313
+				?>
2314 2314
             </div>
2315 2315
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2316 2316
         </div>
2317 2317
         <?php
2318
-    }
2319
-
2320
-
2321
-    private function _espresso_links_post_box()
2322
-    {
2323
-        // Hiding until we actually have content to put in here...
2324
-        // add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2325
-    }
2326
-
2327
-
2328
-    public function espresso_links_post_box()
2329
-    {
2330
-        // Hiding until we actually have content to put in here...
2331
-        // EEH_Template::display_template(
2332
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2333
-        // );
2334
-    }
2335
-
2336
-
2337
-    protected function _espresso_sponsors_post_box()
2338
-    {
2339
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2340
-            add_meta_box(
2341
-                'espresso_sponsors_post_box',
2342
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2343
-                [$this, 'espresso_sponsors_post_box'],
2344
-                $this->_wp_page_slug,
2345
-                'side'
2346
-            );
2347
-        }
2348
-    }
2349
-
2350
-
2351
-    public function espresso_sponsors_post_box()
2352
-    {
2353
-        EEH_Template::display_template(
2354
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2355
-        );
2356
-    }
2357
-
2358
-
2359
-    private function _publish_post_box()
2360
-    {
2361
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2362
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2363
-        // then we'll use that for the metabox label.
2364
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2365
-        if (! empty($this->_labels['publishbox'])) {
2366
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2367
-                : $this->_labels['publishbox'];
2368
-        } else {
2369
-            $box_label = esc_html__('Publish', 'event_espresso');
2370
-        }
2371
-        $box_label = apply_filters(
2372
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2373
-            $box_label,
2374
-            $this->_req_action,
2375
-            $this
2376
-        );
2377
-        add_meta_box(
2378
-            $meta_box_ref,
2379
-            $box_label,
2380
-            [$this, 'editor_overview'],
2381
-            $this->_current_screen->id,
2382
-            'side',
2383
-            'high'
2384
-        );
2385
-    }
2386
-
2387
-
2388
-    public function editor_overview()
2389
-    {
2390
-        // if we have extra content set let's add it in if not make sure its empty
2391
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2392
-            ? $this->_template_args['publish_box_extra_content']
2393
-            : '';
2394
-        echo EEH_Template::display_template(
2395
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2396
-            $this->_template_args,
2397
-            true
2398
-        );
2399
-    }
2400
-
2401
-
2402
-    /** end of globally available metaboxes section **/
2403
-
2404
-
2405
-    /**
2406
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2407
-     * protected method.
2408
-     *
2409
-     * @param string $name
2410
-     * @param int    $id
2411
-     * @param bool   $delete
2412
-     * @param string $save_close_redirect_URL
2413
-     * @param bool   $both_btns
2414
-     * @throws EE_Error
2415
-     * @throws InvalidArgumentException
2416
-     * @throws InvalidDataTypeException
2417
-     * @throws InvalidInterfaceException
2418
-     * @see   $this->_set_publish_post_box_vars for param details
2419
-     * @since 4.6.0
2420
-     */
2421
-    public function set_publish_post_box_vars(
2422
-        $name = '',
2423
-        $id = 0,
2424
-        $delete = false,
2425
-        $save_close_redirect_URL = '',
2426
-        $both_btns = true
2427
-    ) {
2428
-        $this->_set_publish_post_box_vars(
2429
-            $name,
2430
-            $id,
2431
-            $delete,
2432
-            $save_close_redirect_URL,
2433
-            $both_btns
2434
-        );
2435
-    }
2436
-
2437
-
2438
-    /**
2439
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2440
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2441
-     * save, and save and close buttons to work properly, then you will want to include a
2442
-     * values for the name and id arguments.
2443
-     *
2444
-     * @param string  $name                       key used for the action ID (i.e. event_id)
2445
-     * @param int     $id                         id attached to the item published
2446
-     * @param string  $delete                     page route callback for the delete action
2447
-     * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2448
-     * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2449
-     *                                            the Save button
2450
-     * @throws EE_Error
2451
-     * @throws InvalidArgumentException
2452
-     * @throws InvalidDataTypeException
2453
-     * @throws InvalidInterfaceException
2454
-     * @todo  Add in validation for name/id arguments.
2455
-     */
2456
-    protected function _set_publish_post_box_vars(
2457
-        $name = '',
2458
-        $id = 0,
2459
-        $delete = '',
2460
-        $save_close_redirect_URL = '',
2461
-        $both_btns = true
2462
-    ) {
2463
-        // if Save & Close, use a custom redirect URL or default to the main page?
2464
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2465
-            ? $save_close_redirect_URL
2466
-            : $this->_admin_base_url;
2467
-        // create the Save & Close and Save buttons
2468
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2469
-        // if we have extra content set let's add it in if not make sure its empty
2470
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2471
-            ? $this->_template_args['publish_box_extra_content']
2472
-            : '';
2473
-        if ($delete && ! empty($id)) {
2474
-            // make sure we have a default if just true is sent.
2475
-            $delete           = ! empty($delete) ? $delete : 'delete';
2476
-            $delete_link_args = [$name => $id];
2477
-            $delete           = $this->get_action_link_or_button(
2478
-                $delete,
2479
-                $delete,
2480
-                $delete_link_args,
2481
-                'submitdelete deletion',
2482
-                '',
2483
-                false
2484
-            );
2485
-        }
2486
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2487
-        if (! empty($name) && ! empty($id)) {
2488
-            $hidden_field_arr[ $name ] = [
2489
-                'type'  => 'hidden',
2490
-                'value' => $id,
2491
-            ];
2492
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2493
-        } else {
2494
-            $hf = '';
2495
-        }
2496
-        // add hidden field
2497
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2498
-            ? $hf[ $name ]['field']
2499
-            : $hf;
2500
-    }
2501
-
2502
-
2503
-    /**
2504
-     * displays an error message to ppl who have javascript disabled
2505
-     *
2506
-     * @return void
2507
-     */
2508
-    private function _display_no_javascript_warning()
2509
-    {
2510
-        ?>
2318
+	}
2319
+
2320
+
2321
+	private function _espresso_links_post_box()
2322
+	{
2323
+		// Hiding until we actually have content to put in here...
2324
+		// add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2325
+	}
2326
+
2327
+
2328
+	public function espresso_links_post_box()
2329
+	{
2330
+		// Hiding until we actually have content to put in here...
2331
+		// EEH_Template::display_template(
2332
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2333
+		// );
2334
+	}
2335
+
2336
+
2337
+	protected function _espresso_sponsors_post_box()
2338
+	{
2339
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2340
+			add_meta_box(
2341
+				'espresso_sponsors_post_box',
2342
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2343
+				[$this, 'espresso_sponsors_post_box'],
2344
+				$this->_wp_page_slug,
2345
+				'side'
2346
+			);
2347
+		}
2348
+	}
2349
+
2350
+
2351
+	public function espresso_sponsors_post_box()
2352
+	{
2353
+		EEH_Template::display_template(
2354
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2355
+		);
2356
+	}
2357
+
2358
+
2359
+	private function _publish_post_box()
2360
+	{
2361
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2362
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2363
+		// then we'll use that for the metabox label.
2364
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2365
+		if (! empty($this->_labels['publishbox'])) {
2366
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2367
+				: $this->_labels['publishbox'];
2368
+		} else {
2369
+			$box_label = esc_html__('Publish', 'event_espresso');
2370
+		}
2371
+		$box_label = apply_filters(
2372
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2373
+			$box_label,
2374
+			$this->_req_action,
2375
+			$this
2376
+		);
2377
+		add_meta_box(
2378
+			$meta_box_ref,
2379
+			$box_label,
2380
+			[$this, 'editor_overview'],
2381
+			$this->_current_screen->id,
2382
+			'side',
2383
+			'high'
2384
+		);
2385
+	}
2386
+
2387
+
2388
+	public function editor_overview()
2389
+	{
2390
+		// if we have extra content set let's add it in if not make sure its empty
2391
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2392
+			? $this->_template_args['publish_box_extra_content']
2393
+			: '';
2394
+		echo EEH_Template::display_template(
2395
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2396
+			$this->_template_args,
2397
+			true
2398
+		);
2399
+	}
2400
+
2401
+
2402
+	/** end of globally available metaboxes section **/
2403
+
2404
+
2405
+	/**
2406
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2407
+	 * protected method.
2408
+	 *
2409
+	 * @param string $name
2410
+	 * @param int    $id
2411
+	 * @param bool   $delete
2412
+	 * @param string $save_close_redirect_URL
2413
+	 * @param bool   $both_btns
2414
+	 * @throws EE_Error
2415
+	 * @throws InvalidArgumentException
2416
+	 * @throws InvalidDataTypeException
2417
+	 * @throws InvalidInterfaceException
2418
+	 * @see   $this->_set_publish_post_box_vars for param details
2419
+	 * @since 4.6.0
2420
+	 */
2421
+	public function set_publish_post_box_vars(
2422
+		$name = '',
2423
+		$id = 0,
2424
+		$delete = false,
2425
+		$save_close_redirect_URL = '',
2426
+		$both_btns = true
2427
+	) {
2428
+		$this->_set_publish_post_box_vars(
2429
+			$name,
2430
+			$id,
2431
+			$delete,
2432
+			$save_close_redirect_URL,
2433
+			$both_btns
2434
+		);
2435
+	}
2436
+
2437
+
2438
+	/**
2439
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2440
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2441
+	 * save, and save and close buttons to work properly, then you will want to include a
2442
+	 * values for the name and id arguments.
2443
+	 *
2444
+	 * @param string  $name                       key used for the action ID (i.e. event_id)
2445
+	 * @param int     $id                         id attached to the item published
2446
+	 * @param string  $delete                     page route callback for the delete action
2447
+	 * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2448
+	 * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2449
+	 *                                            the Save button
2450
+	 * @throws EE_Error
2451
+	 * @throws InvalidArgumentException
2452
+	 * @throws InvalidDataTypeException
2453
+	 * @throws InvalidInterfaceException
2454
+	 * @todo  Add in validation for name/id arguments.
2455
+	 */
2456
+	protected function _set_publish_post_box_vars(
2457
+		$name = '',
2458
+		$id = 0,
2459
+		$delete = '',
2460
+		$save_close_redirect_URL = '',
2461
+		$both_btns = true
2462
+	) {
2463
+		// if Save & Close, use a custom redirect URL or default to the main page?
2464
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2465
+			? $save_close_redirect_URL
2466
+			: $this->_admin_base_url;
2467
+		// create the Save & Close and Save buttons
2468
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2469
+		// if we have extra content set let's add it in if not make sure its empty
2470
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2471
+			? $this->_template_args['publish_box_extra_content']
2472
+			: '';
2473
+		if ($delete && ! empty($id)) {
2474
+			// make sure we have a default if just true is sent.
2475
+			$delete           = ! empty($delete) ? $delete : 'delete';
2476
+			$delete_link_args = [$name => $id];
2477
+			$delete           = $this->get_action_link_or_button(
2478
+				$delete,
2479
+				$delete,
2480
+				$delete_link_args,
2481
+				'submitdelete deletion',
2482
+				'',
2483
+				false
2484
+			);
2485
+		}
2486
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2487
+		if (! empty($name) && ! empty($id)) {
2488
+			$hidden_field_arr[ $name ] = [
2489
+				'type'  => 'hidden',
2490
+				'value' => $id,
2491
+			];
2492
+			$hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2493
+		} else {
2494
+			$hf = '';
2495
+		}
2496
+		// add hidden field
2497
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2498
+			? $hf[ $name ]['field']
2499
+			: $hf;
2500
+	}
2501
+
2502
+
2503
+	/**
2504
+	 * displays an error message to ppl who have javascript disabled
2505
+	 *
2506
+	 * @return void
2507
+	 */
2508
+	private function _display_no_javascript_warning()
2509
+	{
2510
+		?>
2511 2511
         <noscript>
2512 2512
             <div id="no-js-message" class="error">
2513 2513
                 <p style="font-size:1.3em;">
2514 2514
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2515 2515
                     <?php esc_html_e(
2516
-                        'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2517
-                        'event_espresso'
2518
-                    ); ?>
2516
+						'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2517
+						'event_espresso'
2518
+					); ?>
2519 2519
                 </p>
2520 2520
             </div>
2521 2521
         </noscript>
2522 2522
         <?php
2523
-    }
2524
-
2525
-
2526
-    /**
2527
-     * displays espresso success and/or error notices
2528
-     *
2529
-     * @return void
2530
-     */
2531
-    protected function _display_espresso_notices()
2532
-    {
2533
-        $notices = $this->_get_transient(true);
2534
-        echo stripslashes($notices);
2535
-    }
2536
-
2537
-
2538
-    /**
2539
-     * spinny things pacify the masses
2540
-     *
2541
-     * @return void
2542
-     */
2543
-    protected function _add_admin_page_ajax_loading_img()
2544
-    {
2545
-        ?>
2523
+	}
2524
+
2525
+
2526
+	/**
2527
+	 * displays espresso success and/or error notices
2528
+	 *
2529
+	 * @return void
2530
+	 */
2531
+	protected function _display_espresso_notices()
2532
+	{
2533
+		$notices = $this->_get_transient(true);
2534
+		echo stripslashes($notices);
2535
+	}
2536
+
2537
+
2538
+	/**
2539
+	 * spinny things pacify the masses
2540
+	 *
2541
+	 * @return void
2542
+	 */
2543
+	protected function _add_admin_page_ajax_loading_img()
2544
+	{
2545
+		?>
2546 2546
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2547 2547
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2548
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2548
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2549 2549
         </div>
2550 2550
         <?php
2551
-    }
2551
+	}
2552 2552
 
2553 2553
 
2554
-    /**
2555
-     * add admin page overlay for modal boxes
2556
-     *
2557
-     * @return void
2558
-     */
2559
-    protected function _add_admin_page_overlay()
2560
-    {
2561
-        ?>
2554
+	/**
2555
+	 * add admin page overlay for modal boxes
2556
+	 *
2557
+	 * @return void
2558
+	 */
2559
+	protected function _add_admin_page_overlay()
2560
+	{
2561
+		?>
2562 2562
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2563 2563
         <?php
2564
-    }
2565
-
2566
-
2567
-    /**
2568
-     * facade for add_meta_box
2569
-     *
2570
-     * @param string  $action        where the metabox gets displayed
2571
-     * @param string  $title         Title of Metabox (output in metabox header)
2572
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2573
-     *                               instead of the one created in here.
2574
-     * @param array   $callback_args an array of args supplied for the metabox
2575
-     * @param string  $column        what metabox column
2576
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2577
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2578
-     *                               created but just set our own callback for wp's add_meta_box.
2579
-     * @throws DomainException
2580
-     */
2581
-    public function _add_admin_page_meta_box(
2582
-        $action,
2583
-        $title,
2584
-        $callback,
2585
-        $callback_args,
2586
-        $column = 'normal',
2587
-        $priority = 'high',
2588
-        $create_func = true
2589
-    ) {
2590
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2591
-        // 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.
2592
-        if (empty($callback_args) && $create_func) {
2593
-            $callback_args = [
2594
-                'template_path' => $this->_template_path,
2595
-                'template_args' => $this->_template_args,
2596
-            ];
2597
-        }
2598
-        // 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)
2599
-        $call_back_func = $create_func
2600
-            ? function ($post, $metabox) {
2601
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2602
-                echo EEH_Template::display_template(
2603
-                    $metabox['args']['template_path'],
2604
-                    $metabox['args']['template_args'],
2605
-                    true
2606
-                );
2607
-            }
2608
-            : $callback;
2609
-        add_meta_box(
2610
-            str_replace('_', '-', $action) . '-mbox',
2611
-            $title,
2612
-            $call_back_func,
2613
-            $this->_wp_page_slug,
2614
-            $column,
2615
-            $priority,
2616
-            $callback_args
2617
-        );
2618
-    }
2619
-
2620
-
2621
-    /**
2622
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2623
-     *
2624
-     * @throws DomainException
2625
-     * @throws EE_Error
2626
-     */
2627
-    public function display_admin_page_with_metabox_columns()
2628
-    {
2629
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2630
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2631
-            $this->_column_template_path,
2632
-            $this->_template_args,
2633
-            true
2634
-        );
2635
-        // the final wrapper
2636
-        $this->admin_page_wrapper();
2637
-    }
2638
-
2639
-
2640
-    /**
2641
-     * generates  HTML wrapper for an admin details page
2642
-     *
2643
-     * @return void
2644
-     * @throws EE_Error
2645
-     * @throws DomainException
2646
-     */
2647
-    public function display_admin_page_with_sidebar()
2648
-    {
2649
-        $this->_display_admin_page(true);
2650
-    }
2651
-
2652
-
2653
-    /**
2654
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2655
-     *
2656
-     * @return void
2657
-     * @throws EE_Error
2658
-     * @throws DomainException
2659
-     */
2660
-    public function display_admin_page_with_no_sidebar()
2661
-    {
2662
-        $this->_display_admin_page();
2663
-    }
2664
-
2665
-
2666
-    /**
2667
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2668
-     *
2669
-     * @return void
2670
-     * @throws EE_Error
2671
-     * @throws DomainException
2672
-     */
2673
-    public function display_about_admin_page()
2674
-    {
2675
-        $this->_display_admin_page(false, true);
2676
-    }
2677
-
2678
-
2679
-    /**
2680
-     * display_admin_page
2681
-     * contains the code for actually displaying an admin page
2682
-     *
2683
-     * @param boolean $sidebar true with sidebar, false without
2684
-     * @param boolean $about   use the about_admin_wrapper instead of the default.
2685
-     * @return void
2686
-     * @throws DomainException
2687
-     * @throws EE_Error
2688
-     */
2689
-    private function _display_admin_page($sidebar = false, $about = false)
2690
-    {
2691
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2692
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2693
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2694
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2695
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2696
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2697
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2698
-            ? 'poststuff'
2699
-            : 'espresso-default-admin';
2700
-        $template_path                                     = $sidebar
2701
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2702
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2703
-        if ($this->request->isAjax()) {
2704
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2705
-        }
2706
-        $template_path                                     = ! empty($this->_column_template_path)
2707
-            ? $this->_column_template_path : $template_path;
2708
-        $this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2709
-            ? $this->_template_args['admin_page_content']
2710
-            : '';
2711
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2712
-            ? $this->_template_args['before_admin_page_content']
2713
-            : '';
2714
-        $this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2715
-            ? $this->_template_args['after_admin_page_content']
2716
-            : '';
2717
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2718
-            $template_path,
2719
-            $this->_template_args,
2720
-            true
2721
-        );
2722
-        // the final template wrapper
2723
-        $this->admin_page_wrapper($about);
2724
-    }
2725
-
2726
-
2727
-    /**
2728
-     * This is used to display caf preview pages.
2729
-     *
2730
-     * @param string $utm_campaign_source what is the key used for google analytics link
2731
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2732
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2733
-     * @return void
2734
-     * @throws DomainException
2735
-     * @throws EE_Error
2736
-     * @throws InvalidArgumentException
2737
-     * @throws InvalidDataTypeException
2738
-     * @throws InvalidInterfaceException
2739
-     * @since 4.3.2
2740
-     */
2741
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2742
-    {
2743
-        // let's generate a default preview action button if there isn't one already present.
2744
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2745
-            'Upgrade to Event Espresso 4 Right Now',
2746
-            'event_espresso'
2747
-        );
2748
-        $buy_now_url                                   = add_query_arg(
2749
-            [
2750
-                'ee_ver'       => 'ee4',
2751
-                'utm_source'   => 'ee4_plugin_admin',
2752
-                'utm_medium'   => 'link',
2753
-                'utm_campaign' => $utm_campaign_source,
2754
-                'utm_content'  => 'buy_now_button',
2755
-            ],
2756
-            'https://eventespresso.com/pricing/'
2757
-        );
2758
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2759
-            ? $this->get_action_link_or_button(
2760
-                '',
2761
-                'buy_now',
2762
-                [],
2763
-                'button-primary button-large',
2764
-                esc_url_raw($buy_now_url),
2765
-                true
2766
-            )
2767
-            : $this->_template_args['preview_action_button'];
2768
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2769
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2770
-            $this->_template_args,
2771
-            true
2772
-        );
2773
-        $this->_display_admin_page($display_sidebar);
2774
-    }
2775
-
2776
-
2777
-    /**
2778
-     * display_admin_list_table_page_with_sidebar
2779
-     * generates HTML wrapper for an admin_page with list_table
2780
-     *
2781
-     * @return void
2782
-     * @throws EE_Error
2783
-     * @throws DomainException
2784
-     */
2785
-    public function display_admin_list_table_page_with_sidebar()
2786
-    {
2787
-        $this->_display_admin_list_table_page(true);
2788
-    }
2789
-
2790
-
2791
-    /**
2792
-     * display_admin_list_table_page_with_no_sidebar
2793
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2794
-     *
2795
-     * @return void
2796
-     * @throws EE_Error
2797
-     * @throws DomainException
2798
-     */
2799
-    public function display_admin_list_table_page_with_no_sidebar()
2800
-    {
2801
-        $this->_display_admin_list_table_page();
2802
-    }
2803
-
2804
-
2805
-    /**
2806
-     * generates html wrapper for an admin_list_table page
2807
-     *
2808
-     * @param boolean $sidebar whether to display with sidebar or not.
2809
-     * @return void
2810
-     * @throws DomainException
2811
-     * @throws EE_Error
2812
-     */
2813
-    private function _display_admin_list_table_page($sidebar = false)
2814
-    {
2815
-        // setup search attributes
2816
-        $this->_set_search_attributes();
2817
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
2818
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2819
-        $this->_template_args['table_url']        = $this->request->isAjax()
2820
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2821
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2822
-        $this->_template_args['list_table']       = $this->_list_table_object;
2823
-        $this->_template_args['current_route']    = $this->_req_action;
2824
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2825
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2826
-        if (! empty($ajax_sorting_callback)) {
2827
-            $sortable_list_table_form_fields = wp_nonce_field(
2828
-                $ajax_sorting_callback . '_nonce',
2829
-                $ajax_sorting_callback . '_nonce',
2830
-                false,
2831
-                false
2832
-            );
2833
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2834
-                                                . $this->page_slug
2835
-                                                . '" />';
2836
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2837
-                                                . $ajax_sorting_callback
2838
-                                                . '" />';
2839
-        } else {
2840
-            $sortable_list_table_form_fields = '';
2841
-        }
2842
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2843
-        $hidden_form_fields                                      =
2844
-            isset($this->_template_args['list_table_hidden_fields'])
2845
-                ? $this->_template_args['list_table_hidden_fields']
2846
-                : '';
2847
-        $nonce_ref                                               = $this->_req_action . '_nonce';
2848
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
2849
-                                                                    . $nonce_ref
2850
-                                                                    . '" value="'
2851
-                                                                    . wp_create_nonce($nonce_ref)
2852
-                                                                    . '">';
2853
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2854
-        // display message about search results?
2855
-        $search = $this->request->getRequestParam('s');
2856
-        $this->_template_args['before_list_table'] .= ! empty($search)
2857
-            ? '<p class="ee-search-results">' . sprintf(
2858
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2859
-                trim($search, '%')
2860
-            ) . '</p>'
2861
-            : '';
2862
-        // filter before_list_table template arg
2863
-        $this->_template_args['before_list_table'] = apply_filters(
2864
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2865
-            $this->_template_args['before_list_table'],
2866
-            $this->page_slug,
2867
-            $this->request->requestParams(),
2868
-            $this->_req_action
2869
-        );
2870
-        // convert to array and filter again
2871
-        // arrays are easier to inject new items in a specific location,
2872
-        // but would not be backwards compatible, so we have to add a new filter
2873
-        $this->_template_args['before_list_table'] = implode(
2874
-            " \n",
2875
-            (array) apply_filters(
2876
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2877
-                (array) $this->_template_args['before_list_table'],
2878
-                $this->page_slug,
2879
-                $this->request->requestParams(),
2880
-                $this->_req_action
2881
-            )
2882
-        );
2883
-        // filter after_list_table template arg
2884
-        $this->_template_args['after_list_table'] = apply_filters(
2885
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2886
-            $this->_template_args['after_list_table'],
2887
-            $this->page_slug,
2888
-            $this->request->requestParams(),
2889
-            $this->_req_action
2890
-        );
2891
-        // convert to array and filter again
2892
-        // arrays are easier to inject new items in a specific location,
2893
-        // but would not be backwards compatible, so we have to add a new filter
2894
-        $this->_template_args['after_list_table']   = implode(
2895
-            " \n",
2896
-            (array) apply_filters(
2897
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2898
-                (array) $this->_template_args['after_list_table'],
2899
-                $this->page_slug,
2900
-                $this->request->requestParams(),
2901
-                $this->_req_action
2902
-            )
2903
-        );
2904
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2905
-            $template_path,
2906
-            $this->_template_args,
2907
-            true
2908
-        );
2909
-        // the final template wrapper
2910
-        if ($sidebar) {
2911
-            $this->display_admin_page_with_sidebar();
2912
-        } else {
2913
-            $this->display_admin_page_with_no_sidebar();
2914
-        }
2915
-    }
2916
-
2917
-
2918
-    /**
2919
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2920
-     * html string for the legend.
2921
-     * $items are expected in an array in the following format:
2922
-     * $legend_items = array(
2923
-     *        'item_id' => array(
2924
-     *            'icon' => 'http://url_to_icon_being_described.png',
2925
-     *            'desc' => esc_html__('localized description of item');
2926
-     *        )
2927
-     * );
2928
-     *
2929
-     * @param array $items see above for format of array
2930
-     * @return string html string of legend
2931
-     * @throws DomainException
2932
-     */
2933
-    protected function _display_legend($items)
2934
-    {
2935
-        $this->_template_args['items'] = apply_filters(
2936
-            'FHEE__EE_Admin_Page___display_legend__items',
2937
-            (array) $items,
2938
-            $this
2939
-        );
2940
-        return EEH_Template::display_template(
2941
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2942
-            $this->_template_args,
2943
-            true
2944
-        );
2945
-    }
2946
-
2947
-
2948
-    /**
2949
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2950
-     * The returned json object is created from an array in the following format:
2951
-     * array(
2952
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2953
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
2954
-     *  'notices' => '', // - contains any EE_Error formatted notices
2955
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
2956
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
2957
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
2958
-     *  that might be included in here)
2959
-     * )
2960
-     * The json object is populated by whatever is set in the $_template_args property.
2961
-     *
2962
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
2963
-     *                                 instead of displayed.
2964
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
2965
-     * @return void
2966
-     * @throws EE_Error
2967
-     */
2968
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
2969
-    {
2970
-        // make sure any EE_Error notices have been handled.
2971
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
2972
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
2973
-        unset($this->_template_args['data']);
2974
-        $json = [
2975
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2976
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2977
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2978
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2979
-            'notices'   => EE_Error::get_notices(),
2980
-            'content'   => isset($this->_template_args['admin_page_content'])
2981
-                ? $this->_template_args['admin_page_content'] : '',
2982
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
2983
-            'isEEajax'  => true
2984
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2985
-        ];
2986
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
2987
-        if (null === error_get_last() || ! headers_sent()) {
2988
-            header('Content-Type: application/json; charset=UTF-8');
2989
-        }
2990
-        echo wp_json_encode($json);
2991
-        exit();
2992
-    }
2993
-
2994
-
2995
-    /**
2996
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2997
-     *
2998
-     * @return void
2999
-     * @throws EE_Error
3000
-     */
3001
-    public function return_json()
3002
-    {
3003
-        if ($this->request->isAjax()) {
3004
-            $this->_return_json();
3005
-        } else {
3006
-            throw new EE_Error(
3007
-                sprintf(
3008
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3009
-                    __FUNCTION__
3010
-                )
3011
-            );
3012
-        }
3013
-    }
3014
-
3015
-
3016
-    /**
3017
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3018
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3019
-     *
3020
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3021
-     */
3022
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3023
-    {
3024
-        $this->_hook_obj = $hook_obj;
3025
-    }
3026
-
3027
-
3028
-    /**
3029
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3030
-     *
3031
-     * @param boolean $about whether to use the special about page wrapper or default.
3032
-     * @return void
3033
-     * @throws DomainException
3034
-     * @throws EE_Error
3035
-     */
3036
-    public function admin_page_wrapper($about = false)
3037
-    {
3038
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3039
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3040
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3041
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3042
-
3043
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3044
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3045
-            isset($this->_template_args['before_admin_page_content'])
3046
-                ? $this->_template_args['before_admin_page_content']
3047
-                : ''
3048
-        );
3049
-
3050
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3051
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3052
-            isset($this->_template_args['after_admin_page_content'])
3053
-                ? $this->_template_args['after_admin_page_content']
3054
-                : ''
3055
-        );
3056
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3057
-
3058
-        if ($this->request->isAjax()) {
3059
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3060
-                // $template_path,
3061
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3062
-                $this->_template_args,
3063
-                true
3064
-            );
3065
-            $this->_return_json();
3066
-        }
3067
-        // load settings page wrapper template
3068
-        $template_path = $about
3069
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3070
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3071
-
3072
-        EEH_Template::display_template($template_path, $this->_template_args);
3073
-    }
3074
-
3075
-
3076
-    /**
3077
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3078
-     *
3079
-     * @return string html
3080
-     * @throws EE_Error
3081
-     */
3082
-    protected function _get_main_nav_tabs()
3083
-    {
3084
-        // let's generate the html using the EEH_Tabbed_Content helper.
3085
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3086
-        // (rather than setting in the page_routes array)
3087
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3088
-    }
3089
-
3090
-
3091
-    /**
3092
-     *        sort nav tabs
3093
-     *
3094
-     * @param $a
3095
-     * @param $b
3096
-     * @return int
3097
-     */
3098
-    private function _sort_nav_tabs($a, $b)
3099
-    {
3100
-        if ($a['order'] === $b['order']) {
3101
-            return 0;
3102
-        }
3103
-        return ($a['order'] < $b['order']) ? -1 : 1;
3104
-    }
3105
-
3106
-
3107
-    /**
3108
-     *    generates HTML for the forms used on admin pages
3109
-     *
3110
-     * @param array  $input_vars   - array of input field details
3111
-     * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3112
-     *                             use)
3113
-     * @param bool   $id
3114
-     * @return array|string
3115
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3116
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3117
-     */
3118
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3119
-    {
3120
-        return $generator === 'string'
3121
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3122
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3123
-    }
3124
-
3125
-
3126
-    /**
3127
-     * generates the "Save" and "Save & Close" buttons for edit forms
3128
-     *
3129
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3130
-     *                                   Close" button.
3131
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3132
-     *                                   'Save', [1] => 'save & close')
3133
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3134
-     *                                   via the "name" value in the button).  We can also use this to just dump
3135
-     *                                   default actions by submitting some other value.
3136
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3137
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3138
-     *                                   close (normal form handling).
3139
-     */
3140
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3141
-    {
3142
-        // make sure $text and $actions are in an array
3143
-        $text          = (array) $text;
3144
-        $actions       = (array) $actions;
3145
-        $referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3146
-        $button_text   = ! empty($text)
3147
-            ? $text
3148
-            : [
3149
-                esc_html__('Save', 'event_espresso'),
3150
-                esc_html__('Save and Close', 'event_espresso'),
3151
-            ];
3152
-        $default_names = ['save', 'save_and_close'];
3153
-        $buttons = '';
3154
-        foreach ($button_text as $key => $button) {
3155
-            $ref     = $default_names[ $key ];
3156
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3157
-            $buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3158
-                        . 'value="' . $button . '" name="' . $name . '" '
3159
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3160
-            if (! $both) {
3161
-                break;
3162
-            }
3163
-        }
3164
-        // add in a hidden index for the current page (so save and close redirects properly)
3165
-        $buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3166
-                   . $referrer_url
3167
-                   . '" />';
3168
-        $this->_template_args['save_buttons'] = $buttons;
3169
-    }
3170
-
3171
-
3172
-    /**
3173
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3174
-     *
3175
-     * @param string $route
3176
-     * @param array  $additional_hidden_fields
3177
-     * @see   $this->_set_add_edit_form_tags() for details on params
3178
-     * @since 4.6.0
3179
-     */
3180
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3181
-    {
3182
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3183
-    }
3184
-
3185
-
3186
-    /**
3187
-     * set form open and close tags on add/edit pages.
3188
-     *
3189
-     * @param string $route                    the route you want the form to direct to
3190
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3191
-     * @return void
3192
-     */
3193
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3194
-    {
3195
-        if (empty($route)) {
3196
-            $user_msg = esc_html__(
3197
-                'An error occurred. No action was set for this page\'s form.',
3198
-                'event_espresso'
3199
-            );
3200
-            $dev_msg  = $user_msg . "\n"
3201
-                        . sprintf(
3202
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3203
-                            __FUNCTION__,
3204
-                            __CLASS__
3205
-                        );
3206
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3207
-        }
3208
-        // open form
3209
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3210
-                                                             . $this->_admin_base_url
3211
-                                                             . '" id="'
3212
-                                                             . $route
3213
-                                                             . '_event_form" >';
3214
-        // add nonce
3215
-        $nonce                                             =
3216
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3217
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3218
-        // add REQUIRED form action
3219
-        $hidden_fields = [
3220
-            'action' => ['type' => 'hidden', 'value' => $route],
3221
-        ];
3222
-        // merge arrays
3223
-        $hidden_fields = is_array($additional_hidden_fields)
3224
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3225
-            : $hidden_fields;
3226
-        // generate form fields
3227
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3228
-        // add fields to form
3229
-        foreach ((array) $form_fields as $form_field) {
3230
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3231
-        }
3232
-        // close form
3233
-        $this->_template_args['after_admin_page_content'] = '</form>';
3234
-    }
3235
-
3236
-
3237
-    /**
3238
-     * Public Wrapper for _redirect_after_action() method since its
3239
-     * discovered it would be useful for external code to have access.
3240
-     *
3241
-     * @param bool   $success
3242
-     * @param string $what
3243
-     * @param string $action_desc
3244
-     * @param array  $query_args
3245
-     * @param bool   $override_overwrite
3246
-     * @throws EE_Error
3247
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3248
-     * @since 4.5.0
3249
-     */
3250
-    public function redirect_after_action(
3251
-        $success = false,
3252
-        $what = 'item',
3253
-        $action_desc = 'processed',
3254
-        $query_args = [],
3255
-        $override_overwrite = false
3256
-    ) {
3257
-        $this->_redirect_after_action(
3258
-            $success,
3259
-            $what,
3260
-            $action_desc,
3261
-            $query_args,
3262
-            $override_overwrite
3263
-        );
3264
-    }
3265
-
3266
-
3267
-    /**
3268
-     * Helper method for merging existing request data with the returned redirect url.
3269
-     *
3270
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3271
-     * filters are still applied.
3272
-     *
3273
-     * @param array $new_route_data
3274
-     * @return array
3275
-     */
3276
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3277
-    {
3278
-        foreach ($this->request->requestParams() as $ref => $value) {
3279
-            // unset nonces
3280
-            if (strpos($ref, 'nonce') !== false) {
3281
-                $this->request->unSetRequestParam($ref);
3282
-                continue;
3283
-            }
3284
-            // urlencode values.
3285
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3286
-            $this->request->setRequestParam($ref, $value);
3287
-        }
3288
-        return array_merge($this->request->requestParams(), $new_route_data);
3289
-    }
3290
-
3291
-
3292
-    /**
3293
-     *    _redirect_after_action
3294
-     *
3295
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3296
-     * @param string $what               - what the action was performed on
3297
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3298
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3299
-     *                                   action is completed
3300
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3301
-     *                                   override this so that they show.
3302
-     * @return void
3303
-     * @throws EE_Error
3304
-     */
3305
-    protected function _redirect_after_action(
3306
-        $success = 0,
3307
-        $what = 'item',
3308
-        $action_desc = 'processed',
3309
-        $query_args = [],
3310
-        $override_overwrite = false
3311
-    ) {
3312
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3313
-        // class name for actions/filters.
3314
-        $classname = get_class($this);
3315
-        // set redirect url.
3316
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3317
-        // otherwise we go with whatever is set as the _admin_base_url
3318
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3319
-        $notices      = EE_Error::get_notices(false);
3320
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3321
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3322
-            EE_Error::overwrite_success();
3323
-        }
3324
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3325
-            // how many records affected ? more than one record ? or just one ?
3326
-            if ($success > 1) {
3327
-                // set plural msg
3328
-                EE_Error::add_success(
3329
-                    sprintf(
3330
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3331
-                        $what,
3332
-                        $action_desc
3333
-                    ),
3334
-                    __FILE__,
3335
-                    __FUNCTION__,
3336
-                    __LINE__
3337
-                );
3338
-            } elseif ($success === 1) {
3339
-                // set singular msg
3340
-                EE_Error::add_success(
3341
-                    sprintf(
3342
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3343
-                        $what,
3344
-                        $action_desc
3345
-                    ),
3346
-                    __FILE__,
3347
-                    __FUNCTION__,
3348
-                    __LINE__
3349
-                );
3350
-            }
3351
-        }
3352
-        // check that $query_args isn't something crazy
3353
-        if (! is_array($query_args)) {
3354
-            $query_args = [];
3355
-        }
3356
-        /**
3357
-         * Allow injecting actions before the query_args are modified for possible different
3358
-         * redirections on save and close actions
3359
-         *
3360
-         * @param array $query_args       The original query_args array coming into the
3361
-         *                                method.
3362
-         * @since 4.2.0
3363
-         */
3364
-        do_action(
3365
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3366
-            $query_args
3367
-        );
3368
-        // calculate where we're going (if we have a "save and close" button pushed)
3369
-
3370
-        if (
3371
-            $this->request->requestParamIsSet('save_and_close')
3372
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3373
-        ) {
3374
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3375
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3376
-            // regenerate query args array from referrer URL
3377
-            parse_str($parsed_url['query'], $query_args);
3378
-            // correct page and action will be in the query args now
3379
-            $redirect_url = admin_url('admin.php');
3380
-        }
3381
-        // merge any default query_args set in _default_route_query_args property
3382
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3383
-            $args_to_merge = [];
3384
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3385
-                // is there a wp_referer array in our _default_route_query_args property?
3386
-                if ($query_param === 'wp_referer') {
3387
-                    $query_value = (array) $query_value;
3388
-                    foreach ($query_value as $reference => $value) {
3389
-                        if (strpos($reference, 'nonce') !== false) {
3390
-                            continue;
3391
-                        }
3392
-                        // finally we will override any arguments in the referer with
3393
-                        // what might be set on the _default_route_query_args array.
3394
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3395
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3396
-                        } else {
3397
-                            $args_to_merge[ $reference ] = urlencode($value);
3398
-                        }
3399
-                    }
3400
-                    continue;
3401
-                }
3402
-                $args_to_merge[ $query_param ] = $query_value;
3403
-            }
3404
-            // now let's merge these arguments but override with what was specifically sent in to the
3405
-            // redirect.
3406
-            $query_args = array_merge($args_to_merge, $query_args);
3407
-        }
3408
-        $this->_process_notices($query_args);
3409
-        // generate redirect url
3410
-        // if redirecting to anything other than the main page, add a nonce
3411
-        if (isset($query_args['action'])) {
3412
-            // manually generate wp_nonce and merge that with the query vars
3413
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3414
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3415
-        }
3416
-        // we're adding some hooks and filters in here for processing any things just before redirects
3417
-        // (example: an admin page has done an insert or update and we want to run something after that).
3418
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3419
-        $redirect_url = apply_filters(
3420
-            'FHEE_redirect_' . $classname . $this->_req_action,
3421
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3422
-            $query_args
3423
-        );
3424
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3425
-        if ($this->request->isAjax()) {
3426
-            $default_data                    = [
3427
-                'close'        => true,
3428
-                'redirect_url' => $redirect_url,
3429
-                'where'        => 'main',
3430
-                'what'         => 'append',
3431
-            ];
3432
-            $this->_template_args['success'] = $success;
3433
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3434
-                $default_data,
3435
-                $this->_template_args['data']
3436
-            ) : $default_data;
3437
-            $this->_return_json();
3438
-        }
3439
-        wp_safe_redirect($redirect_url);
3440
-        exit();
3441
-    }
3442
-
3443
-
3444
-    /**
3445
-     * process any notices before redirecting (or returning ajax request)
3446
-     * This method sets the $this->_template_args['notices'] attribute;
3447
-     *
3448
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3449
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3450
-     *                                  page_routes haven't been defined yet.
3451
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3452
-     *                                  still save a transient for the notice.
3453
-     * @return void
3454
-     * @throws EE_Error
3455
-     */
3456
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3457
-    {
3458
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3459
-        if ($this->request->isAjax()) {
3460
-            $notices = EE_Error::get_notices(false);
3461
-            if (empty($this->_template_args['success'])) {
3462
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3463
-            }
3464
-            if (empty($this->_template_args['errors'])) {
3465
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3466
-            }
3467
-            if (empty($this->_template_args['attention'])) {
3468
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3469
-            }
3470
-        }
3471
-        $this->_template_args['notices'] = EE_Error::get_notices();
3472
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3473
-        if (! $this->request->isAjax() || $sticky_notices) {
3474
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3475
-            $this->_add_transient(
3476
-                $route,
3477
-                $this->_template_args['notices'],
3478
-                true,
3479
-                $skip_route_verify
3480
-            );
3481
-        }
3482
-    }
3483
-
3484
-
3485
-    /**
3486
-     * get_action_link_or_button
3487
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3488
-     *
3489
-     * @param string $action        use this to indicate which action the url is generated with.
3490
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3491
-     *                              property.
3492
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3493
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3494
-     * @param string $base_url      If this is not provided
3495
-     *                              the _admin_base_url will be used as the default for the button base_url.
3496
-     *                              Otherwise this value will be used.
3497
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3498
-     * @return string
3499
-     * @throws InvalidArgumentException
3500
-     * @throws InvalidInterfaceException
3501
-     * @throws InvalidDataTypeException
3502
-     * @throws EE_Error
3503
-     */
3504
-    public function get_action_link_or_button(
3505
-        $action,
3506
-        $type = 'add',
3507
-        $extra_request = [],
3508
-        $class = 'button-primary',
3509
-        $base_url = '',
3510
-        $exclude_nonce = false
3511
-    ) {
3512
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3513
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3514
-            throw new EE_Error(
3515
-                sprintf(
3516
-                    esc_html__(
3517
-                        'There is no page route for given action for the button.  This action was given: %s',
3518
-                        'event_espresso'
3519
-                    ),
3520
-                    $action
3521
-                )
3522
-            );
3523
-        }
3524
-        if (! isset($this->_labels['buttons'][ $type ])) {
3525
-            throw new EE_Error(
3526
-                sprintf(
3527
-                    esc_html__(
3528
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3529
-                        'event_espresso'
3530
-                    ),
3531
-                    $type
3532
-                )
3533
-            );
3534
-        }
3535
-        // finally check user access for this button.
3536
-        $has_access = $this->check_user_access($action, true);
3537
-        if (! $has_access) {
3538
-            return '';
3539
-        }
3540
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3541
-        $query_args = [
3542
-            'action' => $action,
3543
-        ];
3544
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3545
-        if (! empty($extra_request)) {
3546
-            $query_args = array_merge($extra_request, $query_args);
3547
-        }
3548
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3549
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3550
-    }
3551
-
3552
-
3553
-    /**
3554
-     * _per_page_screen_option
3555
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3556
-     *
3557
-     * @return void
3558
-     * @throws InvalidArgumentException
3559
-     * @throws InvalidInterfaceException
3560
-     * @throws InvalidDataTypeException
3561
-     */
3562
-    protected function _per_page_screen_option()
3563
-    {
3564
-        $option = 'per_page';
3565
-        $args   = [
3566
-            'label'   => apply_filters(
3567
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3568
-                $this->_admin_page_title,
3569
-                $this
3570
-            ),
3571
-            'default' => (int) apply_filters(
3572
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3573
-                20
3574
-            ),
3575
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3576
-        ];
3577
-        // ONLY add the screen option if the user has access to it.
3578
-        if ($this->check_user_access($this->_current_view, true)) {
3579
-            add_screen_option($option, $args);
3580
-        }
3581
-    }
3582
-
3583
-
3584
-    /**
3585
-     * set_per_page_screen_option
3586
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3587
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3588
-     * admin_menu.
3589
-     *
3590
-     * @return void
3591
-     */
3592
-    private function _set_per_page_screen_options()
3593
-    {
3594
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3595
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3596
-            if (! $user = wp_get_current_user()) {
3597
-                return;
3598
-            }
3599
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3600
-            if (! $option) {
3601
-                return;
3602
-            }
3603
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3604
-            $map_option = $option;
3605
-            $option     = str_replace('-', '_', $option);
3606
-            switch ($map_option) {
3607
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3608
-                    $max_value = apply_filters(
3609
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3610
-                        999,
3611
-                        $this->_current_page,
3612
-                        $this->_current_view
3613
-                    );
3614
-                    if ($value < 1) {
3615
-                        return;
3616
-                    }
3617
-                    $value = min($value, $max_value);
3618
-                    break;
3619
-                default:
3620
-                    $value = apply_filters(
3621
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3622
-                        false,
3623
-                        $option,
3624
-                        $value
3625
-                    );
3626
-                    if (false === $value) {
3627
-                        return;
3628
-                    }
3629
-                    break;
3630
-            }
3631
-            update_user_meta($user->ID, $option, $value);
3632
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3633
-            exit;
3634
-        }
3635
-    }
3636
-
3637
-
3638
-    /**
3639
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3640
-     *
3641
-     * @param array $data array that will be assigned to template args.
3642
-     */
3643
-    public function set_template_args($data)
3644
-    {
3645
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3646
-    }
3647
-
3648
-
3649
-    /**
3650
-     * This makes available the WP transient system for temporarily moving data between routes
3651
-     *
3652
-     * @param string $route             the route that should receive the transient
3653
-     * @param array  $data              the data that gets sent
3654
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3655
-     *                                  normal route transient.
3656
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3657
-     *                                  when we are adding a transient before page_routes have been defined.
3658
-     * @return void
3659
-     * @throws EE_Error
3660
-     */
3661
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3662
-    {
3663
-        $user_id = get_current_user_id();
3664
-        if (! $skip_route_verify) {
3665
-            $this->_verify_route($route);
3666
-        }
3667
-        // now let's set the string for what kind of transient we're setting
3668
-        $transient = $notices
3669
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3670
-            : 'rte_tx_' . $route . '_' . $user_id;
3671
-        $data      = $notices ? ['notices' => $data] : $data;
3672
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3673
-        $existing = is_multisite() && is_network_admin()
3674
-            ? get_site_transient($transient)
3675
-            : get_transient($transient);
3676
-        if ($existing) {
3677
-            $data = array_merge((array) $data, (array) $existing);
3678
-        }
3679
-        if (is_multisite() && is_network_admin()) {
3680
-            set_site_transient($transient, $data, 8);
3681
-        } else {
3682
-            set_transient($transient, $data, 8);
3683
-        }
3684
-    }
3685
-
3686
-
3687
-    /**
3688
-     * this retrieves the temporary transient that has been set for moving data between routes.
3689
-     *
3690
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3691
-     * @param string $route
3692
-     * @return mixed data
3693
-     */
3694
-    protected function _get_transient($notices = false, $route = '')
3695
-    {
3696
-        $user_id   = get_current_user_id();
3697
-        $route     = ! $route ? $this->_req_action : $route;
3698
-        $transient = $notices
3699
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3700
-            : 'rte_tx_' . $route . '_' . $user_id;
3701
-        $data      = is_multisite() && is_network_admin()
3702
-            ? get_site_transient($transient)
3703
-            : get_transient($transient);
3704
-        // delete transient after retrieval (just in case it hasn't expired);
3705
-        if (is_multisite() && is_network_admin()) {
3706
-            delete_site_transient($transient);
3707
-        } else {
3708
-            delete_transient($transient);
3709
-        }
3710
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3711
-    }
3712
-
3713
-
3714
-    /**
3715
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3716
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3717
-     * default route callback on the EE_Admin page you want it run.)
3718
-     *
3719
-     * @return void
3720
-     */
3721
-    protected function _transient_garbage_collection()
3722
-    {
3723
-        global $wpdb;
3724
-        // retrieve all existing transients
3725
-        $query =
3726
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3727
-        if ($results = $wpdb->get_results($query)) {
3728
-            foreach ($results as $result) {
3729
-                $transient = str_replace('_transient_', '', $result->option_name);
3730
-                get_transient($transient);
3731
-                if (is_multisite() && is_network_admin()) {
3732
-                    get_site_transient($transient);
3733
-                }
3734
-            }
3735
-        }
3736
-    }
3737
-
3738
-
3739
-    /**
3740
-     * get_view
3741
-     *
3742
-     * @return string content of _view property
3743
-     */
3744
-    public function get_view()
3745
-    {
3746
-        return $this->_view;
3747
-    }
3748
-
3749
-
3750
-    /**
3751
-     * getter for the protected $_views property
3752
-     *
3753
-     * @return array
3754
-     */
3755
-    public function get_views()
3756
-    {
3757
-        return $this->_views;
3758
-    }
3759
-
3760
-
3761
-    /**
3762
-     * get_current_page
3763
-     *
3764
-     * @return string _current_page property value
3765
-     */
3766
-    public function get_current_page()
3767
-    {
3768
-        return $this->_current_page;
3769
-    }
3770
-
3771
-
3772
-    /**
3773
-     * get_current_view
3774
-     *
3775
-     * @return string _current_view property value
3776
-     */
3777
-    public function get_current_view()
3778
-    {
3779
-        return $this->_current_view;
3780
-    }
3781
-
3782
-
3783
-    /**
3784
-     * get_current_screen
3785
-     *
3786
-     * @return object The current WP_Screen object
3787
-     */
3788
-    public function get_current_screen()
3789
-    {
3790
-        return $this->_current_screen;
3791
-    }
3792
-
3793
-
3794
-    /**
3795
-     * get_current_page_view_url
3796
-     *
3797
-     * @return string This returns the url for the current_page_view.
3798
-     */
3799
-    public function get_current_page_view_url()
3800
-    {
3801
-        return $this->_current_page_view_url;
3802
-    }
3803
-
3804
-
3805
-    /**
3806
-     * just returns the Request
3807
-     *
3808
-     * @return RequestInterface
3809
-     */
3810
-    public function get_request()
3811
-    {
3812
-        return $this->request;
3813
-    }
3814
-
3815
-
3816
-    /**
3817
-     * just returns the _req_data property
3818
-     *
3819
-     * @return array
3820
-     */
3821
-    public function get_request_data()
3822
-    {
3823
-        return $this->request->requestParams();
3824
-    }
3825
-
3826
-
3827
-    /**
3828
-     * returns the _req_data protected property
3829
-     *
3830
-     * @return string
3831
-     */
3832
-    public function get_req_action()
3833
-    {
3834
-        return $this->_req_action;
3835
-    }
3836
-
3837
-
3838
-    /**
3839
-     * @return bool  value of $_is_caf property
3840
-     */
3841
-    public function is_caf()
3842
-    {
3843
-        return $this->_is_caf;
3844
-    }
3845
-
3846
-
3847
-    /**
3848
-     * @return mixed
3849
-     */
3850
-    public function default_espresso_metaboxes()
3851
-    {
3852
-        return $this->_default_espresso_metaboxes;
3853
-    }
3854
-
3855
-
3856
-    /**
3857
-     * @return mixed
3858
-     */
3859
-    public function admin_base_url()
3860
-    {
3861
-        return $this->_admin_base_url;
3862
-    }
3863
-
3864
-
3865
-    /**
3866
-     * @return mixed
3867
-     */
3868
-    public function wp_page_slug()
3869
-    {
3870
-        return $this->_wp_page_slug;
3871
-    }
3872
-
3873
-
3874
-    /**
3875
-     * updates  espresso configuration settings
3876
-     *
3877
-     * @param string                   $tab
3878
-     * @param EE_Config_Base|EE_Config $config
3879
-     * @param string                   $file file where error occurred
3880
-     * @param string                   $func function  where error occurred
3881
-     * @param string                   $line line no where error occurred
3882
-     * @return boolean
3883
-     */
3884
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3885
-    {
3886
-        // remove any options that are NOT going to be saved with the config settings.
3887
-        if (isset($config->core->ee_ueip_optin)) {
3888
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3889
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3890
-            update_option('ee_ueip_has_notified', true);
3891
-        }
3892
-        // and save it (note we're also doing the network save here)
3893
-        $net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
3894
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
3895
-        if ($config_saved && $net_saved) {
3896
-            EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3897
-            return true;
3898
-        }
3899
-        EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3900
-        return false;
3901
-    }
3902
-
3903
-
3904
-    /**
3905
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3906
-     *
3907
-     * @return array
3908
-     */
3909
-    public function get_yes_no_values()
3910
-    {
3911
-        return $this->_yes_no_values;
3912
-    }
3913
-
3914
-
3915
-    protected function _get_dir()
3916
-    {
3917
-        $reflector = new ReflectionClass(get_class($this));
3918
-        return dirname($reflector->getFileName());
3919
-    }
3920
-
3921
-
3922
-    /**
3923
-     * A helper for getting a "next link".
3924
-     *
3925
-     * @param string $url   The url to link to
3926
-     * @param string $class The class to use.
3927
-     * @return string
3928
-     */
3929
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3930
-    {
3931
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3932
-    }
3933
-
3934
-
3935
-    /**
3936
-     * A helper for getting a "previous link".
3937
-     *
3938
-     * @param string $url   The url to link to
3939
-     * @param string $class The class to use.
3940
-     * @return string
3941
-     */
3942
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3943
-    {
3944
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3945
-    }
3946
-
3947
-
3948
-
3949
-
3950
-
3951
-
3952
-
3953
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3954
-
3955
-
3956
-    /**
3957
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
3958
-     * 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
3959
-     * _req_data array.
3960
-     *
3961
-     * @return bool success/fail
3962
-     * @throws EE_Error
3963
-     * @throws InvalidArgumentException
3964
-     * @throws ReflectionException
3965
-     * @throws InvalidDataTypeException
3966
-     * @throws InvalidInterfaceException
3967
-     */
3968
-    protected function _process_resend_registration()
3969
-    {
3970
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3971
-        do_action(
3972
-            'AHEE__EE_Admin_Page___process_resend_registration',
3973
-            $this->_template_args['success'],
3974
-            $this->request->requestParams()
3975
-        );
3976
-        return $this->_template_args['success'];
3977
-    }
3978
-
3979
-
3980
-    /**
3981
-     * This automatically processes any payment message notifications when manual payment has been applied.
3982
-     *
3983
-     * @param EE_Payment $payment
3984
-     * @return bool success/fail
3985
-     */
3986
-    protected function _process_payment_notification(EE_Payment $payment)
3987
-    {
3988
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3989
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3990
-        $this->_template_args['success'] = apply_filters(
3991
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
3992
-            false,
3993
-            $payment
3994
-        );
3995
-        return $this->_template_args['success'];
3996
-    }
3997
-
3998
-
3999
-    /**
4000
-     * @param EEM_Base      $entity_model
4001
-     * @param string        $entity_PK_name name of the primary key field used as a request param, ie: id, ID, etc
4002
-     * @param string        $action         one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4003
-     * @param string        $delete_column  name of the field that denotes whether entity is trashed
4004
-     * @param callable|null $callback       called after entity is trashed, restored, or deleted
4005
-     * @return int|float
4006
-     * @throws EE_Error
4007
-     */
4008
-    protected function trashRestoreDeleteEntities(
4009
-        EEM_Base $entity_model,
4010
-        string $entity_PK_name,
4011
-        string $action = EE_Admin_List_Table::ACTION_DELETE,
4012
-        string $delete_column = '',
4013
-        callable $callback = null
4014
-    ) {
4015
-        $entity_PK      = $entity_model->get_primary_key_field();
4016
-        $entity_PK_name = $entity_PK_name ?: $entity_PK->get_name();
4017
-        $entity_PK_type = $this->resolveEntityFieldDataType($entity_PK);
4018
-        // grab ID if deleting a single entity
4019
-        if ($this->request->requestParamIsSet($entity_PK_name)) {
4020
-            $ID = $this->request->getRequestParam($entity_PK_name, 0, $entity_PK_type);
4021
-            return $this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback) ? 1 : 0;
4022
-        }
4023
-        // or grab checkbox array if bulk deleting
4024
-        $checkboxes = $this->request->getRequestParam('checkbox', [], $entity_PK_type, true);
4025
-        if (empty($checkboxes)) {
4026
-            return 0;
4027
-        }
4028
-        $success = 0;
4029
-        $IDs     = array_keys($checkboxes);
4030
-        // cycle thru bulk action checkboxes
4031
-        foreach ($IDs as $ID) {
4032
-            // increment $success
4033
-            if ($this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback)) {
4034
-                $success++;
4035
-            }
4036
-        }
4037
-        $count = (int) count($checkboxes);
4038
-        // if multiple entities were deleted successfully, then $deleted will be full count of deletions,
4039
-        // otherwise it will be a fraction of ( actual deletions / total entities to be deleted )
4040
-        return $success === $count ? $count : $success / $count;
4041
-    }
4042
-
4043
-
4044
-    /**
4045
-     * @param EE_Primary_Key_Field_Base $entity_PK
4046
-     * @return string
4047
-     * @throws EE_Error
4048
-     * @since   $VID:$
4049
-     */
4050
-    private function resolveEntityFieldDataType(EE_Primary_Key_Field_Base $entity_PK): string
4051
-    {
4052
-        $entity_PK_type = $entity_PK->getSchemaType();
4053
-        switch ($entity_PK_type) {
4054
-            case 'boolean':
4055
-                return 'bool';
4056
-            case 'integer':
4057
-                return 'int';
4058
-            case 'number':
4059
-                return 'float';
4060
-            case 'string':
4061
-                return 'string';
4062
-        }
4063
-        throw new RuntimeException(
4064
-            sprintf(
4065
-                esc_html__(
4066
-                    '"%1$s" is an invalid schema type for the %2$s primary key.',
4067
-                    'event_espresso'
4068
-                ),
4069
-                $entity_PK_type,
4070
-                $entity_PK->get_name()
4071
-            )
4072
-        );
4073
-    }
4074
-
4075
-
4076
-    /**
4077
-     * @param EEM_Base      $entity_model
4078
-     * @param int|string    $entity_ID
4079
-     * @param string        $action        one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4080
-     * @param string        $delete_column name of the field that denotes whether entity is trashed
4081
-     * @param callable|null $callback      called after entity is trashed, restored, or deleted
4082
-     * @return bool
4083
-     */
4084
-    protected function trashRestoreDeleteEntity(
4085
-        EEM_Base $entity_model,
4086
-        $entity_ID,
4087
-        string $action,
4088
-        string $delete_column,
4089
-        callable $callback = null
4090
-    ) {
4091
-        $entity_ID = absint($entity_ID);
4092
-        if (! $entity_ID) {
4093
-            $this->trashRestoreDeleteError($action, $entity_model);
4094
-        }
4095
-        $result = 0;
4096
-        try {
4097
-            switch ($action) {
4098
-                case EE_Admin_List_Table::ACTION_DELETE:
4099
-                    $result = (bool) $entity_model->delete_permanently_by_ID($entity_ID);
4100
-                    break;
4101
-                case EE_Admin_List_Table::ACTION_RESTORE:
4102
-                    $this->validateDeleteColumn($entity_model, $delete_column);
4103
-                    $result = $entity_model->update_by_ID([$delete_column => 0], $entity_ID);
4104
-                    break;
4105
-                case EE_Admin_List_Table::ACTION_TRASH:
4106
-                    $this->validateDeleteColumn($entity_model, $delete_column);
4107
-                    $result = $entity_model->update_by_ID([$delete_column => 1], $entity_ID);
4108
-                    break;
4109
-            }
4110
-        } catch (Exception $exception) {
4111
-            $this->trashRestoreDeleteError($action, $entity_model, $exception);
4112
-        }
4113
-        if (is_callable($callback)) {
4114
-            call_user_func_array($callback, [$entity_model, $entity_ID, $action, $result, $delete_column]);
4115
-        }
4116
-        return $result;
4117
-    }
4118
-
4119
-
4120
-    /**
4121
-     * @param EEM_Base $entity_model
4122
-     * @param string   $delete_column
4123
-     * @since $VID:$
4124
-     */
4125
-    private function validateDeleteColumn(EEM_Base $entity_model, string $delete_column)
4126
-    {
4127
-        if (empty($delete_column)) {
4128
-            throw new DomainException(
4129
-                sprintf(
4130
-                    esc_html__(
4131
-                        'You need to specify the name of the "delete column" on the %2$s model, in order to trash or restore an entity.',
4132
-                        'event_espresso'
4133
-                    ),
4134
-                    $entity_model->get_this_model_name()
4135
-                )
4136
-            );
4137
-        }
4138
-        if (! $entity_model->has_field($delete_column)) {
4139
-            throw new DomainException(
4140
-                sprintf(
4141
-                    esc_html__(
4142
-                        'The %1$s field does not exist on the %2$s model.',
4143
-                        'event_espresso'
4144
-                    ),
4145
-                    $delete_column,
4146
-                    $entity_model->get_this_model_name()
4147
-                )
4148
-            );
4149
-        }
4150
-    }
4151
-
4152
-
4153
-    /**
4154
-     * @param EEM_Base       $entity_model
4155
-     * @param Exception|null $exception
4156
-     * @param string         $action
4157
-     * @since $VID:$
4158
-     */
4159
-    private function trashRestoreDeleteError(string $action, EEM_Base $entity_model, ?Exception $exception = null)
4160
-    {
4161
-        if ($exception instanceof Exception) {
4162
-            throw new RuntimeException(
4163
-                sprintf(
4164
-                    esc_html__(
4165
-                        'Could not %1$s the %2$s because the following error occurred: %3$s',
4166
-                        'event_espresso'
4167
-                    ),
4168
-                    $action,
4169
-                    $entity_model->get_this_model_name(),
4170
-                    $exception->getMessage()
4171
-                )
4172
-            );
4173
-        }
4174
-        throw new RuntimeException(
4175
-            sprintf(
4176
-                esc_html__(
4177
-                    'Could not %1$s the %2$s because an invalid ID was received.',
4178
-                    'event_espresso'
4179
-                ),
4180
-                $action,
4181
-                $entity_model->get_this_model_name()
4182
-            )
4183
-        );
4184
-    }
2564
+	}
2565
+
2566
+
2567
+	/**
2568
+	 * facade for add_meta_box
2569
+	 *
2570
+	 * @param string  $action        where the metabox gets displayed
2571
+	 * @param string  $title         Title of Metabox (output in metabox header)
2572
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2573
+	 *                               instead of the one created in here.
2574
+	 * @param array   $callback_args an array of args supplied for the metabox
2575
+	 * @param string  $column        what metabox column
2576
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2577
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2578
+	 *                               created but just set our own callback for wp's add_meta_box.
2579
+	 * @throws DomainException
2580
+	 */
2581
+	public function _add_admin_page_meta_box(
2582
+		$action,
2583
+		$title,
2584
+		$callback,
2585
+		$callback_args,
2586
+		$column = 'normal',
2587
+		$priority = 'high',
2588
+		$create_func = true
2589
+	) {
2590
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2591
+		// 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.
2592
+		if (empty($callback_args) && $create_func) {
2593
+			$callback_args = [
2594
+				'template_path' => $this->_template_path,
2595
+				'template_args' => $this->_template_args,
2596
+			];
2597
+		}
2598
+		// 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)
2599
+		$call_back_func = $create_func
2600
+			? function ($post, $metabox) {
2601
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2602
+				echo EEH_Template::display_template(
2603
+					$metabox['args']['template_path'],
2604
+					$metabox['args']['template_args'],
2605
+					true
2606
+				);
2607
+			}
2608
+			: $callback;
2609
+		add_meta_box(
2610
+			str_replace('_', '-', $action) . '-mbox',
2611
+			$title,
2612
+			$call_back_func,
2613
+			$this->_wp_page_slug,
2614
+			$column,
2615
+			$priority,
2616
+			$callback_args
2617
+		);
2618
+	}
2619
+
2620
+
2621
+	/**
2622
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2623
+	 *
2624
+	 * @throws DomainException
2625
+	 * @throws EE_Error
2626
+	 */
2627
+	public function display_admin_page_with_metabox_columns()
2628
+	{
2629
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2630
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2631
+			$this->_column_template_path,
2632
+			$this->_template_args,
2633
+			true
2634
+		);
2635
+		// the final wrapper
2636
+		$this->admin_page_wrapper();
2637
+	}
2638
+
2639
+
2640
+	/**
2641
+	 * generates  HTML wrapper for an admin details page
2642
+	 *
2643
+	 * @return void
2644
+	 * @throws EE_Error
2645
+	 * @throws DomainException
2646
+	 */
2647
+	public function display_admin_page_with_sidebar()
2648
+	{
2649
+		$this->_display_admin_page(true);
2650
+	}
2651
+
2652
+
2653
+	/**
2654
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2655
+	 *
2656
+	 * @return void
2657
+	 * @throws EE_Error
2658
+	 * @throws DomainException
2659
+	 */
2660
+	public function display_admin_page_with_no_sidebar()
2661
+	{
2662
+		$this->_display_admin_page();
2663
+	}
2664
+
2665
+
2666
+	/**
2667
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2668
+	 *
2669
+	 * @return void
2670
+	 * @throws EE_Error
2671
+	 * @throws DomainException
2672
+	 */
2673
+	public function display_about_admin_page()
2674
+	{
2675
+		$this->_display_admin_page(false, true);
2676
+	}
2677
+
2678
+
2679
+	/**
2680
+	 * display_admin_page
2681
+	 * contains the code for actually displaying an admin page
2682
+	 *
2683
+	 * @param boolean $sidebar true with sidebar, false without
2684
+	 * @param boolean $about   use the about_admin_wrapper instead of the default.
2685
+	 * @return void
2686
+	 * @throws DomainException
2687
+	 * @throws EE_Error
2688
+	 */
2689
+	private function _display_admin_page($sidebar = false, $about = false)
2690
+	{
2691
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2692
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2693
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2694
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2695
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2696
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2697
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2698
+			? 'poststuff'
2699
+			: 'espresso-default-admin';
2700
+		$template_path                                     = $sidebar
2701
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2702
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2703
+		if ($this->request->isAjax()) {
2704
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2705
+		}
2706
+		$template_path                                     = ! empty($this->_column_template_path)
2707
+			? $this->_column_template_path : $template_path;
2708
+		$this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2709
+			? $this->_template_args['admin_page_content']
2710
+			: '';
2711
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2712
+			? $this->_template_args['before_admin_page_content']
2713
+			: '';
2714
+		$this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2715
+			? $this->_template_args['after_admin_page_content']
2716
+			: '';
2717
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2718
+			$template_path,
2719
+			$this->_template_args,
2720
+			true
2721
+		);
2722
+		// the final template wrapper
2723
+		$this->admin_page_wrapper($about);
2724
+	}
2725
+
2726
+
2727
+	/**
2728
+	 * This is used to display caf preview pages.
2729
+	 *
2730
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2731
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2732
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2733
+	 * @return void
2734
+	 * @throws DomainException
2735
+	 * @throws EE_Error
2736
+	 * @throws InvalidArgumentException
2737
+	 * @throws InvalidDataTypeException
2738
+	 * @throws InvalidInterfaceException
2739
+	 * @since 4.3.2
2740
+	 */
2741
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2742
+	{
2743
+		// let's generate a default preview action button if there isn't one already present.
2744
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2745
+			'Upgrade to Event Espresso 4 Right Now',
2746
+			'event_espresso'
2747
+		);
2748
+		$buy_now_url                                   = add_query_arg(
2749
+			[
2750
+				'ee_ver'       => 'ee4',
2751
+				'utm_source'   => 'ee4_plugin_admin',
2752
+				'utm_medium'   => 'link',
2753
+				'utm_campaign' => $utm_campaign_source,
2754
+				'utm_content'  => 'buy_now_button',
2755
+			],
2756
+			'https://eventespresso.com/pricing/'
2757
+		);
2758
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2759
+			? $this->get_action_link_or_button(
2760
+				'',
2761
+				'buy_now',
2762
+				[],
2763
+				'button-primary button-large',
2764
+				esc_url_raw($buy_now_url),
2765
+				true
2766
+			)
2767
+			: $this->_template_args['preview_action_button'];
2768
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2769
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2770
+			$this->_template_args,
2771
+			true
2772
+		);
2773
+		$this->_display_admin_page($display_sidebar);
2774
+	}
2775
+
2776
+
2777
+	/**
2778
+	 * display_admin_list_table_page_with_sidebar
2779
+	 * generates HTML wrapper for an admin_page with list_table
2780
+	 *
2781
+	 * @return void
2782
+	 * @throws EE_Error
2783
+	 * @throws DomainException
2784
+	 */
2785
+	public function display_admin_list_table_page_with_sidebar()
2786
+	{
2787
+		$this->_display_admin_list_table_page(true);
2788
+	}
2789
+
2790
+
2791
+	/**
2792
+	 * display_admin_list_table_page_with_no_sidebar
2793
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2794
+	 *
2795
+	 * @return void
2796
+	 * @throws EE_Error
2797
+	 * @throws DomainException
2798
+	 */
2799
+	public function display_admin_list_table_page_with_no_sidebar()
2800
+	{
2801
+		$this->_display_admin_list_table_page();
2802
+	}
2803
+
2804
+
2805
+	/**
2806
+	 * generates html wrapper for an admin_list_table page
2807
+	 *
2808
+	 * @param boolean $sidebar whether to display with sidebar or not.
2809
+	 * @return void
2810
+	 * @throws DomainException
2811
+	 * @throws EE_Error
2812
+	 */
2813
+	private function _display_admin_list_table_page($sidebar = false)
2814
+	{
2815
+		// setup search attributes
2816
+		$this->_set_search_attributes();
2817
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
2818
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2819
+		$this->_template_args['table_url']        = $this->request->isAjax()
2820
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2821
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2822
+		$this->_template_args['list_table']       = $this->_list_table_object;
2823
+		$this->_template_args['current_route']    = $this->_req_action;
2824
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2825
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2826
+		if (! empty($ajax_sorting_callback)) {
2827
+			$sortable_list_table_form_fields = wp_nonce_field(
2828
+				$ajax_sorting_callback . '_nonce',
2829
+				$ajax_sorting_callback . '_nonce',
2830
+				false,
2831
+				false
2832
+			);
2833
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2834
+												. $this->page_slug
2835
+												. '" />';
2836
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2837
+												. $ajax_sorting_callback
2838
+												. '" />';
2839
+		} else {
2840
+			$sortable_list_table_form_fields = '';
2841
+		}
2842
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2843
+		$hidden_form_fields                                      =
2844
+			isset($this->_template_args['list_table_hidden_fields'])
2845
+				? $this->_template_args['list_table_hidden_fields']
2846
+				: '';
2847
+		$nonce_ref                                               = $this->_req_action . '_nonce';
2848
+		$hidden_form_fields                                      .= '<input type="hidden" name="'
2849
+																	. $nonce_ref
2850
+																	. '" value="'
2851
+																	. wp_create_nonce($nonce_ref)
2852
+																	. '">';
2853
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2854
+		// display message about search results?
2855
+		$search = $this->request->getRequestParam('s');
2856
+		$this->_template_args['before_list_table'] .= ! empty($search)
2857
+			? '<p class="ee-search-results">' . sprintf(
2858
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2859
+				trim($search, '%')
2860
+			) . '</p>'
2861
+			: '';
2862
+		// filter before_list_table template arg
2863
+		$this->_template_args['before_list_table'] = apply_filters(
2864
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2865
+			$this->_template_args['before_list_table'],
2866
+			$this->page_slug,
2867
+			$this->request->requestParams(),
2868
+			$this->_req_action
2869
+		);
2870
+		// convert to array and filter again
2871
+		// arrays are easier to inject new items in a specific location,
2872
+		// but would not be backwards compatible, so we have to add a new filter
2873
+		$this->_template_args['before_list_table'] = implode(
2874
+			" \n",
2875
+			(array) apply_filters(
2876
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2877
+				(array) $this->_template_args['before_list_table'],
2878
+				$this->page_slug,
2879
+				$this->request->requestParams(),
2880
+				$this->_req_action
2881
+			)
2882
+		);
2883
+		// filter after_list_table template arg
2884
+		$this->_template_args['after_list_table'] = apply_filters(
2885
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2886
+			$this->_template_args['after_list_table'],
2887
+			$this->page_slug,
2888
+			$this->request->requestParams(),
2889
+			$this->_req_action
2890
+		);
2891
+		// convert to array and filter again
2892
+		// arrays are easier to inject new items in a specific location,
2893
+		// but would not be backwards compatible, so we have to add a new filter
2894
+		$this->_template_args['after_list_table']   = implode(
2895
+			" \n",
2896
+			(array) apply_filters(
2897
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2898
+				(array) $this->_template_args['after_list_table'],
2899
+				$this->page_slug,
2900
+				$this->request->requestParams(),
2901
+				$this->_req_action
2902
+			)
2903
+		);
2904
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2905
+			$template_path,
2906
+			$this->_template_args,
2907
+			true
2908
+		);
2909
+		// the final template wrapper
2910
+		if ($sidebar) {
2911
+			$this->display_admin_page_with_sidebar();
2912
+		} else {
2913
+			$this->display_admin_page_with_no_sidebar();
2914
+		}
2915
+	}
2916
+
2917
+
2918
+	/**
2919
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2920
+	 * html string for the legend.
2921
+	 * $items are expected in an array in the following format:
2922
+	 * $legend_items = array(
2923
+	 *        'item_id' => array(
2924
+	 *            'icon' => 'http://url_to_icon_being_described.png',
2925
+	 *            'desc' => esc_html__('localized description of item');
2926
+	 *        )
2927
+	 * );
2928
+	 *
2929
+	 * @param array $items see above for format of array
2930
+	 * @return string html string of legend
2931
+	 * @throws DomainException
2932
+	 */
2933
+	protected function _display_legend($items)
2934
+	{
2935
+		$this->_template_args['items'] = apply_filters(
2936
+			'FHEE__EE_Admin_Page___display_legend__items',
2937
+			(array) $items,
2938
+			$this
2939
+		);
2940
+		return EEH_Template::display_template(
2941
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2942
+			$this->_template_args,
2943
+			true
2944
+		);
2945
+	}
2946
+
2947
+
2948
+	/**
2949
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2950
+	 * The returned json object is created from an array in the following format:
2951
+	 * array(
2952
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2953
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
2954
+	 *  'notices' => '', // - contains any EE_Error formatted notices
2955
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
2956
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
2957
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
2958
+	 *  that might be included in here)
2959
+	 * )
2960
+	 * The json object is populated by whatever is set in the $_template_args property.
2961
+	 *
2962
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
2963
+	 *                                 instead of displayed.
2964
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
2965
+	 * @return void
2966
+	 * @throws EE_Error
2967
+	 */
2968
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
2969
+	{
2970
+		// make sure any EE_Error notices have been handled.
2971
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
2972
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
2973
+		unset($this->_template_args['data']);
2974
+		$json = [
2975
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2976
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2977
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2978
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2979
+			'notices'   => EE_Error::get_notices(),
2980
+			'content'   => isset($this->_template_args['admin_page_content'])
2981
+				? $this->_template_args['admin_page_content'] : '',
2982
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
2983
+			'isEEajax'  => true
2984
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2985
+		];
2986
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
2987
+		if (null === error_get_last() || ! headers_sent()) {
2988
+			header('Content-Type: application/json; charset=UTF-8');
2989
+		}
2990
+		echo wp_json_encode($json);
2991
+		exit();
2992
+	}
2993
+
2994
+
2995
+	/**
2996
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2997
+	 *
2998
+	 * @return void
2999
+	 * @throws EE_Error
3000
+	 */
3001
+	public function return_json()
3002
+	{
3003
+		if ($this->request->isAjax()) {
3004
+			$this->_return_json();
3005
+		} else {
3006
+			throw new EE_Error(
3007
+				sprintf(
3008
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3009
+					__FUNCTION__
3010
+				)
3011
+			);
3012
+		}
3013
+	}
3014
+
3015
+
3016
+	/**
3017
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3018
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3019
+	 *
3020
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3021
+	 */
3022
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3023
+	{
3024
+		$this->_hook_obj = $hook_obj;
3025
+	}
3026
+
3027
+
3028
+	/**
3029
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3030
+	 *
3031
+	 * @param boolean $about whether to use the special about page wrapper or default.
3032
+	 * @return void
3033
+	 * @throws DomainException
3034
+	 * @throws EE_Error
3035
+	 */
3036
+	public function admin_page_wrapper($about = false)
3037
+	{
3038
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3039
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3040
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3041
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3042
+
3043
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3044
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3045
+			isset($this->_template_args['before_admin_page_content'])
3046
+				? $this->_template_args['before_admin_page_content']
3047
+				: ''
3048
+		);
3049
+
3050
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3051
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3052
+			isset($this->_template_args['after_admin_page_content'])
3053
+				? $this->_template_args['after_admin_page_content']
3054
+				: ''
3055
+		);
3056
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3057
+
3058
+		if ($this->request->isAjax()) {
3059
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3060
+				// $template_path,
3061
+				EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3062
+				$this->_template_args,
3063
+				true
3064
+			);
3065
+			$this->_return_json();
3066
+		}
3067
+		// load settings page wrapper template
3068
+		$template_path = $about
3069
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3070
+			: EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3071
+
3072
+		EEH_Template::display_template($template_path, $this->_template_args);
3073
+	}
3074
+
3075
+
3076
+	/**
3077
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3078
+	 *
3079
+	 * @return string html
3080
+	 * @throws EE_Error
3081
+	 */
3082
+	protected function _get_main_nav_tabs()
3083
+	{
3084
+		// let's generate the html using the EEH_Tabbed_Content helper.
3085
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3086
+		// (rather than setting in the page_routes array)
3087
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3088
+	}
3089
+
3090
+
3091
+	/**
3092
+	 *        sort nav tabs
3093
+	 *
3094
+	 * @param $a
3095
+	 * @param $b
3096
+	 * @return int
3097
+	 */
3098
+	private function _sort_nav_tabs($a, $b)
3099
+	{
3100
+		if ($a['order'] === $b['order']) {
3101
+			return 0;
3102
+		}
3103
+		return ($a['order'] < $b['order']) ? -1 : 1;
3104
+	}
3105
+
3106
+
3107
+	/**
3108
+	 *    generates HTML for the forms used on admin pages
3109
+	 *
3110
+	 * @param array  $input_vars   - array of input field details
3111
+	 * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3112
+	 *                             use)
3113
+	 * @param bool   $id
3114
+	 * @return array|string
3115
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3116
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3117
+	 */
3118
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3119
+	{
3120
+		return $generator === 'string'
3121
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3122
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3123
+	}
3124
+
3125
+
3126
+	/**
3127
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3128
+	 *
3129
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3130
+	 *                                   Close" button.
3131
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3132
+	 *                                   'Save', [1] => 'save & close')
3133
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3134
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3135
+	 *                                   default actions by submitting some other value.
3136
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3137
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3138
+	 *                                   close (normal form handling).
3139
+	 */
3140
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3141
+	{
3142
+		// make sure $text and $actions are in an array
3143
+		$text          = (array) $text;
3144
+		$actions       = (array) $actions;
3145
+		$referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3146
+		$button_text   = ! empty($text)
3147
+			? $text
3148
+			: [
3149
+				esc_html__('Save', 'event_espresso'),
3150
+				esc_html__('Save and Close', 'event_espresso'),
3151
+			];
3152
+		$default_names = ['save', 'save_and_close'];
3153
+		$buttons = '';
3154
+		foreach ($button_text as $key => $button) {
3155
+			$ref     = $default_names[ $key ];
3156
+			$name    = ! empty($actions) ? $actions[ $key ] : $ref;
3157
+			$buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3158
+						. 'value="' . $button . '" name="' . $name . '" '
3159
+						. 'id="' . $this->_current_view . '_' . $ref . '" />';
3160
+			if (! $both) {
3161
+				break;
3162
+			}
3163
+		}
3164
+		// add in a hidden index for the current page (so save and close redirects properly)
3165
+		$buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3166
+				   . $referrer_url
3167
+				   . '" />';
3168
+		$this->_template_args['save_buttons'] = $buttons;
3169
+	}
3170
+
3171
+
3172
+	/**
3173
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3174
+	 *
3175
+	 * @param string $route
3176
+	 * @param array  $additional_hidden_fields
3177
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3178
+	 * @since 4.6.0
3179
+	 */
3180
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3181
+	{
3182
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3183
+	}
3184
+
3185
+
3186
+	/**
3187
+	 * set form open and close tags on add/edit pages.
3188
+	 *
3189
+	 * @param string $route                    the route you want the form to direct to
3190
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3191
+	 * @return void
3192
+	 */
3193
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3194
+	{
3195
+		if (empty($route)) {
3196
+			$user_msg = esc_html__(
3197
+				'An error occurred. No action was set for this page\'s form.',
3198
+				'event_espresso'
3199
+			);
3200
+			$dev_msg  = $user_msg . "\n"
3201
+						. sprintf(
3202
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3203
+							__FUNCTION__,
3204
+							__CLASS__
3205
+						);
3206
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3207
+		}
3208
+		// open form
3209
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3210
+															 . $this->_admin_base_url
3211
+															 . '" id="'
3212
+															 . $route
3213
+															 . '_event_form" >';
3214
+		// add nonce
3215
+		$nonce                                             =
3216
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3217
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3218
+		// add REQUIRED form action
3219
+		$hidden_fields = [
3220
+			'action' => ['type' => 'hidden', 'value' => $route],
3221
+		];
3222
+		// merge arrays
3223
+		$hidden_fields = is_array($additional_hidden_fields)
3224
+			? array_merge($hidden_fields, $additional_hidden_fields)
3225
+			: $hidden_fields;
3226
+		// generate form fields
3227
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3228
+		// add fields to form
3229
+		foreach ((array) $form_fields as $form_field) {
3230
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3231
+		}
3232
+		// close form
3233
+		$this->_template_args['after_admin_page_content'] = '</form>';
3234
+	}
3235
+
3236
+
3237
+	/**
3238
+	 * Public Wrapper for _redirect_after_action() method since its
3239
+	 * discovered it would be useful for external code to have access.
3240
+	 *
3241
+	 * @param bool   $success
3242
+	 * @param string $what
3243
+	 * @param string $action_desc
3244
+	 * @param array  $query_args
3245
+	 * @param bool   $override_overwrite
3246
+	 * @throws EE_Error
3247
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3248
+	 * @since 4.5.0
3249
+	 */
3250
+	public function redirect_after_action(
3251
+		$success = false,
3252
+		$what = 'item',
3253
+		$action_desc = 'processed',
3254
+		$query_args = [],
3255
+		$override_overwrite = false
3256
+	) {
3257
+		$this->_redirect_after_action(
3258
+			$success,
3259
+			$what,
3260
+			$action_desc,
3261
+			$query_args,
3262
+			$override_overwrite
3263
+		);
3264
+	}
3265
+
3266
+
3267
+	/**
3268
+	 * Helper method for merging existing request data with the returned redirect url.
3269
+	 *
3270
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3271
+	 * filters are still applied.
3272
+	 *
3273
+	 * @param array $new_route_data
3274
+	 * @return array
3275
+	 */
3276
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3277
+	{
3278
+		foreach ($this->request->requestParams() as $ref => $value) {
3279
+			// unset nonces
3280
+			if (strpos($ref, 'nonce') !== false) {
3281
+				$this->request->unSetRequestParam($ref);
3282
+				continue;
3283
+			}
3284
+			// urlencode values.
3285
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3286
+			$this->request->setRequestParam($ref, $value);
3287
+		}
3288
+		return array_merge($this->request->requestParams(), $new_route_data);
3289
+	}
3290
+
3291
+
3292
+	/**
3293
+	 *    _redirect_after_action
3294
+	 *
3295
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3296
+	 * @param string $what               - what the action was performed on
3297
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3298
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3299
+	 *                                   action is completed
3300
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3301
+	 *                                   override this so that they show.
3302
+	 * @return void
3303
+	 * @throws EE_Error
3304
+	 */
3305
+	protected function _redirect_after_action(
3306
+		$success = 0,
3307
+		$what = 'item',
3308
+		$action_desc = 'processed',
3309
+		$query_args = [],
3310
+		$override_overwrite = false
3311
+	) {
3312
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3313
+		// class name for actions/filters.
3314
+		$classname = get_class($this);
3315
+		// set redirect url.
3316
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3317
+		// otherwise we go with whatever is set as the _admin_base_url
3318
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3319
+		$notices      = EE_Error::get_notices(false);
3320
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3321
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3322
+			EE_Error::overwrite_success();
3323
+		}
3324
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3325
+			// how many records affected ? more than one record ? or just one ?
3326
+			if ($success > 1) {
3327
+				// set plural msg
3328
+				EE_Error::add_success(
3329
+					sprintf(
3330
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3331
+						$what,
3332
+						$action_desc
3333
+					),
3334
+					__FILE__,
3335
+					__FUNCTION__,
3336
+					__LINE__
3337
+				);
3338
+			} elseif ($success === 1) {
3339
+				// set singular msg
3340
+				EE_Error::add_success(
3341
+					sprintf(
3342
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3343
+						$what,
3344
+						$action_desc
3345
+					),
3346
+					__FILE__,
3347
+					__FUNCTION__,
3348
+					__LINE__
3349
+				);
3350
+			}
3351
+		}
3352
+		// check that $query_args isn't something crazy
3353
+		if (! is_array($query_args)) {
3354
+			$query_args = [];
3355
+		}
3356
+		/**
3357
+		 * Allow injecting actions before the query_args are modified for possible different
3358
+		 * redirections on save and close actions
3359
+		 *
3360
+		 * @param array $query_args       The original query_args array coming into the
3361
+		 *                                method.
3362
+		 * @since 4.2.0
3363
+		 */
3364
+		do_action(
3365
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3366
+			$query_args
3367
+		);
3368
+		// calculate where we're going (if we have a "save and close" button pushed)
3369
+
3370
+		if (
3371
+			$this->request->requestParamIsSet('save_and_close')
3372
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3373
+		) {
3374
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3375
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3376
+			// regenerate query args array from referrer URL
3377
+			parse_str($parsed_url['query'], $query_args);
3378
+			// correct page and action will be in the query args now
3379
+			$redirect_url = admin_url('admin.php');
3380
+		}
3381
+		// merge any default query_args set in _default_route_query_args property
3382
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3383
+			$args_to_merge = [];
3384
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3385
+				// is there a wp_referer array in our _default_route_query_args property?
3386
+				if ($query_param === 'wp_referer') {
3387
+					$query_value = (array) $query_value;
3388
+					foreach ($query_value as $reference => $value) {
3389
+						if (strpos($reference, 'nonce') !== false) {
3390
+							continue;
3391
+						}
3392
+						// finally we will override any arguments in the referer with
3393
+						// what might be set on the _default_route_query_args array.
3394
+						if (isset($this->_default_route_query_args[ $reference ])) {
3395
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3396
+						} else {
3397
+							$args_to_merge[ $reference ] = urlencode($value);
3398
+						}
3399
+					}
3400
+					continue;
3401
+				}
3402
+				$args_to_merge[ $query_param ] = $query_value;
3403
+			}
3404
+			// now let's merge these arguments but override with what was specifically sent in to the
3405
+			// redirect.
3406
+			$query_args = array_merge($args_to_merge, $query_args);
3407
+		}
3408
+		$this->_process_notices($query_args);
3409
+		// generate redirect url
3410
+		// if redirecting to anything other than the main page, add a nonce
3411
+		if (isset($query_args['action'])) {
3412
+			// manually generate wp_nonce and merge that with the query vars
3413
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3414
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3415
+		}
3416
+		// we're adding some hooks and filters in here for processing any things just before redirects
3417
+		// (example: an admin page has done an insert or update and we want to run something after that).
3418
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3419
+		$redirect_url = apply_filters(
3420
+			'FHEE_redirect_' . $classname . $this->_req_action,
3421
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3422
+			$query_args
3423
+		);
3424
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3425
+		if ($this->request->isAjax()) {
3426
+			$default_data                    = [
3427
+				'close'        => true,
3428
+				'redirect_url' => $redirect_url,
3429
+				'where'        => 'main',
3430
+				'what'         => 'append',
3431
+			];
3432
+			$this->_template_args['success'] = $success;
3433
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3434
+				$default_data,
3435
+				$this->_template_args['data']
3436
+			) : $default_data;
3437
+			$this->_return_json();
3438
+		}
3439
+		wp_safe_redirect($redirect_url);
3440
+		exit();
3441
+	}
3442
+
3443
+
3444
+	/**
3445
+	 * process any notices before redirecting (or returning ajax request)
3446
+	 * This method sets the $this->_template_args['notices'] attribute;
3447
+	 *
3448
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3449
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3450
+	 *                                  page_routes haven't been defined yet.
3451
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3452
+	 *                                  still save a transient for the notice.
3453
+	 * @return void
3454
+	 * @throws EE_Error
3455
+	 */
3456
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3457
+	{
3458
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3459
+		if ($this->request->isAjax()) {
3460
+			$notices = EE_Error::get_notices(false);
3461
+			if (empty($this->_template_args['success'])) {
3462
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3463
+			}
3464
+			if (empty($this->_template_args['errors'])) {
3465
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3466
+			}
3467
+			if (empty($this->_template_args['attention'])) {
3468
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3469
+			}
3470
+		}
3471
+		$this->_template_args['notices'] = EE_Error::get_notices();
3472
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3473
+		if (! $this->request->isAjax() || $sticky_notices) {
3474
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3475
+			$this->_add_transient(
3476
+				$route,
3477
+				$this->_template_args['notices'],
3478
+				true,
3479
+				$skip_route_verify
3480
+			);
3481
+		}
3482
+	}
3483
+
3484
+
3485
+	/**
3486
+	 * get_action_link_or_button
3487
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3488
+	 *
3489
+	 * @param string $action        use this to indicate which action the url is generated with.
3490
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3491
+	 *                              property.
3492
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3493
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3494
+	 * @param string $base_url      If this is not provided
3495
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3496
+	 *                              Otherwise this value will be used.
3497
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3498
+	 * @return string
3499
+	 * @throws InvalidArgumentException
3500
+	 * @throws InvalidInterfaceException
3501
+	 * @throws InvalidDataTypeException
3502
+	 * @throws EE_Error
3503
+	 */
3504
+	public function get_action_link_or_button(
3505
+		$action,
3506
+		$type = 'add',
3507
+		$extra_request = [],
3508
+		$class = 'button-primary',
3509
+		$base_url = '',
3510
+		$exclude_nonce = false
3511
+	) {
3512
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3513
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3514
+			throw new EE_Error(
3515
+				sprintf(
3516
+					esc_html__(
3517
+						'There is no page route for given action for the button.  This action was given: %s',
3518
+						'event_espresso'
3519
+					),
3520
+					$action
3521
+				)
3522
+			);
3523
+		}
3524
+		if (! isset($this->_labels['buttons'][ $type ])) {
3525
+			throw new EE_Error(
3526
+				sprintf(
3527
+					esc_html__(
3528
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3529
+						'event_espresso'
3530
+					),
3531
+					$type
3532
+				)
3533
+			);
3534
+		}
3535
+		// finally check user access for this button.
3536
+		$has_access = $this->check_user_access($action, true);
3537
+		if (! $has_access) {
3538
+			return '';
3539
+		}
3540
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3541
+		$query_args = [
3542
+			'action' => $action,
3543
+		];
3544
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3545
+		if (! empty($extra_request)) {
3546
+			$query_args = array_merge($extra_request, $query_args);
3547
+		}
3548
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3549
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3550
+	}
3551
+
3552
+
3553
+	/**
3554
+	 * _per_page_screen_option
3555
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3556
+	 *
3557
+	 * @return void
3558
+	 * @throws InvalidArgumentException
3559
+	 * @throws InvalidInterfaceException
3560
+	 * @throws InvalidDataTypeException
3561
+	 */
3562
+	protected function _per_page_screen_option()
3563
+	{
3564
+		$option = 'per_page';
3565
+		$args   = [
3566
+			'label'   => apply_filters(
3567
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3568
+				$this->_admin_page_title,
3569
+				$this
3570
+			),
3571
+			'default' => (int) apply_filters(
3572
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3573
+				20
3574
+			),
3575
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3576
+		];
3577
+		// ONLY add the screen option if the user has access to it.
3578
+		if ($this->check_user_access($this->_current_view, true)) {
3579
+			add_screen_option($option, $args);
3580
+		}
3581
+	}
3582
+
3583
+
3584
+	/**
3585
+	 * set_per_page_screen_option
3586
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3587
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3588
+	 * admin_menu.
3589
+	 *
3590
+	 * @return void
3591
+	 */
3592
+	private function _set_per_page_screen_options()
3593
+	{
3594
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3595
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3596
+			if (! $user = wp_get_current_user()) {
3597
+				return;
3598
+			}
3599
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3600
+			if (! $option) {
3601
+				return;
3602
+			}
3603
+			$value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3604
+			$map_option = $option;
3605
+			$option     = str_replace('-', '_', $option);
3606
+			switch ($map_option) {
3607
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3608
+					$max_value = apply_filters(
3609
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3610
+						999,
3611
+						$this->_current_page,
3612
+						$this->_current_view
3613
+					);
3614
+					if ($value < 1) {
3615
+						return;
3616
+					}
3617
+					$value = min($value, $max_value);
3618
+					break;
3619
+				default:
3620
+					$value = apply_filters(
3621
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3622
+						false,
3623
+						$option,
3624
+						$value
3625
+					);
3626
+					if (false === $value) {
3627
+						return;
3628
+					}
3629
+					break;
3630
+			}
3631
+			update_user_meta($user->ID, $option, $value);
3632
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3633
+			exit;
3634
+		}
3635
+	}
3636
+
3637
+
3638
+	/**
3639
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3640
+	 *
3641
+	 * @param array $data array that will be assigned to template args.
3642
+	 */
3643
+	public function set_template_args($data)
3644
+	{
3645
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3646
+	}
3647
+
3648
+
3649
+	/**
3650
+	 * This makes available the WP transient system for temporarily moving data between routes
3651
+	 *
3652
+	 * @param string $route             the route that should receive the transient
3653
+	 * @param array  $data              the data that gets sent
3654
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3655
+	 *                                  normal route transient.
3656
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3657
+	 *                                  when we are adding a transient before page_routes have been defined.
3658
+	 * @return void
3659
+	 * @throws EE_Error
3660
+	 */
3661
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3662
+	{
3663
+		$user_id = get_current_user_id();
3664
+		if (! $skip_route_verify) {
3665
+			$this->_verify_route($route);
3666
+		}
3667
+		// now let's set the string for what kind of transient we're setting
3668
+		$transient = $notices
3669
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3670
+			: 'rte_tx_' . $route . '_' . $user_id;
3671
+		$data      = $notices ? ['notices' => $data] : $data;
3672
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3673
+		$existing = is_multisite() && is_network_admin()
3674
+			? get_site_transient($transient)
3675
+			: get_transient($transient);
3676
+		if ($existing) {
3677
+			$data = array_merge((array) $data, (array) $existing);
3678
+		}
3679
+		if (is_multisite() && is_network_admin()) {
3680
+			set_site_transient($transient, $data, 8);
3681
+		} else {
3682
+			set_transient($transient, $data, 8);
3683
+		}
3684
+	}
3685
+
3686
+
3687
+	/**
3688
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3689
+	 *
3690
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3691
+	 * @param string $route
3692
+	 * @return mixed data
3693
+	 */
3694
+	protected function _get_transient($notices = false, $route = '')
3695
+	{
3696
+		$user_id   = get_current_user_id();
3697
+		$route     = ! $route ? $this->_req_action : $route;
3698
+		$transient = $notices
3699
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3700
+			: 'rte_tx_' . $route . '_' . $user_id;
3701
+		$data      = is_multisite() && is_network_admin()
3702
+			? get_site_transient($transient)
3703
+			: get_transient($transient);
3704
+		// delete transient after retrieval (just in case it hasn't expired);
3705
+		if (is_multisite() && is_network_admin()) {
3706
+			delete_site_transient($transient);
3707
+		} else {
3708
+			delete_transient($transient);
3709
+		}
3710
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3711
+	}
3712
+
3713
+
3714
+	/**
3715
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3716
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3717
+	 * default route callback on the EE_Admin page you want it run.)
3718
+	 *
3719
+	 * @return void
3720
+	 */
3721
+	protected function _transient_garbage_collection()
3722
+	{
3723
+		global $wpdb;
3724
+		// retrieve all existing transients
3725
+		$query =
3726
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3727
+		if ($results = $wpdb->get_results($query)) {
3728
+			foreach ($results as $result) {
3729
+				$transient = str_replace('_transient_', '', $result->option_name);
3730
+				get_transient($transient);
3731
+				if (is_multisite() && is_network_admin()) {
3732
+					get_site_transient($transient);
3733
+				}
3734
+			}
3735
+		}
3736
+	}
3737
+
3738
+
3739
+	/**
3740
+	 * get_view
3741
+	 *
3742
+	 * @return string content of _view property
3743
+	 */
3744
+	public function get_view()
3745
+	{
3746
+		return $this->_view;
3747
+	}
3748
+
3749
+
3750
+	/**
3751
+	 * getter for the protected $_views property
3752
+	 *
3753
+	 * @return array
3754
+	 */
3755
+	public function get_views()
3756
+	{
3757
+		return $this->_views;
3758
+	}
3759
+
3760
+
3761
+	/**
3762
+	 * get_current_page
3763
+	 *
3764
+	 * @return string _current_page property value
3765
+	 */
3766
+	public function get_current_page()
3767
+	{
3768
+		return $this->_current_page;
3769
+	}
3770
+
3771
+
3772
+	/**
3773
+	 * get_current_view
3774
+	 *
3775
+	 * @return string _current_view property value
3776
+	 */
3777
+	public function get_current_view()
3778
+	{
3779
+		return $this->_current_view;
3780
+	}
3781
+
3782
+
3783
+	/**
3784
+	 * get_current_screen
3785
+	 *
3786
+	 * @return object The current WP_Screen object
3787
+	 */
3788
+	public function get_current_screen()
3789
+	{
3790
+		return $this->_current_screen;
3791
+	}
3792
+
3793
+
3794
+	/**
3795
+	 * get_current_page_view_url
3796
+	 *
3797
+	 * @return string This returns the url for the current_page_view.
3798
+	 */
3799
+	public function get_current_page_view_url()
3800
+	{
3801
+		return $this->_current_page_view_url;
3802
+	}
3803
+
3804
+
3805
+	/**
3806
+	 * just returns the Request
3807
+	 *
3808
+	 * @return RequestInterface
3809
+	 */
3810
+	public function get_request()
3811
+	{
3812
+		return $this->request;
3813
+	}
3814
+
3815
+
3816
+	/**
3817
+	 * just returns the _req_data property
3818
+	 *
3819
+	 * @return array
3820
+	 */
3821
+	public function get_request_data()
3822
+	{
3823
+		return $this->request->requestParams();
3824
+	}
3825
+
3826
+
3827
+	/**
3828
+	 * returns the _req_data protected property
3829
+	 *
3830
+	 * @return string
3831
+	 */
3832
+	public function get_req_action()
3833
+	{
3834
+		return $this->_req_action;
3835
+	}
3836
+
3837
+
3838
+	/**
3839
+	 * @return bool  value of $_is_caf property
3840
+	 */
3841
+	public function is_caf()
3842
+	{
3843
+		return $this->_is_caf;
3844
+	}
3845
+
3846
+
3847
+	/**
3848
+	 * @return mixed
3849
+	 */
3850
+	public function default_espresso_metaboxes()
3851
+	{
3852
+		return $this->_default_espresso_metaboxes;
3853
+	}
3854
+
3855
+
3856
+	/**
3857
+	 * @return mixed
3858
+	 */
3859
+	public function admin_base_url()
3860
+	{
3861
+		return $this->_admin_base_url;
3862
+	}
3863
+
3864
+
3865
+	/**
3866
+	 * @return mixed
3867
+	 */
3868
+	public function wp_page_slug()
3869
+	{
3870
+		return $this->_wp_page_slug;
3871
+	}
3872
+
3873
+
3874
+	/**
3875
+	 * updates  espresso configuration settings
3876
+	 *
3877
+	 * @param string                   $tab
3878
+	 * @param EE_Config_Base|EE_Config $config
3879
+	 * @param string                   $file file where error occurred
3880
+	 * @param string                   $func function  where error occurred
3881
+	 * @param string                   $line line no where error occurred
3882
+	 * @return boolean
3883
+	 */
3884
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3885
+	{
3886
+		// remove any options that are NOT going to be saved with the config settings.
3887
+		if (isset($config->core->ee_ueip_optin)) {
3888
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3889
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3890
+			update_option('ee_ueip_has_notified', true);
3891
+		}
3892
+		// and save it (note we're also doing the network save here)
3893
+		$net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
3894
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
3895
+		if ($config_saved && $net_saved) {
3896
+			EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3897
+			return true;
3898
+		}
3899
+		EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3900
+		return false;
3901
+	}
3902
+
3903
+
3904
+	/**
3905
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3906
+	 *
3907
+	 * @return array
3908
+	 */
3909
+	public function get_yes_no_values()
3910
+	{
3911
+		return $this->_yes_no_values;
3912
+	}
3913
+
3914
+
3915
+	protected function _get_dir()
3916
+	{
3917
+		$reflector = new ReflectionClass(get_class($this));
3918
+		return dirname($reflector->getFileName());
3919
+	}
3920
+
3921
+
3922
+	/**
3923
+	 * A helper for getting a "next link".
3924
+	 *
3925
+	 * @param string $url   The url to link to
3926
+	 * @param string $class The class to use.
3927
+	 * @return string
3928
+	 */
3929
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3930
+	{
3931
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3932
+	}
3933
+
3934
+
3935
+	/**
3936
+	 * A helper for getting a "previous link".
3937
+	 *
3938
+	 * @param string $url   The url to link to
3939
+	 * @param string $class The class to use.
3940
+	 * @return string
3941
+	 */
3942
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3943
+	{
3944
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3945
+	}
3946
+
3947
+
3948
+
3949
+
3950
+
3951
+
3952
+
3953
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3954
+
3955
+
3956
+	/**
3957
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
3958
+	 * 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
3959
+	 * _req_data array.
3960
+	 *
3961
+	 * @return bool success/fail
3962
+	 * @throws EE_Error
3963
+	 * @throws InvalidArgumentException
3964
+	 * @throws ReflectionException
3965
+	 * @throws InvalidDataTypeException
3966
+	 * @throws InvalidInterfaceException
3967
+	 */
3968
+	protected function _process_resend_registration()
3969
+	{
3970
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3971
+		do_action(
3972
+			'AHEE__EE_Admin_Page___process_resend_registration',
3973
+			$this->_template_args['success'],
3974
+			$this->request->requestParams()
3975
+		);
3976
+		return $this->_template_args['success'];
3977
+	}
3978
+
3979
+
3980
+	/**
3981
+	 * This automatically processes any payment message notifications when manual payment has been applied.
3982
+	 *
3983
+	 * @param EE_Payment $payment
3984
+	 * @return bool success/fail
3985
+	 */
3986
+	protected function _process_payment_notification(EE_Payment $payment)
3987
+	{
3988
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3989
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3990
+		$this->_template_args['success'] = apply_filters(
3991
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
3992
+			false,
3993
+			$payment
3994
+		);
3995
+		return $this->_template_args['success'];
3996
+	}
3997
+
3998
+
3999
+	/**
4000
+	 * @param EEM_Base      $entity_model
4001
+	 * @param string        $entity_PK_name name of the primary key field used as a request param, ie: id, ID, etc
4002
+	 * @param string        $action         one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4003
+	 * @param string        $delete_column  name of the field that denotes whether entity is trashed
4004
+	 * @param callable|null $callback       called after entity is trashed, restored, or deleted
4005
+	 * @return int|float
4006
+	 * @throws EE_Error
4007
+	 */
4008
+	protected function trashRestoreDeleteEntities(
4009
+		EEM_Base $entity_model,
4010
+		string $entity_PK_name,
4011
+		string $action = EE_Admin_List_Table::ACTION_DELETE,
4012
+		string $delete_column = '',
4013
+		callable $callback = null
4014
+	) {
4015
+		$entity_PK      = $entity_model->get_primary_key_field();
4016
+		$entity_PK_name = $entity_PK_name ?: $entity_PK->get_name();
4017
+		$entity_PK_type = $this->resolveEntityFieldDataType($entity_PK);
4018
+		// grab ID if deleting a single entity
4019
+		if ($this->request->requestParamIsSet($entity_PK_name)) {
4020
+			$ID = $this->request->getRequestParam($entity_PK_name, 0, $entity_PK_type);
4021
+			return $this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback) ? 1 : 0;
4022
+		}
4023
+		// or grab checkbox array if bulk deleting
4024
+		$checkboxes = $this->request->getRequestParam('checkbox', [], $entity_PK_type, true);
4025
+		if (empty($checkboxes)) {
4026
+			return 0;
4027
+		}
4028
+		$success = 0;
4029
+		$IDs     = array_keys($checkboxes);
4030
+		// cycle thru bulk action checkboxes
4031
+		foreach ($IDs as $ID) {
4032
+			// increment $success
4033
+			if ($this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback)) {
4034
+				$success++;
4035
+			}
4036
+		}
4037
+		$count = (int) count($checkboxes);
4038
+		// if multiple entities were deleted successfully, then $deleted will be full count of deletions,
4039
+		// otherwise it will be a fraction of ( actual deletions / total entities to be deleted )
4040
+		return $success === $count ? $count : $success / $count;
4041
+	}
4042
+
4043
+
4044
+	/**
4045
+	 * @param EE_Primary_Key_Field_Base $entity_PK
4046
+	 * @return string
4047
+	 * @throws EE_Error
4048
+	 * @since   $VID:$
4049
+	 */
4050
+	private function resolveEntityFieldDataType(EE_Primary_Key_Field_Base $entity_PK): string
4051
+	{
4052
+		$entity_PK_type = $entity_PK->getSchemaType();
4053
+		switch ($entity_PK_type) {
4054
+			case 'boolean':
4055
+				return 'bool';
4056
+			case 'integer':
4057
+				return 'int';
4058
+			case 'number':
4059
+				return 'float';
4060
+			case 'string':
4061
+				return 'string';
4062
+		}
4063
+		throw new RuntimeException(
4064
+			sprintf(
4065
+				esc_html__(
4066
+					'"%1$s" is an invalid schema type for the %2$s primary key.',
4067
+					'event_espresso'
4068
+				),
4069
+				$entity_PK_type,
4070
+				$entity_PK->get_name()
4071
+			)
4072
+		);
4073
+	}
4074
+
4075
+
4076
+	/**
4077
+	 * @param EEM_Base      $entity_model
4078
+	 * @param int|string    $entity_ID
4079
+	 * @param string        $action        one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4080
+	 * @param string        $delete_column name of the field that denotes whether entity is trashed
4081
+	 * @param callable|null $callback      called after entity is trashed, restored, or deleted
4082
+	 * @return bool
4083
+	 */
4084
+	protected function trashRestoreDeleteEntity(
4085
+		EEM_Base $entity_model,
4086
+		$entity_ID,
4087
+		string $action,
4088
+		string $delete_column,
4089
+		callable $callback = null
4090
+	) {
4091
+		$entity_ID = absint($entity_ID);
4092
+		if (! $entity_ID) {
4093
+			$this->trashRestoreDeleteError($action, $entity_model);
4094
+		}
4095
+		$result = 0;
4096
+		try {
4097
+			switch ($action) {
4098
+				case EE_Admin_List_Table::ACTION_DELETE:
4099
+					$result = (bool) $entity_model->delete_permanently_by_ID($entity_ID);
4100
+					break;
4101
+				case EE_Admin_List_Table::ACTION_RESTORE:
4102
+					$this->validateDeleteColumn($entity_model, $delete_column);
4103
+					$result = $entity_model->update_by_ID([$delete_column => 0], $entity_ID);
4104
+					break;
4105
+				case EE_Admin_List_Table::ACTION_TRASH:
4106
+					$this->validateDeleteColumn($entity_model, $delete_column);
4107
+					$result = $entity_model->update_by_ID([$delete_column => 1], $entity_ID);
4108
+					break;
4109
+			}
4110
+		} catch (Exception $exception) {
4111
+			$this->trashRestoreDeleteError($action, $entity_model, $exception);
4112
+		}
4113
+		if (is_callable($callback)) {
4114
+			call_user_func_array($callback, [$entity_model, $entity_ID, $action, $result, $delete_column]);
4115
+		}
4116
+		return $result;
4117
+	}
4118
+
4119
+
4120
+	/**
4121
+	 * @param EEM_Base $entity_model
4122
+	 * @param string   $delete_column
4123
+	 * @since $VID:$
4124
+	 */
4125
+	private function validateDeleteColumn(EEM_Base $entity_model, string $delete_column)
4126
+	{
4127
+		if (empty($delete_column)) {
4128
+			throw new DomainException(
4129
+				sprintf(
4130
+					esc_html__(
4131
+						'You need to specify the name of the "delete column" on the %2$s model, in order to trash or restore an entity.',
4132
+						'event_espresso'
4133
+					),
4134
+					$entity_model->get_this_model_name()
4135
+				)
4136
+			);
4137
+		}
4138
+		if (! $entity_model->has_field($delete_column)) {
4139
+			throw new DomainException(
4140
+				sprintf(
4141
+					esc_html__(
4142
+						'The %1$s field does not exist on the %2$s model.',
4143
+						'event_espresso'
4144
+					),
4145
+					$delete_column,
4146
+					$entity_model->get_this_model_name()
4147
+				)
4148
+			);
4149
+		}
4150
+	}
4151
+
4152
+
4153
+	/**
4154
+	 * @param EEM_Base       $entity_model
4155
+	 * @param Exception|null $exception
4156
+	 * @param string         $action
4157
+	 * @since $VID:$
4158
+	 */
4159
+	private function trashRestoreDeleteError(string $action, EEM_Base $entity_model, ?Exception $exception = null)
4160
+	{
4161
+		if ($exception instanceof Exception) {
4162
+			throw new RuntimeException(
4163
+				sprintf(
4164
+					esc_html__(
4165
+						'Could not %1$s the %2$s because the following error occurred: %3$s',
4166
+						'event_espresso'
4167
+					),
4168
+					$action,
4169
+					$entity_model->get_this_model_name(),
4170
+					$exception->getMessage()
4171
+				)
4172
+			);
4173
+		}
4174
+		throw new RuntimeException(
4175
+			sprintf(
4176
+				esc_html__(
4177
+					'Could not %1$s the %2$s because an invalid ID was received.',
4178
+					'event_espresso'
4179
+				),
4180
+				$action,
4181
+				$entity_model->get_this_model_name()
4182
+			)
4183
+		);
4184
+	}
4185 4185
 }
Please login to merge, or discard this patch.
Spacing   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
         $ee_menu_slugs = (array) $ee_menu_slugs;
515 515
         if (
516 516
             ! $this->request->isAjax()
517
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
517
+            && ( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page]))
518 518
         ) {
519 519
             return;
520 520
         }
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
             : $req_action;
535 535
 
536 536
         $this->_current_view = $this->_req_action;
537
-        $this->_req_nonce    = $this->_req_action . '_nonce';
537
+        $this->_req_nonce    = $this->_req_action.'_nonce';
538 538
         $this->_define_page_props();
539 539
         $this->_current_page_view_url = add_query_arg(
540 540
             ['page' => $this->_current_page, 'action' => $this->_current_view],
@@ -571,21 +571,21 @@  discard block
 block discarded – undo
571 571
         }
572 572
         // filter routes and page_config so addons can add their stuff. Filtering done per class
573 573
         $this->_page_routes = apply_filters(
574
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
574
+            'FHEE__'.get_class($this).'__page_setup__page_routes',
575 575
             $this->_page_routes,
576 576
             $this
577 577
         );
578 578
         $this->_page_config = apply_filters(
579
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
579
+            'FHEE__'.get_class($this).'__page_setup__page_config',
580 580
             $this->_page_config,
581 581
             $this
582 582
         );
583 583
         // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
584 584
         // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
585
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
585
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
586 586
             add_action(
587 587
                 'AHEE__EE_Admin_Page__route_admin_request',
588
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
588
+                [$this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view],
589 589
                 10,
590 590
                 2
591 591
             );
@@ -598,8 +598,8 @@  discard block
 block discarded – undo
598 598
             if ($this->_is_UI_request) {
599 599
                 // admin_init stuff - global, all views for this page class, specific view
600 600
                 add_action('admin_init', [$this, 'admin_init'], 10);
601
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
602
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
601
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
602
+                    add_action('admin_init', [$this, 'admin_init_'.$this->_current_view], 15);
603 603
                 }
604 604
             } else {
605 605
                 // hijack regular WP loading and route admin request immediately
@@ -618,12 +618,12 @@  discard block
 block discarded – undo
618 618
      */
619 619
     private function _do_other_page_hooks()
620 620
     {
621
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
621
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, []);
622 622
         foreach ($registered_pages as $page) {
623 623
             // now let's setup the file name and class that should be present
624 624
             $classname = str_replace('.class.php', '', $page);
625 625
             // autoloaders should take care of loading file
626
-            if (! class_exists($classname)) {
626
+            if ( ! class_exists($classname)) {
627 627
                 $error_msg[] = sprintf(
628 628
                     esc_html__(
629 629
                         'Something went wrong with loading the %s admin hooks page.',
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
                                    ),
641 641
                                    $page,
642 642
                                    '<br />',
643
-                                   '<strong>' . $classname . '</strong>'
643
+                                   '<strong>'.$classname.'</strong>'
644 644
                                );
645 645
                 throw new EE_Error(implode('||', $error_msg));
646 646
             }
@@ -682,13 +682,13 @@  discard block
 block discarded – undo
682 682
         // load admin_notices - global, page class, and view specific
683 683
         add_action('admin_notices', [$this, 'admin_notices_global'], 5);
684 684
         add_action('admin_notices', [$this, 'admin_notices'], 10);
685
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
686
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
685
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
686
+            add_action('admin_notices', [$this, 'admin_notices_'.$this->_current_view], 15);
687 687
         }
688 688
         // load network admin_notices - global, page class, and view specific
689 689
         add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
690
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
691
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
690
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
691
+            add_action('network_admin_notices', [$this, 'network_admin_notices_'.$this->_current_view]);
692 692
         }
693 693
         // this will save any per_page screen options if they are present
694 694
         $this->_set_per_page_screen_options();
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
     protected function _verify_routes()
810 810
     {
811 811
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
812
-        if (! $this->_current_page && ! $this->request->isAjax()) {
812
+        if ( ! $this->_current_page && ! $this->request->isAjax()) {
813 813
             return false;
814 814
         }
815 815
         $this->_route = false;
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
                 $this->_admin_page_title
822 822
             );
823 823
             // developer error msg
824
-            $error_msg .= '||' . $error_msg
824
+            $error_msg .= '||'.$error_msg
825 825
                           . esc_html__(
826 826
                               ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
827 827
                               'event_espresso'
@@ -830,9 +830,9 @@  discard block
 block discarded – undo
830 830
         }
831 831
         // and that the requested page route exists
832 832
         if (array_key_exists($this->_req_action, $this->_page_routes)) {
833
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
834
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
835
-                ? $this->_page_config[ $this->_req_action ]
833
+            $this->_route        = $this->_page_routes[$this->_req_action];
834
+            $this->_route_config = isset($this->_page_config[$this->_req_action])
835
+                ? $this->_page_config[$this->_req_action]
836 836
                 : [];
837 837
         } else {
838 838
             // user error msg
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
                 $this->_admin_page_title
845 845
             );
846 846
             // developer error msg
847
-            $error_msg .= '||' . $error_msg
847
+            $error_msg .= '||'.$error_msg
848 848
                           . sprintf(
849 849
                               esc_html__(
850 850
                                   ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
             throw new EE_Error($error_msg);
856 856
         }
857 857
         // and that a default route exists
858
-        if (! array_key_exists('default', $this->_page_routes)) {
858
+        if ( ! array_key_exists('default', $this->_page_routes)) {
859 859
             // user error msg
860 860
             $error_msg = sprintf(
861 861
                 esc_html__(
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
                 $this->_admin_page_title
866 866
             );
867 867
             // developer error msg
868
-            $error_msg .= '||' . $error_msg
868
+            $error_msg .= '||'.$error_msg
869 869
                           . esc_html__(
870 870
                               ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
871 871
                               'event_espresso'
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
             $this->_admin_page_title
907 907
         );
908 908
         // developer error msg
909
-        $error_msg .= '||' . $error_msg
909
+        $error_msg .= '||'.$error_msg
910 910
                       . sprintf(
911 911
                           esc_html__(
912 912
                               ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
     protected function _verify_nonce($nonce, $nonce_ref)
932 932
     {
933 933
         // verify nonce against expected value
934
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
934
+        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
935 935
             // these are not the droids you are looking for !!!
936 936
             $msg = sprintf(
937 937
                 esc_html__('%sNonce Fail.%s', 'event_espresso'),
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
                     __CLASS__
949 949
                 );
950 950
             }
951
-            if (! $this->request->isAjax()) {
951
+            if ( ! $this->request->isAjax()) {
952 952
                 wp_die($msg);
953 953
             }
954 954
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
      */
973 973
     protected function _route_admin_request()
974 974
     {
975
-        if (! $this->_is_UI_request) {
975
+        if ( ! $this->_is_UI_request) {
976 976
             $this->_verify_routes();
977 977
         }
978 978
         $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
         $error_msg = '';
993 993
         // action right before calling route
994 994
         // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
995
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
995
+        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
996 996
             do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
997 997
         }
998 998
         // right before calling the route, let's clean the _wp_http_referer
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
                 wp_unslash($this->request->getServerParam('REQUEST_URI'))
1004 1004
             )
1005 1005
         );
1006
-        if (! empty($func)) {
1006
+        if ( ! empty($func)) {
1007 1007
             if (is_array($func)) {
1008 1008
                 list($class, $method) = $func;
1009 1009
             } elseif (strpos($func, '::') !== false) {
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
                 $class  = $this;
1013 1013
                 $method = $func;
1014 1014
             }
1015
-            if (! (is_object($class) && $class === $this)) {
1015
+            if ( ! (is_object($class) && $class === $this)) {
1016 1016
                 // send along this admin page object for access by addons.
1017 1017
                 $args['admin_page_object'] = $this;
1018 1018
             }
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
                     $method
1054 1054
                 );
1055 1055
             }
1056
-            if (! empty($error_msg)) {
1056
+            if ( ! empty($error_msg)) {
1057 1057
                 throw new EE_Error($error_msg);
1058 1058
             }
1059 1059
         }
@@ -1138,7 +1138,7 @@  discard block
 block discarded – undo
1138 1138
                 if (strpos($key, 'nonce') !== false) {
1139 1139
                     continue;
1140 1140
                 }
1141
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1141
+                $args['wp_referer['.$key.']'] = is_string($value) ? htmlspecialchars($value) : $value;
1142 1142
             }
1143 1143
         }
1144 1144
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1177,12 +1177,12 @@  discard block
 block discarded – undo
1177 1177
      */
1178 1178
     protected function _add_help_tabs()
1179 1179
     {
1180
-        if (isset($this->_page_config[ $this->_req_action ])) {
1181
-            $config = $this->_page_config[ $this->_req_action ];
1180
+        if (isset($this->_page_config[$this->_req_action])) {
1181
+            $config = $this->_page_config[$this->_req_action];
1182 1182
             // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1183 1183
             if (is_array($config) && isset($config['help_sidebar'])) {
1184 1184
                 // check that the callback given is valid
1185
-                if (! method_exists($this, $config['help_sidebar'])) {
1185
+                if ( ! method_exists($this, $config['help_sidebar'])) {
1186 1186
                     throw new EE_Error(
1187 1187
                         sprintf(
1188 1188
                             esc_html__(
@@ -1195,18 +1195,18 @@  discard block
 block discarded – undo
1195 1195
                     );
1196 1196
                 }
1197 1197
                 $content = apply_filters(
1198
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1198
+                    'FHEE__'.get_class($this).'__add_help_tabs__help_sidebar',
1199 1199
                     $this->{$config['help_sidebar']}()
1200 1200
                 );
1201 1201
                 $this->_current_screen->set_help_sidebar($content);
1202 1202
             }
1203
-            if (! isset($config['help_tabs'])) {
1203
+            if ( ! isset($config['help_tabs'])) {
1204 1204
                 return;
1205 1205
             } //no help tabs for this route
1206 1206
             foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1207 1207
                 // we're here so there ARE help tabs!
1208 1208
                 // make sure we've got what we need
1209
-                if (! isset($cfg['title'])) {
1209
+                if ( ! isset($cfg['title'])) {
1210 1210
                     throw new EE_Error(
1211 1211
                         esc_html__(
1212 1212
                             'The _page_config array is not set up properly for help tabs.  It is missing a title',
@@ -1214,7 +1214,7 @@  discard block
 block discarded – undo
1214 1214
                         )
1215 1215
                     );
1216 1216
                 }
1217
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1217
+                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1218 1218
                     throw new EE_Error(
1219 1219
                         esc_html__(
1220 1220
                             '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',
@@ -1223,11 +1223,11 @@  discard block
 block discarded – undo
1223 1223
                     );
1224 1224
                 }
1225 1225
                 // first priority goes to content.
1226
-                if (! empty($cfg['content'])) {
1226
+                if ( ! empty($cfg['content'])) {
1227 1227
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1228 1228
                     // second priority goes to filename
1229
-                } elseif (! empty($cfg['filename'])) {
1230
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1229
+                } elseif ( ! empty($cfg['filename'])) {
1230
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1231 1231
                     // 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)
1232 1232
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1233 1233
                                                              . basename($this->_get_dir())
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
                                                              . $cfg['filename']
1236 1236
                                                              . '.help_tab.php' : $file_path;
1237 1237
                     // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1238
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1238
+                    if ( ! isset($cfg['callback']) && ! is_readable($file_path)) {
1239 1239
                         EE_Error::add_error(
1240 1240
                             sprintf(
1241 1241
                                 esc_html__(
@@ -1283,7 +1283,7 @@  discard block
 block discarded – undo
1283 1283
                     return;
1284 1284
                 }
1285 1285
                 // setup config array for help tab method
1286
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1286
+                $id  = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1287 1287
                 $_ht = [
1288 1288
                     'id'       => $id,
1289 1289
                     'title'    => $cfg['title'],
@@ -1307,8 +1307,8 @@  discard block
 block discarded – undo
1307 1307
             $qtips = (array) $this->_route_config['qtips'];
1308 1308
             // load qtip loader
1309 1309
             $path = [
1310
-                $this->_get_dir() . '/qtips/',
1311
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1310
+                $this->_get_dir().'/qtips/',
1311
+                EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1312 1312
             ];
1313 1313
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1314 1314
         }
@@ -1330,7 +1330,7 @@  discard block
 block discarded – undo
1330 1330
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1331 1331
         $i = 0;
1332 1332
         foreach ($this->_page_config as $slug => $config) {
1333
-            if (! is_array($config) || empty($config['nav'])) {
1333
+            if ( ! is_array($config) || empty($config['nav'])) {
1334 1334
                 continue;
1335 1335
             }
1336 1336
             // no nav tab for this config
@@ -1339,12 +1339,12 @@  discard block
 block discarded – undo
1339 1339
                 // nav tab is only to appear when route requested.
1340 1340
                 continue;
1341 1341
             }
1342
-            if (! $this->check_user_access($slug, true)) {
1342
+            if ( ! $this->check_user_access($slug, true)) {
1343 1343
                 // no nav tab because current user does not have access.
1344 1344
                 continue;
1345 1345
             }
1346
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1347
-            $this->_nav_tabs[ $slug ] = [
1346
+            $css_class                = isset($config['css_class']) ? $config['css_class'].' ' : '';
1347
+            $this->_nav_tabs[$slug] = [
1348 1348
                 'url'       => isset($config['nav']['url'])
1349 1349
                     ? $config['nav']['url']
1350 1350
                     : self::add_query_args_and_nonce(
@@ -1356,14 +1356,14 @@  discard block
 block discarded – undo
1356 1356
                     : ucwords(
1357 1357
                         str_replace('_', ' ', $slug)
1358 1358
                     ),
1359
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1359
+                'css_class' => $this->_req_action === $slug ? $css_class.'nav-tab-active' : $css_class,
1360 1360
                 'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1361 1361
             ];
1362 1362
             $i++;
1363 1363
         }
1364 1364
         // if $this->_nav_tabs is empty then lets set the default
1365 1365
         if (empty($this->_nav_tabs)) {
1366
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1366
+            $this->_nav_tabs[$this->_default_nav_tab_name] = [
1367 1367
                 'url'       => $this->_admin_base_url,
1368 1368
                 'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1369 1369
                 'css_class' => 'nav-tab-active',
@@ -1388,10 +1388,10 @@  discard block
 block discarded – undo
1388 1388
             foreach ($this->_route_config['labels'] as $label => $text) {
1389 1389
                 if (is_array($text)) {
1390 1390
                     foreach ($text as $sublabel => $subtext) {
1391
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1391
+                        $this->_labels[$label][$sublabel] = $subtext;
1392 1392
                     }
1393 1393
                 } else {
1394
-                    $this->_labels[ $label ] = $text;
1394
+                    $this->_labels[$label] = $text;
1395 1395
                 }
1396 1396
             }
1397 1397
         }
@@ -1413,12 +1413,12 @@  discard block
 block discarded – undo
1413 1413
     {
1414 1414
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1415 1415
         $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1416
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1416
+        $capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1417 1417
                           && is_array(
1418
-                              $this->_page_routes[ $route_to_check ]
1418
+                              $this->_page_routes[$route_to_check]
1419 1419
                           )
1420
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1421
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1420
+                          && ! empty($this->_page_routes[$route_to_check]['capability'])
1421
+            ? $this->_page_routes[$route_to_check]['capability'] : null;
1422 1422
         if (empty($capability) && empty($route_to_check)) {
1423 1423
             $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1424 1424
                 : $this->_route['capability'];
@@ -1538,7 +1538,7 @@  discard block
 block discarded – undo
1538 1538
         ';
1539 1539
 
1540 1540
         // current set timezone for timezone js
1541
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1541
+        echo '<span id="current_timezone" class="hidden">'.esc_html(EEH_DTT_Helper::get_timezone()).'</span>';
1542 1542
     }
1543 1543
 
1544 1544
 
@@ -1572,7 +1572,7 @@  discard block
 block discarded – undo
1572 1572
         // loop through the array and setup content
1573 1573
         foreach ($help_array as $trigger => $help) {
1574 1574
             // make sure the array is setup properly
1575
-            if (! isset($help['title']) || ! isset($help['content'])) {
1575
+            if ( ! isset($help['title']) || ! isset($help['content'])) {
1576 1576
                 throw new EE_Error(
1577 1577
                     esc_html__(
1578 1578
                         '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',
@@ -1586,8 +1586,8 @@  discard block
 block discarded – undo
1586 1586
                 'help_popup_title'   => $help['title'],
1587 1587
                 'help_popup_content' => $help['content'],
1588 1588
             ];
1589
-            $content       .= EEH_Template::display_template(
1590
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1589
+            $content .= EEH_Template::display_template(
1590
+                EE_ADMIN_TEMPLATE.'admin_help_popup.template.php',
1591 1591
                 $template_args,
1592 1592
                 true
1593 1593
             );
@@ -1609,15 +1609,15 @@  discard block
 block discarded – undo
1609 1609
     private function _get_help_content()
1610 1610
     {
1611 1611
         // what is the method we're looking for?
1612
-        $method_name = '_help_popup_content_' . $this->_req_action;
1612
+        $method_name = '_help_popup_content_'.$this->_req_action;
1613 1613
         // if method doesn't exist let's get out.
1614
-        if (! method_exists($this, $method_name)) {
1614
+        if ( ! method_exists($this, $method_name)) {
1615 1615
             return [];
1616 1616
         }
1617 1617
         // k we're good to go let's retrieve the help array
1618 1618
         $help_array = call_user_func([$this, $method_name]);
1619 1619
         // make sure we've got an array!
1620
-        if (! is_array($help_array)) {
1620
+        if ( ! is_array($help_array)) {
1621 1621
             throw new EE_Error(
1622 1622
                 esc_html__(
1623 1623
                     'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
@@ -1649,15 +1649,15 @@  discard block
 block discarded – undo
1649 1649
         // 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
1650 1650
         $help_array   = $this->_get_help_content();
1651 1651
         $help_content = '';
1652
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1653
-            $help_array[ $trigger_id ] = [
1652
+        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1653
+            $help_array[$trigger_id] = [
1654 1654
                 'title'   => esc_html__('Missing Content', 'event_espresso'),
1655 1655
                 'content' => esc_html__(
1656 1656
                     '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.)',
1657 1657
                     'event_espresso'
1658 1658
                 ),
1659 1659
             ];
1660
-            $help_content              = $this->_set_help_popup_content($help_array);
1660
+            $help_content = $this->_set_help_popup_content($help_array);
1661 1661
         }
1662 1662
         // let's setup the trigger
1663 1663
         $content = '<a class="ee-dialog" href="?height='
@@ -1725,15 +1725,15 @@  discard block
 block discarded – undo
1725 1725
         // register all styles
1726 1726
         wp_register_style(
1727 1727
             'espresso-ui-theme',
1728
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1728
+            EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1729 1729
             [],
1730 1730
             EVENT_ESPRESSO_VERSION
1731 1731
         );
1732
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1732
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1733 1733
         // helpers styles
1734 1734
         wp_register_style(
1735 1735
             'ee-text-links',
1736
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1736
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css',
1737 1737
             [],
1738 1738
             EVENT_ESPRESSO_VERSION
1739 1739
         );
@@ -1741,21 +1741,21 @@  discard block
 block discarded – undo
1741 1741
         // register all scripts
1742 1742
         wp_register_script(
1743 1743
             'ee-dialog',
1744
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1744
+            EE_ADMIN_URL.'assets/ee-dialog-helper.js',
1745 1745
             ['jquery', 'jquery-ui-draggable'],
1746 1746
             EVENT_ESPRESSO_VERSION,
1747 1747
             true
1748 1748
         );
1749 1749
         wp_register_script(
1750 1750
             'ee_admin_js',
1751
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1751
+            EE_ADMIN_URL.'assets/ee-admin-page.js',
1752 1752
             ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1753 1753
             EVENT_ESPRESSO_VERSION,
1754 1754
             true
1755 1755
         );
1756 1756
         wp_register_script(
1757 1757
             'jquery-ui-timepicker-addon',
1758
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1758
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js',
1759 1759
             ['jquery-ui-datepicker', 'jquery-ui-slider'],
1760 1760
             EVENT_ESPRESSO_VERSION,
1761 1761
             true
@@ -1763,7 +1763,7 @@  discard block
 block discarded – undo
1763 1763
         // script for sorting tables
1764 1764
         wp_register_script(
1765 1765
             'espresso_ajax_table_sorting',
1766
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1766
+            EE_ADMIN_URL.'assets/espresso_ajax_table_sorting.js',
1767 1767
             ['ee_admin_js', 'jquery-ui-sortable'],
1768 1768
             EVENT_ESPRESSO_VERSION,
1769 1769
             true
@@ -1771,7 +1771,7 @@  discard block
 block discarded – undo
1771 1771
         // script for parsing uri's
1772 1772
         wp_register_script(
1773 1773
             'ee-parse-uri',
1774
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1774
+            EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js',
1775 1775
             [],
1776 1776
             EVENT_ESPRESSO_VERSION,
1777 1777
             true
@@ -1779,7 +1779,7 @@  discard block
 block discarded – undo
1779 1779
         // and parsing associative serialized form elements
1780 1780
         wp_register_script(
1781 1781
             'ee-serialize-full-array',
1782
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1782
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js',
1783 1783
             ['jquery'],
1784 1784
             EVENT_ESPRESSO_VERSION,
1785 1785
             true
@@ -1787,28 +1787,28 @@  discard block
 block discarded – undo
1787 1787
         // helpers scripts
1788 1788
         wp_register_script(
1789 1789
             'ee-text-links',
1790
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1790
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js',
1791 1791
             ['jquery'],
1792 1792
             EVENT_ESPRESSO_VERSION,
1793 1793
             true
1794 1794
         );
1795 1795
         wp_register_script(
1796 1796
             'ee-moment-core',
1797
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1797
+            EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js',
1798 1798
             [],
1799 1799
             EVENT_ESPRESSO_VERSION,
1800 1800
             true
1801 1801
         );
1802 1802
         wp_register_script(
1803 1803
             'ee-moment',
1804
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1804
+            EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js',
1805 1805
             ['ee-moment-core'],
1806 1806
             EVENT_ESPRESSO_VERSION,
1807 1807
             true
1808 1808
         );
1809 1809
         wp_register_script(
1810 1810
             'ee-datepicker',
1811
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1811
+            EE_ADMIN_URL.'assets/ee-datepicker.js',
1812 1812
             ['jquery-ui-timepicker-addon', 'ee-moment'],
1813 1813
             EVENT_ESPRESSO_VERSION,
1814 1814
             true
@@ -1841,7 +1841,7 @@  discard block
 block discarded – undo
1841 1841
         wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1842 1842
         add_filter(
1843 1843
             'admin_body_class',
1844
-            function ($classes) {
1844
+            function($classes) {
1845 1845
                 if (strpos($classes, 'espresso-admin') === false) {
1846 1846
                     $classes .= ' espresso-admin';
1847 1847
                 }
@@ -1929,12 +1929,12 @@  discard block
 block discarded – undo
1929 1929
     protected function _set_list_table()
1930 1930
     {
1931 1931
         // first is this a list_table view?
1932
-        if (! isset($this->_route_config['list_table'])) {
1932
+        if ( ! isset($this->_route_config['list_table'])) {
1933 1933
             return;
1934 1934
         } //not a list_table view so get out.
1935 1935
         // list table functions are per view specific (because some admin pages might have more than one list table!)
1936
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
1937
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1936
+        $list_table_view = '_set_list_table_views_'.$this->_req_action;
1937
+        if ( ! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1938 1938
             // user error msg
1939 1939
             $error_msg = esc_html__(
1940 1940
                 'An error occurred. The requested list table views could not be found.',
@@ -1954,10 +1954,10 @@  discard block
 block discarded – undo
1954 1954
         }
1955 1955
         // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1956 1956
         $this->_views = apply_filters(
1957
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1957
+            'FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action,
1958 1958
             $this->_views
1959 1959
         );
1960
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1960
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
1961 1961
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1962 1962
         $this->_set_list_table_view();
1963 1963
         $this->_set_list_table_object();
@@ -1992,7 +1992,7 @@  discard block
 block discarded – undo
1992 1992
     protected function _set_list_table_object()
1993 1993
     {
1994 1994
         if (isset($this->_route_config['list_table'])) {
1995
-            if (! class_exists($this->_route_config['list_table'])) {
1995
+            if ( ! class_exists($this->_route_config['list_table'])) {
1996 1996
                 throw new EE_Error(
1997 1997
                     sprintf(
1998 1998
                         esc_html__(
@@ -2030,15 +2030,15 @@  discard block
 block discarded – undo
2030 2030
         foreach ($this->_views as $key => $view) {
2031 2031
             $query_args = [];
2032 2032
             // check for current view
2033
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2033
+            $this->_views[$key]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2034 2034
             $query_args['action']                        = $this->_req_action;
2035
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2035
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
2036 2036
             $query_args['status']                        = $view['slug'];
2037 2037
             // merge any other arguments sent in.
2038
-            if (isset($extra_query_args[ $view['slug'] ])) {
2039
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2038
+            if (isset($extra_query_args[$view['slug']])) {
2039
+                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
2040 2040
             }
2041
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2041
+            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2042 2042
         }
2043 2043
         return $this->_views;
2044 2044
     }
@@ -2069,14 +2069,14 @@  discard block
 block discarded – undo
2069 2069
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2070 2070
         foreach ($values as $value) {
2071 2071
             if ($value < $max_entries) {
2072
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2072
+                $selected = $value === $per_page ? ' selected="'.$per_page.'"' : '';
2073 2073
                 $entries_per_page_dropdown .= '
2074
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2074
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
2075 2075
             }
2076 2076
         }
2077
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2077
+        $selected = $max_entries === $per_page ? ' selected="'.$per_page.'"' : '';
2078 2078
         $entries_per_page_dropdown .= '
2079
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2079
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
2080 2080
         $entries_per_page_dropdown .= '
2081 2081
 					</select>
2082 2082
 					entries
@@ -2100,7 +2100,7 @@  discard block
 block discarded – undo
2100 2100
             empty($this->_search_btn_label) ? $this->page_label
2101 2101
                 : $this->_search_btn_label
2102 2102
         );
2103
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2103
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
2104 2104
     }
2105 2105
 
2106 2106
 
@@ -2188,7 +2188,7 @@  discard block
 block discarded – undo
2188 2188
             $total_columns                                       = ! empty($screen_columns)
2189 2189
                 ? $screen_columns
2190 2190
                 : $this->_route_config['columns'][1];
2191
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2191
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
2192 2192
             $this->_template_args['current_page']                = $this->_wp_page_slug;
2193 2193
             $this->_template_args['screen']                      = $this->_current_screen;
2194 2194
             $this->_column_template_path                         = EE_ADMIN_TEMPLATE
@@ -2233,7 +2233,7 @@  discard block
 block discarded – undo
2233 2233
      */
2234 2234
     protected function _espresso_ratings_request()
2235 2235
     {
2236
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2236
+        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2237 2237
             return;
2238 2238
         }
2239 2239
         $ratings_box_title = apply_filters(
@@ -2261,7 +2261,7 @@  discard block
 block discarded – undo
2261 2261
     public function espresso_ratings_request()
2262 2262
     {
2263 2263
         EEH_Template::display_template(
2264
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2264
+            EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php',
2265 2265
             []
2266 2266
         );
2267 2267
     }
@@ -2269,22 +2269,22 @@  discard block
 block discarded – undo
2269 2269
 
2270 2270
     public static function cached_rss_display($rss_id, $url)
2271 2271
     {
2272
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2272
+        $loading = '<p class="widget-loading hide-if-no-js">'
2273 2273
                      . esc_html__('Loading&#8230;', 'event_espresso')
2274 2274
                      . '</p><p class="hide-if-js">'
2275 2275
                      . esc_html__('This widget requires JavaScript.', 'event_espresso')
2276 2276
                      . '</p>';
2277
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2278
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2279
-        $post      = '</div>' . "\n";
2280
-        $cache_key = 'ee_rss_' . md5($rss_id);
2277
+        $pre       = '<div class="espresso-rss-display">'."\n\t";
2278
+        $pre .= '<span id="'.esc_attr($rss_id).'_url" class="hidden">'.esc_url_raw($url).'</span>';
2279
+        $post      = '</div>'."\n";
2280
+        $cache_key = 'ee_rss_'.md5($rss_id);
2281 2281
         $output    = get_transient($cache_key);
2282 2282
         if ($output !== false) {
2283
-            echo wp_kses($pre . $output . $post, AllowedTags::getWithFormTags());
2283
+            echo wp_kses($pre.$output.$post, AllowedTags::getWithFormTags());
2284 2284
             return true;
2285 2285
         }
2286
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2287
-            echo wp_kses($pre . $loading . $post, AllowedTags::getWithFormTags());
2286
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
2287
+            echo wp_kses($pre.$loading.$post, AllowedTags::getWithFormTags());
2288 2288
             return false;
2289 2289
         }
2290 2290
         ob_start();
@@ -2351,19 +2351,19 @@  discard block
 block discarded – undo
2351 2351
     public function espresso_sponsors_post_box()
2352 2352
     {
2353 2353
         EEH_Template::display_template(
2354
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2354
+            EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'
2355 2355
         );
2356 2356
     }
2357 2357
 
2358 2358
 
2359 2359
     private function _publish_post_box()
2360 2360
     {
2361
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2361
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2362 2362
         // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2363 2363
         // then we'll use that for the metabox label.
2364 2364
         // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2365
-        if (! empty($this->_labels['publishbox'])) {
2366
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2365
+        if ( ! empty($this->_labels['publishbox'])) {
2366
+            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2367 2367
                 : $this->_labels['publishbox'];
2368 2368
         } else {
2369 2369
             $box_label = esc_html__('Publish', 'event_espresso');
@@ -2392,7 +2392,7 @@  discard block
 block discarded – undo
2392 2392
             ? $this->_template_args['publish_box_extra_content']
2393 2393
             : '';
2394 2394
         echo EEH_Template::display_template(
2395
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2395
+            EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php',
2396 2396
             $this->_template_args,
2397 2397
             true
2398 2398
         );
@@ -2484,18 +2484,18 @@  discard block
 block discarded – undo
2484 2484
             );
2485 2485
         }
2486 2486
         $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2487
-        if (! empty($name) && ! empty($id)) {
2488
-            $hidden_field_arr[ $name ] = [
2487
+        if ( ! empty($name) && ! empty($id)) {
2488
+            $hidden_field_arr[$name] = [
2489 2489
                 'type'  => 'hidden',
2490 2490
                 'value' => $id,
2491 2491
             ];
2492
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2492
+            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2493 2493
         } else {
2494 2494
             $hf = '';
2495 2495
         }
2496 2496
         // add hidden field
2497 2497
         $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2498
-            ? $hf[ $name ]['field']
2498
+            ? $hf[$name]['field']
2499 2499
             : $hf;
2500 2500
     }
2501 2501
 
@@ -2597,7 +2597,7 @@  discard block
 block discarded – undo
2597 2597
         }
2598 2598
         // 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)
2599 2599
         $call_back_func = $create_func
2600
-            ? function ($post, $metabox) {
2600
+            ? function($post, $metabox) {
2601 2601
                 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2602 2602
                 echo EEH_Template::display_template(
2603 2603
                     $metabox['args']['template_path'],
@@ -2607,7 +2607,7 @@  discard block
 block discarded – undo
2607 2607
             }
2608 2608
             : $callback;
2609 2609
         add_meta_box(
2610
-            str_replace('_', '-', $action) . '-mbox',
2610
+            str_replace('_', '-', $action).'-mbox',
2611 2611
             $title,
2612 2612
             $call_back_func,
2613 2613
             $this->_wp_page_slug,
@@ -2699,9 +2699,9 @@  discard block
 block discarded – undo
2699 2699
             : 'espresso-default-admin';
2700 2700
         $template_path                                     = $sidebar
2701 2701
             ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2702
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2702
+            : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2703 2703
         if ($this->request->isAjax()) {
2704
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2704
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2705 2705
         }
2706 2706
         $template_path                                     = ! empty($this->_column_template_path)
2707 2707
             ? $this->_column_template_path : $template_path;
@@ -2741,11 +2741,11 @@  discard block
 block discarded – undo
2741 2741
     public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2742 2742
     {
2743 2743
         // let's generate a default preview action button if there isn't one already present.
2744
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2744
+        $this->_labels['buttons']['buy_now'] = esc_html__(
2745 2745
             'Upgrade to Event Espresso 4 Right Now',
2746 2746
             'event_espresso'
2747 2747
         );
2748
-        $buy_now_url                                   = add_query_arg(
2748
+        $buy_now_url = add_query_arg(
2749 2749
             [
2750 2750
                 'ee_ver'       => 'ee4',
2751 2751
                 'utm_source'   => 'ee4_plugin_admin',
@@ -2765,8 +2765,8 @@  discard block
 block discarded – undo
2765 2765
                 true
2766 2766
             )
2767 2767
             : $this->_template_args['preview_action_button'];
2768
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2769
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2768
+        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2769
+            EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php',
2770 2770
             $this->_template_args,
2771 2771
             true
2772 2772
         );
@@ -2815,7 +2815,7 @@  discard block
 block discarded – undo
2815 2815
         // setup search attributes
2816 2816
         $this->_set_search_attributes();
2817 2817
         $this->_template_args['current_page']     = $this->_wp_page_slug;
2818
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2818
+        $template_path                            = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2819 2819
         $this->_template_args['table_url']        = $this->request->isAjax()
2820 2820
             ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2821 2821
             : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
@@ -2823,10 +2823,10 @@  discard block
 block discarded – undo
2823 2823
         $this->_template_args['current_route']    = $this->_req_action;
2824 2824
         $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2825 2825
         $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2826
-        if (! empty($ajax_sorting_callback)) {
2826
+        if ( ! empty($ajax_sorting_callback)) {
2827 2827
             $sortable_list_table_form_fields = wp_nonce_field(
2828
-                $ajax_sorting_callback . '_nonce',
2829
-                $ajax_sorting_callback . '_nonce',
2828
+                $ajax_sorting_callback.'_nonce',
2829
+                $ajax_sorting_callback.'_nonce',
2830 2830
                 false,
2831 2831
                 false
2832 2832
             );
@@ -2844,20 +2844,20 @@  discard block
 block discarded – undo
2844 2844
             isset($this->_template_args['list_table_hidden_fields'])
2845 2845
                 ? $this->_template_args['list_table_hidden_fields']
2846 2846
                 : '';
2847
-        $nonce_ref                                               = $this->_req_action . '_nonce';
2848
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
2847
+        $nonce_ref = $this->_req_action.'_nonce';
2848
+        $hidden_form_fields .= '<input type="hidden" name="'
2849 2849
                                                                     . $nonce_ref
2850 2850
                                                                     . '" value="'
2851 2851
                                                                     . wp_create_nonce($nonce_ref)
2852 2852
                                                                     . '">';
2853
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2853
+        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2854 2854
         // display message about search results?
2855 2855
         $search = $this->request->getRequestParam('s');
2856 2856
         $this->_template_args['before_list_table'] .= ! empty($search)
2857
-            ? '<p class="ee-search-results">' . sprintf(
2857
+            ? '<p class="ee-search-results">'.sprintf(
2858 2858
                 esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2859 2859
                 trim($search, '%')
2860
-            ) . '</p>'
2860
+            ).'</p>'
2861 2861
             : '';
2862 2862
         // filter before_list_table template arg
2863 2863
         $this->_template_args['before_list_table'] = apply_filters(
@@ -2891,7 +2891,7 @@  discard block
 block discarded – undo
2891 2891
         // convert to array and filter again
2892 2892
         // arrays are easier to inject new items in a specific location,
2893 2893
         // but would not be backwards compatible, so we have to add a new filter
2894
-        $this->_template_args['after_list_table']   = implode(
2894
+        $this->_template_args['after_list_table'] = implode(
2895 2895
             " \n",
2896 2896
             (array) apply_filters(
2897 2897
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
@@ -2938,7 +2938,7 @@  discard block
 block discarded – undo
2938 2938
             $this
2939 2939
         );
2940 2940
         return EEH_Template::display_template(
2941
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2941
+            EE_ADMIN_TEMPLATE.'admin_details_legend.template.php',
2942 2942
             $this->_template_args,
2943 2943
             true
2944 2944
         );
@@ -3047,18 +3047,18 @@  discard block
 block discarded – undo
3047 3047
                 : ''
3048 3048
         );
3049 3049
 
3050
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3050
+        $this->_template_args['after_admin_page_content'] = apply_filters(
3051 3051
             "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3052 3052
             isset($this->_template_args['after_admin_page_content'])
3053 3053
                 ? $this->_template_args['after_admin_page_content']
3054 3054
                 : ''
3055 3055
         );
3056
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3056
+        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3057 3057
 
3058 3058
         if ($this->request->isAjax()) {
3059 3059
             $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3060 3060
                 // $template_path,
3061
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3061
+                EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php',
3062 3062
                 $this->_template_args,
3063 3063
                 true
3064 3064
             );
@@ -3067,7 +3067,7 @@  discard block
 block discarded – undo
3067 3067
         // load settings page wrapper template
3068 3068
         $template_path = $about
3069 3069
             ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3070
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3070
+            : EE_ADMIN_TEMPLATE.'admin_wrapper.template.php';
3071 3071
 
3072 3072
         EEH_Template::display_template($template_path, $this->_template_args);
3073 3073
     }
@@ -3152,12 +3152,12 @@  discard block
 block discarded – undo
3152 3152
         $default_names = ['save', 'save_and_close'];
3153 3153
         $buttons = '';
3154 3154
         foreach ($button_text as $key => $button) {
3155
-            $ref     = $default_names[ $key ];
3156
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3157
-            $buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3158
-                        . 'value="' . $button . '" name="' . $name . '" '
3159
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3160
-            if (! $both) {
3155
+            $ref     = $default_names[$key];
3156
+            $name    = ! empty($actions) ? $actions[$key] : $ref;
3157
+            $buttons .= '<input type="submit" class="button-primary '.$ref.'" '
3158
+                        . 'value="'.$button.'" name="'.$name.'" '
3159
+                        . 'id="'.$this->_current_view.'_'.$ref.'" />';
3160
+            if ( ! $both) {
3161 3161
                 break;
3162 3162
             }
3163 3163
         }
@@ -3197,13 +3197,13 @@  discard block
 block discarded – undo
3197 3197
                 'An error occurred. No action was set for this page\'s form.',
3198 3198
                 'event_espresso'
3199 3199
             );
3200
-            $dev_msg  = $user_msg . "\n"
3200
+            $dev_msg = $user_msg."\n"
3201 3201
                         . sprintf(
3202 3202
                             esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3203 3203
                             __FUNCTION__,
3204 3204
                             __CLASS__
3205 3205
                         );
3206
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3206
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
3207 3207
         }
3208 3208
         // open form
3209 3209
         $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
@@ -3212,9 +3212,9 @@  discard block
 block discarded – undo
3212 3212
                                                              . $route
3213 3213
                                                              . '_event_form" >';
3214 3214
         // add nonce
3215
-        $nonce                                             =
3216
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3217
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3215
+        $nonce =
3216
+            wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
3217
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
3218 3218
         // add REQUIRED form action
3219 3219
         $hidden_fields = [
3220 3220
             'action' => ['type' => 'hidden', 'value' => $route],
@@ -3227,7 +3227,7 @@  discard block
 block discarded – undo
3227 3227
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3228 3228
         // add fields to form
3229 3229
         foreach ((array) $form_fields as $form_field) {
3230
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3230
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
3231 3231
         }
3232 3232
         // close form
3233 3233
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -3318,10 +3318,10 @@  discard block
 block discarded – undo
3318 3318
         $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3319 3319
         $notices      = EE_Error::get_notices(false);
3320 3320
         // overwrite default success messages //BUT ONLY if overwrite not overridden
3321
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3321
+        if ( ! $override_overwrite || ! empty($notices['errors'])) {
3322 3322
             EE_Error::overwrite_success();
3323 3323
         }
3324
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3324
+        if ( ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3325 3325
             // how many records affected ? more than one record ? or just one ?
3326 3326
             if ($success > 1) {
3327 3327
                 // set plural msg
@@ -3350,7 +3350,7 @@  discard block
 block discarded – undo
3350 3350
             }
3351 3351
         }
3352 3352
         // check that $query_args isn't something crazy
3353
-        if (! is_array($query_args)) {
3353
+        if ( ! is_array($query_args)) {
3354 3354
             $query_args = [];
3355 3355
         }
3356 3356
         /**
@@ -3379,7 +3379,7 @@  discard block
 block discarded – undo
3379 3379
             $redirect_url = admin_url('admin.php');
3380 3380
         }
3381 3381
         // merge any default query_args set in _default_route_query_args property
3382
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3382
+        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3383 3383
             $args_to_merge = [];
3384 3384
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
3385 3385
                 // is there a wp_referer array in our _default_route_query_args property?
@@ -3391,15 +3391,15 @@  discard block
 block discarded – undo
3391 3391
                         }
3392 3392
                         // finally we will override any arguments in the referer with
3393 3393
                         // what might be set on the _default_route_query_args array.
3394
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3395
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3394
+                        if (isset($this->_default_route_query_args[$reference])) {
3395
+                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3396 3396
                         } else {
3397
-                            $args_to_merge[ $reference ] = urlencode($value);
3397
+                            $args_to_merge[$reference] = urlencode($value);
3398 3398
                         }
3399 3399
                     }
3400 3400
                     continue;
3401 3401
                 }
3402
-                $args_to_merge[ $query_param ] = $query_value;
3402
+                $args_to_merge[$query_param] = $query_value;
3403 3403
             }
3404 3404
             // now let's merge these arguments but override with what was specifically sent in to the
3405 3405
             // redirect.
@@ -3411,19 +3411,19 @@  discard block
 block discarded – undo
3411 3411
         if (isset($query_args['action'])) {
3412 3412
             // manually generate wp_nonce and merge that with the query vars
3413 3413
             // becuz the wp_nonce_url function wrecks havoc on some vars
3414
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3414
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
3415 3415
         }
3416 3416
         // we're adding some hooks and filters in here for processing any things just before redirects
3417 3417
         // (example: an admin page has done an insert or update and we want to run something after that).
3418
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3418
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
3419 3419
         $redirect_url = apply_filters(
3420
-            'FHEE_redirect_' . $classname . $this->_req_action,
3420
+            'FHEE_redirect_'.$classname.$this->_req_action,
3421 3421
             self::add_query_args_and_nonce($query_args, $redirect_url),
3422 3422
             $query_args
3423 3423
         );
3424 3424
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3425 3425
         if ($this->request->isAjax()) {
3426
-            $default_data                    = [
3426
+            $default_data = [
3427 3427
                 'close'        => true,
3428 3428
                 'redirect_url' => $redirect_url,
3429 3429
                 'where'        => 'main',
@@ -3470,7 +3470,7 @@  discard block
 block discarded – undo
3470 3470
         }
3471 3471
         $this->_template_args['notices'] = EE_Error::get_notices();
3472 3472
         // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3473
-        if (! $this->request->isAjax() || $sticky_notices) {
3473
+        if ( ! $this->request->isAjax() || $sticky_notices) {
3474 3474
             $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3475 3475
             $this->_add_transient(
3476 3476
                 $route,
@@ -3510,7 +3510,7 @@  discard block
 block discarded – undo
3510 3510
         $exclude_nonce = false
3511 3511
     ) {
3512 3512
         // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3513
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3513
+        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3514 3514
             throw new EE_Error(
3515 3515
                 sprintf(
3516 3516
                     esc_html__(
@@ -3521,7 +3521,7 @@  discard block
 block discarded – undo
3521 3521
                 )
3522 3522
             );
3523 3523
         }
3524
-        if (! isset($this->_labels['buttons'][ $type ])) {
3524
+        if ( ! isset($this->_labels['buttons'][$type])) {
3525 3525
             throw new EE_Error(
3526 3526
                 sprintf(
3527 3527
                     esc_html__(
@@ -3534,7 +3534,7 @@  discard block
 block discarded – undo
3534 3534
         }
3535 3535
         // finally check user access for this button.
3536 3536
         $has_access = $this->check_user_access($action, true);
3537
-        if (! $has_access) {
3537
+        if ( ! $has_access) {
3538 3538
             return '';
3539 3539
         }
3540 3540
         $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
@@ -3542,11 +3542,11 @@  discard block
 block discarded – undo
3542 3542
             'action' => $action,
3543 3543
         ];
3544 3544
         // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3545
-        if (! empty($extra_request)) {
3545
+        if ( ! empty($extra_request)) {
3546 3546
             $query_args = array_merge($extra_request, $query_args);
3547 3547
         }
3548 3548
         $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3549
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3549
+        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3550 3550
     }
3551 3551
 
3552 3552
 
@@ -3572,7 +3572,7 @@  discard block
 block discarded – undo
3572 3572
                 'FHEE__EE_Admin_Page___per_page_screen_options__default',
3573 3573
                 20
3574 3574
             ),
3575
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3575
+            'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3576 3576
         ];
3577 3577
         // ONLY add the screen option if the user has access to it.
3578 3578
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3593,18 +3593,18 @@  discard block
 block discarded – undo
3593 3593
     {
3594 3594
         if ($this->request->requestParamIsSet('wp_screen_options')) {
3595 3595
             check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3596
-            if (! $user = wp_get_current_user()) {
3596
+            if ( ! $user = wp_get_current_user()) {
3597 3597
                 return;
3598 3598
             }
3599 3599
             $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3600
-            if (! $option) {
3600
+            if ( ! $option) {
3601 3601
                 return;
3602 3602
             }
3603
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3603
+            $value = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3604 3604
             $map_option = $option;
3605 3605
             $option     = str_replace('-', '_', $option);
3606 3606
             switch ($map_option) {
3607
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3607
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3608 3608
                     $max_value = apply_filters(
3609 3609
                         'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3610 3610
                         999,
@@ -3661,13 +3661,13 @@  discard block
 block discarded – undo
3661 3661
     protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3662 3662
     {
3663 3663
         $user_id = get_current_user_id();
3664
-        if (! $skip_route_verify) {
3664
+        if ( ! $skip_route_verify) {
3665 3665
             $this->_verify_route($route);
3666 3666
         }
3667 3667
         // now let's set the string for what kind of transient we're setting
3668 3668
         $transient = $notices
3669
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3670
-            : 'rte_tx_' . $route . '_' . $user_id;
3669
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3670
+            : 'rte_tx_'.$route.'_'.$user_id;
3671 3671
         $data      = $notices ? ['notices' => $data] : $data;
3672 3672
         // is there already a transient for this route?  If there is then let's ADD to that transient
3673 3673
         $existing = is_multisite() && is_network_admin()
@@ -3696,8 +3696,8 @@  discard block
 block discarded – undo
3696 3696
         $user_id   = get_current_user_id();
3697 3697
         $route     = ! $route ? $this->_req_action : $route;
3698 3698
         $transient = $notices
3699
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3700
-            : 'rte_tx_' . $route . '_' . $user_id;
3699
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3700
+            : 'rte_tx_'.$route.'_'.$user_id;
3701 3701
         $data      = is_multisite() && is_network_admin()
3702 3702
             ? get_site_transient($transient)
3703 3703
             : get_transient($transient);
@@ -3928,7 +3928,7 @@  discard block
 block discarded – undo
3928 3928
      */
3929 3929
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3930 3930
     {
3931
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3931
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3932 3932
     }
3933 3933
 
3934 3934
 
@@ -3941,7 +3941,7 @@  discard block
 block discarded – undo
3941 3941
      */
3942 3942
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3943 3943
     {
3944
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3944
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3945 3945
     }
3946 3946
 
3947 3947
 
@@ -4089,7 +4089,7 @@  discard block
 block discarded – undo
4089 4089
         callable $callback = null
4090 4090
     ) {
4091 4091
         $entity_ID = absint($entity_ID);
4092
-        if (! $entity_ID) {
4092
+        if ( ! $entity_ID) {
4093 4093
             $this->trashRestoreDeleteError($action, $entity_model);
4094 4094
         }
4095 4095
         $result = 0;
@@ -4135,7 +4135,7 @@  discard block
 block discarded – undo
4135 4135
                 )
4136 4136
             );
4137 4137
         }
4138
-        if (! $entity_model->has_field($delete_column)) {
4138
+        if ( ! $entity_model->has_field($delete_column)) {
4139 4139
             throw new DomainException(
4140 4140
                 sprintf(
4141 4141
                     esc_html__(
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.30.rc.030');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.30.rc.030');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
141 141
\ No newline at end of file
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 2 patches
Indentation   +1413 added lines, -1413 removed lines patch added patch discarded remove patch
@@ -20,1428 +20,1428 @@
 block discarded – undo
20 20
 class General_Settings_Admin_Page extends EE_Admin_Page
21 21
 {
22 22
 
23
-    /**
24
-     * @var EE_Core_Config
25
-     */
26
-    public $core_config;
27
-
28
-
29
-    /**
30
-     * Initialize basic properties.
31
-     */
32
-    protected function _init_page_props()
33
-    {
34
-        $this->page_slug        = GEN_SET_PG_SLUG;
35
-        $this->page_label       = GEN_SET_LABEL;
36
-        $this->_admin_base_url  = GEN_SET_ADMIN_URL;
37
-        $this->_admin_base_path = GEN_SET_ADMIN;
38
-    }
39
-
40
-
41
-    /**
42
-     * Set ajax hooks
43
-     */
44
-    protected function _ajax_hooks()
45
-    {
46
-        add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
47
-        add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
48
-        add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
49
-        add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
50
-    }
51
-
52
-
53
-    /**
54
-     * More page properties initialization.
55
-     */
56
-    protected function _define_page_props()
57
-    {
58
-        $this->_admin_page_title = GEN_SET_LABEL;
59
-        $this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
60
-    }
61
-
62
-
63
-    /**
64
-     * Set page routes property.
65
-     */
66
-    protected function _set_page_routes()
67
-    {
68
-        $this->_page_routes = [
69
-            'critical_pages'                => [
70
-                'func'       => '_espresso_page_settings',
71
-                'capability' => 'manage_options',
72
-            ],
73
-            'update_espresso_page_settings' => [
74
-                'func'       => '_update_espresso_page_settings',
75
-                'capability' => 'manage_options',
76
-                'noheader'   => true,
77
-            ],
78
-            'default'                       => [
79
-                'func'       => '_your_organization_settings',
80
-                'capability' => 'manage_options',
81
-            ],
82
-
83
-            'update_your_organization_settings' => [
84
-                'func'       => '_update_your_organization_settings',
85
-                'capability' => 'manage_options',
86
-                'noheader'   => true,
87
-            ],
88
-
89
-            'admin_option_settings' => [
90
-                'func'       => '_admin_option_settings',
91
-                'capability' => 'manage_options',
92
-            ],
93
-
94
-            'update_admin_option_settings' => [
95
-                'func'       => '_update_admin_option_settings',
96
-                'capability' => 'manage_options',
97
-                'noheader'   => true,
98
-            ],
99
-
100
-            'country_settings' => [
101
-                'func'       => '_country_settings',
102
-                'capability' => 'manage_options',
103
-            ],
104
-
105
-            'update_country_settings' => [
106
-                'func'       => '_update_country_settings',
107
-                'capability' => 'manage_options',
108
-                'noheader'   => true,
109
-            ],
110
-
111
-            'display_country_settings' => [
112
-                'func'       => 'display_country_settings',
113
-                'capability' => 'manage_options',
114
-                'noheader'   => true,
115
-            ],
116
-
117
-            'add_new_state' => [
118
-                'func'       => 'add_new_state',
119
-                'capability' => 'manage_options',
120
-                'noheader'   => true,
121
-            ],
122
-
123
-            'delete_state'            => [
124
-                'func'       => 'delete_state',
125
-                'capability' => 'manage_options',
126
-                'noheader'   => true,
127
-            ],
128
-            'privacy_settings'        => [
129
-                'func'       => 'privacySettings',
130
-                'capability' => 'manage_options',
131
-            ],
132
-            'update_privacy_settings' => [
133
-                'func'               => 'updatePrivacySettings',
134
-                'capability'         => 'manage_options',
135
-                'noheader'           => true,
136
-                'headers_sent_route' => 'privacy_settings',
137
-            ],
138
-        ];
139
-    }
140
-
141
-
142
-    /**
143
-     * Set page configuration property
144
-     */
145
-    protected function _set_page_config()
146
-    {
147
-        $this->_page_config = [
148
-            'critical_pages'        => [
149
-                'nav'           => [
150
-                    'label' => esc_html__('Critical Pages', 'event_espresso'),
151
-                    'order' => 50,
152
-                ],
153
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
154
-                'help_tabs'     => [
155
-                    'general_settings_critical_pages_help_tab' => [
156
-                        'title'    => esc_html__('Critical Pages', 'event_espresso'),
157
-                        'filename' => 'general_settings_critical_pages',
158
-                    ],
159
-                ],
160
-                'require_nonce' => false,
161
-            ],
162
-            'default'               => [
163
-                'nav'           => [
164
-                    'label' => esc_html__('Your Organization', 'event_espresso'),
165
-                    'order' => 20,
166
-                ],
167
-                'help_tabs'     => [
168
-                    'general_settings_your_organization_help_tab' => [
169
-                        'title'    => esc_html__('Your Organization', 'event_espresso'),
170
-                        'filename' => 'general_settings_your_organization',
171
-                    ],
172
-                ],
173
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
174
-                'require_nonce' => false,
175
-            ],
176
-            'admin_option_settings' => [
177
-                'nav'           => [
178
-                    'label' => esc_html__('Admin Options', 'event_espresso'),
179
-                    'order' => 60,
180
-                ],
181
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
182
-                'help_tabs'     => [
183
-                    'general_settings_admin_options_help_tab' => [
184
-                        'title'    => esc_html__('Admin Options', 'event_espresso'),
185
-                        'filename' => 'general_settings_admin_options',
186
-                    ],
187
-                ],
188
-                'require_nonce' => false,
189
-            ],
190
-            'country_settings'      => [
191
-                'nav'           => [
192
-                    'label' => esc_html__('Countries', 'event_espresso'),
193
-                    'order' => 70,
194
-                ],
195
-                'help_tabs'     => [
196
-                    'general_settings_countries_help_tab' => [
197
-                        'title'    => esc_html__('Countries', 'event_espresso'),
198
-                        'filename' => 'general_settings_countries',
199
-                    ],
200
-                ],
201
-                'require_nonce' => false,
202
-            ],
203
-            'privacy_settings'      => [
204
-                'nav'           => [
205
-                    'label' => esc_html__('Privacy', 'event_espresso'),
206
-                    'order' => 80,
207
-                ],
208
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
209
-                'require_nonce' => false,
210
-            ],
211
-        ];
212
-    }
213
-
214
-
215
-    protected function _add_screen_options()
216
-    {
217
-    }
218
-
219
-
220
-    protected function _add_feature_pointers()
221
-    {
222
-    }
223
-
224
-
225
-    /**
226
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
227
-     */
228
-    public function load_scripts_styles()
229
-    {
230
-        // styles
231
-        wp_enqueue_style('espresso-ui-theme');
232
-        // scripts
233
-        wp_enqueue_script('ee_admin_js');
234
-    }
235
-
236
-
237
-    /**
238
-     * Execute logic running on `admin_init`
239
-     */
240
-    public function admin_init()
241
-    {
242
-        $this->core_config = EE_Registry::instance()->CFG->core;
243
-
244
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
245
-            esc_html__(
246
-                'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
247
-                'event_espresso'
248
-            )
249
-        );
250
-        EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
251
-            esc_html__(
252
-                'An error occurred! Please refresh the page and try again.',
253
-                'event_espresso'
254
-            )
255
-        );
256
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
257
-            esc_html__(
258
-                'Are you sure you want to delete this State / Province?',
259
-                'event_espresso'
260
-            )
261
-        );
262
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
263
-            'admin-ajax.php?page=espresso_general_settings',
264
-            is_ssl() ? 'https://' : 'http://'
265
-        );
266
-    }
267
-
268
-
269
-    public function admin_notices()
270
-    {
271
-    }
272
-
273
-
274
-    public function admin_footer_scripts()
275
-    {
276
-    }
277
-
278
-
279
-    /**
280
-     * Enqueue scripts and styles for the default route.
281
-     */
282
-    public function load_scripts_styles_default()
283
-    {
284
-        // styles
285
-        wp_enqueue_style('thickbox');
286
-        // scripts
287
-        wp_enqueue_script('media-upload');
288
-        wp_enqueue_script('thickbox');
289
-        wp_register_script(
290
-            'organization_settings',
291
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
292
-            ['jquery', 'media-upload', 'thickbox'],
293
-            EVENT_ESPRESSO_VERSION,
294
-            true
295
-        );
296
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
297
-        wp_enqueue_script('organization_settings');
298
-        wp_enqueue_style('organization-css');
299
-        $confirm_image_delete = [
300
-            'text' => wp_strip_all_tags(
301
-                esc_html__(
302
-                    'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
303
-                    'event_espresso'
304
-                )
305
-            ),
306
-        ];
307
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
308
-    }
309
-
310
-
311
-    /**
312
-     * Enqueue scripts and styles for the country settings route.
313
-     */
314
-    public function load_scripts_styles_country_settings()
315
-    {
316
-        // scripts
317
-        wp_register_script(
318
-            'gen_settings_countries',
319
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
320
-            ['ee_admin_js'],
321
-            EVENT_ESPRESSO_VERSION,
322
-            true
323
-        );
324
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
325
-        wp_enqueue_script('gen_settings_countries');
326
-        wp_enqueue_style('organization-css');
327
-    }
328
-
329
-
330
-    /*************        Espresso Pages        *************/
331
-    /**
332
-     * _espresso_page_settings
333
-     *
334
-     * @throws EE_Error
335
-     * @throws DomainException
336
-     * @throws DomainException
337
-     * @throws InvalidDataTypeException
338
-     * @throws InvalidArgumentException
339
-     */
340
-    protected function _espresso_page_settings()
341
-    {
342
-        // Check to make sure all of the main pages are set up properly,
343
-        // if not create the default pages and display an admin notice
344
-        EEH_Activation::verify_default_pages_exist();
345
-        $this->_transient_garbage_collection();
346
-
347
-        $this->_template_args['values'] = $this->_yes_no_values;
348
-
349
-        $this->_template_args['reg_page_id']  = $this->core_config->reg_page_id ?? null;
350
-        $this->_template_args['reg_page_obj'] = isset($this->core_config->reg_page_id)
351
-            ? get_post($this->core_config->reg_page_id)
352
-            : false;
353
-
354
-        $this->_template_args['txn_page_id']  = $this->core_config->txn_page_id ?? null;
355
-        $this->_template_args['txn_page_obj'] = isset($this->core_config->txn_page_id)
356
-            ? get_post($this->core_config->txn_page_id)
357
-            : false;
358
-
359
-        $this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
360
-        $this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
361
-            ? get_post($this->core_config->thank_you_page_id)
362
-            : false;
363
-
364
-        $this->_template_args['cancel_page_id']  = $this->core_config->cancel_page_id ?? null;
365
-        $this->_template_args['cancel_page_obj'] = isset($this->core_config->cancel_page_id)
366
-            ? get_post($this->core_config->cancel_page_id)
367
-            : false;
368
-
369
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
370
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
371
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
372
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
373
-            $this->_template_args,
374
-            true
375
-        );
376
-        $this->display_admin_page_with_sidebar();
377
-    }
378
-
379
-
380
-    /**
381
-     * Handler for updating espresso page settings.
382
-     *
383
-     * @throws EE_Error
384
-     */
385
-    protected function _update_espresso_page_settings()
386
-    {
387
-        // capture incoming request data && set page IDs
388
-        $this->core_config->reg_page_id       = $this->request->getRequestParam(
389
-            'reg_page_id',
390
-            $this->core_config->reg_page_id,
391
-            DataType::INT
392
-        );
393
-        $this->core_config->txn_page_id       = $this->request->getRequestParam(
394
-            'txn_page_id',
395
-            $this->core_config->txn_page_id,
396
-            DataType::INT
397
-        );
398
-        $this->core_config->thank_you_page_id = $this->request->getRequestParam(
399
-            'thank_you_page_id',
400
-            $this->core_config->thank_you_page_id,
401
-            DataType::INT
402
-        );
403
-        $this->core_config->cancel_page_id    = $this->request->getRequestParam(
404
-            'cancel_page_id',
405
-            $this->core_config->cancel_page_id,
406
-            DataType::INT
407
-        );
408
-
409
-        $this->core_config = apply_filters(
410
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
411
-            $this->core_config,
412
-            $this->request->requestParams()
413
-        );
414
-
415
-        $what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
416
-        $this->_redirect_after_action(
417
-            $this->_update_espresso_configuration(
418
-                $what,
419
-                $this->core_config,
420
-                __FILE__,
421
-                __FUNCTION__,
422
-                __LINE__
423
-            ),
424
-            $what,
425
-            '',
426
-            [
427
-                'action' => 'critical_pages',
428
-            ],
429
-            true
430
-        );
431
-    }
432
-
433
-
434
-    /*************        Your Organization        *************/
435
-
436
-
437
-    /**
438
-     * @throws DomainException
439
-     * @throws EE_Error
440
-     * @throws InvalidArgumentException
441
-     * @throws InvalidDataTypeException
442
-     * @throws InvalidInterfaceException
443
-     */
444
-    protected function _your_organization_settings()
445
-    {
446
-        $this->_template_args['admin_page_content'] = '';
447
-        try {
448
-            /** @var OrganizationSettings $organization_settings_form */
449
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
450
-
451
-            $this->_template_args['admin_page_content'] = EEH_HTML::div(
452
-                $organization_settings_form->display(),
453
-                '',
454
-                'padding'
455
-            );
456
-        } catch (Exception $e) {
457
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
458
-        }
459
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
460
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
461
-        $this->display_admin_page_with_sidebar();
462
-    }
463
-
464
-
465
-    /**
466
-     * Handler for updating organization settings.
467
-     *
468
-     * @throws EE_Error
469
-     */
470
-    protected function _update_your_organization_settings()
471
-    {
472
-        try {
473
-            /** @var OrganizationSettings $organization_settings_form */
474
-            $organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
475
-
476
-            $success = $organization_settings_form->process($this->request->requestParams());
477
-
478
-            EE_Registry::instance()->CFG = apply_filters(
479
-                'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
480
-                EE_Registry::instance()->CFG
481
-            );
482
-        } catch (Exception $e) {
483
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
484
-            $success = false;
485
-        }
486
-
487
-        if ($success) {
488
-            $success = $this->_update_espresso_configuration(
489
-                esc_html__('Your Organization Settings', 'event_espresso'),
490
-                EE_Registry::instance()->CFG,
491
-                __FILE__,
492
-                __FUNCTION__,
493
-                __LINE__
494
-            );
495
-        }
496
-
497
-        $this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
498
-    }
499
-
500
-
501
-
502
-    /*************        Admin Options        *************/
503
-
504
-
505
-    /**
506
-     * _admin_option_settings
507
-     *
508
-     * @throws EE_Error
509
-     * @throws LogicException
510
-     */
511
-    protected function _admin_option_settings()
512
-    {
513
-        $this->_template_args['admin_page_content'] = '';
514
-        try {
515
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
516
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
517
-            $this->_template_args['values'] = $this->_yes_no_values;
518
-            // also need to account for the do_action that was in the old template
519
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
520
-            $this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
521
-        } catch (Exception $e) {
522
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
523
-        }
524
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
525
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
526
-        $this->display_admin_page_with_sidebar();
527
-    }
528
-
529
-
530
-    /**
531
-     * _update_admin_option_settings
532
-     *
533
-     * @throws EE_Error
534
-     * @throws InvalidDataTypeException
535
-     * @throws InvalidFormSubmissionException
536
-     * @throws InvalidArgumentException
537
-     * @throws LogicException
538
-     */
539
-    protected function _update_admin_option_settings()
540
-    {
541
-        try {
542
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
543
-            $admin_options_settings_form->process(
544
-                $this->request->getRequestParam(
545
-                    $admin_options_settings_form->slug(),
546
-                    [],
547
-                    DataType::OBJECT // need to change this to ARRAY after min PHP version gets bumped to 7+
548
-                )
549
-            );
550
-            EE_Registry::instance()->CFG->admin = apply_filters(
551
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
552
-                EE_Registry::instance()->CFG->admin
553
-            );
554
-        } catch (Exception $e) {
555
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
556
-        }
557
-        $this->_redirect_after_action(
558
-            apply_filters(
559
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
560
-                $this->_update_espresso_configuration(
561
-                    esc_html__('Admin Options', 'event_espresso'),
562
-                    EE_Registry::instance()->CFG->admin,
563
-                    __FILE__,
564
-                    __FUNCTION__,
565
-                    __LINE__
566
-                )
567
-            ),
568
-            esc_html__('Admin Options', 'event_espresso'),
569
-            'updated',
570
-            ['action' => 'admin_option_settings']
571
-        );
572
-    }
573
-
574
-
575
-    /*************        Countries        *************/
576
-
577
-
578
-    /**
579
-     * @param string|null $default
580
-     * @return string
581
-     */
582
-    protected function getCountryISO(?string $default = null): string
583
-    {
584
-        $default = $default ?? $this->getCountryIsoForSite();
585
-        $CNT_ISO = $this->request->getRequestParam('country', $default);
586
-        return strtoupper($CNT_ISO);
587
-    }
588
-
589
-
590
-    /**
591
-     * @return string
592
-     */
593
-    protected function getCountryIsoForSite(): string
594
-    {
595
-        return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
596
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
597
-            : 'US';
598
-    }
599
-
600
-
601
-    /**
602
-     * @param string          $CNT_ISO
603
-     * @param EE_Country|null $country
604
-     * @return EE_Base_Class|EE_Country
605
-     * @throws EE_Error
606
-     * @throws InvalidArgumentException
607
-     * @throws InvalidDataTypeException
608
-     * @throws InvalidInterfaceException
609
-     * @throws ReflectionException
610
-     */
611
-    protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
612
-    {
613
-        /** @var EE_Country $country */
614
-        return $country instanceof EE_Country && $country->ID() === $CNT_ISO
615
-            ? $country
616
-            : EEM_Country::instance()->get_one_by_ID($CNT_ISO);
617
-    }
618
-
619
-
620
-    /**
621
-     * Output Country Settings view.
622
-     *
623
-     * @throws DomainException
624
-     * @throws EE_Error
625
-     * @throws InvalidArgumentException
626
-     * @throws InvalidDataTypeException
627
-     * @throws InvalidInterfaceException
628
-     * @throws ReflectionException
629
-     */
630
-    protected function _country_settings()
631
-    {
632
-        $CNT_ISO = $this->getCountryISO();
633
-
634
-        $this->_template_args['values']    = $this->_yes_no_values;
635
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
636
-            EE_Question::new_instance(
637
-                [
638
-                    'QST_ID'           => 0,
639
-                    'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
640
-                    'QST_system'       => 'admin-country',
641
-                ]
642
-            ),
643
-            EE_Answer::new_instance(
644
-                [
645
-                    'ANS_ID'    => 0,
646
-                    'ANS_value' => $CNT_ISO,
647
-                ]
648
-            ),
649
-            [
650
-                'input_id'       => 'country',
651
-                'input_name'     => 'country',
652
-                'input_prefix'   => '',
653
-                'append_qstn_id' => false,
654
-            ]
655
-        );
656
-
657
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
658
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
659
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
660
-        $this->_template_args['country_details_settings'] = $this->display_country_settings(
661
-            $country->ID(),
662
-            $country
663
-        );
664
-        $this->_template_args['country_states_settings']  = $this->display_country_states(
665
-            $country->ID(),
666
-            $country
667
-        );
668
-        $this->_template_args['CNT_name_for_site']        = $country->name();
669
-
670
-        $this->_set_add_edit_form_tags('update_country_settings');
671
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
672
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
673
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
674
-            $this->_template_args,
675
-            true
676
-        );
677
-        $this->display_admin_page_with_no_sidebar();
678
-    }
679
-
680
-
681
-    /**
682
-     * @param string          $CNT_ISO
683
-     * @param EE_Country|null $country
684
-     * @return string
685
-     * @throws DomainException
686
-     * @throws EE_Error
687
-     * @throws InvalidArgumentException
688
-     * @throws InvalidDataTypeException
689
-     * @throws InvalidInterfaceException
690
-     * @throws ReflectionException
691
-     */
692
-    public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
693
-    {
694
-        $CNT_ISO          = $this->getCountryISO($CNT_ISO);
695
-        $CNT_ISO_for_site = $this->getCountryIsoForSite();
696
-
697
-        if (! $CNT_ISO) {
698
-            return '';
699
-        }
700
-
701
-        // for ajax
702
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
703
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
704
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
705
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
706
-        $country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
707
-        $CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
708
-        $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
709
-
710
-        $country_input_types            = [
711
-            'CNT_active'      => [
712
-                'type'             => 'RADIO_BTN',
713
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
714
-                'class'            => '',
715
-                'options'          => $this->_yes_no_values,
716
-                'use_desc_4_label' => true,
717
-            ],
718
-            'CNT_ISO'         => [
719
-                'type'       => 'TEXT',
720
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
721
-                'class'      => 'small-text',
722
-            ],
723
-            'CNT_ISO3'        => [
724
-                'type'       => 'TEXT',
725
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
726
-                'class'      => 'small-text',
727
-            ],
728
-            // 'RGN_ID'          => [
729
-            //     'type'       => 'TEXT',
730
-            //     'input_name' => 'cntry[' . $CNT_ISO . ']',
731
-            //     'class'      => 'ee-input-size--small',
732
-            // ],
733
-            'CNT_name'        => [
734
-                'type'       => 'TEXT',
735
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
736
-                'class'      => 'regular-text',
737
-            ],
738
-            'CNT_cur_code'    => [
739
-                'type'       => 'TEXT',
740
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
741
-                'class'      => 'small-text',
742
-                'disabled'   => $CNT_cur_disabled,
743
-            ],
744
-            'CNT_cur_single'  => [
745
-                'type'       => 'TEXT',
746
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
747
-                'class'      => 'medium-text',
748
-                'disabled'   => $CNT_cur_disabled,
749
-            ],
750
-            'CNT_cur_plural'  => [
751
-                'type'       => 'TEXT',
752
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
753
-                'class'      => 'medium-text',
754
-                'disabled'   => $CNT_cur_disabled,
755
-            ],
756
-            'CNT_cur_sign'    => [
757
-                'type'         => 'TEXT',
758
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
759
-                'class'        => 'small-text',
760
-                'htmlentities' => false,
761
-                'disabled'     => $CNT_cur_disabled,
762
-            ],
763
-            'CNT_cur_sign_b4' => [
764
-                'type'             => 'RADIO_BTN',
765
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
766
-                'class'            => '',
767
-                'options'          => $this->_yes_no_values,
768
-                'use_desc_4_label' => true,
769
-                'disabled'         => $CNT_cur_disabled,
770
-            ],
771
-            'CNT_cur_dec_plc' => [
772
-                'type'       => 'RADIO_BTN',
773
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
774
-                'class'      => '',
775
-                'options'    => [
776
-                    ['id' => 0, 'text' => ''],
777
-                    ['id' => 1, 'text' => ''],
778
-                    ['id' => 2, 'text' => ''],
779
-                    ['id' => 3, 'text' => ''],
780
-                ],
781
-                'disabled'   => $CNT_cur_disabled,
782
-            ],
783
-            'CNT_cur_dec_mrk' => [
784
-                'type'             => 'RADIO_BTN',
785
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
786
-                'class'            => '',
787
-                'options'          => [
788
-                    [
789
-                        'id'   => ',',
790
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
791
-                    ],
792
-                    ['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
793
-                ],
794
-                'use_desc_4_label' => true,
795
-                'disabled'         => $CNT_cur_disabled,
796
-            ],
797
-            'CNT_cur_thsnds'  => [
798
-                'type'             => 'RADIO_BTN',
799
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
800
-                'class'            => '',
801
-                'options'          => [
802
-                    [
803
-                        'id'   => ',',
804
-                        'text' => esc_html__(', (comma)', 'event_espresso'),
805
-                    ],
806
-                    [
807
-                        'id'   => '.',
808
-                        'text' => esc_html__('. (decimal)', 'event_espresso'),
809
-                    ],
810
-                    [
811
-                        'id'   => '&nbsp;',
812
-                        'text' => esc_html__('(space)', 'event_espresso'),
813
-                    ],
814
-                ],
815
-                'use_desc_4_label' => true,
816
-                'disabled'         => $CNT_cur_disabled,
817
-            ],
818
-            'CNT_tel_code'    => [
819
-                'type'       => 'TEXT',
820
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
821
-                'class'      => 'small-text',
822
-            ],
823
-            'CNT_is_EU'       => [
824
-                'type'             => 'RADIO_BTN',
825
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
826
-                'class'            => '',
827
-                'options'          => $this->_yes_no_values,
828
-                'use_desc_4_label' => true,
829
-            ],
830
-        ];
831
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
832
-            $country,
833
-            $country_input_types
834
-        );
835
-        $country_details_settings       = EEH_Template::display_template(
836
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
837
-            $this->_template_args,
838
-            true
839
-        );
840
-
841
-        if (defined('DOING_AJAX')) {
842
-            $notices = EE_Error::get_notices(false, false, false);
843
-            echo wp_json_encode(
844
-                [
845
-                    'return_data' => $country_details_settings,
846
-                    'success'     => $notices['success'],
847
-                    'errors'      => $notices['errors'],
848
-                ]
849
-            );
850
-            die();
851
-        }
852
-        return $country_details_settings;
853
-    }
854
-
855
-
856
-    /**
857
-     * @param string          $CNT_ISO
858
-     * @param EE_Country|null $country
859
-     * @return string
860
-     * @throws DomainException
861
-     * @throws EE_Error
862
-     * @throws InvalidArgumentException
863
-     * @throws InvalidDataTypeException
864
-     * @throws InvalidInterfaceException
865
-     * @throws ReflectionException
866
-     */
867
-    public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
868
-    {
869
-        $CNT_ISO = $this->getCountryISO($CNT_ISO);
870
-        if (! $CNT_ISO) {
871
-            return '';
872
-        }
873
-        // for ajax
874
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
875
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
876
-        add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
877
-        add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
878
-        $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
879
-        if (empty($states)) {
880
-            /** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
881
-            $countrySubRegionDao = $this->loader->getShared(
882
-                'EventEspresso\core\services\address\CountrySubRegionDao'
883
-            );
884
-            if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
885
-                $country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
886
-                if ($countrySubRegionDao->saveCountrySubRegions($country)) {
887
-                    $states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
888
-                }
889
-            }
890
-        }
891
-        if (is_array($states)) {
892
-            foreach ($states as $STA_ID => $state) {
893
-                if ($state instanceof EE_State) {
894
-                    $inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
895
-                        $state,
896
-                        [
897
-                            'STA_abbrev' => [
898
-                                'type'             => 'TEXT',
899
-                                'label'            => esc_html__('Code', 'event_espresso'),
900
-                                'input_name'       => 'states[' . $STA_ID . ']',
901
-                                'class'            => 'small-text',
902
-                                'add_mobile_label' => true,
903
-                            ],
904
-                            'STA_name'   => [
905
-                                'type'             => 'TEXT',
906
-                                'label'            => esc_html__('Name', 'event_espresso'),
907
-                                'input_name'       => 'states[' . $STA_ID . ']',
908
-                                'class'            => 'regular-text',
909
-                                'add_mobile_label' => true,
910
-                            ],
911
-                            'STA_active' => [
912
-                                'type'             => 'RADIO_BTN',
913
-                                'label'            => esc_html__(
914
-                                    'State Appears in Dropdown Select Lists',
915
-                                    'event_espresso'
916
-                                ),
917
-                                'input_name'       => 'states[' . $STA_ID . ']',
918
-                                'options'          => $this->_yes_no_values,
919
-                                'use_desc_4_label' => true,
920
-                                'add_mobile_label' => true,
921
-                            ],
922
-                        ]
923
-                    );
924
-
925
-                    $delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
926
-                        [
927
-                            'action'     => 'delete_state',
928
-                            'STA_ID'     => $STA_ID,
929
-                            'CNT_ISO'    => $CNT_ISO,
930
-                            'STA_abbrev' => $state->abbrev(),
931
-                        ],
932
-                        GEN_SET_ADMIN_URL
933
-                    );
934
-
935
-                    $this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
936
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
937
-                }
938
-            }
939
-        } else {
940
-            $this->_template_args['states'] = false;
941
-        }
942
-
943
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
944
-            ['action' => 'add_new_state'],
945
-            GEN_SET_ADMIN_URL
946
-        );
947
-
948
-        $state_details_settings = EEH_Template::display_template(
949
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
950
-            $this->_template_args,
951
-            true
952
-        );
953
-
954
-        if (defined('DOING_AJAX')) {
955
-            $notices = EE_Error::get_notices(false, false, false);
956
-            echo wp_json_encode(
957
-                [
958
-                    'return_data' => $state_details_settings,
959
-                    'success'     => $notices['success'],
960
-                    'errors'      => $notices['errors'],
961
-                ]
962
-            );
963
-            die();
964
-        }
965
-        return $state_details_settings;
966
-    }
967
-
968
-
969
-    /**
970
-     * @return void
971
-     * @throws EE_Error
972
-     * @throws InvalidArgumentException
973
-     * @throws InvalidDataTypeException
974
-     * @throws InvalidInterfaceException
975
-     * @throws ReflectionException
976
-     */
977
-    public function add_new_state()
978
-    {
979
-        $success = true;
980
-        $CNT_ISO = $this->getCountryISO('');
981
-        if (! $CNT_ISO) {
982
-            EE_Error::add_error(
983
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
984
-                __FILE__,
985
-                __FUNCTION__,
986
-                __LINE__
987
-            );
988
-            $success = false;
989
-        }
990
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
991
-        if (! $STA_abbrev) {
992
-            EE_Error::add_error(
993
-                esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
994
-                __FILE__,
995
-                __FUNCTION__,
996
-                __LINE__
997
-            );
998
-            $success = false;
999
-        }
1000
-        $STA_name = $this->request->getRequestParam('STA_name');
1001
-        if (! $STA_name) {
1002
-            EE_Error::add_error(
1003
-                esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1004
-                __FILE__,
1005
-                __FUNCTION__,
1006
-                __LINE__
1007
-            );
1008
-            $success = false;
1009
-        }
1010
-
1011
-        if ($success) {
1012
-            $cols_n_values = [
1013
-                'CNT_ISO'    => $CNT_ISO,
1014
-                'STA_abbrev' => $STA_abbrev,
1015
-                'STA_name'   => $STA_name,
1016
-                'STA_active' => true,
1017
-            ];
1018
-            $success       = EEM_State::instance()->insert($cols_n_values);
1019
-            EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1020
-        }
1021
-
1022
-        if (defined('DOING_AJAX')) {
1023
-            $notices = EE_Error::get_notices(false, false, false);
1024
-            echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1025
-            die();
1026
-        } else {
1027
-            $this->_redirect_after_action(
1028
-                $success,
1029
-                esc_html__('State', 'event_espresso'),
1030
-                'added',
1031
-                ['action' => 'country_settings']
1032
-            );
1033
-        }
1034
-    }
1035
-
1036
-
1037
-    /**
1038
-     * @return void
1039
-     * @throws EE_Error
1040
-     * @throws InvalidArgumentException
1041
-     * @throws InvalidDataTypeException
1042
-     * @throws InvalidInterfaceException
1043
-     * @throws ReflectionException
1044
-     */
1045
-    public function delete_state()
1046
-    {
1047
-        $CNT_ISO    = $this->getCountryISO();
1048
-        $STA_ID     = $this->request->getRequestParam('STA_ID');
1049
-        $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1050
-
1051
-        if (! $STA_ID) {
1052
-            EE_Error::add_error(
1053
-                esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1054
-                __FILE__,
1055
-                __FUNCTION__,
1056
-                __LINE__
1057
-            );
1058
-            return;
1059
-        }
1060
-
1061
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
1062
-        if ($success !== false) {
1063
-            do_action(
1064
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1065
-                $CNT_ISO,
1066
-                $STA_ID,
1067
-                ['STA_abbrev' => $STA_abbrev]
1068
-            );
1069
-            EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1070
-        }
1071
-        if (defined('DOING_AJAX')) {
1072
-            $notices                = EE_Error::get_notices(false);
1073
-            $notices['return_data'] = true;
1074
-            echo wp_json_encode($notices);
1075
-            die();
1076
-        } else {
1077
-            $this->_redirect_after_action(
1078
-                $success,
1079
-                esc_html__('State', 'event_espresso'),
1080
-                'deleted',
1081
-                ['action' => 'country_settings']
1082
-            );
1083
-        }
1084
-    }
1085
-
1086
-
1087
-    /**
1088
-     *        _update_country_settings
1089
-     *
1090
-     * @return void
1091
-     * @throws EE_Error
1092
-     * @throws InvalidArgumentException
1093
-     * @throws InvalidDataTypeException
1094
-     * @throws InvalidInterfaceException
1095
-     * @throws ReflectionException
1096
-     */
1097
-    protected function _update_country_settings()
1098
-    {
1099
-        $CNT_ISO = $this->getCountryISO();
1100
-        if (! $CNT_ISO) {
1101
-            EE_Error::add_error(
1102
-                esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1103
-                __FILE__,
1104
-                __FUNCTION__,
1105
-                __LINE__
1106
-            );
1107
-            return;
1108
-        }
1109
-
1110
-        $country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1111
-
1112
-        $cols_n_values                    = [];
1113
-        $cols_n_values['CNT_ISO3']        = strtoupper(
1114
-            $this->request->getRequestParam('cntry', '', $country->ISO3())
1115
-        );
1116
-        $cols_n_values['CNT_name']        = $this->request->getRequestParam(
1117
-            "cntry[$CNT_ISO][CNT_name]",
1118
-            $country->name()
1119
-        );
1120
-        $cols_n_values['CNT_cur_code']    = strtoupper(
1121
-            $this->request->getRequestParam(
1122
-                "cntry[$CNT_ISO][CNT_cur_code]",
1123
-                $country->currency_code()
1124
-            )
1125
-        );
1126
-        $cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1127
-            "cntry[$CNT_ISO][CNT_cur_single]",
1128
-            $country->currency_name_single()
1129
-        );
1130
-        $cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1131
-            "cntry[$CNT_ISO][CNT_cur_plural]",
1132
-            $country->currency_name_plural()
1133
-        );
1134
-        $cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1135
-            "cntry[$CNT_ISO][CNT_cur_sign]",
1136
-            $country->currency_sign()
1137
-        );
1138
-        $cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1139
-            "cntry[$CNT_ISO][CNT_cur_sign_b4]",
1140
-            $country->currency_sign_before(),
1141
-            DataType::BOOL
1142
-        );
1143
-        $cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1144
-            "cntry[$CNT_ISO][CNT_cur_dec_plc]",
1145
-            $country->currency_decimal_places()
1146
-        );
1147
-        $cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1148
-            "cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1149
-            $country->currency_decimal_mark()
1150
-        );
1151
-        $cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1152
-            "cntry[$CNT_ISO][CNT_cur_thsnds]",
1153
-            $country->currency_thousands_separator()
1154
-        );
1155
-        $cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1156
-            "cntry[$CNT_ISO][CNT_tel_code]",
1157
-            $country->telephoneCode()
1158
-        );
1159
-        $cols_n_values['CNT_active']      = $this->request->getRequestParam(
1160
-            "cntry[$CNT_ISO][CNT_active]",
1161
-            $country->isActive(),
1162
-            DataType::BOOL
1163
-        );
1164
-
1165
-        // allow filtering of country data
1166
-        $cols_n_values = apply_filters(
1167
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1168
-            $cols_n_values
1169
-        );
1170
-
1171
-        // where values
1172
-        $where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1173
-        // run the update
1174
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1175
-
1176
-        // allow filtering of states data
1177
-        $states = apply_filters(
1178
-            'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1179
-            $this->request->getRequestParam('states', [], DataType::STRING, true)
1180
-        );
1181
-
1182
-        if (! empty($states) && $success !== false) {
1183
-            // loop thru state data ( looks like : states[75][STA_name] )
1184
-            foreach ($states as $STA_ID => $state) {
1185
-                $cols_n_values = [
1186
-                    'CNT_ISO'    => $CNT_ISO,
1187
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1188
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1189
-                    'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1190
-                ];
1191
-                // where values
1192
-                $where_cols_n_values = [['STA_ID' => $STA_ID]];
1193
-                // run the update
1194
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1195
-                if ($success !== false) {
1196
-                    do_action(
1197
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1198
-                        $CNT_ISO,
1199
-                        $STA_ID,
1200
-                        $cols_n_values
1201
-                    );
1202
-                }
1203
-            }
1204
-        }
1205
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1206
-        if (
1207
-            isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1208
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1209
-        ) {
1210
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1211
-            EE_Registry::instance()->CFG->update_espresso_config();
1212
-        }
1213
-
1214
-        if ($success !== false) {
1215
-            EE_Error::add_success(
1216
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1217
-            );
1218
-        }
1219
-        $this->_redirect_after_action(
1220
-            $success,
1221
-            '',
1222
-            '',
1223
-            ['action' => 'country_settings', 'country' => $CNT_ISO],
1224
-            true
1225
-        );
1226
-    }
1227
-
1228
-
1229
-    /**
1230
-     * form_form_field_label_wrap
1231
-     *
1232
-     * @param string $label
1233
-     * @return string
1234
-     */
1235
-    public function country_form_field_label_wrap(string $label): string
1236
-    {
1237
-        return '
23
+	/**
24
+	 * @var EE_Core_Config
25
+	 */
26
+	public $core_config;
27
+
28
+
29
+	/**
30
+	 * Initialize basic properties.
31
+	 */
32
+	protected function _init_page_props()
33
+	{
34
+		$this->page_slug        = GEN_SET_PG_SLUG;
35
+		$this->page_label       = GEN_SET_LABEL;
36
+		$this->_admin_base_url  = GEN_SET_ADMIN_URL;
37
+		$this->_admin_base_path = GEN_SET_ADMIN;
38
+	}
39
+
40
+
41
+	/**
42
+	 * Set ajax hooks
43
+	 */
44
+	protected function _ajax_hooks()
45
+	{
46
+		add_action('wp_ajax_espresso_display_country_settings', [$this, 'display_country_settings']);
47
+		add_action('wp_ajax_espresso_display_country_states', [$this, 'display_country_states']);
48
+		add_action('wp_ajax_espresso_delete_state', [$this, 'delete_state'], 10, 3);
49
+		add_action('wp_ajax_espresso_add_new_state', [$this, 'add_new_state']);
50
+	}
51
+
52
+
53
+	/**
54
+	 * More page properties initialization.
55
+	 */
56
+	protected function _define_page_props()
57
+	{
58
+		$this->_admin_page_title = GEN_SET_LABEL;
59
+		$this->_labels           = ['publishbox' => esc_html__('Update Settings', 'event_espresso')];
60
+	}
61
+
62
+
63
+	/**
64
+	 * Set page routes property.
65
+	 */
66
+	protected function _set_page_routes()
67
+	{
68
+		$this->_page_routes = [
69
+			'critical_pages'                => [
70
+				'func'       => '_espresso_page_settings',
71
+				'capability' => 'manage_options',
72
+			],
73
+			'update_espresso_page_settings' => [
74
+				'func'       => '_update_espresso_page_settings',
75
+				'capability' => 'manage_options',
76
+				'noheader'   => true,
77
+			],
78
+			'default'                       => [
79
+				'func'       => '_your_organization_settings',
80
+				'capability' => 'manage_options',
81
+			],
82
+
83
+			'update_your_organization_settings' => [
84
+				'func'       => '_update_your_organization_settings',
85
+				'capability' => 'manage_options',
86
+				'noheader'   => true,
87
+			],
88
+
89
+			'admin_option_settings' => [
90
+				'func'       => '_admin_option_settings',
91
+				'capability' => 'manage_options',
92
+			],
93
+
94
+			'update_admin_option_settings' => [
95
+				'func'       => '_update_admin_option_settings',
96
+				'capability' => 'manage_options',
97
+				'noheader'   => true,
98
+			],
99
+
100
+			'country_settings' => [
101
+				'func'       => '_country_settings',
102
+				'capability' => 'manage_options',
103
+			],
104
+
105
+			'update_country_settings' => [
106
+				'func'       => '_update_country_settings',
107
+				'capability' => 'manage_options',
108
+				'noheader'   => true,
109
+			],
110
+
111
+			'display_country_settings' => [
112
+				'func'       => 'display_country_settings',
113
+				'capability' => 'manage_options',
114
+				'noheader'   => true,
115
+			],
116
+
117
+			'add_new_state' => [
118
+				'func'       => 'add_new_state',
119
+				'capability' => 'manage_options',
120
+				'noheader'   => true,
121
+			],
122
+
123
+			'delete_state'            => [
124
+				'func'       => 'delete_state',
125
+				'capability' => 'manage_options',
126
+				'noheader'   => true,
127
+			],
128
+			'privacy_settings'        => [
129
+				'func'       => 'privacySettings',
130
+				'capability' => 'manage_options',
131
+			],
132
+			'update_privacy_settings' => [
133
+				'func'               => 'updatePrivacySettings',
134
+				'capability'         => 'manage_options',
135
+				'noheader'           => true,
136
+				'headers_sent_route' => 'privacy_settings',
137
+			],
138
+		];
139
+	}
140
+
141
+
142
+	/**
143
+	 * Set page configuration property
144
+	 */
145
+	protected function _set_page_config()
146
+	{
147
+		$this->_page_config = [
148
+			'critical_pages'        => [
149
+				'nav'           => [
150
+					'label' => esc_html__('Critical Pages', 'event_espresso'),
151
+					'order' => 50,
152
+				],
153
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
154
+				'help_tabs'     => [
155
+					'general_settings_critical_pages_help_tab' => [
156
+						'title'    => esc_html__('Critical Pages', 'event_espresso'),
157
+						'filename' => 'general_settings_critical_pages',
158
+					],
159
+				],
160
+				'require_nonce' => false,
161
+			],
162
+			'default'               => [
163
+				'nav'           => [
164
+					'label' => esc_html__('Your Organization', 'event_espresso'),
165
+					'order' => 20,
166
+				],
167
+				'help_tabs'     => [
168
+					'general_settings_your_organization_help_tab' => [
169
+						'title'    => esc_html__('Your Organization', 'event_espresso'),
170
+						'filename' => 'general_settings_your_organization',
171
+					],
172
+				],
173
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
174
+				'require_nonce' => false,
175
+			],
176
+			'admin_option_settings' => [
177
+				'nav'           => [
178
+					'label' => esc_html__('Admin Options', 'event_espresso'),
179
+					'order' => 60,
180
+				],
181
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
182
+				'help_tabs'     => [
183
+					'general_settings_admin_options_help_tab' => [
184
+						'title'    => esc_html__('Admin Options', 'event_espresso'),
185
+						'filename' => 'general_settings_admin_options',
186
+					],
187
+				],
188
+				'require_nonce' => false,
189
+			],
190
+			'country_settings'      => [
191
+				'nav'           => [
192
+					'label' => esc_html__('Countries', 'event_espresso'),
193
+					'order' => 70,
194
+				],
195
+				'help_tabs'     => [
196
+					'general_settings_countries_help_tab' => [
197
+						'title'    => esc_html__('Countries', 'event_espresso'),
198
+						'filename' => 'general_settings_countries',
199
+					],
200
+				],
201
+				'require_nonce' => false,
202
+			],
203
+			'privacy_settings'      => [
204
+				'nav'           => [
205
+					'label' => esc_html__('Privacy', 'event_espresso'),
206
+					'order' => 80,
207
+				],
208
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
209
+				'require_nonce' => false,
210
+			],
211
+		];
212
+	}
213
+
214
+
215
+	protected function _add_screen_options()
216
+	{
217
+	}
218
+
219
+
220
+	protected function _add_feature_pointers()
221
+	{
222
+	}
223
+
224
+
225
+	/**
226
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
227
+	 */
228
+	public function load_scripts_styles()
229
+	{
230
+		// styles
231
+		wp_enqueue_style('espresso-ui-theme');
232
+		// scripts
233
+		wp_enqueue_script('ee_admin_js');
234
+	}
235
+
236
+
237
+	/**
238
+	 * Execute logic running on `admin_init`
239
+	 */
240
+	public function admin_init()
241
+	{
242
+		$this->core_config = EE_Registry::instance()->CFG->core;
243
+
244
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = wp_strip_all_tags(
245
+			esc_html__(
246
+				'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
247
+				'event_espresso'
248
+			)
249
+		);
250
+		EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
251
+			esc_html__(
252
+				'An error occurred! Please refresh the page and try again.',
253
+				'event_espresso'
254
+			)
255
+		);
256
+		EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
257
+			esc_html__(
258
+				'Are you sure you want to delete this State / Province?',
259
+				'event_espresso'
260
+			)
261
+		);
262
+		EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
263
+			'admin-ajax.php?page=espresso_general_settings',
264
+			is_ssl() ? 'https://' : 'http://'
265
+		);
266
+	}
267
+
268
+
269
+	public function admin_notices()
270
+	{
271
+	}
272
+
273
+
274
+	public function admin_footer_scripts()
275
+	{
276
+	}
277
+
278
+
279
+	/**
280
+	 * Enqueue scripts and styles for the default route.
281
+	 */
282
+	public function load_scripts_styles_default()
283
+	{
284
+		// styles
285
+		wp_enqueue_style('thickbox');
286
+		// scripts
287
+		wp_enqueue_script('media-upload');
288
+		wp_enqueue_script('thickbox');
289
+		wp_register_script(
290
+			'organization_settings',
291
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
292
+			['jquery', 'media-upload', 'thickbox'],
293
+			EVENT_ESPRESSO_VERSION,
294
+			true
295
+		);
296
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
297
+		wp_enqueue_script('organization_settings');
298
+		wp_enqueue_style('organization-css');
299
+		$confirm_image_delete = [
300
+			'text' => wp_strip_all_tags(
301
+				esc_html__(
302
+					'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
303
+					'event_espresso'
304
+				)
305
+			),
306
+		];
307
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
308
+	}
309
+
310
+
311
+	/**
312
+	 * Enqueue scripts and styles for the country settings route.
313
+	 */
314
+	public function load_scripts_styles_country_settings()
315
+	{
316
+		// scripts
317
+		wp_register_script(
318
+			'gen_settings_countries',
319
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
320
+			['ee_admin_js'],
321
+			EVENT_ESPRESSO_VERSION,
322
+			true
323
+		);
324
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
325
+		wp_enqueue_script('gen_settings_countries');
326
+		wp_enqueue_style('organization-css');
327
+	}
328
+
329
+
330
+	/*************        Espresso Pages        *************/
331
+	/**
332
+	 * _espresso_page_settings
333
+	 *
334
+	 * @throws EE_Error
335
+	 * @throws DomainException
336
+	 * @throws DomainException
337
+	 * @throws InvalidDataTypeException
338
+	 * @throws InvalidArgumentException
339
+	 */
340
+	protected function _espresso_page_settings()
341
+	{
342
+		// Check to make sure all of the main pages are set up properly,
343
+		// if not create the default pages and display an admin notice
344
+		EEH_Activation::verify_default_pages_exist();
345
+		$this->_transient_garbage_collection();
346
+
347
+		$this->_template_args['values'] = $this->_yes_no_values;
348
+
349
+		$this->_template_args['reg_page_id']  = $this->core_config->reg_page_id ?? null;
350
+		$this->_template_args['reg_page_obj'] = isset($this->core_config->reg_page_id)
351
+			? get_post($this->core_config->reg_page_id)
352
+			: false;
353
+
354
+		$this->_template_args['txn_page_id']  = $this->core_config->txn_page_id ?? null;
355
+		$this->_template_args['txn_page_obj'] = isset($this->core_config->txn_page_id)
356
+			? get_post($this->core_config->txn_page_id)
357
+			: false;
358
+
359
+		$this->_template_args['thank_you_page_id']  = $this->core_config->thank_you_page_id ?? null;
360
+		$this->_template_args['thank_you_page_obj'] = isset($this->core_config->thank_you_page_id)
361
+			? get_post($this->core_config->thank_you_page_id)
362
+			: false;
363
+
364
+		$this->_template_args['cancel_page_id']  = $this->core_config->cancel_page_id ?? null;
365
+		$this->_template_args['cancel_page_obj'] = isset($this->core_config->cancel_page_id)
366
+			? get_post($this->core_config->cancel_page_id)
367
+			: false;
368
+
369
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
370
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
371
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
372
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
373
+			$this->_template_args,
374
+			true
375
+		);
376
+		$this->display_admin_page_with_sidebar();
377
+	}
378
+
379
+
380
+	/**
381
+	 * Handler for updating espresso page settings.
382
+	 *
383
+	 * @throws EE_Error
384
+	 */
385
+	protected function _update_espresso_page_settings()
386
+	{
387
+		// capture incoming request data && set page IDs
388
+		$this->core_config->reg_page_id       = $this->request->getRequestParam(
389
+			'reg_page_id',
390
+			$this->core_config->reg_page_id,
391
+			DataType::INT
392
+		);
393
+		$this->core_config->txn_page_id       = $this->request->getRequestParam(
394
+			'txn_page_id',
395
+			$this->core_config->txn_page_id,
396
+			DataType::INT
397
+		);
398
+		$this->core_config->thank_you_page_id = $this->request->getRequestParam(
399
+			'thank_you_page_id',
400
+			$this->core_config->thank_you_page_id,
401
+			DataType::INT
402
+		);
403
+		$this->core_config->cancel_page_id    = $this->request->getRequestParam(
404
+			'cancel_page_id',
405
+			$this->core_config->cancel_page_id,
406
+			DataType::INT
407
+		);
408
+
409
+		$this->core_config = apply_filters(
410
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
411
+			$this->core_config,
412
+			$this->request->requestParams()
413
+		);
414
+
415
+		$what = esc_html__('Critical Pages & Shortcodes', 'event_espresso');
416
+		$this->_redirect_after_action(
417
+			$this->_update_espresso_configuration(
418
+				$what,
419
+				$this->core_config,
420
+				__FILE__,
421
+				__FUNCTION__,
422
+				__LINE__
423
+			),
424
+			$what,
425
+			'',
426
+			[
427
+				'action' => 'critical_pages',
428
+			],
429
+			true
430
+		);
431
+	}
432
+
433
+
434
+	/*************        Your Organization        *************/
435
+
436
+
437
+	/**
438
+	 * @throws DomainException
439
+	 * @throws EE_Error
440
+	 * @throws InvalidArgumentException
441
+	 * @throws InvalidDataTypeException
442
+	 * @throws InvalidInterfaceException
443
+	 */
444
+	protected function _your_organization_settings()
445
+	{
446
+		$this->_template_args['admin_page_content'] = '';
447
+		try {
448
+			/** @var OrganizationSettings $organization_settings_form */
449
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
450
+
451
+			$this->_template_args['admin_page_content'] = EEH_HTML::div(
452
+				$organization_settings_form->display(),
453
+				'',
454
+				'padding'
455
+			);
456
+		} catch (Exception $e) {
457
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
458
+		}
459
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
460
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
461
+		$this->display_admin_page_with_sidebar();
462
+	}
463
+
464
+
465
+	/**
466
+	 * Handler for updating organization settings.
467
+	 *
468
+	 * @throws EE_Error
469
+	 */
470
+	protected function _update_your_organization_settings()
471
+	{
472
+		try {
473
+			/** @var OrganizationSettings $organization_settings_form */
474
+			$organization_settings_form = $this->loader->getShared(OrganizationSettings::class);
475
+
476
+			$success = $organization_settings_form->process($this->request->requestParams());
477
+
478
+			EE_Registry::instance()->CFG = apply_filters(
479
+				'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
480
+				EE_Registry::instance()->CFG
481
+			);
482
+		} catch (Exception $e) {
483
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
484
+			$success = false;
485
+		}
486
+
487
+		if ($success) {
488
+			$success = $this->_update_espresso_configuration(
489
+				esc_html__('Your Organization Settings', 'event_espresso'),
490
+				EE_Registry::instance()->CFG,
491
+				__FILE__,
492
+				__FUNCTION__,
493
+				__LINE__
494
+			);
495
+		}
496
+
497
+		$this->_redirect_after_action($success, '', '', ['action' => 'default'], true);
498
+	}
499
+
500
+
501
+
502
+	/*************        Admin Options        *************/
503
+
504
+
505
+	/**
506
+	 * _admin_option_settings
507
+	 *
508
+	 * @throws EE_Error
509
+	 * @throws LogicException
510
+	 */
511
+	protected function _admin_option_settings()
512
+	{
513
+		$this->_template_args['admin_page_content'] = '';
514
+		try {
515
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
516
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
517
+			$this->_template_args['values'] = $this->_yes_no_values;
518
+			// also need to account for the do_action that was in the old template
519
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
520
+			$this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
521
+		} catch (Exception $e) {
522
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
523
+		}
524
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
525
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
526
+		$this->display_admin_page_with_sidebar();
527
+	}
528
+
529
+
530
+	/**
531
+	 * _update_admin_option_settings
532
+	 *
533
+	 * @throws EE_Error
534
+	 * @throws InvalidDataTypeException
535
+	 * @throws InvalidFormSubmissionException
536
+	 * @throws InvalidArgumentException
537
+	 * @throws LogicException
538
+	 */
539
+	protected function _update_admin_option_settings()
540
+	{
541
+		try {
542
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
543
+			$admin_options_settings_form->process(
544
+				$this->request->getRequestParam(
545
+					$admin_options_settings_form->slug(),
546
+					[],
547
+					DataType::OBJECT // need to change this to ARRAY after min PHP version gets bumped to 7+
548
+				)
549
+			);
550
+			EE_Registry::instance()->CFG->admin = apply_filters(
551
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
552
+				EE_Registry::instance()->CFG->admin
553
+			);
554
+		} catch (Exception $e) {
555
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
556
+		}
557
+		$this->_redirect_after_action(
558
+			apply_filters(
559
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
560
+				$this->_update_espresso_configuration(
561
+					esc_html__('Admin Options', 'event_espresso'),
562
+					EE_Registry::instance()->CFG->admin,
563
+					__FILE__,
564
+					__FUNCTION__,
565
+					__LINE__
566
+				)
567
+			),
568
+			esc_html__('Admin Options', 'event_espresso'),
569
+			'updated',
570
+			['action' => 'admin_option_settings']
571
+		);
572
+	}
573
+
574
+
575
+	/*************        Countries        *************/
576
+
577
+
578
+	/**
579
+	 * @param string|null $default
580
+	 * @return string
581
+	 */
582
+	protected function getCountryISO(?string $default = null): string
583
+	{
584
+		$default = $default ?? $this->getCountryIsoForSite();
585
+		$CNT_ISO = $this->request->getRequestParam('country', $default);
586
+		return strtoupper($CNT_ISO);
587
+	}
588
+
589
+
590
+	/**
591
+	 * @return string
592
+	 */
593
+	protected function getCountryIsoForSite(): string
594
+	{
595
+		return ! empty(EE_Registry::instance()->CFG->organization->CNT_ISO)
596
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
597
+			: 'US';
598
+	}
599
+
600
+
601
+	/**
602
+	 * @param string          $CNT_ISO
603
+	 * @param EE_Country|null $country
604
+	 * @return EE_Base_Class|EE_Country
605
+	 * @throws EE_Error
606
+	 * @throws InvalidArgumentException
607
+	 * @throws InvalidDataTypeException
608
+	 * @throws InvalidInterfaceException
609
+	 * @throws ReflectionException
610
+	 */
611
+	protected function verifyOrGetCountryFromIso(string $CNT_ISO, ?EE_Country $country = null)
612
+	{
613
+		/** @var EE_Country $country */
614
+		return $country instanceof EE_Country && $country->ID() === $CNT_ISO
615
+			? $country
616
+			: EEM_Country::instance()->get_one_by_ID($CNT_ISO);
617
+	}
618
+
619
+
620
+	/**
621
+	 * Output Country Settings view.
622
+	 *
623
+	 * @throws DomainException
624
+	 * @throws EE_Error
625
+	 * @throws InvalidArgumentException
626
+	 * @throws InvalidDataTypeException
627
+	 * @throws InvalidInterfaceException
628
+	 * @throws ReflectionException
629
+	 */
630
+	protected function _country_settings()
631
+	{
632
+		$CNT_ISO = $this->getCountryISO();
633
+
634
+		$this->_template_args['values']    = $this->_yes_no_values;
635
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
636
+			EE_Question::new_instance(
637
+				[
638
+					'QST_ID'           => 0,
639
+					'QST_display_text' => esc_html__('Select Country', 'event_espresso'),
640
+					'QST_system'       => 'admin-country',
641
+				]
642
+			),
643
+			EE_Answer::new_instance(
644
+				[
645
+					'ANS_ID'    => 0,
646
+					'ANS_value' => $CNT_ISO,
647
+				]
648
+			),
649
+			[
650
+				'input_id'       => 'country',
651
+				'input_name'     => 'country',
652
+				'input_prefix'   => '',
653
+				'append_qstn_id' => false,
654
+			]
655
+		);
656
+
657
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
658
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10);
659
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10);
660
+		$this->_template_args['country_details_settings'] = $this->display_country_settings(
661
+			$country->ID(),
662
+			$country
663
+		);
664
+		$this->_template_args['country_states_settings']  = $this->display_country_states(
665
+			$country->ID(),
666
+			$country
667
+		);
668
+		$this->_template_args['CNT_name_for_site']        = $country->name();
669
+
670
+		$this->_set_add_edit_form_tags('update_country_settings');
671
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
672
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
673
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
674
+			$this->_template_args,
675
+			true
676
+		);
677
+		$this->display_admin_page_with_no_sidebar();
678
+	}
679
+
680
+
681
+	/**
682
+	 * @param string          $CNT_ISO
683
+	 * @param EE_Country|null $country
684
+	 * @return string
685
+	 * @throws DomainException
686
+	 * @throws EE_Error
687
+	 * @throws InvalidArgumentException
688
+	 * @throws InvalidDataTypeException
689
+	 * @throws InvalidInterfaceException
690
+	 * @throws ReflectionException
691
+	 */
692
+	public function display_country_settings(string $CNT_ISO = '', ?EE_Country $country = null): string
693
+	{
694
+		$CNT_ISO          = $this->getCountryISO($CNT_ISO);
695
+		$CNT_ISO_for_site = $this->getCountryIsoForSite();
696
+
697
+		if (! $CNT_ISO) {
698
+			return '';
699
+		}
700
+
701
+		// for ajax
702
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
703
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
704
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'country_form_field_label_wrap'], 10, 2);
705
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'country_form_field_input__wrap'], 10, 2);
706
+		$country                                  = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
707
+		$CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
708
+		$this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
709
+
710
+		$country_input_types            = [
711
+			'CNT_active'      => [
712
+				'type'             => 'RADIO_BTN',
713
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
714
+				'class'            => '',
715
+				'options'          => $this->_yes_no_values,
716
+				'use_desc_4_label' => true,
717
+			],
718
+			'CNT_ISO'         => [
719
+				'type'       => 'TEXT',
720
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
721
+				'class'      => 'small-text',
722
+			],
723
+			'CNT_ISO3'        => [
724
+				'type'       => 'TEXT',
725
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
726
+				'class'      => 'small-text',
727
+			],
728
+			// 'RGN_ID'          => [
729
+			//     'type'       => 'TEXT',
730
+			//     'input_name' => 'cntry[' . $CNT_ISO . ']',
731
+			//     'class'      => 'ee-input-size--small',
732
+			// ],
733
+			'CNT_name'        => [
734
+				'type'       => 'TEXT',
735
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
736
+				'class'      => 'regular-text',
737
+			],
738
+			'CNT_cur_code'    => [
739
+				'type'       => 'TEXT',
740
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
741
+				'class'      => 'small-text',
742
+				'disabled'   => $CNT_cur_disabled,
743
+			],
744
+			'CNT_cur_single'  => [
745
+				'type'       => 'TEXT',
746
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
747
+				'class'      => 'medium-text',
748
+				'disabled'   => $CNT_cur_disabled,
749
+			],
750
+			'CNT_cur_plural'  => [
751
+				'type'       => 'TEXT',
752
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
753
+				'class'      => 'medium-text',
754
+				'disabled'   => $CNT_cur_disabled,
755
+			],
756
+			'CNT_cur_sign'    => [
757
+				'type'         => 'TEXT',
758
+				'input_name'   => 'cntry[' . $CNT_ISO . ']',
759
+				'class'        => 'small-text',
760
+				'htmlentities' => false,
761
+				'disabled'     => $CNT_cur_disabled,
762
+			],
763
+			'CNT_cur_sign_b4' => [
764
+				'type'             => 'RADIO_BTN',
765
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
766
+				'class'            => '',
767
+				'options'          => $this->_yes_no_values,
768
+				'use_desc_4_label' => true,
769
+				'disabled'         => $CNT_cur_disabled,
770
+			],
771
+			'CNT_cur_dec_plc' => [
772
+				'type'       => 'RADIO_BTN',
773
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
774
+				'class'      => '',
775
+				'options'    => [
776
+					['id' => 0, 'text' => ''],
777
+					['id' => 1, 'text' => ''],
778
+					['id' => 2, 'text' => ''],
779
+					['id' => 3, 'text' => ''],
780
+				],
781
+				'disabled'   => $CNT_cur_disabled,
782
+			],
783
+			'CNT_cur_dec_mrk' => [
784
+				'type'             => 'RADIO_BTN',
785
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
786
+				'class'            => '',
787
+				'options'          => [
788
+					[
789
+						'id'   => ',',
790
+						'text' => esc_html__(', (comma)', 'event_espresso'),
791
+					],
792
+					['id' => '.', 'text' => esc_html__('. (decimal)', 'event_espresso')],
793
+				],
794
+				'use_desc_4_label' => true,
795
+				'disabled'         => $CNT_cur_disabled,
796
+			],
797
+			'CNT_cur_thsnds'  => [
798
+				'type'             => 'RADIO_BTN',
799
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
800
+				'class'            => '',
801
+				'options'          => [
802
+					[
803
+						'id'   => ',',
804
+						'text' => esc_html__(', (comma)', 'event_espresso'),
805
+					],
806
+					[
807
+						'id'   => '.',
808
+						'text' => esc_html__('. (decimal)', 'event_espresso'),
809
+					],
810
+					[
811
+						'id'   => '&nbsp;',
812
+						'text' => esc_html__('(space)', 'event_espresso'),
813
+					],
814
+				],
815
+				'use_desc_4_label' => true,
816
+				'disabled'         => $CNT_cur_disabled,
817
+			],
818
+			'CNT_tel_code'    => [
819
+				'type'       => 'TEXT',
820
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
821
+				'class'      => 'small-text',
822
+			],
823
+			'CNT_is_EU'       => [
824
+				'type'             => 'RADIO_BTN',
825
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
826
+				'class'            => '',
827
+				'options'          => $this->_yes_no_values,
828
+				'use_desc_4_label' => true,
829
+			],
830
+		];
831
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
832
+			$country,
833
+			$country_input_types
834
+		);
835
+		$country_details_settings       = EEH_Template::display_template(
836
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
837
+			$this->_template_args,
838
+			true
839
+		);
840
+
841
+		if (defined('DOING_AJAX')) {
842
+			$notices = EE_Error::get_notices(false, false, false);
843
+			echo wp_json_encode(
844
+				[
845
+					'return_data' => $country_details_settings,
846
+					'success'     => $notices['success'],
847
+					'errors'      => $notices['errors'],
848
+				]
849
+			);
850
+			die();
851
+		}
852
+		return $country_details_settings;
853
+	}
854
+
855
+
856
+	/**
857
+	 * @param string          $CNT_ISO
858
+	 * @param EE_Country|null $country
859
+	 * @return string
860
+	 * @throws DomainException
861
+	 * @throws EE_Error
862
+	 * @throws InvalidArgumentException
863
+	 * @throws InvalidDataTypeException
864
+	 * @throws InvalidInterfaceException
865
+	 * @throws ReflectionException
866
+	 */
867
+	public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
868
+	{
869
+		$CNT_ISO = $this->getCountryISO($CNT_ISO);
870
+		if (! $CNT_ISO) {
871
+			return '';
872
+		}
873
+		// for ajax
874
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
875
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
876
+		add_filter('FHEE__EEH_Form_Fields__label_html', [$this, 'state_form_field_label_wrap'], 10, 2);
877
+		add_filter('FHEE__EEH_Form_Fields__input_html', [$this, 'state_form_field_input__wrap'], 10);
878
+		$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
879
+		if (empty($states)) {
880
+			/** @var EventEspresso\core\services\address\CountrySubRegionDao $countrySubRegionDao */
881
+			$countrySubRegionDao = $this->loader->getShared(
882
+				'EventEspresso\core\services\address\CountrySubRegionDao'
883
+			);
884
+			if ($countrySubRegionDao instanceof EventEspresso\core\services\address\CountrySubRegionDao) {
885
+				$country = $this->verifyOrGetCountryFromIso($CNT_ISO, $country);
886
+				if ($countrySubRegionDao->saveCountrySubRegions($country)) {
887
+					$states = EEM_State::instance()->get_all_states_for_these_countries([$CNT_ISO => $CNT_ISO]);
888
+				}
889
+			}
890
+		}
891
+		if (is_array($states)) {
892
+			foreach ($states as $STA_ID => $state) {
893
+				if ($state instanceof EE_State) {
894
+					$inputs = EE_Question_Form_Input::generate_question_form_inputs_for_object(
895
+						$state,
896
+						[
897
+							'STA_abbrev' => [
898
+								'type'             => 'TEXT',
899
+								'label'            => esc_html__('Code', 'event_espresso'),
900
+								'input_name'       => 'states[' . $STA_ID . ']',
901
+								'class'            => 'small-text',
902
+								'add_mobile_label' => true,
903
+							],
904
+							'STA_name'   => [
905
+								'type'             => 'TEXT',
906
+								'label'            => esc_html__('Name', 'event_espresso'),
907
+								'input_name'       => 'states[' . $STA_ID . ']',
908
+								'class'            => 'regular-text',
909
+								'add_mobile_label' => true,
910
+							],
911
+							'STA_active' => [
912
+								'type'             => 'RADIO_BTN',
913
+								'label'            => esc_html__(
914
+									'State Appears in Dropdown Select Lists',
915
+									'event_espresso'
916
+								),
917
+								'input_name'       => 'states[' . $STA_ID . ']',
918
+								'options'          => $this->_yes_no_values,
919
+								'use_desc_4_label' => true,
920
+								'add_mobile_label' => true,
921
+							],
922
+						]
923
+					);
924
+
925
+					$delete_state_url = EE_Admin_Page::add_query_args_and_nonce(
926
+						[
927
+							'action'     => 'delete_state',
928
+							'STA_ID'     => $STA_ID,
929
+							'CNT_ISO'    => $CNT_ISO,
930
+							'STA_abbrev' => $state->abbrev(),
931
+						],
932
+						GEN_SET_ADMIN_URL
933
+					);
934
+
935
+					$this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
936
+					$this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
937
+				}
938
+			}
939
+		} else {
940
+			$this->_template_args['states'] = false;
941
+		}
942
+
943
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
944
+			['action' => 'add_new_state'],
945
+			GEN_SET_ADMIN_URL
946
+		);
947
+
948
+		$state_details_settings = EEH_Template::display_template(
949
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
950
+			$this->_template_args,
951
+			true
952
+		);
953
+
954
+		if (defined('DOING_AJAX')) {
955
+			$notices = EE_Error::get_notices(false, false, false);
956
+			echo wp_json_encode(
957
+				[
958
+					'return_data' => $state_details_settings,
959
+					'success'     => $notices['success'],
960
+					'errors'      => $notices['errors'],
961
+				]
962
+			);
963
+			die();
964
+		}
965
+		return $state_details_settings;
966
+	}
967
+
968
+
969
+	/**
970
+	 * @return void
971
+	 * @throws EE_Error
972
+	 * @throws InvalidArgumentException
973
+	 * @throws InvalidDataTypeException
974
+	 * @throws InvalidInterfaceException
975
+	 * @throws ReflectionException
976
+	 */
977
+	public function add_new_state()
978
+	{
979
+		$success = true;
980
+		$CNT_ISO = $this->getCountryISO('');
981
+		if (! $CNT_ISO) {
982
+			EE_Error::add_error(
983
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
984
+				__FILE__,
985
+				__FUNCTION__,
986
+				__LINE__
987
+			);
988
+			$success = false;
989
+		}
990
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
991
+		if (! $STA_abbrev) {
992
+			EE_Error::add_error(
993
+				esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
994
+				__FILE__,
995
+				__FUNCTION__,
996
+				__LINE__
997
+			);
998
+			$success = false;
999
+		}
1000
+		$STA_name = $this->request->getRequestParam('STA_name');
1001
+		if (! $STA_name) {
1002
+			EE_Error::add_error(
1003
+				esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1004
+				__FILE__,
1005
+				__FUNCTION__,
1006
+				__LINE__
1007
+			);
1008
+			$success = false;
1009
+		}
1010
+
1011
+		if ($success) {
1012
+			$cols_n_values = [
1013
+				'CNT_ISO'    => $CNT_ISO,
1014
+				'STA_abbrev' => $STA_abbrev,
1015
+				'STA_name'   => $STA_name,
1016
+				'STA_active' => true,
1017
+			];
1018
+			$success       = EEM_State::instance()->insert($cols_n_values);
1019
+			EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1020
+		}
1021
+
1022
+		if (defined('DOING_AJAX')) {
1023
+			$notices = EE_Error::get_notices(false, false, false);
1024
+			echo wp_json_encode(array_merge($notices, ['return_data' => $CNT_ISO]));
1025
+			die();
1026
+		} else {
1027
+			$this->_redirect_after_action(
1028
+				$success,
1029
+				esc_html__('State', 'event_espresso'),
1030
+				'added',
1031
+				['action' => 'country_settings']
1032
+			);
1033
+		}
1034
+	}
1035
+
1036
+
1037
+	/**
1038
+	 * @return void
1039
+	 * @throws EE_Error
1040
+	 * @throws InvalidArgumentException
1041
+	 * @throws InvalidDataTypeException
1042
+	 * @throws InvalidInterfaceException
1043
+	 * @throws ReflectionException
1044
+	 */
1045
+	public function delete_state()
1046
+	{
1047
+		$CNT_ISO    = $this->getCountryISO();
1048
+		$STA_ID     = $this->request->getRequestParam('STA_ID');
1049
+		$STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1050
+
1051
+		if (! $STA_ID) {
1052
+			EE_Error::add_error(
1053
+				esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1054
+				__FILE__,
1055
+				__FUNCTION__,
1056
+				__LINE__
1057
+			);
1058
+			return;
1059
+		}
1060
+
1061
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
1062
+		if ($success !== false) {
1063
+			do_action(
1064
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1065
+				$CNT_ISO,
1066
+				$STA_ID,
1067
+				['STA_abbrev' => $STA_abbrev]
1068
+			);
1069
+			EE_Error::add_success(esc_html__('The State was deleted successfully.', 'event_espresso'));
1070
+		}
1071
+		if (defined('DOING_AJAX')) {
1072
+			$notices                = EE_Error::get_notices(false);
1073
+			$notices['return_data'] = true;
1074
+			echo wp_json_encode($notices);
1075
+			die();
1076
+		} else {
1077
+			$this->_redirect_after_action(
1078
+				$success,
1079
+				esc_html__('State', 'event_espresso'),
1080
+				'deleted',
1081
+				['action' => 'country_settings']
1082
+			);
1083
+		}
1084
+	}
1085
+
1086
+
1087
+	/**
1088
+	 *        _update_country_settings
1089
+	 *
1090
+	 * @return void
1091
+	 * @throws EE_Error
1092
+	 * @throws InvalidArgumentException
1093
+	 * @throws InvalidDataTypeException
1094
+	 * @throws InvalidInterfaceException
1095
+	 * @throws ReflectionException
1096
+	 */
1097
+	protected function _update_country_settings()
1098
+	{
1099
+		$CNT_ISO = $this->getCountryISO();
1100
+		if (! $CNT_ISO) {
1101
+			EE_Error::add_error(
1102
+				esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1103
+				__FILE__,
1104
+				__FUNCTION__,
1105
+				__LINE__
1106
+			);
1107
+			return;
1108
+		}
1109
+
1110
+		$country = $this->verifyOrGetCountryFromIso($CNT_ISO);
1111
+
1112
+		$cols_n_values                    = [];
1113
+		$cols_n_values['CNT_ISO3']        = strtoupper(
1114
+			$this->request->getRequestParam('cntry', '', $country->ISO3())
1115
+		);
1116
+		$cols_n_values['CNT_name']        = $this->request->getRequestParam(
1117
+			"cntry[$CNT_ISO][CNT_name]",
1118
+			$country->name()
1119
+		);
1120
+		$cols_n_values['CNT_cur_code']    = strtoupper(
1121
+			$this->request->getRequestParam(
1122
+				"cntry[$CNT_ISO][CNT_cur_code]",
1123
+				$country->currency_code()
1124
+			)
1125
+		);
1126
+		$cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1127
+			"cntry[$CNT_ISO][CNT_cur_single]",
1128
+			$country->currency_name_single()
1129
+		);
1130
+		$cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1131
+			"cntry[$CNT_ISO][CNT_cur_plural]",
1132
+			$country->currency_name_plural()
1133
+		);
1134
+		$cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1135
+			"cntry[$CNT_ISO][CNT_cur_sign]",
1136
+			$country->currency_sign()
1137
+		);
1138
+		$cols_n_values['CNT_cur_sign_b4'] = $this->request->getRequestParam(
1139
+			"cntry[$CNT_ISO][CNT_cur_sign_b4]",
1140
+			$country->currency_sign_before(),
1141
+			DataType::BOOL
1142
+		);
1143
+		$cols_n_values['CNT_cur_dec_plc'] = $this->request->getRequestParam(
1144
+			"cntry[$CNT_ISO][CNT_cur_dec_plc]",
1145
+			$country->currency_decimal_places()
1146
+		);
1147
+		$cols_n_values['CNT_cur_dec_mrk'] = $this->request->getRequestParam(
1148
+			"cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1149
+			$country->currency_decimal_mark()
1150
+		);
1151
+		$cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1152
+			"cntry[$CNT_ISO][CNT_cur_thsnds]",
1153
+			$country->currency_thousands_separator()
1154
+		);
1155
+		$cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1156
+			"cntry[$CNT_ISO][CNT_tel_code]",
1157
+			$country->telephoneCode()
1158
+		);
1159
+		$cols_n_values['CNT_active']      = $this->request->getRequestParam(
1160
+			"cntry[$CNT_ISO][CNT_active]",
1161
+			$country->isActive(),
1162
+			DataType::BOOL
1163
+		);
1164
+
1165
+		// allow filtering of country data
1166
+		$cols_n_values = apply_filters(
1167
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1168
+			$cols_n_values
1169
+		);
1170
+
1171
+		// where values
1172
+		$where_cols_n_values = [['CNT_ISO' => $CNT_ISO]];
1173
+		// run the update
1174
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1175
+
1176
+		// allow filtering of states data
1177
+		$states = apply_filters(
1178
+			'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1179
+			$this->request->getRequestParam('states', [], DataType::STRING, true)
1180
+		);
1181
+
1182
+		if (! empty($states) && $success !== false) {
1183
+			// loop thru state data ( looks like : states[75][STA_name] )
1184
+			foreach ($states as $STA_ID => $state) {
1185
+				$cols_n_values = [
1186
+					'CNT_ISO'    => $CNT_ISO,
1187
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1188
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1189
+					'STA_active' => filter_var($state['STA_active'], FILTER_VALIDATE_BOOLEAN),
1190
+				];
1191
+				// where values
1192
+				$where_cols_n_values = [['STA_ID' => $STA_ID]];
1193
+				// run the update
1194
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1195
+				if ($success !== false) {
1196
+					do_action(
1197
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1198
+						$CNT_ISO,
1199
+						$STA_ID,
1200
+						$cols_n_values
1201
+					);
1202
+				}
1203
+			}
1204
+		}
1205
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1206
+		if (
1207
+			isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1208
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1209
+		) {
1210
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1211
+			EE_Registry::instance()->CFG->update_espresso_config();
1212
+		}
1213
+
1214
+		if ($success !== false) {
1215
+			EE_Error::add_success(
1216
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1217
+			);
1218
+		}
1219
+		$this->_redirect_after_action(
1220
+			$success,
1221
+			'',
1222
+			'',
1223
+			['action' => 'country_settings', 'country' => $CNT_ISO],
1224
+			true
1225
+		);
1226
+	}
1227
+
1228
+
1229
+	/**
1230
+	 * form_form_field_label_wrap
1231
+	 *
1232
+	 * @param string $label
1233
+	 * @return string
1234
+	 */
1235
+	public function country_form_field_label_wrap(string $label): string
1236
+	{
1237
+		return '
1238 1238
 			<tr>
1239 1239
 				<th>
1240 1240
 					' . $label . '
1241 1241
 				</th>';
1242
-    }
1243
-
1244
-
1245
-    /**
1246
-     * form_form_field_input__wrap
1247
-     *
1248
-     * @param string $input
1249
-     * @return string
1250
-     */
1251
-    public function country_form_field_input__wrap(string $input): string
1252
-    {
1253
-        return '
1242
+	}
1243
+
1244
+
1245
+	/**
1246
+	 * form_form_field_input__wrap
1247
+	 *
1248
+	 * @param string $input
1249
+	 * @return string
1250
+	 */
1251
+	public function country_form_field_input__wrap(string $input): string
1252
+	{
1253
+		return '
1254 1254
 				<td class="general-settings-country-input-td">
1255 1255
 					' . $input . '
1256 1256
 				</td>
1257 1257
 			</tr>';
1258
-    }
1259
-
1260
-
1261
-    /**
1262
-     * form_form_field_label_wrap
1263
-     *
1264
-     * @param string $label
1265
-     * @param string $required_text
1266
-     * @return string
1267
-     */
1268
-    public function state_form_field_label_wrap(string $label, string $required_text): string
1269
-    {
1270
-        return $required_text;
1271
-    }
1272
-
1273
-
1274
-    /**
1275
-     * form_form_field_input__wrap
1276
-     *
1277
-     * @param string $input
1278
-     * @return string
1279
-     */
1280
-    public function state_form_field_input__wrap(string $input): string
1281
-    {
1282
-        return '
1258
+	}
1259
+
1260
+
1261
+	/**
1262
+	 * form_form_field_label_wrap
1263
+	 *
1264
+	 * @param string $label
1265
+	 * @param string $required_text
1266
+	 * @return string
1267
+	 */
1268
+	public function state_form_field_label_wrap(string $label, string $required_text): string
1269
+	{
1270
+		return $required_text;
1271
+	}
1272
+
1273
+
1274
+	/**
1275
+	 * form_form_field_input__wrap
1276
+	 *
1277
+	 * @param string $input
1278
+	 * @return string
1279
+	 */
1280
+	public function state_form_field_input__wrap(string $input): string
1281
+	{
1282
+		return '
1283 1283
 				<td class="general-settings-country-state-input-td">
1284 1284
 					' . $input . '
1285 1285
 				</td>';
1286
-    }
1287
-
1288
-
1289
-    /***********/
1290
-
1291
-
1292
-    /**
1293
-     * displays edit and view links for critical EE pages
1294
-     *
1295
-     * @param int $ee_page_id
1296
-     * @return string
1297
-     */
1298
-    public static function edit_view_links(int $ee_page_id): string
1299
-    {
1300
-        $edit_url = add_query_arg(
1301
-            ['post' => $ee_page_id, 'action' => 'edit'],
1302
-            admin_url('post.php')
1303
-        );
1304
-        $links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1305
-        $links    .= ' &nbsp;|&nbsp; ';
1306
-        $links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1307
-
1308
-        return $links;
1309
-    }
1310
-
1311
-
1312
-    /**
1313
-     * displays page and shortcode status for critical EE pages
1314
-     *
1315
-     * @param WP_Post $ee_page
1316
-     * @param string  $shortcode
1317
-     * @return string
1318
-     */
1319
-    public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1320
-    {
1321
-        // page status
1322
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1323
-            $pg_colour = 'green';
1324
-            $pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1325
-        } else {
1326
-            $pg_colour = 'red';
1327
-            $pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1328
-        }
1329
-
1330
-        // shortcode status
1331
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1332
-            $sc_colour = 'green';
1333
-            $sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1334
-        } else {
1335
-            $sc_colour = 'red';
1336
-            $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1337
-        }
1338
-
1339
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1340
-               . $pg_status
1341
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1342
-    }
1343
-
1344
-
1345
-    /**
1346
-     * generates a dropdown of all parent pages - copied from WP core
1347
-     *
1348
-     * @param int  $default
1349
-     * @param int  $parent
1350
-     * @param int  $level
1351
-     * @param bool $echo
1352
-     * @return string;
1353
-     */
1354
-    public static function page_settings_dropdown(
1355
-        int $default = 0,
1356
-        int $parent = 0,
1357
-        int $level = 0,
1358
-        bool $echo = true
1359
-    ): string {
1360
-        global $wpdb;
1361
-        $items  = $wpdb->get_results(
1362
-            $wpdb->prepare(
1363
-                "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1364
-                $parent
1365
-            )
1366
-        );
1367
-        $output = '';
1368
-
1369
-        if ($items) {
1370
-            $level = absint($level);
1371
-            foreach ($items as $item) {
1372
-                $ID         = absint($item->ID);
1373
-                $post_title = wp_strip_all_tags($item->post_title);
1374
-                $pad        = str_repeat('&nbsp;', $level * 3);
1375
-                $option     = "\n\t";
1376
-                $option     .= '<option class="level-' . $level . '" ';
1377
-                $option     .= 'value="' . $ID . '" ';
1378
-                $option     .= $ID === absint($default) ? ' selected' : '';
1379
-                $option     .= '>';
1380
-                $option     .= "$pad {$post_title}";
1381
-                $option     .= '</option>';
1382
-                $output     .= $option;
1383
-                ob_start();
1384
-                parent_dropdown($default, $item->ID, $level + 1);
1385
-                $output .= ob_get_clean();
1386
-            }
1387
-        }
1388
-        if ($echo) {
1389
-            echo wp_kses($output, AllowedTags::getAllowedTags());
1390
-            return '';
1391
-        }
1392
-        return $output;
1393
-    }
1394
-
1395
-
1396
-    /**
1397
-     * Loads the scripts for the privacy settings form
1398
-     */
1399
-    public function load_scripts_styles_privacy_settings()
1400
-    {
1401
-        $form_handler = $this->loader->getShared(
1402
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1403
-        );
1404
-        $form_handler->enqueueStylesAndScripts();
1405
-    }
1406
-
1407
-
1408
-    /**
1409
-     * display the privacy settings form
1410
-     *
1411
-     * @throws EE_Error
1412
-     */
1413
-    public function privacySettings()
1414
-    {
1415
-        $this->_set_add_edit_form_tags('update_privacy_settings');
1416
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1417
-        $form_handler                               = $this->loader->getShared(
1418
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1419
-        );
1420
-        $this->_template_args['admin_page_content'] = EEH_HTML::div(
1421
-            $form_handler->display(),
1422
-            '',
1423
-            'padding'
1424
-        );
1425
-        $this->display_admin_page_with_sidebar();
1426
-    }
1427
-
1428
-
1429
-    /**
1430
-     * Update the privacy settings from form data
1431
-     *
1432
-     * @throws EE_Error
1433
-     */
1434
-    public function updatePrivacySettings()
1435
-    {
1436
-        $form_handler = $this->loader->getShared(
1437
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1438
-        );
1439
-        $success      = $form_handler->process($this->get_request_data());
1440
-        $this->_redirect_after_action(
1441
-            $success,
1442
-            esc_html__('Registration Form Options', 'event_espresso'),
1443
-            'updated',
1444
-            ['action' => 'privacy_settings']
1445
-        );
1446
-    }
1286
+	}
1287
+
1288
+
1289
+	/***********/
1290
+
1291
+
1292
+	/**
1293
+	 * displays edit and view links for critical EE pages
1294
+	 *
1295
+	 * @param int $ee_page_id
1296
+	 * @return string
1297
+	 */
1298
+	public static function edit_view_links(int $ee_page_id): string
1299
+	{
1300
+		$edit_url = add_query_arg(
1301
+			['post' => $ee_page_id, 'action' => 'edit'],
1302
+			admin_url('post.php')
1303
+		);
1304
+		$links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1305
+		$links    .= ' &nbsp;|&nbsp; ';
1306
+		$links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1307
+
1308
+		return $links;
1309
+	}
1310
+
1311
+
1312
+	/**
1313
+	 * displays page and shortcode status for critical EE pages
1314
+	 *
1315
+	 * @param WP_Post $ee_page
1316
+	 * @param string  $shortcode
1317
+	 * @return string
1318
+	 */
1319
+	public static function page_and_shortcode_status(WP_Post $ee_page, string $shortcode): string
1320
+	{
1321
+		// page status
1322
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1323
+			$pg_colour = 'green';
1324
+			$pg_status = sprintf(esc_html__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1325
+		} else {
1326
+			$pg_colour = 'red';
1327
+			$pg_status = sprintf(esc_html__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1328
+		}
1329
+
1330
+		// shortcode status
1331
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1332
+			$sc_colour = 'green';
1333
+			$sc_status = sprintf(esc_html__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1334
+		} else {
1335
+			$sc_colour = 'red';
1336
+			$sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1337
+		}
1338
+
1339
+		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1340
+			   . $pg_status
1341
+			   . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1342
+	}
1343
+
1344
+
1345
+	/**
1346
+	 * generates a dropdown of all parent pages - copied from WP core
1347
+	 *
1348
+	 * @param int  $default
1349
+	 * @param int  $parent
1350
+	 * @param int  $level
1351
+	 * @param bool $echo
1352
+	 * @return string;
1353
+	 */
1354
+	public static function page_settings_dropdown(
1355
+		int $default = 0,
1356
+		int $parent = 0,
1357
+		int $level = 0,
1358
+		bool $echo = true
1359
+	): string {
1360
+		global $wpdb;
1361
+		$items  = $wpdb->get_results(
1362
+			$wpdb->prepare(
1363
+				"SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1364
+				$parent
1365
+			)
1366
+		);
1367
+		$output = '';
1368
+
1369
+		if ($items) {
1370
+			$level = absint($level);
1371
+			foreach ($items as $item) {
1372
+				$ID         = absint($item->ID);
1373
+				$post_title = wp_strip_all_tags($item->post_title);
1374
+				$pad        = str_repeat('&nbsp;', $level * 3);
1375
+				$option     = "\n\t";
1376
+				$option     .= '<option class="level-' . $level . '" ';
1377
+				$option     .= 'value="' . $ID . '" ';
1378
+				$option     .= $ID === absint($default) ? ' selected' : '';
1379
+				$option     .= '>';
1380
+				$option     .= "$pad {$post_title}";
1381
+				$option     .= '</option>';
1382
+				$output     .= $option;
1383
+				ob_start();
1384
+				parent_dropdown($default, $item->ID, $level + 1);
1385
+				$output .= ob_get_clean();
1386
+			}
1387
+		}
1388
+		if ($echo) {
1389
+			echo wp_kses($output, AllowedTags::getAllowedTags());
1390
+			return '';
1391
+		}
1392
+		return $output;
1393
+	}
1394
+
1395
+
1396
+	/**
1397
+	 * Loads the scripts for the privacy settings form
1398
+	 */
1399
+	public function load_scripts_styles_privacy_settings()
1400
+	{
1401
+		$form_handler = $this->loader->getShared(
1402
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1403
+		);
1404
+		$form_handler->enqueueStylesAndScripts();
1405
+	}
1406
+
1407
+
1408
+	/**
1409
+	 * display the privacy settings form
1410
+	 *
1411
+	 * @throws EE_Error
1412
+	 */
1413
+	public function privacySettings()
1414
+	{
1415
+		$this->_set_add_edit_form_tags('update_privacy_settings');
1416
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1417
+		$form_handler                               = $this->loader->getShared(
1418
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1419
+		);
1420
+		$this->_template_args['admin_page_content'] = EEH_HTML::div(
1421
+			$form_handler->display(),
1422
+			'',
1423
+			'padding'
1424
+		);
1425
+		$this->display_admin_page_with_sidebar();
1426
+	}
1427
+
1428
+
1429
+	/**
1430
+	 * Update the privacy settings from form data
1431
+	 *
1432
+	 * @throws EE_Error
1433
+	 */
1434
+	public function updatePrivacySettings()
1435
+	{
1436
+		$form_handler = $this->loader->getShared(
1437
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'
1438
+		);
1439
+		$success      = $form_handler->process($this->get_request_data());
1440
+		$this->_redirect_after_action(
1441
+			$success,
1442
+			esc_html__('Registration Form Options', 'event_espresso'),
1443
+			'updated',
1444
+			['action' => 'privacy_settings']
1445
+		);
1446
+	}
1447 1447
 }
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -247,19 +247,19 @@  discard block
 block discarded – undo
247 247
                 'event_espresso'
248 248
             )
249 249
         );
250
-        EE_Registry::$i18n_js_strings['error_occurred']          = wp_strip_all_tags(
250
+        EE_Registry::$i18n_js_strings['error_occurred'] = wp_strip_all_tags(
251 251
             esc_html__(
252 252
                 'An error occurred! Please refresh the page and try again.',
253 253
                 'event_espresso'
254 254
             )
255 255
         );
256
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = wp_strip_all_tags(
256
+        EE_Registry::$i18n_js_strings['confirm_delete_state'] = wp_strip_all_tags(
257 257
             esc_html__(
258 258
                 'Are you sure you want to delete this State / Province?',
259 259
                 'event_espresso'
260 260
             )
261 261
         );
262
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
262
+        EE_Registry::$i18n_js_strings['ajax_url'] = admin_url(
263 263
             'admin-ajax.php?page=espresso_general_settings',
264 264
             is_ssl() ? 'https://' : 'http://'
265 265
         );
@@ -288,12 +288,12 @@  discard block
 block discarded – undo
288 288
         wp_enqueue_script('thickbox');
289 289
         wp_register_script(
290 290
             'organization_settings',
291
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
291
+            GEN_SET_ASSETS_URL.'your_organization_settings.js',
292 292
             ['jquery', 'media-upload', 'thickbox'],
293 293
             EVENT_ESPRESSO_VERSION,
294 294
             true
295 295
         );
296
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
296
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', [], EVENT_ESPRESSO_VERSION);
297 297
         wp_enqueue_script('organization_settings');
298 298
         wp_enqueue_style('organization-css');
299 299
         $confirm_image_delete = [
@@ -316,12 +316,12 @@  discard block
 block discarded – undo
316 316
         // scripts
317 317
         wp_register_script(
318 318
             'gen_settings_countries',
319
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
319
+            GEN_SET_ASSETS_URL.'gen_settings_countries.js',
320 320
             ['ee_admin_js'],
321 321
             EVENT_ESPRESSO_VERSION,
322 322
             true
323 323
         );
324
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', [], EVENT_ESPRESSO_VERSION);
324
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', [], EVENT_ESPRESSO_VERSION);
325 325
         wp_enqueue_script('gen_settings_countries');
326 326
         wp_enqueue_style('organization-css');
327 327
     }
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
         $this->_set_add_edit_form_tags('update_espresso_page_settings');
370 370
         $this->_set_publish_post_box_vars(null, false, false, null, false);
371 371
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
372
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
372
+            GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php',
373 373
             $this->_template_args,
374 374
             true
375 375
         );
@@ -385,12 +385,12 @@  discard block
 block discarded – undo
385 385
     protected function _update_espresso_page_settings()
386 386
     {
387 387
         // capture incoming request data && set page IDs
388
-        $this->core_config->reg_page_id       = $this->request->getRequestParam(
388
+        $this->core_config->reg_page_id = $this->request->getRequestParam(
389 389
             'reg_page_id',
390 390
             $this->core_config->reg_page_id,
391 391
             DataType::INT
392 392
         );
393
-        $this->core_config->txn_page_id       = $this->request->getRequestParam(
393
+        $this->core_config->txn_page_id = $this->request->getRequestParam(
394 394
             'txn_page_id',
395 395
             $this->core_config->txn_page_id,
396 396
             DataType::INT
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
             $this->core_config->thank_you_page_id,
401 401
             DataType::INT
402 402
         );
403
-        $this->core_config->cancel_page_id    = $this->request->getRequestParam(
403
+        $this->core_config->cancel_page_id = $this->request->getRequestParam(
404 404
             'cancel_page_id',
405 405
             $this->core_config->cancel_page_id,
406 406
             DataType::INT
@@ -661,16 +661,16 @@  discard block
 block discarded – undo
661 661
             $country->ID(),
662 662
             $country
663 663
         );
664
-        $this->_template_args['country_states_settings']  = $this->display_country_states(
664
+        $this->_template_args['country_states_settings'] = $this->display_country_states(
665 665
             $country->ID(),
666 666
             $country
667 667
         );
668
-        $this->_template_args['CNT_name_for_site']        = $country->name();
668
+        $this->_template_args['CNT_name_for_site'] = $country->name();
669 669
 
670 670
         $this->_set_add_edit_form_tags('update_country_settings');
671 671
         $this->_set_publish_post_box_vars(null, false, false, null, false);
672 672
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
673
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
673
+            GEN_SET_TEMPLATE_PATH.'countries_settings.template.php',
674 674
             $this->_template_args,
675 675
             true
676 676
         );
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
         $CNT_ISO          = $this->getCountryISO($CNT_ISO);
695 695
         $CNT_ISO_for_site = $this->getCountryIsoForSite();
696 696
 
697
-        if (! $CNT_ISO) {
697
+        if ( ! $CNT_ISO) {
698 698
             return '';
699 699
         }
700 700
 
@@ -707,22 +707,22 @@  discard block
 block discarded – undo
707 707
         $CNT_cur_disabled                         = $CNT_ISO !== $CNT_ISO_for_site;
708 708
         $this->_template_args['CNT_cur_disabled'] = $CNT_cur_disabled;
709 709
 
710
-        $country_input_types            = [
710
+        $country_input_types = [
711 711
             'CNT_active'      => [
712 712
                 'type'             => 'RADIO_BTN',
713
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
713
+                'input_name'       => 'cntry['.$CNT_ISO.']',
714 714
                 'class'            => '',
715 715
                 'options'          => $this->_yes_no_values,
716 716
                 'use_desc_4_label' => true,
717 717
             ],
718 718
             'CNT_ISO'         => [
719 719
                 'type'       => 'TEXT',
720
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
720
+                'input_name' => 'cntry['.$CNT_ISO.']',
721 721
                 'class'      => 'small-text',
722 722
             ],
723 723
             'CNT_ISO3'        => [
724 724
                 'type'       => 'TEXT',
725
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
725
+                'input_name' => 'cntry['.$CNT_ISO.']',
726 726
                 'class'      => 'small-text',
727 727
             ],
728 728
             // 'RGN_ID'          => [
@@ -732,37 +732,37 @@  discard block
 block discarded – undo
732 732
             // ],
733 733
             'CNT_name'        => [
734 734
                 'type'       => 'TEXT',
735
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
735
+                'input_name' => 'cntry['.$CNT_ISO.']',
736 736
                 'class'      => 'regular-text',
737 737
             ],
738 738
             'CNT_cur_code'    => [
739 739
                 'type'       => 'TEXT',
740
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
740
+                'input_name' => 'cntry['.$CNT_ISO.']',
741 741
                 'class'      => 'small-text',
742 742
                 'disabled'   => $CNT_cur_disabled,
743 743
             ],
744 744
             'CNT_cur_single'  => [
745 745
                 'type'       => 'TEXT',
746
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
746
+                'input_name' => 'cntry['.$CNT_ISO.']',
747 747
                 'class'      => 'medium-text',
748 748
                 'disabled'   => $CNT_cur_disabled,
749 749
             ],
750 750
             'CNT_cur_plural'  => [
751 751
                 'type'       => 'TEXT',
752
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
752
+                'input_name' => 'cntry['.$CNT_ISO.']',
753 753
                 'class'      => 'medium-text',
754 754
                 'disabled'   => $CNT_cur_disabled,
755 755
             ],
756 756
             'CNT_cur_sign'    => [
757 757
                 'type'         => 'TEXT',
758
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
758
+                'input_name'   => 'cntry['.$CNT_ISO.']',
759 759
                 'class'        => 'small-text',
760 760
                 'htmlentities' => false,
761 761
                 'disabled'     => $CNT_cur_disabled,
762 762
             ],
763 763
             'CNT_cur_sign_b4' => [
764 764
                 'type'             => 'RADIO_BTN',
765
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
765
+                'input_name'       => 'cntry['.$CNT_ISO.']',
766 766
                 'class'            => '',
767 767
                 'options'          => $this->_yes_no_values,
768 768
                 'use_desc_4_label' => true,
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
             ],
771 771
             'CNT_cur_dec_plc' => [
772 772
                 'type'       => 'RADIO_BTN',
773
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
773
+                'input_name' => 'cntry['.$CNT_ISO.']',
774 774
                 'class'      => '',
775 775
                 'options'    => [
776 776
                     ['id' => 0, 'text' => ''],
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
             ],
783 783
             'CNT_cur_dec_mrk' => [
784 784
                 'type'             => 'RADIO_BTN',
785
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
785
+                'input_name'       => 'cntry['.$CNT_ISO.']',
786 786
                 'class'            => '',
787 787
                 'options'          => [
788 788
                     [
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
             ],
797 797
             'CNT_cur_thsnds'  => [
798 798
                 'type'             => 'RADIO_BTN',
799
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
799
+                'input_name'       => 'cntry['.$CNT_ISO.']',
800 800
                 'class'            => '',
801 801
                 'options'          => [
802 802
                     [
@@ -817,12 +817,12 @@  discard block
 block discarded – undo
817 817
             ],
818 818
             'CNT_tel_code'    => [
819 819
                 'type'       => 'TEXT',
820
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
820
+                'input_name' => 'cntry['.$CNT_ISO.']',
821 821
                 'class'      => 'small-text',
822 822
             ],
823 823
             'CNT_is_EU'       => [
824 824
                 'type'             => 'RADIO_BTN',
825
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
825
+                'input_name'       => 'cntry['.$CNT_ISO.']',
826 826
                 'class'            => '',
827 827
                 'options'          => $this->_yes_no_values,
828 828
                 'use_desc_4_label' => true,
@@ -832,8 +832,8 @@  discard block
 block discarded – undo
832 832
             $country,
833 833
             $country_input_types
834 834
         );
835
-        $country_details_settings       = EEH_Template::display_template(
836
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
835
+        $country_details_settings = EEH_Template::display_template(
836
+            GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php',
837 837
             $this->_template_args,
838 838
             true
839 839
         );
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
     public function display_country_states(string $CNT_ISO = '', ?EE_Country $country = null): string
868 868
     {
869 869
         $CNT_ISO = $this->getCountryISO($CNT_ISO);
870
-        if (! $CNT_ISO) {
870
+        if ( ! $CNT_ISO) {
871 871
             return '';
872 872
         }
873 873
         // for ajax
@@ -897,14 +897,14 @@  discard block
 block discarded – undo
897 897
                             'STA_abbrev' => [
898 898
                                 'type'             => 'TEXT',
899 899
                                 'label'            => esc_html__('Code', 'event_espresso'),
900
-                                'input_name'       => 'states[' . $STA_ID . ']',
900
+                                'input_name'       => 'states['.$STA_ID.']',
901 901
                                 'class'            => 'small-text',
902 902
                                 'add_mobile_label' => true,
903 903
                             ],
904 904
                             'STA_name'   => [
905 905
                                 'type'             => 'TEXT',
906 906
                                 'label'            => esc_html__('Name', 'event_espresso'),
907
-                                'input_name'       => 'states[' . $STA_ID . ']',
907
+                                'input_name'       => 'states['.$STA_ID.']',
908 908
                                 'class'            => 'regular-text',
909 909
                                 'add_mobile_label' => true,
910 910
                             ],
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
                                     'State Appears in Dropdown Select Lists',
915 915
                                     'event_espresso'
916 916
                                 ),
917
-                                'input_name'       => 'states[' . $STA_ID . ']',
917
+                                'input_name'       => 'states['.$STA_ID.']',
918 918
                                 'options'          => $this->_yes_no_values,
919 919
                                 'use_desc_4_label' => true,
920 920
                                 'add_mobile_label' => true,
@@ -932,8 +932,8 @@  discard block
 block discarded – undo
932 932
                         GEN_SET_ADMIN_URL
933 933
                     );
934 934
 
935
-                    $this->_template_args['states'][ $STA_ID ]['inputs']           = $inputs;
936
-                    $this->_template_args['states'][ $STA_ID ]['delete_state_url'] = $delete_state_url;
935
+                    $this->_template_args['states'][$STA_ID]['inputs']           = $inputs;
936
+                    $this->_template_args['states'][$STA_ID]['delete_state_url'] = $delete_state_url;
937 937
                 }
938 938
             }
939 939
         } else {
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
         );
947 947
 
948 948
         $state_details_settings = EEH_Template::display_template(
949
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
949
+            GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php',
950 950
             $this->_template_args,
951 951
             true
952 952
         );
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
     {
979 979
         $success = true;
980 980
         $CNT_ISO = $this->getCountryISO('');
981
-        if (! $CNT_ISO) {
981
+        if ( ! $CNT_ISO) {
982 982
             EE_Error::add_error(
983 983
                 esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
984 984
                 __FILE__,
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
             $success = false;
989 989
         }
990 990
         $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
991
-        if (! $STA_abbrev) {
991
+        if ( ! $STA_abbrev) {
992 992
             EE_Error::add_error(
993 993
                 esc_html__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
994 994
                 __FILE__,
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
             $success = false;
999 999
         }
1000 1000
         $STA_name = $this->request->getRequestParam('STA_name');
1001
-        if (! $STA_name) {
1001
+        if ( ! $STA_name) {
1002 1002
             EE_Error::add_error(
1003 1003
                 esc_html__('No State name or an invalid State name was received.', 'event_espresso'),
1004 1004
                 __FILE__,
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
                 'STA_name'   => $STA_name,
1016 1016
                 'STA_active' => true,
1017 1017
             ];
1018
-            $success       = EEM_State::instance()->insert($cols_n_values);
1018
+            $success = EEM_State::instance()->insert($cols_n_values);
1019 1019
             EE_Error::add_success(esc_html__('The State was added successfully.', 'event_espresso'));
1020 1020
         }
1021 1021
 
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
         $STA_ID     = $this->request->getRequestParam('STA_ID');
1049 1049
         $STA_abbrev = $this->request->getRequestParam('STA_abbrev');
1050 1050
 
1051
-        if (! $STA_ID) {
1051
+        if ( ! $STA_ID) {
1052 1052
             EE_Error::add_error(
1053 1053
                 esc_html__('No State ID or an invalid State ID was received.', 'event_espresso'),
1054 1054
                 __FILE__,
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
     protected function _update_country_settings()
1098 1098
     {
1099 1099
         $CNT_ISO = $this->getCountryISO();
1100
-        if (! $CNT_ISO) {
1100
+        if ( ! $CNT_ISO) {
1101 1101
             EE_Error::add_error(
1102 1102
                 esc_html__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1103 1103
                 __FILE__,
@@ -1117,21 +1117,21 @@  discard block
 block discarded – undo
1117 1117
             "cntry[$CNT_ISO][CNT_name]",
1118 1118
             $country->name()
1119 1119
         );
1120
-        $cols_n_values['CNT_cur_code']    = strtoupper(
1120
+        $cols_n_values['CNT_cur_code'] = strtoupper(
1121 1121
             $this->request->getRequestParam(
1122 1122
                 "cntry[$CNT_ISO][CNT_cur_code]",
1123 1123
                 $country->currency_code()
1124 1124
             )
1125 1125
         );
1126
-        $cols_n_values['CNT_cur_single']  = $this->request->getRequestParam(
1126
+        $cols_n_values['CNT_cur_single'] = $this->request->getRequestParam(
1127 1127
             "cntry[$CNT_ISO][CNT_cur_single]",
1128 1128
             $country->currency_name_single()
1129 1129
         );
1130
-        $cols_n_values['CNT_cur_plural']  = $this->request->getRequestParam(
1130
+        $cols_n_values['CNT_cur_plural'] = $this->request->getRequestParam(
1131 1131
             "cntry[$CNT_ISO][CNT_cur_plural]",
1132 1132
             $country->currency_name_plural()
1133 1133
         );
1134
-        $cols_n_values['CNT_cur_sign']    = $this->request->getRequestParam(
1134
+        $cols_n_values['CNT_cur_sign'] = $this->request->getRequestParam(
1135 1135
             "cntry[$CNT_ISO][CNT_cur_sign]",
1136 1136
             $country->currency_sign()
1137 1137
         );
@@ -1148,15 +1148,15 @@  discard block
 block discarded – undo
1148 1148
             "cntry[$CNT_ISO][CNT_cur_dec_mrk]",
1149 1149
             $country->currency_decimal_mark()
1150 1150
         );
1151
-        $cols_n_values['CNT_cur_thsnds']  = $this->request->getRequestParam(
1151
+        $cols_n_values['CNT_cur_thsnds'] = $this->request->getRequestParam(
1152 1152
             "cntry[$CNT_ISO][CNT_cur_thsnds]",
1153 1153
             $country->currency_thousands_separator()
1154 1154
         );
1155
-        $cols_n_values['CNT_tel_code']    = $this->request->getRequestParam(
1155
+        $cols_n_values['CNT_tel_code'] = $this->request->getRequestParam(
1156 1156
             "cntry[$CNT_ISO][CNT_tel_code]",
1157 1157
             $country->telephoneCode()
1158 1158
         );
1159
-        $cols_n_values['CNT_active']      = $this->request->getRequestParam(
1159
+        $cols_n_values['CNT_active'] = $this->request->getRequestParam(
1160 1160
             "cntry[$CNT_ISO][CNT_active]",
1161 1161
             $country->isActive(),
1162 1162
             DataType::BOOL
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
             $this->request->getRequestParam('states', [], DataType::STRING, true)
1180 1180
         );
1181 1181
 
1182
-        if (! empty($states) && $success !== false) {
1182
+        if ( ! empty($states) && $success !== false) {
1183 1183
             // loop thru state data ( looks like : states[75][STA_name] )
1184 1184
             foreach ($states as $STA_ID => $state) {
1185 1185
                 $cols_n_values = [
@@ -1237,7 +1237,7 @@  discard block
 block discarded – undo
1237 1237
         return '
1238 1238
 			<tr>
1239 1239
 				<th>
1240
-					' . $label . '
1240
+					' . $label.'
1241 1241
 				</th>';
1242 1242
     }
1243 1243
 
@@ -1252,7 +1252,7 @@  discard block
 block discarded – undo
1252 1252
     {
1253 1253
         return '
1254 1254
 				<td class="general-settings-country-input-td">
1255
-					' . $input . '
1255
+					' . $input.'
1256 1256
 				</td>
1257 1257
 			</tr>';
1258 1258
     }
@@ -1281,7 +1281,7 @@  discard block
 block discarded – undo
1281 1281
     {
1282 1282
         return '
1283 1283
 				<td class="general-settings-country-state-input-td">
1284
-					' . $input . '
1284
+					' . $input.'
1285 1285
 				</td>';
1286 1286
     }
1287 1287
 
@@ -1301,9 +1301,9 @@  discard block
 block discarded – undo
1301 1301
             ['post' => $ee_page_id, 'action' => 'edit'],
1302 1302
             admin_url('post.php')
1303 1303
         );
1304
-        $links    = '<a href="' . esc_url_raw($edit_url) . '" >' . esc_html__('Edit', 'event_espresso') . '</a>';
1304
+        $links = '<a href="'.esc_url_raw($edit_url).'" >'.esc_html__('Edit', 'event_espresso').'</a>';
1305 1305
         $links    .= ' &nbsp;|&nbsp; ';
1306
-        $links    .= '<a href="' . get_permalink($ee_page_id) . '" >' . esc_html__('View', 'event_espresso') . '</a>';
1306
+        $links    .= '<a href="'.get_permalink($ee_page_id).'" >'.esc_html__('View', 'event_espresso').'</a>';
1307 1307
 
1308 1308
         return $links;
1309 1309
     }
@@ -1336,9 +1336,9 @@  discard block
 block discarded – undo
1336 1336
             $sc_status = sprintf(esc_html__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1337 1337
         }
1338 1338
 
1339
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1339
+        return '<span style="color:'.$pg_colour.'; margin-right:2em;"><strong>'
1340 1340
                . $pg_status
1341
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1341
+               . '</strong></span><span style="color:'.$sc_colour.'"><strong>'.$sc_status.'</strong></span>';
1342 1342
     }
1343 1343
 
1344 1344
 
@@ -1358,7 +1358,7 @@  discard block
 block discarded – undo
1358 1358
         bool $echo = true
1359 1359
     ): string {
1360 1360
         global $wpdb;
1361
-        $items  = $wpdb->get_results(
1361
+        $items = $wpdb->get_results(
1362 1362
             $wpdb->prepare(
1363 1363
                 "SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1364 1364
                 $parent
@@ -1373,8 +1373,8 @@  discard block
 block discarded – undo
1373 1373
                 $post_title = wp_strip_all_tags($item->post_title);
1374 1374
                 $pad        = str_repeat('&nbsp;', $level * 3);
1375 1375
                 $option     = "\n\t";
1376
-                $option     .= '<option class="level-' . $level . '" ';
1377
-                $option     .= 'value="' . $ID . '" ';
1376
+                $option     .= '<option class="level-'.$level.'" ';
1377
+                $option     .= 'value="'.$ID.'" ';
1378 1378
                 $option     .= $ID === absint($default) ? ' selected' : '';
1379 1379
                 $option     .= '>';
1380 1380
                 $option     .= "$pad {$post_title}";
Please login to merge, or discard this patch.