@@ -6,9 +6,9 @@ |
||
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> |
@@ -15,39 +15,39 @@ |
||
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 | } |
@@ -53,8 +53,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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( |
@@ -15,646 +15,646 @@ discard block |
||
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 |
||
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 | } |
@@ -16,19 +16,19 @@ discard block |
||
16 | 16 | $has_answers = $question->has_answers(); |
17 | 17 | |
18 | 18 | if ($QST_system === 'country') { |
19 | - echo EEH_HTML::div( |
|
20 | - EEH_HTML::h4( |
|
21 | - '<span class="dashicons dashicons-info"></span>' . esc_html__('Did you know...', 'event_espresso') |
|
22 | - ) . |
|
23 | - EEH_HTML::p( |
|
24 | - esc_html__( |
|
25 | - 'If you add a State/Province Select input immediately after this Country Select input when building your registration form, then the State/Province Select input options will change to correspond with the choice made in this input. So for example, choosing "United States" in this Country Select input will populate the State/Province Select input with just the state options for the United States.', |
|
26 | - 'event_espresso' |
|
27 | - ) |
|
28 | - ), |
|
29 | - '', |
|
30 | - 'ee-info-box' |
|
31 | - ); |
|
19 | + echo EEH_HTML::div( |
|
20 | + EEH_HTML::h4( |
|
21 | + '<span class="dashicons dashicons-info"></span>' . esc_html__('Did you know...', 'event_espresso') |
|
22 | + ) . |
|
23 | + EEH_HTML::p( |
|
24 | + esc_html__( |
|
25 | + 'If you add a State/Province Select input immediately after this Country Select input when building your registration form, then the State/Province Select input options will change to correspond with the choice made in this input. So for example, choosing "United States" in this Country Select input will populate the State/Province Select input with just the state options for the United States.', |
|
26 | + 'event_espresso' |
|
27 | + ) |
|
28 | + ), |
|
29 | + '', |
|
30 | + 'ee-info-box' |
|
31 | + ); |
|
32 | 32 | } |
33 | 33 | ?> |
34 | 34 | |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | </th> |
55 | 55 | <td> |
56 | 56 | <?php |
57 | - $disabled_attr = ! empty($QST_system) ? ' disabled="disabled"' : ''; |
|
58 | - $id = ! empty($QST_system) ? '_disabled' : ''; |
|
59 | - ?> |
|
57 | + $disabled_attr = ! empty($QST_system) ? ' disabled="disabled"' : ''; |
|
58 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
59 | + ?> |
|
60 | 60 | <input type="text" class="regular-text" id="QST_admin_label<?php echo $id ?>" |
61 | 61 | name="QST_admin_label<?php echo $id ?>" |
62 | 62 | value="<?php $question->f('QST_admin_label') ?>"<?php echo $disabled_attr ?>/> |
@@ -85,18 +85,18 @@ discard block |
||
85 | 85 | </th> |
86 | 86 | <td> |
87 | 87 | <?php |
88 | - $disabled_attr = ! empty($QST_system) ? ' disabled="disabled"' : ''; |
|
89 | - $id = ! empty($QST_system) ? '_disabled' : ''; |
|
90 | - $admin_only = $question->get('QST_admin_only'); |
|
91 | - $checked = ! empty($admin_only) ? ' checked="checked"' : ''; |
|
92 | - ?> |
|
88 | + $disabled_attr = ! empty($QST_system) ? ' disabled="disabled"' : ''; |
|
89 | + $id = ! empty($QST_system) ? '_disabled' : ''; |
|
90 | + $admin_only = $question->get('QST_admin_only'); |
|
91 | + $checked = ! empty($admin_only) ? ' checked="checked"' : ''; |
|
92 | + ?> |
|
93 | 93 | <input class="QST_admin_only" type="checkbox" id="QST_admin_only<?php echo $id; ?>" |
94 | 94 | name="QST_admin_only<?php echo $id; ?>" value="1"<?php echo $disabled_attr; |
95 | - echo $checked; ?>/> |
|
95 | + echo $checked; ?>/> |
|
96 | 96 | <br/> |
97 | 97 | <p class="description"> |
98 | 98 | <?php |
99 | - if (! empty($QST_system)) { ?> |
|
99 | + if (! empty($QST_system)) { ?> |
|
100 | 100 | <span class="description" style="color:#D54E21;"> |
101 | 101 | <?php esc_html_e('System question! This field cannot be changed.', 'event_espresso') ?> |
102 | 102 | </span> |
@@ -113,32 +113,32 @@ discard block |
||
113 | 113 | </th> |
114 | 114 | <td> |
115 | 115 | <?php |
116 | - $disabled = ! empty($QST_system) && $QST_system !== EEM_Attendee::system_question_phone; |
|
117 | - if ($disabled) { |
|
118 | - $disabled_attr = 'disabled="disabled"'; |
|
119 | - $id = '_disabled'; |
|
120 | - } else { |
|
121 | - $disabled_attr = ''; |
|
122 | - $id = ''; |
|
123 | - } |
|
116 | + $disabled = ! empty($QST_system) && $QST_system !== EEM_Attendee::system_question_phone; |
|
117 | + if ($disabled) { |
|
118 | + $disabled_attr = 'disabled="disabled"'; |
|
119 | + $id = '_disabled'; |
|
120 | + } else { |
|
121 | + $disabled_attr = ''; |
|
122 | + $id = ''; |
|
123 | + } |
|
124 | 124 | |
125 | - echo EEH_Form_Fields::select_input( |
|
126 | - 'QST_type' . $id, |
|
127 | - $question_types, |
|
128 | - $question->type(), |
|
129 | - 'id="QST_type' . $id . '"' . $disabled_attr |
|
130 | - ); |
|
131 | - if ($disabled) { ?> |
|
125 | + echo EEH_Form_Fields::select_input( |
|
126 | + 'QST_type' . $id, |
|
127 | + $question_types, |
|
128 | + $question->type(), |
|
129 | + 'id="QST_type' . $id . '"' . $disabled_attr |
|
130 | + ); |
|
131 | + if ($disabled) { ?> |
|
132 | 132 | <input type="hidden" id="QST_type" name="QST_type" value="<?php echo $question->type() ?>"/> |
133 | 133 | <?php |
134 | - $explanatory_text = esc_html__('System question! This field cannot be changed.', 'event_espresso'); |
|
135 | - } else { |
|
136 | - $explanatory_text = esc_html__( |
|
137 | - 'Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.', |
|
138 | - 'event_espresso' |
|
139 | - ); |
|
140 | - } |
|
141 | - if ($disabled || $has_answers) { ?> |
|
134 | + $explanatory_text = esc_html__('System question! This field cannot be changed.', 'event_espresso'); |
|
135 | + } else { |
|
136 | + $explanatory_text = esc_html__( |
|
137 | + 'Because there are currently answers for this question in the database, your options to change the question type have been limited to similar question-types.', |
|
138 | + 'event_espresso' |
|
139 | + ); |
|
140 | + } |
|
141 | + if ($disabled || $has_answers) { ?> |
|
142 | 142 | <p><span class="description" style="color:#D54E21;"> |
143 | 143 | <?php echo $explanatory_text; ?> |
144 | 144 | </span></p> |
@@ -156,25 +156,25 @@ discard block |
||
156 | 156 | </th> |
157 | 157 | <td> |
158 | 158 | <input id="QST_max" name="QST_max" type="number" <?php echo $max_max === EE_INF ? '' |
159 | - : "max='$max_max'"; ?> value="<?php $question->f('QST_max'); ?>" min="1"> |
|
159 | + : "max='$max_max'"; ?> value="<?php $question->f('QST_max'); ?>" min="1"> |
|
160 | 160 | <p> |
161 | 161 | <span class="description"> |
162 | 162 | <?php esc_html_e( |
163 | - 'Maximum number of characters allowed when answering this question', |
|
164 | - 'event_espresso' |
|
165 | - ); ?> |
|
163 | + 'Maximum number of characters allowed when answering this question', |
|
164 | + 'event_espresso' |
|
165 | + ); ?> |
|
166 | 166 | </span> |
167 | 167 | </p> |
168 | 168 | <?php if ($QST_system) { ?> |
169 | 169 | <p> |
170 | 170 | <span class="description" style="color:#D54E21;"> |
171 | 171 | <?php printf( |
172 | - esc_html__( |
|
173 | - 'System question! The maximum number of characters that can be used for this question is %1$s', |
|
174 | - 'event_espresso' |
|
175 | - ), |
|
176 | - $max_max |
|
177 | - ); ?> |
|
172 | + esc_html__( |
|
173 | + 'System question! The maximum number of characters that can be used for this question is %1$s', |
|
174 | + 'event_espresso' |
|
175 | + ), |
|
176 | + $max_max |
|
177 | + ); ?> |
|
178 | 178 | </span> |
179 | 179 | </p> |
180 | 180 | <?php } ?> |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | </th> |
197 | 197 | <th class="option-desc-header"> |
198 | 198 | <?php esc_html_e( |
199 | - 'Description (optional, only shown on registration form)', |
|
200 | - 'event_espresso' |
|
201 | - ) ?> |
|
199 | + 'Description (optional, only shown on registration form)', |
|
200 | + 'event_espresso' |
|
201 | + ) ?> |
|
202 | 202 | </th> |
203 | 203 | <th> |
204 | 204 | </th> |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | </tr> |
225 | 225 | |
226 | 226 | <?php |
227 | - $count = 0; |
|
228 | - $question_options = $question->options(); |
|
229 | - if (! empty($question_options)) { |
|
230 | - foreach ($question_options as $option_id => $option) { |
|
231 | - $disabled_attr = $has_answers || $option->get('QSO_system') ? ' disabled="disabled"' : ''; |
|
232 | - ?> |
|
227 | + $count = 0; |
|
228 | + $question_options = $question->options(); |
|
229 | + if (! empty($question_options)) { |
|
230 | + foreach ($question_options as $option_id => $option) { |
|
231 | + $disabled_attr = $has_answers || $option->get('QSO_system') ? ' disabled="disabled"' : ''; |
|
232 | + ?> |
|
233 | 233 | <tr class="question-option ee-options-sortable"> |
234 | 234 | <td class="option-value-cell"> |
235 | 235 | <input type="hidden" class="QSO_order" |
@@ -255,21 +255,21 @@ discard block |
||
255 | 255 | <span class="dashicons dashicons-image-flip-vertical sortable-drag-handle ee-icon-size-18"></span> |
256 | 256 | </td> |
257 | 257 | <?php |
258 | - echo EEH_Form_Fields::hidden_input( |
|
259 | - "question_options[{$count}][QST_ID])", |
|
260 | - $option->question_ID() |
|
261 | - ); |
|
262 | - echo EEH_Form_Fields::hidden_input( |
|
263 | - "question_options[{$count}][QSO_ID])", |
|
264 | - $option->ID() |
|
265 | - ); |
|
266 | - $count++; |
|
267 | - ?> |
|
258 | + echo EEH_Form_Fields::hidden_input( |
|
259 | + "question_options[{$count}][QST_ID])", |
|
260 | + $option->question_ID() |
|
261 | + ); |
|
262 | + echo EEH_Form_Fields::hidden_input( |
|
263 | + "question_options[{$count}][QSO_ID])", |
|
264 | + $option->ID() |
|
265 | + ); |
|
266 | + $count++; |
|
267 | + ?> |
|
268 | 268 | </tr> |
269 | 269 | <?php |
270 | - } |
|
271 | - } else { |
|
272 | - ?> |
|
270 | + } |
|
271 | + } else { |
|
272 | + ?> |
|
273 | 273 | <tr class="question-option ee-options-sortable"> |
274 | 274 | <td class="option-value-cell"> |
275 | 275 | <input type="hidden" class="QSO_order" name="question_options[0][QSO_order]" value="0"/> |
@@ -282,19 +282,19 @@ discard block |
||
282 | 282 | </td> |
283 | 283 | <td> |
284 | 284 | <?php |
285 | - echo EEH_Form_Fields::hidden_input("question_options_count", $count); |
|
286 | - ?> |
|
285 | + echo EEH_Form_Fields::hidden_input("question_options_count", $count); |
|
286 | + ?> |
|
287 | 287 | </td> |
288 | 288 | </tr> |
289 | 289 | <?php |
290 | - } |
|
291 | - ?> |
|
290 | + } |
|
291 | + ?> |
|
292 | 292 | <tr style="display:none"> |
293 | 293 | <td colspan="3"> |
294 | 294 | <?php echo EEH_Form_Fields::hidden_input( |
295 | - "question_options_count", |
|
296 | - $count |
|
297 | - ); ?></td> |
|
295 | + "question_options_count", |
|
296 | + $count |
|
297 | + ); ?></td> |
|
298 | 298 | </tr> |
299 | 299 | </tbody> |
300 | 300 | </table> |
@@ -305,16 +305,16 @@ discard block |
||
305 | 305 | |
306 | 306 | <p class="description"> |
307 | 307 | <?php esc_html_e( |
308 | - 'Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.', |
|
309 | - 'event_espresso' |
|
310 | - ) ?> |
|
308 | + 'Answer Options are the choices that you give people to select from for RADIO_BTN, CHECKBOX or DROPDOWN questions. The Value is a simple key that will be saved to the database and the description is optional. Note that values CANNOT contain any HTML, but descriptions can.', |
|
309 | + 'event_espresso' |
|
310 | + ) ?> |
|
311 | 311 | </p> |
312 | 312 | <?php if ($has_answers) : ?> |
313 | 313 | <p class="description" style="color:#D54E21;"> |
314 | 314 | <?php esc_html_e( |
315 | - 'Answer values that are uneditable are this way because there are registrations in the database that have answers for this question. If you need to correct a mistake, or edit an existing option value, then trash the existing one and create a new option with the changes. This will ensure that the existing registrations that chose the original answer will preserve that answer.', |
|
316 | - 'event_espresso' |
|
317 | - ); ?> |
|
315 | + 'Answer values that are uneditable are this way because there are registrations in the database that have answers for this question. If you need to correct a mistake, or edit an existing option value, then trash the existing one and create a new option with the changes. This will ensure that the existing registrations that chose the original answer will preserve that answer.', |
|
316 | + 'event_espresso' |
|
317 | + ); ?> |
|
318 | 318 | </p> |
319 | 319 | |
320 | 320 | <?php endif; ?> |
@@ -328,35 +328,35 @@ discard block |
||
328 | 328 | </th> |
329 | 329 | <td> |
330 | 330 | <?php |
331 | - $system_required = array('fname', 'email'); |
|
332 | - $disabled_attr = in_array($QST_system, $system_required) ? ' disabled="disabled"' : ''; |
|
333 | - $required_on = $question->get('QST_admin_only'); |
|
334 | - $show_required_msg = $required_on ? '' : ' display:none;'; |
|
335 | - $disabled_attr = $required_on || ! empty($disabled_attr) ? ' disabled="disabled"' : ''; |
|
336 | - $id = ! empty($disabled_attr) && in_array($QST_system, $system_required) ? '_disabled' : ''; |
|
337 | - $requiredOptions = array( |
|
338 | - array('text' => esc_html__('Optional', 'event_espresso'), 'id' => 0), |
|
339 | - array('text' => esc_html__('Required', 'event_espresso'), 'id' => 1), |
|
340 | - ); |
|
341 | - echo EEH_Form_Fields::select_input( |
|
342 | - 'QST_required' . $id, |
|
343 | - $requiredOptions, |
|
344 | - $question->required(), |
|
345 | - 'id="QST_required' . $id . '"' . $disabled_attr |
|
346 | - ); |
|
347 | - ?> |
|
331 | + $system_required = array('fname', 'email'); |
|
332 | + $disabled_attr = in_array($QST_system, $system_required) ? ' disabled="disabled"' : ''; |
|
333 | + $required_on = $question->get('QST_admin_only'); |
|
334 | + $show_required_msg = $required_on ? '' : ' display:none;'; |
|
335 | + $disabled_attr = $required_on || ! empty($disabled_attr) ? ' disabled="disabled"' : ''; |
|
336 | + $id = ! empty($disabled_attr) && in_array($QST_system, $system_required) ? '_disabled' : ''; |
|
337 | + $requiredOptions = array( |
|
338 | + array('text' => esc_html__('Optional', 'event_espresso'), 'id' => 0), |
|
339 | + array('text' => esc_html__('Required', 'event_espresso'), 'id' => 1), |
|
340 | + ); |
|
341 | + echo EEH_Form_Fields::select_input( |
|
342 | + 'QST_required' . $id, |
|
343 | + $requiredOptions, |
|
344 | + $question->required(), |
|
345 | + 'id="QST_required' . $id . '"' . $disabled_attr |
|
346 | + ); |
|
347 | + ?> |
|
348 | 348 | <p><span id="required_toggled_on" class="description" |
349 | 349 | style="color:#D54E21;<?php echo $show_required_msg; ?>"> |
350 | 350 | <?php esc_html_e( |
351 | - 'Required is set to optional, and this field is disabled, because the question is Admin-Only.', |
|
352 | - 'event_espresso' |
|
353 | - ) ?> |
|
351 | + 'Required is set to optional, and this field is disabled, because the question is Admin-Only.', |
|
352 | + 'event_espresso' |
|
353 | + ) ?> |
|
354 | 354 | </span></p> |
355 | 355 | <p><span id="required_toggled_off" class="description" style="color:#D54E21; display: none;"> |
356 | 356 | <?php esc_html_e( |
357 | - 'Required option field is no longer disabled because the question is not Admin-Only', |
|
358 | - 'event_espresso' |
|
359 | - ) ?> |
|
357 | + 'Required option field is no longer disabled because the question is not Admin-Only', |
|
358 | + 'event_espresso' |
|
359 | + ) ?> |
|
360 | 360 | </span></p> |
361 | 361 | <?php if (! empty($disabled_attr) && in_array($QST_system, $system_required)) { ?> |
362 | 362 | <input type="hidden" id="QST_required" name="QST_required" value="1"/> |
@@ -372,9 +372,9 @@ discard block |
||
372 | 372 | <th> |
373 | 373 | <label for="QST_required_text"> |
374 | 374 | <?php esc_html_e( |
375 | - 'Required Text', |
|
376 | - 'event_espresso' |
|
377 | - ); ?></label> <?php echo EEH_Template::get_help_tab_link('required_text_info'); ?> |
|
375 | + 'Required Text', |
|
376 | + 'event_espresso' |
|
377 | + ); ?></label> <?php echo EEH_Template::get_help_tab_link('required_text_info'); ?> |
|
378 | 378 | </th> |
379 | 379 | <td> |
380 | 380 | <input type="text" maxlength="100" class="regular-text" id="QST_required_text" name="QST_required_text" |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | if ($QST_system === 'country') { |
19 | 19 | echo EEH_HTML::div( |
20 | 20 | EEH_HTML::h4( |
21 | - '<span class="dashicons dashicons-info"></span>' . esc_html__('Did you know...', 'event_espresso') |
|
22 | - ) . |
|
21 | + '<span class="dashicons dashicons-info"></span>'.esc_html__('Did you know...', 'event_espresso') |
|
22 | + ). |
|
23 | 23 | EEH_HTML::p( |
24 | 24 | esc_html__( |
25 | 25 | 'If you add a State/Province Select input immediately after this Country Select input when building your registration form, then the State/Province Select input options will change to correspond with the choice made in this input. So for example, choosing "United States" in this Country Select input will populate the State/Province Select input with just the state options for the United States.', |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | value="<?php $question->f('QST_admin_label') ?>"<?php echo $disabled_attr ?>/> |
63 | 63 | <input class="QST_order" type="hidden" id="QST_order<?php echo $id; ?>" |
64 | 64 | name="QST_order<?php echo $id; ?>" value="<?php echo $question->get('QST_order'); ?>"/> |
65 | - <?php if (! empty($QST_system)) { ?> |
|
65 | + <?php if ( ! empty($QST_system)) { ?> |
|
66 | 66 | <input type="hidden" id="QST_admin_label" name="QST_admin_label" |
67 | 67 | value="<?php echo $question->admin_label() ?>"/> |
68 | 68 | <?php } ?> |
69 | 69 | <br/> |
70 | 70 | <p class="description"> |
71 | - <?php if (! empty($QST_system)) { ?> |
|
71 | + <?php if ( ! empty($QST_system)) { ?> |
|
72 | 72 | <span class="description" style="color:#D54E21;"> |
73 | 73 | <?php esc_html_e('System question! This field cannot be changed.', 'event_espresso') ?> |
74 | 74 | </span> |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | <br/> |
97 | 97 | <p class="description"> |
98 | 98 | <?php |
99 | - if (! empty($QST_system)) { ?> |
|
99 | + if ( ! empty($QST_system)) { ?> |
|
100 | 100 | <span class="description" style="color:#D54E21;"> |
101 | 101 | <?php esc_html_e('System question! This field cannot be changed.', 'event_espresso') ?> |
102 | 102 | </span> |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | echo EEH_Form_Fields::select_input( |
126 | - 'QST_type' . $id, |
|
126 | + 'QST_type'.$id, |
|
127 | 127 | $question_types, |
128 | 128 | $question->type(), |
129 | - 'id="QST_type' . $id . '"' . $disabled_attr |
|
129 | + 'id="QST_type'.$id.'"'.$disabled_attr |
|
130 | 130 | ); |
131 | 131 | if ($disabled) { ?> |
132 | 132 | <input type="hidden" id="QST_type" name="QST_type" value="<?php echo $question->type() ?>"/> |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | <?php |
227 | 227 | $count = 0; |
228 | 228 | $question_options = $question->options(); |
229 | - if (! empty($question_options)) { |
|
229 | + if ( ! empty($question_options)) { |
|
230 | 230 | foreach ($question_options as $option_id => $option) { |
231 | 231 | $disabled_attr = $has_answers || $option->get('QSO_system') ? ' disabled="disabled"' : ''; |
232 | 232 | ?> |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | value="<?php $option->f('QSO_desc') ?>"> |
250 | 250 | </td> |
251 | 251 | <td> |
252 | - <?php if (! $option->system()) { ?> |
|
252 | + <?php if ( ! $option->system()) { ?> |
|
253 | 253 | <span class="dashicons clickable dashicons-post-trash ee-icon-size-18 remove-option remove-item"></span> |
254 | 254 | <?php } ?> |
255 | 255 | <span class="dashicons dashicons-image-flip-vertical sortable-drag-handle ee-icon-size-18"></span> |
@@ -339,10 +339,10 @@ discard block |
||
339 | 339 | array('text' => esc_html__('Required', 'event_espresso'), 'id' => 1), |
340 | 340 | ); |
341 | 341 | echo EEH_Form_Fields::select_input( |
342 | - 'QST_required' . $id, |
|
342 | + 'QST_required'.$id, |
|
343 | 343 | $requiredOptions, |
344 | 344 | $question->required(), |
345 | - 'id="QST_required' . $id . '"' . $disabled_attr |
|
345 | + 'id="QST_required'.$id.'"'.$disabled_attr |
|
346 | 346 | ); |
347 | 347 | ?> |
348 | 348 | <p><span id="required_toggled_on" class="description" |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | 'event_espresso' |
359 | 359 | ) ?> |
360 | 360 | </span></p> |
361 | - <?php if (! empty($disabled_attr) && in_array($QST_system, $system_required)) { ?> |
|
361 | + <?php if ( ! empty($disabled_attr) && in_array($QST_system, $system_required)) { ?> |
|
362 | 362 | <input type="hidden" id="QST_required" name="QST_required" value="1"/> |
363 | 363 | <p><span class="description" style="color:#D54E21;"> |
364 | 364 | <?php esc_html_e('System question! This field cannot be changed.', 'event_espresso') ?> |
@@ -10,50 +10,50 @@ |
||
10 | 10 | class EES_Espresso_Ticket_Selector extends EES_Shortcode |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @deprecated 4.9.27 |
|
15 | - * @return void |
|
16 | - */ |
|
17 | - public static function set_hooks() |
|
18 | - { |
|
19 | - } |
|
20 | - |
|
21 | - |
|
22 | - |
|
23 | - /** |
|
24 | - * @deprecated 4.9.27 |
|
25 | - * @return void |
|
26 | - */ |
|
27 | - public static function set_hooks_admin() |
|
28 | - { |
|
29 | - } |
|
30 | - |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * @deprecated 4.9.27 |
|
35 | - * @param \WP $WP |
|
36 | - */ |
|
37 | - public function run(WP $WP) |
|
38 | - { |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * @deprecated 4.9.27 |
|
44 | - * @param array $attributes |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function process_shortcode($attributes = array()) |
|
48 | - { |
|
49 | - \EE_Error::doing_it_wrong( |
|
50 | - __METHOD__, |
|
51 | - __( |
|
52 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector instead.', |
|
53 | - 'event_espresso' |
|
54 | - ), |
|
55 | - '4.9.27' |
|
56 | - ); |
|
57 | - return ''; |
|
58 | - } |
|
13 | + /** |
|
14 | + * @deprecated 4.9.27 |
|
15 | + * @return void |
|
16 | + */ |
|
17 | + public static function set_hooks() |
|
18 | + { |
|
19 | + } |
|
20 | + |
|
21 | + |
|
22 | + |
|
23 | + /** |
|
24 | + * @deprecated 4.9.27 |
|
25 | + * @return void |
|
26 | + */ |
|
27 | + public static function set_hooks_admin() |
|
28 | + { |
|
29 | + } |
|
30 | + |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * @deprecated 4.9.27 |
|
35 | + * @param \WP $WP |
|
36 | + */ |
|
37 | + public function run(WP $WP) |
|
38 | + { |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * @deprecated 4.9.27 |
|
44 | + * @param array $attributes |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function process_shortcode($attributes = array()) |
|
48 | + { |
|
49 | + \EE_Error::doing_it_wrong( |
|
50 | + __METHOD__, |
|
51 | + __( |
|
52 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector instead.', |
|
53 | + 'event_espresso' |
|
54 | + ), |
|
55 | + '4.9.27' |
|
56 | + ); |
|
57 | + return ''; |
|
58 | + } |
|
59 | 59 | } |
@@ -11,55 +11,55 @@ |
||
11 | 11 | { |
12 | 12 | |
13 | 13 | |
14 | - /** |
|
15 | - * @deprecated 4.9.27 |
|
16 | - * @return void |
|
17 | - */ |
|
18 | - public static function set_hooks() |
|
19 | - { |
|
20 | - } |
|
14 | + /** |
|
15 | + * @deprecated 4.9.27 |
|
16 | + * @return void |
|
17 | + */ |
|
18 | + public static function set_hooks() |
|
19 | + { |
|
20 | + } |
|
21 | 21 | |
22 | - /** |
|
23 | - * @deprecated 4.9.27 |
|
24 | - * @return void |
|
25 | - */ |
|
26 | - public static function set_hooks_admin() |
|
27 | - { |
|
28 | - } |
|
22 | + /** |
|
23 | + * @deprecated 4.9.27 |
|
24 | + * @return void |
|
25 | + */ |
|
26 | + public static function set_hooks_admin() |
|
27 | + { |
|
28 | + } |
|
29 | 29 | |
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @deprecated 4.9.27 |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public static function set_definitions() |
|
37 | - { |
|
38 | - } |
|
32 | + /** |
|
33 | + * @deprecated 4.9.27 |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public static function set_definitions() |
|
37 | + { |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * @deprecated 4.9.27 |
|
44 | - * @param WP $WP |
|
45 | - * @return void |
|
46 | - * @throws \Exception |
|
47 | - * @throws \EE_Error |
|
48 | - */ |
|
49 | - public function run(WP $WP) |
|
50 | - { |
|
51 | - } |
|
42 | + /** |
|
43 | + * @deprecated 4.9.27 |
|
44 | + * @param WP $WP |
|
45 | + * @return void |
|
46 | + * @throws \Exception |
|
47 | + * @throws \EE_Error |
|
48 | + */ |
|
49 | + public function run(WP $WP) |
|
50 | + { |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * @deprecated 4.9.27 |
|
58 | - * @param array $attributes |
|
59 | - * @return string |
|
60 | - */ |
|
61 | - public function process_shortcode($attributes = array()) |
|
62 | - { |
|
63 | - return __('This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.', 'event_espresso'); |
|
64 | - } |
|
56 | + /** |
|
57 | + * @deprecated 4.9.27 |
|
58 | + * @param array $attributes |
|
59 | + * @return string |
|
60 | + */ |
|
61 | + public function process_shortcode($attributes = array()) |
|
62 | + { |
|
63 | + return __('This is the Event Espresso Transactions page. This page receives instant payment notification (IPN) requests and should have a status of published, but should not be easily accessible by site visitors. Do not add it to your website\'s navigation menu or link to it from another page. Also, do not delete it or change its status to private.', 'event_espresso'); |
|
64 | + } |
|
65 | 65 | } |
@@ -10,50 +10,50 @@ |
||
10 | 10 | class EES_Espresso_Events extends EES_Shortcode |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @deprecated 4.9.27 |
|
15 | - * @return void |
|
16 | - */ |
|
17 | - public static function set_hooks() |
|
18 | - { |
|
19 | - } |
|
20 | - |
|
21 | - /** |
|
22 | - * @deprecated 4.9.27 |
|
23 | - * @return void |
|
24 | - */ |
|
25 | - public static function set_hooks_admin() |
|
26 | - { |
|
27 | - } |
|
28 | - |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * @deprecated 4.9.27 |
|
33 | - * @param WP $WP |
|
34 | - * @return void |
|
35 | - */ |
|
36 | - public function run(WP $WP) |
|
37 | - { |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * @deprecated 4.9.27 |
|
44 | - * @param array $attributes |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function process_shortcode($attributes = array()) |
|
48 | - { |
|
49 | - \EE_Error::doing_it_wrong( |
|
50 | - __METHOD__, |
|
51 | - __( |
|
52 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoEvents instead.', |
|
53 | - 'event_espresso' |
|
54 | - ), |
|
55 | - '4.9.27' |
|
56 | - ); |
|
57 | - return ''; |
|
58 | - } |
|
13 | + /** |
|
14 | + * @deprecated 4.9.27 |
|
15 | + * @return void |
|
16 | + */ |
|
17 | + public static function set_hooks() |
|
18 | + { |
|
19 | + } |
|
20 | + |
|
21 | + /** |
|
22 | + * @deprecated 4.9.27 |
|
23 | + * @return void |
|
24 | + */ |
|
25 | + public static function set_hooks_admin() |
|
26 | + { |
|
27 | + } |
|
28 | + |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * @deprecated 4.9.27 |
|
33 | + * @param WP $WP |
|
34 | + * @return void |
|
35 | + */ |
|
36 | + public function run(WP $WP) |
|
37 | + { |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * @deprecated 4.9.27 |
|
44 | + * @param array $attributes |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function process_shortcode($attributes = array()) |
|
48 | + { |
|
49 | + \EE_Error::doing_it_wrong( |
|
50 | + __METHOD__, |
|
51 | + __( |
|
52 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoEvents instead.', |
|
53 | + 'event_espresso' |
|
54 | + ), |
|
55 | + '4.9.27' |
|
56 | + ); |
|
57 | + return ''; |
|
58 | + } |
|
59 | 59 | } |
@@ -6,66 +6,65 @@ |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage /shortcodes/ |
8 | 8 | * @author Brent Christensen |
9 | - |
|
10 | 9 | * ------------------------------------------------------------------------ |
11 | 10 | */ |
12 | 11 | class EES_Espresso_Checkout extends EES_Shortcode |
13 | 12 | { |
14 | 13 | |
15 | - /** |
|
16 | - * set_hooks - for hooking into EE Core, modules, etc |
|
17 | - * |
|
18 | - * @access public |
|
19 | - * @return void |
|
20 | - */ |
|
21 | - public static function set_hooks() |
|
22 | - { |
|
23 | - } |
|
14 | + /** |
|
15 | + * set_hooks - for hooking into EE Core, modules, etc |
|
16 | + * |
|
17 | + * @access public |
|
18 | + * @return void |
|
19 | + */ |
|
20 | + public static function set_hooks() |
|
21 | + { |
|
22 | + } |
|
24 | 23 | |
25 | - /** |
|
26 | - * set_hooks_admin - for hooking into EE Admin Core, modules, etc |
|
27 | - * |
|
28 | - * @access public |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public static function set_hooks_admin() |
|
32 | - { |
|
33 | - } |
|
24 | + /** |
|
25 | + * set_hooks_admin - for hooking into EE Admin Core, modules, etc |
|
26 | + * |
|
27 | + * @access public |
|
28 | + * @return void |
|
29 | + */ |
|
30 | + public static function set_hooks_admin() |
|
31 | + { |
|
32 | + } |
|
34 | 33 | |
35 | 34 | |
36 | 35 | |
37 | - /** |
|
38 | - * run - initial shortcode module setup called during "wp_loaded" hook |
|
39 | - * this method is primarily used for loading resources that will be required by the shortcode when it is actually processed |
|
40 | - * |
|
41 | - * @access public |
|
42 | - * @param WP $WP |
|
43 | - * @return void |
|
44 | - * @throws \EE_Error |
|
45 | - */ |
|
46 | - public function run(WP $WP) |
|
47 | - { |
|
48 | - } |
|
36 | + /** |
|
37 | + * run - initial shortcode module setup called during "wp_loaded" hook |
|
38 | + * this method is primarily used for loading resources that will be required by the shortcode when it is actually processed |
|
39 | + * |
|
40 | + * @access public |
|
41 | + * @param WP $WP |
|
42 | + * @return void |
|
43 | + * @throws \EE_Error |
|
44 | + */ |
|
45 | + public function run(WP $WP) |
|
46 | + { |
|
47 | + } |
|
49 | 48 | |
50 | 49 | |
51 | 50 | |
52 | - /** |
|
53 | - * process_shortcode - ESPRESSO_CHECKOUT |
|
54 | - * |
|
55 | - * @access public |
|
56 | - * @param array $attributes |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - public function process_shortcode($attributes = array()) |
|
60 | - { |
|
61 | - \EE_Error::doing_it_wrong( |
|
62 | - __METHOD__, |
|
63 | - __( |
|
64 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoCheckout::processShortcode() instead.', |
|
65 | - 'event_espresso' |
|
66 | - ), |
|
67 | - '4.9.27' |
|
68 | - ); |
|
69 | - return ''; |
|
70 | - } |
|
51 | + /** |
|
52 | + * process_shortcode - ESPRESSO_CHECKOUT |
|
53 | + * |
|
54 | + * @access public |
|
55 | + * @param array $attributes |
|
56 | + * @return string |
|
57 | + */ |
|
58 | + public function process_shortcode($attributes = array()) |
|
59 | + { |
|
60 | + \EE_Error::doing_it_wrong( |
|
61 | + __METHOD__, |
|
62 | + __( |
|
63 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoCheckout::processShortcode() instead.', |
|
64 | + 'event_espresso' |
|
65 | + ), |
|
66 | + '4.9.27' |
|
67 | + ); |
|
68 | + return ''; |
|
69 | + } |
|
71 | 70 | } |
@@ -12,56 +12,56 @@ |
||
12 | 12 | { |
13 | 13 | |
14 | 14 | |
15 | - /** |
|
16 | - * run - initial module setup |
|
17 | - * |
|
18 | - * @access public |
|
19 | - * @param WP $WP |
|
20 | - * @return void |
|
21 | - */ |
|
22 | - public function run(WP $WP) |
|
23 | - { |
|
24 | - } |
|
15 | + /** |
|
16 | + * run - initial module setup |
|
17 | + * |
|
18 | + * @access public |
|
19 | + * @param WP $WP |
|
20 | + * @return void |
|
21 | + */ |
|
22 | + public function run(WP $WP) |
|
23 | + { |
|
24 | + } |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * set_hooks - for hooking into EE Core, modules, etc |
|
29 | - * |
|
30 | - * @access public |
|
31 | - * @return void |
|
32 | - */ |
|
33 | - public static function set_hooks() |
|
34 | - { |
|
35 | - } |
|
27 | + /** |
|
28 | + * set_hooks - for hooking into EE Core, modules, etc |
|
29 | + * |
|
30 | + * @access public |
|
31 | + * @return void |
|
32 | + */ |
|
33 | + public static function set_hooks() |
|
34 | + { |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * set_hooks_admin - for hooking into EE Admin Core, modules, etc |
|
39 | - * |
|
40 | - * @access public |
|
41 | - * @return void |
|
42 | - */ |
|
43 | - public static function set_hooks_admin() |
|
44 | - { |
|
45 | - } |
|
37 | + /** |
|
38 | + * set_hooks_admin - for hooking into EE Admin Core, modules, etc |
|
39 | + * |
|
40 | + * @access public |
|
41 | + * @return void |
|
42 | + */ |
|
43 | + public static function set_hooks_admin() |
|
44 | + { |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * @deprecated 4.9.27 |
|
51 | - * @param array $attributes |
|
52 | - * @return string |
|
53 | - * @throws \EE_Error |
|
54 | - */ |
|
55 | - public function process_shortcode($attributes = array()) |
|
56 | - { |
|
57 | - \EE_Error::doing_it_wrong( |
|
58 | - __METHOD__, |
|
59 | - __( |
|
60 | - 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendeesShortcode instead.', |
|
61 | - 'event_espresso' |
|
62 | - ), |
|
63 | - '4.9.27' |
|
64 | - ); |
|
65 | - return ''; |
|
66 | - } |
|
49 | + /** |
|
50 | + * @deprecated 4.9.27 |
|
51 | + * @param array $attributes |
|
52 | + * @return string |
|
53 | + * @throws \EE_Error |
|
54 | + */ |
|
55 | + public function process_shortcode($attributes = array()) |
|
56 | + { |
|
57 | + \EE_Error::doing_it_wrong( |
|
58 | + __METHOD__, |
|
59 | + __( |
|
60 | + 'Usage is deprecated. Please use \EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendeesShortcode instead.', |
|
61 | + 'event_espresso' |
|
62 | + ), |
|
63 | + '4.9.27' |
|
64 | + ); |
|
65 | + return ''; |
|
66 | + } |
|
67 | 67 | } |