Completed
Branch dependabot/npm_and_yarn/@wordp... (e9f48b)
by
unknown
60:52 queued 52:34
created
admin_pages/events/templates/event_publish_box_extras.template.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@  discard block
 block discarded – undo
2 2
     <span class="dashicons dashicons-groups ee-icon-color-ee-green ee-icon-size-20"></span>
3 3
     <a href="<?php echo $view_approved_reg_url; ?>">
4 4
         <?php printf(
5
-            __('%s Registrations', 'event_espresso'),
6
-            EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence')
7
-        ); ?>
5
+			__('%s Registrations', 'event_espresso'),
6
+			EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence')
7
+		); ?>
8 8
     </a>:
9 9
     <?php echo $approved_regs; ?>
10 10
 </div>
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
     <span class="dashicons dashicons-groups ee-icon-color-ee-blue ee-icon-size-20"></span>
13 13
     <a href="<?php echo $view_pending_payment_reg_url; ?>">
14 14
         <?php printf(
15
-            __('%s Registrations', 'event_espresso'),
16
-            EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence')
17
-        ); ?>
15
+			__('%s Registrations', 'event_espresso'),
16
+			EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence')
17
+		); ?>
18 18
     </a>:
19 19
     <?php echo $pending_payment_regs; ?>
20 20
 </div>
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
     <span class="dashicons dashicons-groups ee-icon-color-ee-orange ee-icon-size-20"></span>
23 23
     <a href="<?php echo $view_not_approved_reg_url; ?>">
24 24
         <?php printf(
25
-            __('%s Registrations', 'event_espresso'),
26
-            EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence')
27
-        ); ?>
25
+			__('%s Registrations', 'event_espresso'),
26
+			EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence')
27
+		); ?>
28 28
     </a>:
29 29
     <?php echo $not_approved_regs; ?>
30 30
 </div>
Please login to merge, or discard this patch.
admin_pages/events/templates/event_settings.template.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,15 +12,15 @@
 block discarded – undo
12 12
             <td>
13 13
                 <p>
14 14
                     <?php echo EEH_Form_Fields::select_input(
15
-                        'default_reg_status',
16
-                        $reg_status_array,
17
-                        $default_reg_status
18
-                    ) ?></p>
15
+						'default_reg_status',
16
+						$reg_status_array,
17
+						$default_reg_status
18
+					) ?></p>
19 19
                 <p class="description">
20 20
                     <?php _e(
21
-                        'This setting allows you to preselect what the default registration status setting is when creating an event.  Note that changing this setting does NOT retroactively apply it to existing events.',
22
-                        'event_espresso'
23
-                    ); ?>
21
+						'This setting allows you to preselect what the default registration status setting is when creating an event.  Note that changing this setting does NOT retroactively apply it to existing events.',
22
+						'event_espresso'
23
+					); ?>
24 24
                 </p>
25 25
             </td>
26 26
         </tr>
Please login to merge, or discard this patch.
admin_pages/events/templates/event_tickets_metabox_ticket_row.template.php 1 patch
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,9 +32,12 @@  discard block
 block discarded – undo
32 32
         <?php if (empty($disabled)) : ?>
33 33
             <input type="text" size="1" class="edit-price-PRC_amount ee-small-text-inp ee-inp-right"
34 34
                    name="edit_prices[<?php echo $ticketrow; ?>][1][PRC_amount]" value="<?php echo $PRC_amount; ?>">
35
-        <?php else : ?>
35
+        <?php else {
36
+	: ?>
36 37
             <input type="text" size="1" class="edit-price-PRC_amount ee-small-text-inp ee-inp-right"
37
-                   name="disabled_price_amount" value="<?php echo $PRC_amount; ?>"<?php echo $disabled; ?>>
38
+                   name="disabled_price_amount" value="<?php echo $PRC_amount;
39
+}
40
+?>"<?php echo $disabled; ?>>
38 41
             <input type="hidden" size="1" class="edit-price-PRC_amount ee-small-text-inp ee-inp-right"
39 42
                    name="edit_prices[<?php echo $ticketrow; ?>][1][PRC_amount]" value="<?php echo $PRC_amount; ?>">
40 43
         <?php endif; ?>
@@ -51,9 +54,12 @@  discard block
 block discarded – undo
51 54
             <input type="text" class="edit-ticket-TKT_qty ee-small-text-inp ee-inp-right"
52 55
                    name="<?php echo $edit_ticketrow_name; ?>[<?php echo $ticketrow; ?>][TKT_qty]"
53 56
                    value="<?php echo $TKT_qty; ?>">
54
-        <?php else : ?>
57
+        <?php else {
58
+	: ?>
55 59
             <input type="text" class="edit-ticket-TKT_qty ee-small-text-inp ee-inp-right" name="disabled_tkt_qty"
56
-                   value="<?php echo $TKT_qty; ?>"<?php echo $disabled; ?>>
60
+                   value="<?php echo $TKT_qty;
61
+}
62
+?>"<?php echo $disabled; ?>>
57 63
             <input type="hidden" class="edit-ticket-TKT_qty ee-small-text-inp ee-inp-right"
58 64
                    name="<?php echo $edit_ticketrow_name; ?>[<?php echo $ticketrow; ?>][TKT_qty]"
59 65
                    value="<?php echo $TKT_qty; ?>">
Please login to merge, or discard this patch.
admin_pages/events/templates/event_category_details.template.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
                 <br/>
20 20
                 <p class="small-text">
21 21
                     <?php _e(
22
-                        'This is a default category so you can edit the label and the description but not the slug',
23
-                        'event_espresso'
24
-                    ); ?></p>
22
+						'This is a default category so you can edit the label and the description but not the slug',
23
+						'event_espresso'
24
+					); ?></p>
25 25
             <?php endif; ?>
26 26
         </td>
27 27
     </tr>
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
             <br/>
34 34
             <p class="description">
35 35
                 <?php _e(
36
-                    'Categories are hierarchical.  You can change the parent for this category here.',
37
-                    'event_espresso'
38
-                ); ?></p>
36
+					'Categories are hierarchical.  You can change the parent for this category here.',
37
+					'event_espresso'
38
+				); ?></p>
39 39
         </td>
40 40
     </tr>
41 41
     <tr>
Please login to merge, or discard this patch.
admin_pages/events/templates/event_tickets_metabox_main.template.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -2,9 +2,9 @@  discard block
 block discarded – undo
2 2
     <div id="event-and-ticket-form-content">
3 3
         <h4 class="event-tickets-datetimes-title">
4 4
             <?php _e(
5
-                'Event Datetime',
6
-                'event_espresso'
7
-            ); ?></h4><?php echo $event_datetime_help_link; ?>
5
+				'Event Datetime',
6
+				'event_espresso'
7
+			); ?></h4><?php echo $event_datetime_help_link; ?>
8 8
         <div class="event-datetimes-container">
9 9
             <!-- these are the ids for the current displayed datetimes (on create new this is blank -->
10 10
             <input type="hidden" name="datetime_IDs" id="datetime-IDs" value="<?php echo $existing_datetime_ids; ?>">
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
                         </td>
47 47
                         <td class="event-datetime-column reg-limit-column">
48 48
                             <?php
49
-                            $reg_limit = $time->get_pretty('DTT_reg_limit', 'input');
50
-                            ?>
49
+							$reg_limit = $time->get_pretty('DTT_reg_limit', 'input');
50
+							?>
51 51
                             <input type="text" name="edit_event_datetimes[1][DTT_reg_limit]"
52 52
                                    id="event-datetime-DTT_reg_limit-1"
53 53
                                    class="ee-small-text-inp ee-inp-right event-datetime-DTT_reg_limit"
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
                         </td>
56 56
                         <td class="datetime-tickets-sold">
57 57
                             <?php printf(
58
-                                __('Tickets Sold: %s', 'event_espresso'),
59
-                                $time->get('DTT_sold')
60
-                            ); ?></td>
58
+								__('Tickets Sold: %s', 'event_espresso'),
59
+								$time->get('DTT_sold')
60
+							); ?></td>
61 61
                     </tr>
62 62
                     </tbody>
63 63
                 </table>
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
         <div class="event-tickets-container">
70 70
             <h4 class="event-tickets-datetimes-title">
71 71
                 <?php _e(
72
-                    'Ticket Options',
73
-                    'event_espresso'
74
-                ); ?></h4><?php echo $ticket_options_help_link; ?><br/>
72
+					'Ticket Options',
73
+					'event_espresso'
74
+				); ?></h4><?php echo $ticket_options_help_link; ?><br/>
75 75
             <table class="add-new-ticket-table">
76 76
                 <thead>
77 77
                 <tr valign="top">
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
             <div class="save-cancel-button-container">
98 98
                 <button class="button-secondary ee-create-button" data-context="ticket">
99 99
                     <?php _e(
100
-                        'Create New Ticket',
101
-                        'event_espresso'
102
-                    ); ?></button>
100
+						'Create New Ticket',
101
+						'event_espresso'
102
+					); ?></button>
103 103
             </div>
104 104
         </div> <!-- end .event-tickets-container -->
105 105
         <div style="clear:both"></div>
Please login to merge, or discard this patch.
admin_pages/events/templates/event_registration_options.template.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -6,9 +6,9 @@
 block discarded – undo
6 6
 <p>
7 7
     <label for="max-registrants">
8 8
         <?php _e(
9
-            'Maximum number of tickets allowed per order for this event: ',
10
-            'event_espresso'
11
-        ); ?></label>
9
+			'Maximum number of tickets allowed per order for this event: ',
10
+			'event_espresso'
11
+		); ?></label>
12 12
     <input class="ee-numeric" type="text" id="max-registrants" name="additional_limit"
13 13
            value="<?php echo $additional_limit; ?>" size="4"/>
14 14
 </p>
Please login to merge, or discard this patch.
admin_pages/registration_form/qtips/EE_Registration_Form_Tips.lib.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -15,39 +15,39 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    protected function _set_tips_array()
19
-    {
20
-        $this->_qtipsa = array(
21
-            0 => array(
22
-                'content_id' => 'about-system-lock-icon',
23
-                'target'     => '.questions .ee-system-lock',
24
-                'content'    => __('This question is a system question and cannot be trashed', 'event_espresso'),
25
-                'options'    => array(), // defaults
26
-            ),
27
-            1 => array(
28
-                'content_id' => 'about-non-system-lock-icon',
29
-                'target'     => '.questions .ee-alternate-color',
30
-                'content'    => __(
31
-                    'This question has answers attached to it from registrations that have the question.  It cannot be permanently deleted.',
32
-                    'event_espresso'
33
-                ),
34
-                'options'    => array(),
35
-            ),
36
-            2 => array(
37
-                'content_id' => 'about-question-group-lock-icon',
38
-                'target'     => '.questiongroups .ee-system-lock',
39
-                'content'    => __('This question group is a system group and cannot be trashed', 'event_espresso'),
40
-                'options'    => array(),
41
-            ),
42
-            3 => array(
43
-                'content_id' => 'about-non-system-qg-lock-icon',
44
-                'target'     => '.questiongroups .ee-alternate-color',
45
-                'content'    => __(
46
-                    'This question group has questions that have answers attached to it from registrations that have the question. It cannot be permanently deleted.',
47
-                    'event_espresso'
48
-                ),
49
-                'options'    => array(),
50
-            ),
51
-        );
52
-    }
18
+	protected function _set_tips_array()
19
+	{
20
+		$this->_qtipsa = array(
21
+			0 => array(
22
+				'content_id' => 'about-system-lock-icon',
23
+				'target'     => '.questions .ee-system-lock',
24
+				'content'    => __('This question is a system question and cannot be trashed', 'event_espresso'),
25
+				'options'    => array(), // defaults
26
+			),
27
+			1 => array(
28
+				'content_id' => 'about-non-system-lock-icon',
29
+				'target'     => '.questions .ee-alternate-color',
30
+				'content'    => __(
31
+					'This question has answers attached to it from registrations that have the question.  It cannot be permanently deleted.',
32
+					'event_espresso'
33
+				),
34
+				'options'    => array(),
35
+			),
36
+			2 => array(
37
+				'content_id' => 'about-question-group-lock-icon',
38
+				'target'     => '.questiongroups .ee-system-lock',
39
+				'content'    => __('This question group is a system group and cannot be trashed', 'event_espresso'),
40
+				'options'    => array(),
41
+			),
42
+			3 => array(
43
+				'content_id' => 'about-non-system-qg-lock-icon',
44
+				'target'     => '.questiongroups .ee-alternate-color',
45
+				'content'    => __(
46
+					'This question group has questions that have answers attached to it from registrations that have the question. It cannot be permanently deleted.',
47
+					'event_espresso'
48
+				),
49
+				'options'    => array(),
50
+			),
51
+		);
52
+	}
53 53
 }
Please login to merge, or discard this patch.
admin_pages/registration_form/Registration_Form_Admin_Page_Init.core.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -18,41 +18,41 @@
 block discarded – undo
18 18
 class Registration_Form_Admin_Page_Init extends EE_Admin_Page_Init
19 19
 {
20 20
 
21
-    public function __construct()
22
-    {
23
-        // define some constants
24
-        define('REGISTRATION_FORM_PG_SLUG', 'espresso_registration_form');
25
-        define('REGISTRATION_FORM_LABEL', __('Registration Form', 'event_espresso'));
26
-        define('REGISTRATION_FORM_PG_NAME', REGISTRATION_FORM_LABEL);
27
-        define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES . 'registration_form' . DS);
28
-        define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
29
-        define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
30
-        define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN . 'assets' . DS);
31
-        define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registration_form/assets/');
32
-        define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN . 'templates' . DS);
33
-        define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registration_form/templates/');
34
-        parent::__construct();
35
-    }
21
+	public function __construct()
22
+	{
23
+		// define some constants
24
+		define('REGISTRATION_FORM_PG_SLUG', 'espresso_registration_form');
25
+		define('REGISTRATION_FORM_LABEL', __('Registration Form', 'event_espresso'));
26
+		define('REGISTRATION_FORM_PG_NAME', REGISTRATION_FORM_LABEL);
27
+		define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES . 'registration_form' . DS);
28
+		define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
29
+		define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
30
+		define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN . 'assets' . DS);
31
+		define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registration_form/assets/');
32
+		define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN . 'templates' . DS);
33
+		define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registration_form/templates/');
34
+		parent::__construct();
35
+	}
36 36
 
37
-    protected function _set_init_properties()
38
-    {
39
-        $this->label = __('Registration Form Overview', 'event_espresso');
40
-    }
37
+	protected function _set_init_properties()
38
+	{
39
+		$this->label = __('Registration Form Overview', 'event_espresso');
40
+	}
41 41
 
42 42
 
43
-    protected function _set_menu_map()
44
-    {
45
-        $this->_menu_map = new EE_Admin_Page_Sub_Menu(
46
-            array(
47
-                'menu_group'      => 'management',
48
-                'menu_order'      => 30,
49
-                'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
50
-                'parent_slug'     => 'espresso_events',
51
-                'menu_slug'       => REGISTRATION_FORM_PG_SLUG,
52
-                'menu_label'      => __('Registration Form', 'event_espresso'),
53
-                'capability'      => 'ee_read_questions',
54
-                'admin_init_page' => $this,
55
-            )
56
-        );
57
-    }
43
+	protected function _set_menu_map()
44
+	{
45
+		$this->_menu_map = new EE_Admin_Page_Sub_Menu(
46
+			array(
47
+				'menu_group'      => 'management',
48
+				'menu_order'      => 30,
49
+				'show_on_menu'    => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
50
+				'parent_slug'     => 'espresso_events',
51
+				'menu_slug'       => REGISTRATION_FORM_PG_SLUG,
52
+				'menu_label'      => __('Registration Form', 'event_espresso'),
53
+				'capability'      => 'ee_read_questions',
54
+				'admin_init_page' => $this,
55
+			)
56
+		);
57
+	}
58 58
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -24,13 +24,13 @@
 block discarded – undo
24 24
         define('REGISTRATION_FORM_PG_SLUG', 'espresso_registration_form');
25 25
         define('REGISTRATION_FORM_LABEL', __('Registration Form', 'event_espresso'));
26 26
         define('REGISTRATION_FORM_PG_NAME', REGISTRATION_FORM_LABEL);
27
-        define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES . 'registration_form' . DS);
28
-        define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
29
-        define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page=' . REGISTRATION_FORM_PG_SLUG));
30
-        define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN . 'assets' . DS);
31
-        define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registration_form/assets/');
32
-        define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN . 'templates' . DS);
33
-        define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registration_form/templates/');
27
+        define('REGISTRATION_FORM_ADMIN', EE_ADMIN_PAGES.'registration_form'.DS);
28
+        define('REGISTRATION_FORM_ADMIN_URL', admin_url('admin.php?page='.REGISTRATION_FORM_PG_SLUG));
29
+        define('EE_FORMS_ADMIN_URL', admin_url('admin.php?page='.REGISTRATION_FORM_PG_SLUG));
30
+        define('REGISTRATION_FORM_ASSETS_PATH', REGISTRATION_FORM_ADMIN.'assets'.DS);
31
+        define('REGISTRATION_FORM_ASSETS_URL', EE_ADMIN_PAGES_URL.'registration_form/assets/');
32
+        define('REGISTRATION_FORM_TEMPLATE_PATH', REGISTRATION_FORM_ADMIN.'templates'.DS);
33
+        define('REGISTRATION_FORM_TEMPLATE_URL', EE_ADMIN_PAGES_URL.'registration_form/templates/');
34 34
         parent::__construct();
35 35
     }
36 36
 
Please login to merge, or discard this patch.
admin_pages/registration_form/Registration_Form_Admin_Page.core.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function __construct($routing = true)
55 55
     {
56
-        require_once(EE_MODELS . 'EEM_Question.model.php');
57
-        require_once(EE_MODELS . 'EEM_Question_Group.model.php');
56
+        require_once(EE_MODELS.'EEM_Question.model.php');
57
+        require_once(EE_MODELS.'EEM_Question_Group.model.php');
58 58
         $this->_question_model = EEM_Question::instance();
59 59
         $this->_question_group_model = EEM_Question_Group::instance();
60 60
         parent::__construct($routing);
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
     {
223 223
         wp_register_style(
224 224
             'espresso_registration',
225
-            REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css',
225
+            REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.css',
226 226
             array(),
227 227
             EVENT_ESPRESSO_VERSION
228 228
         );
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         $this->load_scripts_styles_forms();
266 266
         wp_register_script(
267 267
             'espresso_registration_form_single',
268
-            REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js',
268
+            REGISTRATION_FORM_ASSETS_URL.'espresso_registration_form_admin.js',
269 269
             array('jquery-ui-sortable'),
270 270
             EVENT_ESPRESSO_VERSION,
271 271
             true
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 
285 285
     public function recaptcha_info_help_tab()
286 286
     {
287
-        $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php';
287
+        $template = REGISTRATION_FORM_TEMPLATE_PATH.'recaptcha_info_help_tab.template.php';
288 288
         EEH_Template::display_template($template, array());
289 289
     }
290 290
 
@@ -329,16 +329,16 @@  discard block
 block discarded – undo
329 329
     protected function _questions_groups_preview()
330 330
     {
331 331
         $this->_admin_page_title = esc_html__('Question Groups (Preview)', 'event_espresso');
332
-        $this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="'
332
+        $this->_template_args['preview_img'] = '<img src="'.REGISTRATION_FORM_ASSETS_URL.'caf_reg_form_preview.jpg" alt="'
333 333
                                                . esc_attr__(
334 334
                                                    'Preview Question Groups Overview List Table screenshot',
335 335
                                                    'event_espresso'
336
-                                               ) . '" />';
336
+                                               ).'" />';
337 337
         $this->_template_args['preview_text'] = '<strong>'
338 338
                                                 . esc_html__(
339 339
                                                     'Question Groups is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Question Groups feature you are able to create new question groups, edit existing question groups, and create and edit new questions and add them to question groups.',
340 340
                                                     'event_espresso'
341
-                                                ) . '</strong>';
341
+                                                ).'</strong>';
342 342
         $this->display_admin_caf_preview_page('question_groups_tab');
343 343
     }
344 344
 
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
 
357 357
         // some initial checks for proper values.
358 358
         // if QST_admin_only, then no matter what QST_required is we disable.
359
-        if (! empty($this->_req_data['QST_admin_only'])) {
359
+        if ( ! empty($this->_req_data['QST_admin_only'])) {
360 360
             $this->_req_data['QST_required'] = 0;
361 361
         }
362 362
         // if the question shouldn't have a max length, don't let them set one
363
-        if (! isset(
363
+        if ( ! isset(
364 364
             $this->_req_data['QST_type'],
365 365
             $this->_req_data['QST_max']
366 366
         )
@@ -377,13 +377,13 @@  discard block
 block discarded – undo
377 377
             // basically if QSG_identifier is empty or not set
378 378
             if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) {
379 379
                 $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : '';
380
-                $set_column_values[ $fieldName ] = sanitize_title($QSG_name) . '-' . uniqid('', true);
380
+                $set_column_values[$fieldName] = sanitize_title($QSG_name).'-'.uniqid('', true);
381 381
             } //if the admin label is blank, use a slug version of the question text
382 382
             elseif ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) {
383 383
                 $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : '';
384
-                $set_column_values[ $fieldName ] = sanitize_title(wp_trim_words($QST_text, 10));
385
-            } elseif ($fieldName === 'QST_admin_only' && (! isset($this->_req_data['QST_admin_only']))) {
386
-                $set_column_values[ $fieldName ] = 0;
384
+                $set_column_values[$fieldName] = sanitize_title(wp_trim_words($QST_text, 10));
385
+            } elseif ($fieldName === 'QST_admin_only' && ( ! isset($this->_req_data['QST_admin_only']))) {
386
+                $set_column_values[$fieldName] = 0;
387 387
             } elseif ($fieldName === 'QST_max') {
388 388
                 $qst_system = EEM_Question::instance()->get_var(
389 389
                     array(
@@ -397,19 +397,19 @@  discard block
 block discarded – undo
397 397
                 if (empty($this->_req_data['QST_max']) ||
398 398
                     $this->_req_data['QST_max'] > $max_max
399 399
                 ) {
400
-                    $set_column_values[ $fieldName ] = $max_max;
400
+                    $set_column_values[$fieldName] = $max_max;
401 401
                 }
402 402
             }
403 403
 
404 404
 
405 405
             // only add a property to the array if it's not null (otherwise the model should just use the default value)
406
-            if (! isset($set_column_values[ $fieldName ]) &&
407
-                isset($this->_req_data[ $fieldName ])
406
+            if ( ! isset($set_column_values[$fieldName]) &&
407
+                isset($this->_req_data[$fieldName])
408 408
             ) {
409
-                $set_column_values[ $fieldName ] = $this->_req_data[ $fieldName ];
409
+                $set_column_values[$fieldName] = $this->_req_data[$fieldName];
410 410
             }
411 411
         }
412
-        return $set_column_values;// validation fo this data to be performed by the model before insertion.
412
+        return $set_column_values; // validation fo this data to be performed by the model before insertion.
413 413
     }
414 414
 
415 415
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
         }
446 446
 
447 447
         // add PRC_ID to title if editing
448
-        $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
448
+        $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title;
449 449
         if ($ID) {
450 450
             $question = $this->_question_model->get_one_by_ID($ID);
451 451
             $additional_hidden_fields = array('QST_ID' => array('type' => 'hidden', 'value' => $ID));
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
         $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions();
480 480
         $this->_set_publish_post_box_vars('id', $ID);
481 481
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
482
-            REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php',
482
+            REGISTRATION_FORM_TEMPLATE_PATH.'questions_main_meta_box.template.php',
483 483
             $this->_template_args,
484 484
             true
485 485
         );
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
             }
509 509
             $descriptions .= EEH_HTML::p(
510 510
                 $question_type_description,
511
-                'question_type_description-' . $type,
511
+                'question_type_description-'.$type,
512 512
                 'question_type_description description',
513 513
                 'display:none;'
514 514
             );
@@ -542,11 +542,11 @@  discard block
 block discarded – undo
542 542
             // trash removed options, save old ones
543 543
             // get list of all options
544 544
             $options = $question->options();
545
-            if (! empty($options)) {
545
+            if ( ! empty($options)) {
546 546
                 foreach ($options as $option_ID => $option) {
547 547
                     $option_req_index = $this->_get_option_req_data_index($option_ID);
548 548
                     if ($option_req_index !== false) {
549
-                        $option->save($this->_req_data['question_options'][ $option_req_index ]);
549
+                        $option->save($this->_req_data['question_options'][$option_req_index]);
550 550
                     } else {
551 551
                         // not found, remove it
552 552
                         $option->delete();
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
         $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby'];
639 639
         $query_params['order_by'] = array($field_to_order_by => $order);
640 640
         $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null;
641
-        if (! empty($search_string)) {
641
+        if ( ! empty($search_string)) {
642 642
             if ($model instanceof EEM_Question_Group) {
643 643
                 $query_params[0] = array(
644 644
                     'OR' => array(
Please login to merge, or discard this patch.
Indentation   +695 added lines, -695 removed lines patch added patch discarded remove patch
@@ -15,646 +15,646 @@  discard block
 block discarded – undo
15 15
 class Registration_Form_Admin_Page extends EE_Admin_Page
16 16
 {
17 17
 
18
-    /**
19
-     * _question
20
-     * holds the specific question object for the question details screen
21
-     *
22
-     * @var EE_Question $_question
23
-     */
24
-    protected $_question;
25
-
26
-    /**
27
-     * _question_group
28
-     * holds the specific question group object for the question group details screen
29
-     *
30
-     * @var EE_Question_Group $_question_group
31
-     */
32
-    protected $_question_group;
33
-
34
-    /**
35
-     *_question_model EEM_Question model instance (for queries)
36
-     *
37
-     * @var EEM_Question $_question_model ;
38
-     */
39
-    protected $_question_model;
40
-
41
-    /**
42
-     * _question_group_model EEM_Question_group instance (for queries)
43
-     *
44
-     * @var EEM_Question_Group $_question_group_model
45
-     */
46
-    protected $_question_group_model;
47
-
48
-
49
-    /**
50
-     * @Constructor
51
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
52
-     * @access public
53
-     */
54
-    public function __construct($routing = true)
55
-    {
56
-        require_once(EE_MODELS . 'EEM_Question.model.php');
57
-        require_once(EE_MODELS . 'EEM_Question_Group.model.php');
58
-        $this->_question_model = EEM_Question::instance();
59
-        $this->_question_group_model = EEM_Question_Group::instance();
60
-        parent::__construct($routing);
61
-    }
62
-
63
-
64
-    protected function _init_page_props()
65
-    {
66
-        $this->page_slug = REGISTRATION_FORM_PG_SLUG;
67
-        $this->page_label = esc_html__('Registration Form', 'event_espresso');
68
-        $this->_admin_base_url = REGISTRATION_FORM_ADMIN_URL;
69
-        $this->_admin_base_path = REGISTRATION_FORM_ADMIN;
70
-    }
71
-
72
-
73
-    protected function _ajax_hooks()
74
-    {
75
-    }
76
-
77
-
78
-    protected function _define_page_props()
79
-    {
80
-        $this->_admin_page_title = esc_html__('Registration Form', 'event_espresso');
81
-        $this->_labels = array(
82
-            'buttons' => array(
83
-                'edit_question' => esc_html__('Edit Question', 'event_espresso'),
84
-            ),
85
-        );
86
-    }
87
-
88
-
89
-    /**
90
-     *_set_page_routes
91
-     */
92
-    protected function _set_page_routes()
93
-    {
94
-        $qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0;
95
-        $this->_page_routes = array(
96
-            'default' => array(
97
-                'func'       => '_questions_overview_list_table',
98
-                'capability' => 'ee_read_questions',
99
-            ),
100
-
101
-            'edit_question' => array(
102
-                'func'       => '_edit_question',
103
-                'capability' => 'ee_edit_question',
104
-                'obj_id'     => $qst_id,
105
-                'args'       => array('edit'),
106
-            ),
107
-
108
-            'question_groups' => array(
109
-                'func'       => '_questions_groups_preview',
110
-                'capability' => 'ee_read_question_groups',
111
-            ),
112
-
113
-            'update_question' => array(
114
-                'func'       => '_insert_or_update_question',
115
-                'args'       => array('new_question' => false),
116
-                'capability' => 'ee_edit_question',
117
-                'obj_id'     => $qst_id,
118
-                'noheader'   => true,
119
-            ),
120
-        );
121
-    }
122
-
123
-
124
-    protected function _set_page_config()
125
-    {
126
-        $this->_page_config = array(
127
-            'default' => array(
128
-                'nav'           => array(
129
-                    'label' => esc_html__('Questions', 'event_espresso'),
130
-                    'order' => 10,
131
-                ),
132
-                'list_table'    => 'Registration_Form_Questions_Admin_List_Table',
133
-                'metaboxes'     => $this->_default_espresso_metaboxes,
134
-                'help_tabs'     => array(
135
-                    'registration_form_questions_overview_help_tab'                           => array(
136
-                        'title'    => esc_html__('Questions Overview', 'event_espresso'),
137
-                        'filename' => 'registration_form_questions_overview',
138
-                    ),
139
-                    'registration_form_questions_overview_table_column_headings_help_tab'     => array(
140
-                        'title'    => esc_html__('Questions Overview Table Column Headings', 'event_espresso'),
141
-                        'filename' => 'registration_form_questions_overview_table_column_headings',
142
-                    ),
143
-                    'registration_form_questions_overview_views_bulk_actions_search_help_tab' => array(
144
-                        'title'    => esc_html__('Question Overview Views & Bulk Actions & Search', 'event_espresso'),
145
-                        'filename' => 'registration_form_questions_overview_views_bulk_actions_search',
146
-                    ),
147
-                ),
148
-                'help_tour'     => array('Registration_Form_Questions_Overview_Help_Tour'),
149
-                'require_nonce' => false,
150
-                'qtips'         => array(
151
-                    'EE_Registration_Form_Tips',
152
-                )/**/
153
-            ),
154
-
155
-            'question_groups' => array(
156
-                'nav'           => array(
157
-                    'label' => esc_html__('Question Groups', 'event_espresso'),
158
-                    'order' => 20,
159
-                ),
160
-                'metaboxes'     => $this->_default_espresso_metaboxes,
161
-                'help_tabs'     => array(
162
-                    'registration_form_question_groups_help_tab' => array(
163
-                        'title'    => esc_html__('Question Groups', 'event_espresso'),
164
-                        'filename' => 'registration_form_question_groups',
165
-                    ),
166
-                ),
167
-                'help_tour'     => array('Registration_Form_Question_Groups_Help_Tour'),
168
-                'require_nonce' => false,
169
-            ),
170
-
171
-            'edit_question' => array(
172
-                'nav'           => array(
173
-                    'label'      => esc_html__('Edit Question', 'event_espresso'),
174
-                    'order'      => 15,
175
-                    'persistent' => false,
176
-                    'url'        => isset($this->_req_data['question_id']) ? add_query_arg(
177
-                        array('question_id' => $this->_req_data['question_id']),
178
-                        $this->_current_page_view_url
179
-                    ) : $this->_admin_base_url,
180
-                ),
181
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
182
-                'help_tabs'     => array(
183
-                    'registration_form_edit_question_group_help_tab' => array(
184
-                        'title'    => esc_html__('Edit Question', 'event_espresso'),
185
-                        'filename' => 'registration_form_edit_question',
186
-                    ),
187
-                ),
188
-                'help_tour'     => array('Registration_Form_Edit_Question_Help_Tour'),
189
-                'require_nonce' => false,
190
-            ),
191
-        );
192
-    }
193
-
194
-
195
-    protected function _add_screen_options()
196
-    {
197
-        // todo
198
-    }
199
-
200
-    protected function _add_screen_options_default()
201
-    {
202
-        $page_title = $this->_admin_page_title;
203
-        $this->_admin_page_title = esc_html__('Questions', 'event_espresso');
204
-        $this->_per_page_screen_option();
205
-        $this->_admin_page_title = $page_title;
206
-    }
207
-
208
-    protected function _add_screen_options_question_groups()
209
-    {
210
-        $page_title = $this->_admin_page_title;
211
-        $this->_admin_page_title = esc_html__('Question Groups', 'event_espresso');
212
-        $this->_per_page_screen_option();
213
-        $this->_admin_page_title = $page_title;
214
-    }
215
-
216
-    // none of the below group are currently used for Event Categories
217
-    protected function _add_feature_pointers()
218
-    {
219
-    }
220
-
221
-    public function load_scripts_styles()
222
-    {
223
-        wp_register_style(
224
-            'espresso_registration',
225
-            REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css',
226
-            array(),
227
-            EVENT_ESPRESSO_VERSION
228
-        );
229
-        wp_enqueue_style('espresso_registration');
230
-    }
231
-
232
-    public function admin_init()
233
-    {
234
-    }
235
-
236
-    public function admin_notices()
237
-    {
238
-    }
239
-
240
-    public function admin_footer_scripts()
241
-    {
242
-    }
243
-
244
-
245
-    public function load_scripts_styles_default()
246
-    {
247
-    }
248
-
249
-
250
-    public function load_scripts_styles_add_question()
251
-    {
252
-        $this->load_scripts_styles_question_details();
253
-    }
254
-
255
-    public function load_scripts_styles_edit_question()
256
-    {
257
-        $this->load_scripts_styles_question_details();
258
-    }
259
-
260
-    /**
261
-     * Loads the JS required for adding or editing a question
262
-     */
263
-    protected function load_scripts_styles_question_details()
264
-    {
265
-        $this->load_scripts_styles_forms();
266
-        wp_register_script(
267
-            'espresso_registration_form_single',
268
-            REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js',
269
-            array('jquery-ui-sortable'),
270
-            EVENT_ESPRESSO_VERSION,
271
-            true
272
-        );
273
-        wp_enqueue_script('espresso_registration_form_single');
274
-        wp_localize_script(
275
-            'espresso_registration_form_single',
276
-            'ee_question_data',
277
-            array(
278
-                'question_types_with_max'    => EEM_Question::instance()->questionTypesWithMaxLength(),
279
-                'question_type_with_options' => EEM_Question::instance()->question_types_with_options(),
280
-            )
281
-        );
282
-    }
283
-
284
-
285
-    public function recaptcha_info_help_tab()
286
-    {
287
-        $template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php';
288
-        EEH_Template::display_template($template, array());
289
-    }
290
-
291
-
292
-    public function load_scripts_styles_forms()
293
-    {
294
-        // styles
295
-        wp_enqueue_style('espresso-ui-theme');
296
-        // scripts
297
-        wp_enqueue_script('ee_admin_js');
298
-    }
299
-
300
-
301
-    protected function _set_list_table_views_default()
302
-    {
303
-        $this->_views = array(
304
-            'all' => array(
305
-                'slug'  => 'all',
306
-                'label' => esc_html__('View All Questions', 'event_espresso'),
307
-                'count' => 0,
308
-            ),
309
-        );
310
-
311
-        if (EE_Registry::instance()->CAP->current_user_can(
312
-            'ee_delete_questions',
313
-            'espresso_registration_form_trash_questions'
314
-        )
315
-        ) {
316
-            $this->_views['trash'] = array(
317
-                'slug'  => 'trash',
318
-                'label' => esc_html__('Trash', 'event_espresso'),
319
-                'count' => 0,
320
-            );
321
-        }
322
-    }
323
-
324
-    /**
325
-     * This just previews the question groups tab that comes in caffeinated.
326
-     *
327
-     * @return string html
328
-     */
329
-    protected function _questions_groups_preview()
330
-    {
331
-        $this->_admin_page_title = esc_html__('Question Groups (Preview)', 'event_espresso');
332
-        $this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="'
333
-                                               . esc_attr__(
334
-                                                   'Preview Question Groups Overview List Table screenshot',
335
-                                                   'event_espresso'
336
-                                               ) . '" />';
337
-        $this->_template_args['preview_text'] = '<strong>'
338
-                                                . esc_html__(
339
-                                                    'Question Groups is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Question Groups feature you are able to create new question groups, edit existing question groups, and create and edit new questions and add them to question groups.',
340
-                                                    'event_espresso'
341
-                                                ) . '</strong>';
342
-        $this->display_admin_caf_preview_page('question_groups_tab');
343
-    }
344
-
345
-
346
-    /**
347
-     * Extracts the question field's values from the POST request to update or insert them
348
-     *
349
-     * @param \EEM_Base $model
350
-     * @return array where each key is the name of a model's field/db column, and each value is its value.
351
-     */
352
-    protected function _set_column_values_for(EEM_Base $model)
353
-    {
354
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
355
-        $set_column_values = array();
356
-
357
-        // some initial checks for proper values.
358
-        // if QST_admin_only, then no matter what QST_required is we disable.
359
-        if (! empty($this->_req_data['QST_admin_only'])) {
360
-            $this->_req_data['QST_required'] = 0;
361
-        }
362
-        // if the question shouldn't have a max length, don't let them set one
363
-        if (! isset(
364
-            $this->_req_data['QST_type'],
365
-            $this->_req_data['QST_max']
366
-        )
367
-            || ! in_array(
368
-                $this->_req_data['QST_type'],
369
-                EEM_Question::instance()->questionTypesWithMaxLength(),
370
-                true
371
-            )
372
-        ) {
373
-            // they're not allowed to set the max
374
-            $this->_req_data['QST_max'] = null;
375
-        }
376
-        foreach ($model->field_settings() as $fieldName => $settings) {
377
-            // basically if QSG_identifier is empty or not set
378
-            if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) {
379
-                $QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : '';
380
-                $set_column_values[ $fieldName ] = sanitize_title($QSG_name) . '-' . uniqid('', true);
381
-            } //if the admin label is blank, use a slug version of the question text
382
-            elseif ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) {
383
-                $QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : '';
384
-                $set_column_values[ $fieldName ] = sanitize_title(wp_trim_words($QST_text, 10));
385
-            } elseif ($fieldName === 'QST_admin_only' && (! isset($this->_req_data['QST_admin_only']))) {
386
-                $set_column_values[ $fieldName ] = 0;
387
-            } elseif ($fieldName === 'QST_max') {
388
-                $qst_system = EEM_Question::instance()->get_var(
389
-                    array(
390
-                        array(
391
-                            'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0,
392
-                        ),
393
-                    ),
394
-                    'QST_system'
395
-                );
396
-                $max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system);
397
-                if (empty($this->_req_data['QST_max']) ||
398
-                    $this->_req_data['QST_max'] > $max_max
399
-                ) {
400
-                    $set_column_values[ $fieldName ] = $max_max;
401
-                }
402
-            }
403
-
404
-
405
-            // only add a property to the array if it's not null (otherwise the model should just use the default value)
406
-            if (! isset($set_column_values[ $fieldName ]) &&
407
-                isset($this->_req_data[ $fieldName ])
408
-            ) {
409
-                $set_column_values[ $fieldName ] = $this->_req_data[ $fieldName ];
410
-            }
411
-        }
412
-        return $set_column_values;// validation fo this data to be performed by the model before insertion.
413
-    }
414
-
415
-
416
-    /**
417
-     *_questions_overview_list_table
418
-     */
419
-    protected function _questions_overview_list_table()
420
-    {
421
-        $this->_search_btn_label = esc_html__('Questions', 'event_espresso');
422
-        $this->display_admin_list_table_page_with_sidebar();
423
-    }
424
-
425
-
426
-    /**
427
-     * _edit_question
428
-     */
429
-    protected function _edit_question()
430
-    {
431
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
432
-        $ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint(
433
-            $this->_req_data['QST_ID']
434
-        ) : false;
435
-
436
-        switch ($this->_req_action) {
437
-            case 'add_question':
438
-                $this->_admin_page_title = esc_html__('Add Question', 'event_espresso');
439
-                break;
440
-            case 'edit_question':
441
-                $this->_admin_page_title = esc_html__('Edit Question', 'event_espresso');
442
-                break;
443
-            default:
444
-                $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
445
-        }
446
-
447
-        // add PRC_ID to title if editing
448
-        $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
449
-        if ($ID) {
450
-            $question = $this->_question_model->get_one_by_ID($ID);
451
-            $additional_hidden_fields = array('QST_ID' => array('type' => 'hidden', 'value' => $ID));
452
-            $this->_set_add_edit_form_tags('update_question', $additional_hidden_fields);
453
-        } else {
454
-            $question = EE_Question::new_instance();
455
-            $question->set_order_to_latest();
456
-            $this->_set_add_edit_form_tags('insert_question');
457
-        }
458
-        if ($question->system_ID() === EEM_Attendee::system_question_phone) {
459
-            $question_types = array_intersect_key(
460
-                EEM_Question::instance()->allowed_question_types(),
461
-                array_flip(
462
-                    array(
463
-                        EEM_Question::QST_type_text,
464
-                        EEM_Question::QST_type_us_phone,
465
-                    )
466
-                )
467
-            );
468
-        } else {
469
-            $question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category(
470
-                $question->type()
471
-            ) : $this->_question_model->allowed_question_types();
472
-        }
473
-        $this->_template_args['QST_ID'] = $ID;
474
-        $this->_template_args['question'] = $question;
475
-        $this->_template_args['question_types'] = $question_types;
476
-        $this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question(
477
-            $question->system_ID()
478
-        );
479
-        $this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions();
480
-        $this->_set_publish_post_box_vars('id', $ID);
481
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
482
-            REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php',
483
-            $this->_template_args,
484
-            true
485
-        );
486
-
487
-        // the details template wrapper
488
-        $this->display_admin_page_with_sidebar();
489
-    }
490
-
491
-
492
-    /**
493
-     * @return string
494
-     */
495
-    protected function _get_question_type_descriptions()
496
-    {
497
-        EE_Registry::instance()->load_helper('HTML');
498
-        $descriptions = '';
499
-        $question_type_descriptions = EEM_Question::instance()->question_descriptions();
500
-        foreach ($question_type_descriptions as $type => $question_type_description) {
501
-            if ($type == 'HTML_TEXTAREA') {
502
-                $html = new EE_Simple_HTML_Validation_Strategy();
503
-                $question_type_description .= sprintf(
504
-                    esc_html__('%1$s(allowed tags: %2$s)', 'event_espresso'),
505
-                    '<br/>',
506
-                    $html->get_list_of_allowed_tags()
507
-                );
508
-            }
509
-            $descriptions .= EEH_HTML::p(
510
-                $question_type_description,
511
-                'question_type_description-' . $type,
512
-                'question_type_description description',
513
-                'display:none;'
514
-            );
515
-        }
516
-        return $descriptions;
517
-    }
518
-
519
-
520
-    /**
521
-     * @param bool|true $new_question
522
-     * @throws \EE_Error
523
-     */
524
-    protected function _insert_or_update_question($new_question = true)
525
-    {
526
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
527
-        $set_column_values = $this->_set_column_values_for($this->_question_model);
528
-        if ($new_question) {
529
-            $question = EE_Question::new_instance($set_column_values);
530
-            $action_desc = 'added';
531
-        } else {
532
-            $question = EEM_Question::instance()->get_one_by_ID(absint($this->_req_data['QST_ID']));
533
-            foreach ($set_column_values as $field => $new_value) {
534
-                $question->set($field, $new_value);
535
-            }
536
-            $action_desc = 'updated';
537
-        }
538
-        $success = $question->save();
539
-        $ID = $question->ID();
540
-        if ($ID && $question->should_have_question_options()) {
541
-            // save the related options
542
-            // trash removed options, save old ones
543
-            // get list of all options
544
-            $options = $question->options();
545
-            if (! empty($options)) {
546
-                foreach ($options as $option_ID => $option) {
547
-                    $option_req_index = $this->_get_option_req_data_index($option_ID);
548
-                    if ($option_req_index !== false) {
549
-                        $option->save($this->_req_data['question_options'][ $option_req_index ]);
550
-                    } else {
551
-                        // not found, remove it
552
-                        $option->delete();
553
-                    }
554
-                }
555
-            }
556
-            // save new related options
557
-            foreach ($this->_req_data['question_options'] as $index => $option_req_data) {
558
-                // skip $index that is from our sample
559
-                if ($index === 'xxcountxx') {
560
-                    continue;
561
-                }
562
-                // note we allow saving blank options.
563
-                if (empty($option_req_data['QSO_ID'])
564
-                ) {// no ID! save it!
565
-                    $new_option = EE_Question_Option::new_instance(
566
-                        array(
567
-                            'QSO_value' => $option_req_data['QSO_value'],
568
-                            'QSO_desc'  => $option_req_data['QSO_desc'],
569
-                            'QSO_order' => $option_req_data['QSO_order'],
570
-                            'QST_ID'    => $question->ID(),
571
-                        )
572
-                    );
573
-                    $new_option->save();
574
-                }
575
-            }
576
-        }
577
-        $query_args = array('action' => 'edit_question', 'QST_ID' => $ID);
578
-        if ($success !== false) {
579
-            $msg = $new_question
580
-                ? sprintf(
581
-                    esc_html__('The %s has been created', 'event_espresso'),
582
-                    $this->_question_model->item_name()
583
-                )
584
-                : sprintf(
585
-                    esc_html__('The %s has been updated', 'event_espresso'),
586
-                    $this->_question_model->item_name()
587
-                );
588
-            EE_Error::add_success($msg);
589
-        }
590
-
591
-        $this->_redirect_after_action(false, '', $action_desc, $query_args, true);
592
-    }
593
-
594
-
595
-    /**
596
-     * Upon saving a question, there should be an array of 'question_options'. This array is index numerically, but not
597
-     * by ID
598
-     * (this is done because new question options don't have an ID, but we may want to add multiple simultaneously).
599
-     * So, this function gets the index in that request data array called question_options. Returns FALSE if not found.
600
-     *
601
-     * @param int $ID of the question option to find
602
-     * @return int index in question_options array if successful, FALSE if unsuccessful
603
-     */
604
-    protected function _get_option_req_data_index($ID)
605
-    {
606
-        $req_data_for_question_options = $this->_req_data['question_options'];
607
-        foreach ($req_data_for_question_options as $num => $option_data) {
608
-            if (array_key_exists('QSO_ID', $option_data) && (int) $option_data['QSO_ID'] === $ID) {
609
-                return $num;
610
-            }
611
-        }
612
-        return false;
613
-    }
614
-
615
-
616
-
617
-
618
-    /***********/
619
-    /* QUERIES */
620
-    /**
621
-     * For internal use in getting all the query parameters
622
-     * (because it's pretty well the same between question, question groups,
623
-     * and for both when searching for trashed and untrashed ones)
624
-     *
625
-     * @param EEM_Base $model either EEM_Question or EEM_Question_Group
626
-     * @param int      $per_page
627
-     * @param int      $current_page
628
-     * @return array model query params, @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
629
-     */
630
-    protected function get_query_params($model, $per_page = 10, $current_page = 10)
631
-    {
632
-        $query_params = array();
633
-        $offset = ($current_page - 1) * $per_page;
634
-        $query_params['limit'] = array($offset, $per_page);
635
-        $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
636
-            : 'ASC';
637
-        $orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order';
638
-        $field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby'];
639
-        $query_params['order_by'] = array($field_to_order_by => $order);
640
-        $search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null;
641
-        if (! empty($search_string)) {
642
-            if ($model instanceof EEM_Question_Group) {
643
-                $query_params[0] = array(
644
-                    'OR' => array(
645
-                        'QSG_name' => array('LIKE', "%$search_string%"),
646
-                        'QSG_desc' => array('LIKE', "%$search_string%"),
647
-                    ),
648
-                );
649
-            } else {
650
-                $query_params[0] = array(
651
-                    'QST_display_text' => array('LIKE', "%$search_string%"),
652
-                );
653
-            }
654
-        }
655
-
656
-        // capability checks (just leaving this commented out for reference because it illustrates some complicated query params that could be useful when fully implemented)
657
-        /*if ( $model instanceof EEM_Question_Group ) {
18
+	/**
19
+	 * _question
20
+	 * holds the specific question object for the question details screen
21
+	 *
22
+	 * @var EE_Question $_question
23
+	 */
24
+	protected $_question;
25
+
26
+	/**
27
+	 * _question_group
28
+	 * holds the specific question group object for the question group details screen
29
+	 *
30
+	 * @var EE_Question_Group $_question_group
31
+	 */
32
+	protected $_question_group;
33
+
34
+	/**
35
+	 *_question_model EEM_Question model instance (for queries)
36
+	 *
37
+	 * @var EEM_Question $_question_model ;
38
+	 */
39
+	protected $_question_model;
40
+
41
+	/**
42
+	 * _question_group_model EEM_Question_group instance (for queries)
43
+	 *
44
+	 * @var EEM_Question_Group $_question_group_model
45
+	 */
46
+	protected $_question_group_model;
47
+
48
+
49
+	/**
50
+	 * @Constructor
51
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
52
+	 * @access public
53
+	 */
54
+	public function __construct($routing = true)
55
+	{
56
+		require_once(EE_MODELS . 'EEM_Question.model.php');
57
+		require_once(EE_MODELS . 'EEM_Question_Group.model.php');
58
+		$this->_question_model = EEM_Question::instance();
59
+		$this->_question_group_model = EEM_Question_Group::instance();
60
+		parent::__construct($routing);
61
+	}
62
+
63
+
64
+	protected function _init_page_props()
65
+	{
66
+		$this->page_slug = REGISTRATION_FORM_PG_SLUG;
67
+		$this->page_label = esc_html__('Registration Form', 'event_espresso');
68
+		$this->_admin_base_url = REGISTRATION_FORM_ADMIN_URL;
69
+		$this->_admin_base_path = REGISTRATION_FORM_ADMIN;
70
+	}
71
+
72
+
73
+	protected function _ajax_hooks()
74
+	{
75
+	}
76
+
77
+
78
+	protected function _define_page_props()
79
+	{
80
+		$this->_admin_page_title = esc_html__('Registration Form', 'event_espresso');
81
+		$this->_labels = array(
82
+			'buttons' => array(
83
+				'edit_question' => esc_html__('Edit Question', 'event_espresso'),
84
+			),
85
+		);
86
+	}
87
+
88
+
89
+	/**
90
+	 *_set_page_routes
91
+	 */
92
+	protected function _set_page_routes()
93
+	{
94
+		$qst_id = ! empty($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0;
95
+		$this->_page_routes = array(
96
+			'default' => array(
97
+				'func'       => '_questions_overview_list_table',
98
+				'capability' => 'ee_read_questions',
99
+			),
100
+
101
+			'edit_question' => array(
102
+				'func'       => '_edit_question',
103
+				'capability' => 'ee_edit_question',
104
+				'obj_id'     => $qst_id,
105
+				'args'       => array('edit'),
106
+			),
107
+
108
+			'question_groups' => array(
109
+				'func'       => '_questions_groups_preview',
110
+				'capability' => 'ee_read_question_groups',
111
+			),
112
+
113
+			'update_question' => array(
114
+				'func'       => '_insert_or_update_question',
115
+				'args'       => array('new_question' => false),
116
+				'capability' => 'ee_edit_question',
117
+				'obj_id'     => $qst_id,
118
+				'noheader'   => true,
119
+			),
120
+		);
121
+	}
122
+
123
+
124
+	protected function _set_page_config()
125
+	{
126
+		$this->_page_config = array(
127
+			'default' => array(
128
+				'nav'           => array(
129
+					'label' => esc_html__('Questions', 'event_espresso'),
130
+					'order' => 10,
131
+				),
132
+				'list_table'    => 'Registration_Form_Questions_Admin_List_Table',
133
+				'metaboxes'     => $this->_default_espresso_metaboxes,
134
+				'help_tabs'     => array(
135
+					'registration_form_questions_overview_help_tab'                           => array(
136
+						'title'    => esc_html__('Questions Overview', 'event_espresso'),
137
+						'filename' => 'registration_form_questions_overview',
138
+					),
139
+					'registration_form_questions_overview_table_column_headings_help_tab'     => array(
140
+						'title'    => esc_html__('Questions Overview Table Column Headings', 'event_espresso'),
141
+						'filename' => 'registration_form_questions_overview_table_column_headings',
142
+					),
143
+					'registration_form_questions_overview_views_bulk_actions_search_help_tab' => array(
144
+						'title'    => esc_html__('Question Overview Views & Bulk Actions & Search', 'event_espresso'),
145
+						'filename' => 'registration_form_questions_overview_views_bulk_actions_search',
146
+					),
147
+				),
148
+				'help_tour'     => array('Registration_Form_Questions_Overview_Help_Tour'),
149
+				'require_nonce' => false,
150
+				'qtips'         => array(
151
+					'EE_Registration_Form_Tips',
152
+				)/**/
153
+			),
154
+
155
+			'question_groups' => array(
156
+				'nav'           => array(
157
+					'label' => esc_html__('Question Groups', 'event_espresso'),
158
+					'order' => 20,
159
+				),
160
+				'metaboxes'     => $this->_default_espresso_metaboxes,
161
+				'help_tabs'     => array(
162
+					'registration_form_question_groups_help_tab' => array(
163
+						'title'    => esc_html__('Question Groups', 'event_espresso'),
164
+						'filename' => 'registration_form_question_groups',
165
+					),
166
+				),
167
+				'help_tour'     => array('Registration_Form_Question_Groups_Help_Tour'),
168
+				'require_nonce' => false,
169
+			),
170
+
171
+			'edit_question' => array(
172
+				'nav'           => array(
173
+					'label'      => esc_html__('Edit Question', 'event_espresso'),
174
+					'order'      => 15,
175
+					'persistent' => false,
176
+					'url'        => isset($this->_req_data['question_id']) ? add_query_arg(
177
+						array('question_id' => $this->_req_data['question_id']),
178
+						$this->_current_page_view_url
179
+					) : $this->_admin_base_url,
180
+				),
181
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
182
+				'help_tabs'     => array(
183
+					'registration_form_edit_question_group_help_tab' => array(
184
+						'title'    => esc_html__('Edit Question', 'event_espresso'),
185
+						'filename' => 'registration_form_edit_question',
186
+					),
187
+				),
188
+				'help_tour'     => array('Registration_Form_Edit_Question_Help_Tour'),
189
+				'require_nonce' => false,
190
+			),
191
+		);
192
+	}
193
+
194
+
195
+	protected function _add_screen_options()
196
+	{
197
+		// todo
198
+	}
199
+
200
+	protected function _add_screen_options_default()
201
+	{
202
+		$page_title = $this->_admin_page_title;
203
+		$this->_admin_page_title = esc_html__('Questions', 'event_espresso');
204
+		$this->_per_page_screen_option();
205
+		$this->_admin_page_title = $page_title;
206
+	}
207
+
208
+	protected function _add_screen_options_question_groups()
209
+	{
210
+		$page_title = $this->_admin_page_title;
211
+		$this->_admin_page_title = esc_html__('Question Groups', 'event_espresso');
212
+		$this->_per_page_screen_option();
213
+		$this->_admin_page_title = $page_title;
214
+	}
215
+
216
+	// none of the below group are currently used for Event Categories
217
+	protected function _add_feature_pointers()
218
+	{
219
+	}
220
+
221
+	public function load_scripts_styles()
222
+	{
223
+		wp_register_style(
224
+			'espresso_registration',
225
+			REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.css',
226
+			array(),
227
+			EVENT_ESPRESSO_VERSION
228
+		);
229
+		wp_enqueue_style('espresso_registration');
230
+	}
231
+
232
+	public function admin_init()
233
+	{
234
+	}
235
+
236
+	public function admin_notices()
237
+	{
238
+	}
239
+
240
+	public function admin_footer_scripts()
241
+	{
242
+	}
243
+
244
+
245
+	public function load_scripts_styles_default()
246
+	{
247
+	}
248
+
249
+
250
+	public function load_scripts_styles_add_question()
251
+	{
252
+		$this->load_scripts_styles_question_details();
253
+	}
254
+
255
+	public function load_scripts_styles_edit_question()
256
+	{
257
+		$this->load_scripts_styles_question_details();
258
+	}
259
+
260
+	/**
261
+	 * Loads the JS required for adding or editing a question
262
+	 */
263
+	protected function load_scripts_styles_question_details()
264
+	{
265
+		$this->load_scripts_styles_forms();
266
+		wp_register_script(
267
+			'espresso_registration_form_single',
268
+			REGISTRATION_FORM_ASSETS_URL . 'espresso_registration_form_admin.js',
269
+			array('jquery-ui-sortable'),
270
+			EVENT_ESPRESSO_VERSION,
271
+			true
272
+		);
273
+		wp_enqueue_script('espresso_registration_form_single');
274
+		wp_localize_script(
275
+			'espresso_registration_form_single',
276
+			'ee_question_data',
277
+			array(
278
+				'question_types_with_max'    => EEM_Question::instance()->questionTypesWithMaxLength(),
279
+				'question_type_with_options' => EEM_Question::instance()->question_types_with_options(),
280
+			)
281
+		);
282
+	}
283
+
284
+
285
+	public function recaptcha_info_help_tab()
286
+	{
287
+		$template = REGISTRATION_FORM_TEMPLATE_PATH . 'recaptcha_info_help_tab.template.php';
288
+		EEH_Template::display_template($template, array());
289
+	}
290
+
291
+
292
+	public function load_scripts_styles_forms()
293
+	{
294
+		// styles
295
+		wp_enqueue_style('espresso-ui-theme');
296
+		// scripts
297
+		wp_enqueue_script('ee_admin_js');
298
+	}
299
+
300
+
301
+	protected function _set_list_table_views_default()
302
+	{
303
+		$this->_views = array(
304
+			'all' => array(
305
+				'slug'  => 'all',
306
+				'label' => esc_html__('View All Questions', 'event_espresso'),
307
+				'count' => 0,
308
+			),
309
+		);
310
+
311
+		if (EE_Registry::instance()->CAP->current_user_can(
312
+			'ee_delete_questions',
313
+			'espresso_registration_form_trash_questions'
314
+		)
315
+		) {
316
+			$this->_views['trash'] = array(
317
+				'slug'  => 'trash',
318
+				'label' => esc_html__('Trash', 'event_espresso'),
319
+				'count' => 0,
320
+			);
321
+		}
322
+	}
323
+
324
+	/**
325
+	 * This just previews the question groups tab that comes in caffeinated.
326
+	 *
327
+	 * @return string html
328
+	 */
329
+	protected function _questions_groups_preview()
330
+	{
331
+		$this->_admin_page_title = esc_html__('Question Groups (Preview)', 'event_espresso');
332
+		$this->_template_args['preview_img'] = '<img src="' . REGISTRATION_FORM_ASSETS_URL . 'caf_reg_form_preview.jpg" alt="'
333
+											   . esc_attr__(
334
+												   'Preview Question Groups Overview List Table screenshot',
335
+												   'event_espresso'
336
+											   ) . '" />';
337
+		$this->_template_args['preview_text'] = '<strong>'
338
+												. esc_html__(
339
+													'Question Groups is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Question Groups feature you are able to create new question groups, edit existing question groups, and create and edit new questions and add them to question groups.',
340
+													'event_espresso'
341
+												) . '</strong>';
342
+		$this->display_admin_caf_preview_page('question_groups_tab');
343
+	}
344
+
345
+
346
+	/**
347
+	 * Extracts the question field's values from the POST request to update or insert them
348
+	 *
349
+	 * @param \EEM_Base $model
350
+	 * @return array where each key is the name of a model's field/db column, and each value is its value.
351
+	 */
352
+	protected function _set_column_values_for(EEM_Base $model)
353
+	{
354
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
355
+		$set_column_values = array();
356
+
357
+		// some initial checks for proper values.
358
+		// if QST_admin_only, then no matter what QST_required is we disable.
359
+		if (! empty($this->_req_data['QST_admin_only'])) {
360
+			$this->_req_data['QST_required'] = 0;
361
+		}
362
+		// if the question shouldn't have a max length, don't let them set one
363
+		if (! isset(
364
+			$this->_req_data['QST_type'],
365
+			$this->_req_data['QST_max']
366
+		)
367
+			|| ! in_array(
368
+				$this->_req_data['QST_type'],
369
+				EEM_Question::instance()->questionTypesWithMaxLength(),
370
+				true
371
+			)
372
+		) {
373
+			// they're not allowed to set the max
374
+			$this->_req_data['QST_max'] = null;
375
+		}
376
+		foreach ($model->field_settings() as $fieldName => $settings) {
377
+			// basically if QSG_identifier is empty or not set
378
+			if ($fieldName === 'QSG_identifier' && (isset($this->_req_data['QSG_identifier']) && empty($this->_req_data['QSG_identifier']))) {
379
+				$QSG_name = isset($this->_req_data['QSG_name']) ? $this->_req_data['QSG_name'] : '';
380
+				$set_column_values[ $fieldName ] = sanitize_title($QSG_name) . '-' . uniqid('', true);
381
+			} //if the admin label is blank, use a slug version of the question text
382
+			elseif ($fieldName === 'QST_admin_label' && (isset($this->_req_data['QST_admin_label']) && empty($this->_req_data['QST_admin_label']))) {
383
+				$QST_text = isset($this->_req_data['QST_display_text']) ? $this->_req_data['QST_display_text'] : '';
384
+				$set_column_values[ $fieldName ] = sanitize_title(wp_trim_words($QST_text, 10));
385
+			} elseif ($fieldName === 'QST_admin_only' && (! isset($this->_req_data['QST_admin_only']))) {
386
+				$set_column_values[ $fieldName ] = 0;
387
+			} elseif ($fieldName === 'QST_max') {
388
+				$qst_system = EEM_Question::instance()->get_var(
389
+					array(
390
+						array(
391
+							'QST_ID' => isset($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0,
392
+						),
393
+					),
394
+					'QST_system'
395
+				);
396
+				$max_max = EEM_Question::instance()->absolute_max_for_system_question($qst_system);
397
+				if (empty($this->_req_data['QST_max']) ||
398
+					$this->_req_data['QST_max'] > $max_max
399
+				) {
400
+					$set_column_values[ $fieldName ] = $max_max;
401
+				}
402
+			}
403
+
404
+
405
+			// only add a property to the array if it's not null (otherwise the model should just use the default value)
406
+			if (! isset($set_column_values[ $fieldName ]) &&
407
+				isset($this->_req_data[ $fieldName ])
408
+			) {
409
+				$set_column_values[ $fieldName ] = $this->_req_data[ $fieldName ];
410
+			}
411
+		}
412
+		return $set_column_values;// validation fo this data to be performed by the model before insertion.
413
+	}
414
+
415
+
416
+	/**
417
+	 *_questions_overview_list_table
418
+	 */
419
+	protected function _questions_overview_list_table()
420
+	{
421
+		$this->_search_btn_label = esc_html__('Questions', 'event_espresso');
422
+		$this->display_admin_list_table_page_with_sidebar();
423
+	}
424
+
425
+
426
+	/**
427
+	 * _edit_question
428
+	 */
429
+	protected function _edit_question()
430
+	{
431
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
432
+		$ID = isset($this->_req_data['QST_ID']) && ! empty($this->_req_data['QST_ID']) ? absint(
433
+			$this->_req_data['QST_ID']
434
+		) : false;
435
+
436
+		switch ($this->_req_action) {
437
+			case 'add_question':
438
+				$this->_admin_page_title = esc_html__('Add Question', 'event_espresso');
439
+				break;
440
+			case 'edit_question':
441
+				$this->_admin_page_title = esc_html__('Edit Question', 'event_espresso');
442
+				break;
443
+			default:
444
+				$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
445
+		}
446
+
447
+		// add PRC_ID to title if editing
448
+		$this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
449
+		if ($ID) {
450
+			$question = $this->_question_model->get_one_by_ID($ID);
451
+			$additional_hidden_fields = array('QST_ID' => array('type' => 'hidden', 'value' => $ID));
452
+			$this->_set_add_edit_form_tags('update_question', $additional_hidden_fields);
453
+		} else {
454
+			$question = EE_Question::new_instance();
455
+			$question->set_order_to_latest();
456
+			$this->_set_add_edit_form_tags('insert_question');
457
+		}
458
+		if ($question->system_ID() === EEM_Attendee::system_question_phone) {
459
+			$question_types = array_intersect_key(
460
+				EEM_Question::instance()->allowed_question_types(),
461
+				array_flip(
462
+					array(
463
+						EEM_Question::QST_type_text,
464
+						EEM_Question::QST_type_us_phone,
465
+					)
466
+				)
467
+			);
468
+		} else {
469
+			$question_types = $question->has_answers() ? $this->_question_model->question_types_in_same_category(
470
+				$question->type()
471
+			) : $this->_question_model->allowed_question_types();
472
+		}
473
+		$this->_template_args['QST_ID'] = $ID;
474
+		$this->_template_args['question'] = $question;
475
+		$this->_template_args['question_types'] = $question_types;
476
+		$this->_template_args['max_max'] = EEM_Question::instance()->absolute_max_for_system_question(
477
+			$question->system_ID()
478
+		);
479
+		$this->_template_args['question_type_descriptions'] = $this->_get_question_type_descriptions();
480
+		$this->_set_publish_post_box_vars('id', $ID);
481
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
482
+			REGISTRATION_FORM_TEMPLATE_PATH . 'questions_main_meta_box.template.php',
483
+			$this->_template_args,
484
+			true
485
+		);
486
+
487
+		// the details template wrapper
488
+		$this->display_admin_page_with_sidebar();
489
+	}
490
+
491
+
492
+	/**
493
+	 * @return string
494
+	 */
495
+	protected function _get_question_type_descriptions()
496
+	{
497
+		EE_Registry::instance()->load_helper('HTML');
498
+		$descriptions = '';
499
+		$question_type_descriptions = EEM_Question::instance()->question_descriptions();
500
+		foreach ($question_type_descriptions as $type => $question_type_description) {
501
+			if ($type == 'HTML_TEXTAREA') {
502
+				$html = new EE_Simple_HTML_Validation_Strategy();
503
+				$question_type_description .= sprintf(
504
+					esc_html__('%1$s(allowed tags: %2$s)', 'event_espresso'),
505
+					'<br/>',
506
+					$html->get_list_of_allowed_tags()
507
+				);
508
+			}
509
+			$descriptions .= EEH_HTML::p(
510
+				$question_type_description,
511
+				'question_type_description-' . $type,
512
+				'question_type_description description',
513
+				'display:none;'
514
+			);
515
+		}
516
+		return $descriptions;
517
+	}
518
+
519
+
520
+	/**
521
+	 * @param bool|true $new_question
522
+	 * @throws \EE_Error
523
+	 */
524
+	protected function _insert_or_update_question($new_question = true)
525
+	{
526
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
527
+		$set_column_values = $this->_set_column_values_for($this->_question_model);
528
+		if ($new_question) {
529
+			$question = EE_Question::new_instance($set_column_values);
530
+			$action_desc = 'added';
531
+		} else {
532
+			$question = EEM_Question::instance()->get_one_by_ID(absint($this->_req_data['QST_ID']));
533
+			foreach ($set_column_values as $field => $new_value) {
534
+				$question->set($field, $new_value);
535
+			}
536
+			$action_desc = 'updated';
537
+		}
538
+		$success = $question->save();
539
+		$ID = $question->ID();
540
+		if ($ID && $question->should_have_question_options()) {
541
+			// save the related options
542
+			// trash removed options, save old ones
543
+			// get list of all options
544
+			$options = $question->options();
545
+			if (! empty($options)) {
546
+				foreach ($options as $option_ID => $option) {
547
+					$option_req_index = $this->_get_option_req_data_index($option_ID);
548
+					if ($option_req_index !== false) {
549
+						$option->save($this->_req_data['question_options'][ $option_req_index ]);
550
+					} else {
551
+						// not found, remove it
552
+						$option->delete();
553
+					}
554
+				}
555
+			}
556
+			// save new related options
557
+			foreach ($this->_req_data['question_options'] as $index => $option_req_data) {
558
+				// skip $index that is from our sample
559
+				if ($index === 'xxcountxx') {
560
+					continue;
561
+				}
562
+				// note we allow saving blank options.
563
+				if (empty($option_req_data['QSO_ID'])
564
+				) {// no ID! save it!
565
+					$new_option = EE_Question_Option::new_instance(
566
+						array(
567
+							'QSO_value' => $option_req_data['QSO_value'],
568
+							'QSO_desc'  => $option_req_data['QSO_desc'],
569
+							'QSO_order' => $option_req_data['QSO_order'],
570
+							'QST_ID'    => $question->ID(),
571
+						)
572
+					);
573
+					$new_option->save();
574
+				}
575
+			}
576
+		}
577
+		$query_args = array('action' => 'edit_question', 'QST_ID' => $ID);
578
+		if ($success !== false) {
579
+			$msg = $new_question
580
+				? sprintf(
581
+					esc_html__('The %s has been created', 'event_espresso'),
582
+					$this->_question_model->item_name()
583
+				)
584
+				: sprintf(
585
+					esc_html__('The %s has been updated', 'event_espresso'),
586
+					$this->_question_model->item_name()
587
+				);
588
+			EE_Error::add_success($msg);
589
+		}
590
+
591
+		$this->_redirect_after_action(false, '', $action_desc, $query_args, true);
592
+	}
593
+
594
+
595
+	/**
596
+	 * Upon saving a question, there should be an array of 'question_options'. This array is index numerically, but not
597
+	 * by ID
598
+	 * (this is done because new question options don't have an ID, but we may want to add multiple simultaneously).
599
+	 * So, this function gets the index in that request data array called question_options. Returns FALSE if not found.
600
+	 *
601
+	 * @param int $ID of the question option to find
602
+	 * @return int index in question_options array if successful, FALSE if unsuccessful
603
+	 */
604
+	protected function _get_option_req_data_index($ID)
605
+	{
606
+		$req_data_for_question_options = $this->_req_data['question_options'];
607
+		foreach ($req_data_for_question_options as $num => $option_data) {
608
+			if (array_key_exists('QSO_ID', $option_data) && (int) $option_data['QSO_ID'] === $ID) {
609
+				return $num;
610
+			}
611
+		}
612
+		return false;
613
+	}
614
+
615
+
616
+
617
+
618
+	/***********/
619
+	/* QUERIES */
620
+	/**
621
+	 * For internal use in getting all the query parameters
622
+	 * (because it's pretty well the same between question, question groups,
623
+	 * and for both when searching for trashed and untrashed ones)
624
+	 *
625
+	 * @param EEM_Base $model either EEM_Question or EEM_Question_Group
626
+	 * @param int      $per_page
627
+	 * @param int      $current_page
628
+	 * @return array model query params, @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
629
+	 */
630
+	protected function get_query_params($model, $per_page = 10, $current_page = 10)
631
+	{
632
+		$query_params = array();
633
+		$offset = ($current_page - 1) * $per_page;
634
+		$query_params['limit'] = array($offset, $per_page);
635
+		$order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order']
636
+			: 'ASC';
637
+		$orderby_field = $model instanceof EEM_Question ? 'QST_ID' : 'QSG_order';
638
+		$field_to_order_by = empty($this->_req_data['orderby']) ? $orderby_field : $this->_req_data['orderby'];
639
+		$query_params['order_by'] = array($field_to_order_by => $order);
640
+		$search_string = array_key_exists('s', $this->_req_data) ? $this->_req_data['s'] : null;
641
+		if (! empty($search_string)) {
642
+			if ($model instanceof EEM_Question_Group) {
643
+				$query_params[0] = array(
644
+					'OR' => array(
645
+						'QSG_name' => array('LIKE', "%$search_string%"),
646
+						'QSG_desc' => array('LIKE', "%$search_string%"),
647
+					),
648
+				);
649
+			} else {
650
+				$query_params[0] = array(
651
+					'QST_display_text' => array('LIKE', "%$search_string%"),
652
+				);
653
+			}
654
+		}
655
+
656
+		// capability checks (just leaving this commented out for reference because it illustrates some complicated query params that could be useful when fully implemented)
657
+		/*if ( $model instanceof EEM_Question_Group ) {
658 658
             if ( ! EE_Registry::instance()->CAP->current_user_can( 'edit_others_question_groups', 'espresso_registration_form_edit_question_group' ) ) {
659 659
                 $query_params[0] = array(
660 660
                     'AND' => array(
@@ -684,59 +684,59 @@  discard block
 block discarded – undo
684 684
             }
685 685
         }/**/
686 686
 
687
-        return $query_params;
688
-    }
689
-
690
-
691
-    /**
692
-     * @param int        $per_page
693
-     * @param int        $current_page
694
-     * @param bool|false $count
695
-     * @return \EE_Soft_Delete_Base_Class[]|int
696
-     */
697
-    public function get_questions($per_page = 10, $current_page = 1, $count = false)
698
-    {
699
-        $QST = EEM_Question::instance();
700
-        $query_params = $this->get_query_params($QST, $per_page, $current_page);
701
-        if ($count) {
702
-            $where = isset($query_params[0]) ? array($query_params[0]) : array();
703
-            $results = $QST->count($where);
704
-        } else {
705
-            $results = $QST->get_all($query_params);
706
-        }
707
-        return $results;
708
-    }
709
-
710
-
711
-    /**
712
-     * @param            $per_page
713
-     * @param int        $current_page
714
-     * @param bool|false $count
715
-     * @return \EE_Soft_Delete_Base_Class[]|int
716
-     */
717
-    public function get_trashed_questions($per_page, $current_page = 1, $count = false)
718
-    {
719
-        $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
720
-        $where = isset($query_params[0]) ? array($query_params[0]) : array();
721
-        $questions = $count ? EEM_Question::instance()->count_deleted($where)
722
-            : EEM_Question::instance()->get_all_deleted($query_params);
723
-        return $questions;
724
-    }
725
-
726
-
727
-    /**
728
-     * @param            $per_page
729
-     * @param int        $current_page
730
-     * @param bool|false $count
731
-     * @return \EE_Soft_Delete_Base_Class[]
732
-     */
733
-    public function get_question_groups($per_page, $current_page = 1, $count = false)
734
-    {
735
-        /** @type EEM_Question_Group $questionGroupModel */
736
-        $questionGroupModel = EEM_Question_Group::instance();
737
-        // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
738
-        return $questionGroupModel->get_all(
739
-            $this->get_query_params($questionGroupModel, $per_page, $current_page)
740
-        );
741
-    }
687
+		return $query_params;
688
+	}
689
+
690
+
691
+	/**
692
+	 * @param int        $per_page
693
+	 * @param int        $current_page
694
+	 * @param bool|false $count
695
+	 * @return \EE_Soft_Delete_Base_Class[]|int
696
+	 */
697
+	public function get_questions($per_page = 10, $current_page = 1, $count = false)
698
+	{
699
+		$QST = EEM_Question::instance();
700
+		$query_params = $this->get_query_params($QST, $per_page, $current_page);
701
+		if ($count) {
702
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
703
+			$results = $QST->count($where);
704
+		} else {
705
+			$results = $QST->get_all($query_params);
706
+		}
707
+		return $results;
708
+	}
709
+
710
+
711
+	/**
712
+	 * @param            $per_page
713
+	 * @param int        $current_page
714
+	 * @param bool|false $count
715
+	 * @return \EE_Soft_Delete_Base_Class[]|int
716
+	 */
717
+	public function get_trashed_questions($per_page, $current_page = 1, $count = false)
718
+	{
719
+		$query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
720
+		$where = isset($query_params[0]) ? array($query_params[0]) : array();
721
+		$questions = $count ? EEM_Question::instance()->count_deleted($where)
722
+			: EEM_Question::instance()->get_all_deleted($query_params);
723
+		return $questions;
724
+	}
725
+
726
+
727
+	/**
728
+	 * @param            $per_page
729
+	 * @param int        $current_page
730
+	 * @param bool|false $count
731
+	 * @return \EE_Soft_Delete_Base_Class[]
732
+	 */
733
+	public function get_question_groups($per_page, $current_page = 1, $count = false)
734
+	{
735
+		/** @type EEM_Question_Group $questionGroupModel */
736
+		$questionGroupModel = EEM_Question_Group::instance();
737
+		// note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
738
+		return $questionGroupModel->get_all(
739
+			$this->get_query_params($questionGroupModel, $per_page, $current_page)
740
+		);
741
+	}
742 742
 }
Please login to merge, or discard this patch.