@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\admin_pages\registration_form; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @param RegistrationFormEditorForm $RegistrationFormEditorFormInputForm |
46 | 46 | */ |
47 | - public function __construct( RegistrationFormEditorForm $RegistrationFormEditorFormInputForm) { |
|
47 | + public function __construct(RegistrationFormEditorForm $RegistrationFormEditorFormInputForm) { |
|
48 | 48 | $this->reg_form_editor_form = $RegistrationFormEditorFormInputForm; |
49 | 49 | } |
50 | 50 | |
@@ -57,23 +57,23 @@ discard block |
||
57 | 57 | * @return string |
58 | 58 | * @throws \EE_Error |
59 | 59 | */ |
60 | - public function formHTML( $form_input, $form_input_class_name, \EE_Question $question = null ) { |
|
61 | - if ( ! is_subclass_of( $form_input_class_name, 'EE_Form_Input_Base' ) ) { |
|
60 | + public function formHTML($form_input, $form_input_class_name, \EE_Question $question = null) { |
|
61 | + if ( ! is_subclass_of($form_input_class_name, 'EE_Form_Input_Base')) { |
|
62 | 62 | throw new \EE_Error( |
63 | 63 | sprintf( |
64 | - __( 'The class "%1$s" needs to be a sub class of EE_Form_Input_Base.', 'event_espresso' ), |
|
64 | + __('The class "%1$s" needs to be a sub class of EE_Form_Input_Base.', 'event_espresso'), |
|
65 | 65 | $form_input_class_name |
66 | 66 | ) |
67 | 67 | ); |
68 | 68 | } |
69 | 69 | $identifier = $question instanceof \EE_Question ? $question->identifier() : 'clone'; |
70 | - $this->form_input = $this->reg_form_editor_form->formInput( $form_input, $form_input_class_name, $question ); |
|
71 | - $this->input_has_options = $this->form_input instanceof \EE_Form_Input_With_Options_Base ? true :false; |
|
72 | - $html = \EEH_HTML::div( '', '', 'ee-reg-form-editor-form-new-input-form' ); |
|
73 | - $html .= $this->reg_form_editor_form->formInputForm( $form_input, $identifier )->get_html(); |
|
74 | - $html .= \EEH_HTML::div( '', '', 'ee-new-form-input-settings-dv' ); |
|
75 | - $html .= $this->getTabs( $form_input, $identifier ); |
|
76 | - if ( $this->input_has_options ) { |
|
70 | + $this->form_input = $this->reg_form_editor_form->formInput($form_input, $form_input_class_name, $question); |
|
71 | + $this->input_has_options = $this->form_input instanceof \EE_Form_Input_With_Options_Base ? true : false; |
|
72 | + $html = \EEH_HTML::div('', '', 'ee-reg-form-editor-form-new-input-form'); |
|
73 | + $html .= $this->reg_form_editor_form->formInputForm($form_input, $identifier)->get_html(); |
|
74 | + $html .= \EEH_HTML::div('', '', 'ee-new-form-input-settings-dv'); |
|
75 | + $html .= $this->getTabs($form_input, $identifier); |
|
76 | + if ($this->input_has_options) { |
|
77 | 77 | // form input settings |
78 | 78 | $html .= \EEH_HTML::div( |
79 | 79 | '', |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | 'ee-reg-form-input-settings-tab-panel-dv' |
82 | 82 | ); |
83 | 83 | $html .= $this->getInputOptionsFormHeader(); |
84 | - $html .= $this->getInputOptionsForm( $form_input, $identifier ); |
|
84 | + $html .= $this->getInputOptionsForm($form_input, $identifier); |
|
85 | 85 | //$html .= $this->reg_form_editor_form->getInputOptions( $form_input )->get_html(); |
86 | 86 | $html .= $this->getInputOptionsFormFooter(); |
87 | 87 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | "ee-reg-form-input-settings-tab-panel-1-{$identifier}-{$form_input}", |
94 | 94 | 'ee-reg-form-input-settings-tab-panel-dv' |
95 | 95 | ); |
96 | - $html .= $this->reg_form_editor_form->getBasicSettings( $form_input, $identifier, $question )->get_html(); |
|
96 | + $html .= $this->reg_form_editor_form->getBasicSettings($form_input, $identifier, $question)->get_html(); |
|
97 | 97 | $html .= \EEH_HTML::divx(); // end 'ee-reg-form-input-settings-tab-panel-dv' |
98 | 98 | // validation settings |
99 | 99 | $html .= \EEH_HTML::div( |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | 'ee-reg-form-input-settings-tab-panel-dv' |
103 | 103 | ); |
104 | 104 | $html .= $this->reg_form_editor_form |
105 | - ->getValidationSettings( $form_input, $identifier, $form_input_class_name, $question ) |
|
105 | + ->getValidationSettings($form_input, $identifier, $form_input_class_name, $question) |
|
106 | 106 | ->get_html(); |
107 | 107 | $html .= \EEH_HTML::divx(); // end 'ee-reg-form-input-settings-tab-panel-dv' |
108 | 108 | $html .= \EEH_HTML::divx(); // end 'ee-new-form-input-settings-dv' |
@@ -117,18 +117,18 @@ discard block |
||
117 | 117 | * @param string $identifier |
118 | 118 | * @return string |
119 | 119 | */ |
120 | - public function getTabs( $form_input, $identifier = 'clone' ) { |
|
120 | + public function getTabs($form_input, $identifier = 'clone') { |
|
121 | 121 | $tabs = array( |
122 | 122 | 0 => 'Input Options', |
123 | 123 | 1 => 'Basic Settings', |
124 | 124 | 2 => 'Validation Rules', |
125 | 125 | ); |
126 | - if ( ! $this->input_has_options ) { |
|
127 | - unset( $tabs[0] ); |
|
126 | + if ( ! $this->input_has_options) { |
|
127 | + unset($tabs[0]); |
|
128 | 128 | } |
129 | - $html = \EEH_HTML::ul( '', 'ee-reg-form-input-settings-tab-ul'); |
|
129 | + $html = \EEH_HTML::ul('', 'ee-reg-form-input-settings-tab-ul'); |
|
130 | 130 | $order = 1; |
131 | - foreach ( $tabs as $panel => $tab_label ) { |
|
131 | + foreach ($tabs as $panel => $tab_label) { |
|
132 | 132 | $active = $order === 1 ? ' ee-reg-form-input-settings-tab-active' : ''; |
133 | 133 | $html .= \EEH_HTML::li( |
134 | 134 | \EEH_HTML::link( |
@@ -153,24 +153,24 @@ discard block |
||
153 | 153 | * @return string |
154 | 154 | * @throws \EE_Error |
155 | 155 | */ |
156 | - public function getInputOptionsForm( $form_input, $identifier = 'clone' ) { |
|
156 | + public function getInputOptionsForm($form_input, $identifier = 'clone') { |
|
157 | 157 | $html = ''; |
158 | - if ( $this->form_input instanceof \EE_Form_Input_With_Options_Base ) { |
|
159 | - $options = $this->reg_form_editor_form->getInputOptions( $form_input, $this->form_input->options(), $identifier ); |
|
158 | + if ($this->form_input instanceof \EE_Form_Input_With_Options_Base) { |
|
159 | + $options = $this->reg_form_editor_form->getInputOptions($form_input, $this->form_input->options(), $identifier); |
|
160 | 160 | $order = 2; |
161 | - foreach( (array)$options as $key => $input ) { |
|
162 | - if ( $input instanceof \EE_Form_Input_Base ) { |
|
163 | - $html .= $this->getInputOptionsInputs( $key, $input ); |
|
161 | + foreach ((array) $options as $key => $input) { |
|
162 | + if ($input instanceof \EE_Form_Input_Base) { |
|
163 | + $html .= $this->getInputOptionsInputs($key, $input); |
|
164 | 164 | $order++; |
165 | 165 | } |
166 | 166 | } |
167 | - $order = floor( $order /2 ); |
|
167 | + $order = floor($order / 2); |
|
168 | 168 | $hidden = $order > 2 ? true : false; |
169 | - $html .= $this->addEmptyInputOptionsInputs( $form_input, $identifier, 0, $hidden ); |
|
169 | + $html .= $this->addEmptyInputOptionsInputs($form_input, $identifier, 0, $hidden); |
|
170 | 170 | //if ( $order <= 2 ) { |
171 | 171 | // $html .= $this->addEmptyInputOptionsInputs( $form_input, 0, true ); |
172 | 172 | //} |
173 | - $html .= $this->getNewInputOptionOrderInput( $order ); |
|
173 | + $html .= $this->getNewInputOptionOrderInput($order); |
|
174 | 174 | } |
175 | 175 | return $html; |
176 | 176 | } |
@@ -184,13 +184,13 @@ discard block |
||
184 | 184 | * @return array |
185 | 185 | * @throws \EE_Error |
186 | 186 | */ |
187 | - protected function getInputOptionsInputs( $key, \EE_Form_Input_Base $input, $hidden = false ) { |
|
187 | + protected function getInputOptionsInputs($key, \EE_Form_Input_Base $input, $hidden = false) { |
|
188 | 188 | $html = ''; |
189 | 189 | $hide_row = $hidden ? 'display:none;' : ''; |
190 | 190 | $new_row = $hidden ? 'ee-input-option-new-row' : 'ee-input-option-sortable-row'; |
191 | - switch ( substr( $key, 0, 4 ) ) { |
|
191 | + switch (substr($key, 0, 4)) { |
|
192 | 192 | case 'valu' : |
193 | - $html .= \EEH_HTML::tr( '', '', $new_row, $hide_row ); |
|
193 | + $html .= \EEH_HTML::tr('', '', $new_row, $hide_row); |
|
194 | 194 | $html .= \EEH_HTML::td(); |
195 | 195 | $html .= $input->get_html_for_input(); |
196 | 196 | $html .= \EEH_HTML::tdx(); |
@@ -206,25 +206,25 @@ discard block |
||
206 | 206 | '', |
207 | 207 | 'ee-input-option-add dashicons dashicons-plus-alt', |
208 | 208 | '', |
209 | - 'title="' . __( 'Click to Add a New Option', 'event_espresso' ) . '"' |
|
210 | - ) . \EEH_HTML::span( |
|
209 | + 'title="'.__('Click to Add a New Option', 'event_espresso').'"' |
|
210 | + ).\EEH_HTML::span( |
|
211 | 211 | '', |
212 | 212 | '', |
213 | 213 | 'ee-input-option-delete dashicons dashicons-trash', |
214 | 214 | '', |
215 | - 'title="' . __( 'Click to Delete This Option', 'event_espresso' ) . '"' |
|
216 | - ) . \EEH_HTML::span( |
|
215 | + 'title="'.__('Click to Delete This Option', 'event_espresso').'"' |
|
216 | + ).\EEH_HTML::span( |
|
217 | 217 | '', |
218 | 218 | '', |
219 | 219 | 'ee-input-option-sort dashicons dashicons-arrow-up-alt2', |
220 | 220 | '', |
221 | - 'title="' . __( 'Drag to Sort', 'event_espresso' ) . '"' |
|
222 | - ) . \EEH_HTML::span( |
|
221 | + 'title="'.__('Drag to Sort', 'event_espresso').'"' |
|
222 | + ).\EEH_HTML::span( |
|
223 | 223 | '', |
224 | 224 | '', |
225 | 225 | 'ee-input-option-sort dashicons dashicons-arrow-down-alt2', //list-view |
226 | 226 | '', |
227 | - 'title="' . __( 'Drag to Sort', 'event_espresso' ) . '"' |
|
227 | + 'title="'.__('Drag to Sort', 'event_espresso').'"' |
|
228 | 228 | ), |
229 | 229 | '', |
230 | 230 | 'ee-input-option-controls' |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @return string |
247 | 247 | * @throws \EE_Error |
248 | 248 | */ |
249 | - protected function addEmptyInputOptionsInputs( $form_input, $identifier = 'clone', $order = 0, $hidden = true ) { |
|
249 | + protected function addEmptyInputOptionsInputs($form_input, $identifier = 'clone', $order = 0, $hidden = true) { |
|
250 | 250 | $order = $order !== 0 ? $order : 'order'; |
251 | 251 | $html = $this->getInputOptionsInputs( |
252 | 252 | 'value', |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @return string |
281 | 281 | * @throws \EE_Error |
282 | 282 | */ |
283 | - public function getNewInputOptionOrderInput( $order ) { |
|
283 | + public function getNewInputOptionOrderInput($order) { |
|
284 | 284 | $order_input = new \EE_Hidden_Input( |
285 | 285 | array( |
286 | 286 | 'html_name' => 'ee_new_input_option_order', |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | 'default' => $order, |
289 | 289 | ) |
290 | 290 | ); |
291 | - $html = \EEH_HTML::tr( '', '', 'ee_new_input_option_order', 'display:none;' ); |
|
291 | + $html = \EEH_HTML::tr('', '', 'ee_new_input_option_order', 'display:none;'); |
|
292 | 292 | $html .= \EEH_HTML::td(); |
293 | 293 | $html .= $order_input->get_html_for_input(); |
294 | 294 | $html .= \EEH_HTML::tdx(); |
@@ -302,18 +302,18 @@ discard block |
||
302 | 302 | * @return string |
303 | 303 | */ |
304 | 304 | public function getInputOptionsFormHeader() { |
305 | - $html = \EEH_HTML::table( '', '', 'input-options-table form-table' ); |
|
305 | + $html = \EEH_HTML::table('', '', 'input-options-table form-table'); |
|
306 | 306 | $html .= \EEH_HTML::thead( |
307 | 307 | \EEH_HTML::tr( |
308 | - \EEH_HTML::th( __( 'Value', 'event_espresso' ), '', 'option-value-header' ) . |
|
308 | + \EEH_HTML::th(__('Value', 'event_espresso'), '', 'option-value-header'). |
|
309 | 309 | \EEH_HTML::th( |
310 | - __( 'Description (optional, only shown on registration form)', 'event_espresso' ), |
|
310 | + __('Description (optional, only shown on registration form)', 'event_espresso'), |
|
311 | 311 | '', |
312 | 312 | 'option-desc-header' |
313 | 313 | ) |
314 | 314 | ) |
315 | 315 | ); |
316 | - $html .= \EEH_HTML::tbody( '', '', 'ee-input-options-table-body' ); |
|
316 | + $html .= \EEH_HTML::tbody('', '', 'ee-input-options-table-body'); |
|
317 | 317 | return $html; |
318 | 318 | } |
319 | 319 | |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | * @return string |
326 | 326 | */ |
327 | 327 | public function getInputOptionsFormFooter() { |
328 | - return \EEH_HTML::tbodyx() . \EEH_HTML::tablex( '', 'question-options-table' ); |
|
328 | + return \EEH_HTML::tbodyx().\EEH_HTML::tablex('', 'question-options-table'); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ){ |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | } |
5 | 5 | /** |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
37 | 37 | * @access public |
38 | 38 | */ |
39 | - public function __construct( $routing = TRUE ) { |
|
40 | - define( 'REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS ); |
|
41 | - define( 'REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS ); |
|
42 | - define( 'REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/' ); |
|
43 | - define( 'REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS ); |
|
44 | - define( 'REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/' ); |
|
45 | - parent::__construct( $routing ); |
|
39 | + public function __construct($routing = TRUE) { |
|
40 | + define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND.'registration_form'.DS); |
|
41 | + define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN.'assets'.DS); |
|
42 | + define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/'); |
|
43 | + define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN.'templates'.DS); |
|
44 | + define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/templates/'); |
|
45 | + parent::__construct($routing); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | |
53 | 53 | protected function _extend_page_config() { |
54 | 54 | $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN; |
55 | - $qst_id = ! empty( $this->_req_data['QST_ID'] ) && ! is_array( $this->_req_data['QST_ID'] ) ? $this->_req_data['QST_ID'] : 0; |
|
56 | - $qsg_id = ! empty( $this->_req_data['QSG_ID'] ) && ! is_array( $this->_req_data['QSG_ID'] ) ? $this->_req_data['QSG_ID'] : 0; |
|
55 | + $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0; |
|
56 | + $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) ? $this->_req_data['QSG_ID'] : 0; |
|
57 | 57 | |
58 | 58 | $new_page_routes = array( |
59 | 59 | 'question_groups' => array( |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | 'func' => '_trash_or_restore_questions', |
87 | 87 | 'capability' => 'ee_delete_question', |
88 | 88 | 'obj_id' => $qst_id, |
89 | - 'args' => array( 'trash' => FALSE ), |
|
89 | + 'args' => array('trash' => FALSE), |
|
90 | 90 | 'noheader' => TRUE |
91 | 91 | ), |
92 | 92 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | 'trash_question_group' => array( |
147 | 147 | 'func' => '_trash_or_restore_question_groups', |
148 | - 'args' => array( 'trash' => TRUE ), |
|
148 | + 'args' => array('trash' => TRUE), |
|
149 | 149 | 'capability' => 'ee_delete_question_group', |
150 | 150 | 'obj_id' => $qsg_id, |
151 | 151 | 'noheader' => TRUE |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | 'restore_question_group' => array( |
155 | 155 | 'func' => '_trash_or_restore_question_groups', |
156 | - 'args' => array( 'trash' => FALSE ), |
|
156 | + 'args' => array('trash' => FALSE), |
|
157 | 157 | 'capability' => 'ee_delete_question_group', |
158 | 158 | 'obj_id' => $qsg_id, |
159 | 159 | 'noheader' => TRUE |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | 'noheader' => TRUE |
192 | 192 | ), |
193 | 193 | ); |
194 | - $this->_page_routes = array_merge( $this->_page_routes, $new_page_routes ); |
|
194 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
195 | 195 | |
196 | 196 | $new_page_config = array( |
197 | 197 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | 'filename' => 'registration_form_question_groups_views_bulk_actions_search' |
216 | 216 | ), |
217 | 217 | ), |
218 | - 'help_tour' => array( 'Registration_Form_Question_Groups_Help_Tour'), |
|
218 | + 'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'), |
|
219 | 219 | 'metaboxes' => $this->_default_espresso_metaboxes, |
220 | 220 | 'require_nonce' => FALSE, |
221 | 221 | 'qtips' => array( |
@@ -229,14 +229,14 @@ discard block |
||
229 | 229 | 'order' => 5, |
230 | 230 | 'persistent' => FALSE |
231 | 231 | ), |
232 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
232 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
233 | 233 | 'help_tabs' => array( |
234 | 234 | 'registration_form_add_question_help_tab' => array( |
235 | 235 | 'title' => esc_html__('Add Question', 'event_espresso'), |
236 | 236 | 'filename' => 'registration_form_add_question' |
237 | 237 | ), |
238 | 238 | ), |
239 | - 'help_tour' => array( 'Registration_Form_Add_Question_Help_Tour'), |
|
239 | + 'help_tour' => array('Registration_Form_Add_Question_Help_Tour'), |
|
240 | 240 | 'require_nonce' => FALSE |
241 | 241 | ), |
242 | 242 | |
@@ -246,14 +246,14 @@ discard block |
||
246 | 246 | 'order' => 5, |
247 | 247 | 'persistent' => FALSE |
248 | 248 | ), |
249 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
249 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
250 | 250 | 'help_tabs' => array( |
251 | 251 | 'registration_form_add_question_group_help_tab' => array( |
252 | 252 | 'title' => esc_html__('Add Question Group', 'event_espresso'), |
253 | 253 | 'filename' => 'registration_form_add_question_group' |
254 | 254 | ), |
255 | 255 | ), |
256 | - 'help_tour' => array( 'Registration_Form_Add_Question_Group_Help_Tour'), |
|
256 | + 'help_tour' => array('Registration_Form_Add_Question_Group_Help_Tour'), |
|
257 | 257 | 'require_nonce' => FALSE |
258 | 258 | ), |
259 | 259 | |
@@ -262,16 +262,16 @@ discard block |
||
262 | 262 | 'label' => esc_html__('Edit Question Group', 'event_espresso'), |
263 | 263 | 'order' => 5, |
264 | 264 | 'persistent' => FALSE, |
265 | - 'url' => isset($this->_req_data['question_group_id']) ? add_query_arg(array('question_group_id' => $this->_req_data['question_group_id'] ), $this->_current_page_view_url ) : $this->_admin_base_url |
|
265 | + 'url' => isset($this->_req_data['question_group_id']) ? add_query_arg(array('question_group_id' => $this->_req_data['question_group_id']), $this->_current_page_view_url) : $this->_admin_base_url |
|
266 | 266 | ), |
267 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
|
267 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
268 | 268 | 'help_tabs' => array( |
269 | 269 | 'registration_form_edit_question_group_help_tab' => array( |
270 | 270 | 'title' => esc_html__('Edit Question Group', 'event_espresso'), |
271 | 271 | 'filename' => 'registration_form_edit_question_group' |
272 | 272 | ), |
273 | 273 | ), |
274 | - 'help_tour' => array( 'Registration_Form_Edit_Question_Group_Help_Tour'), |
|
274 | + 'help_tour' => array('Registration_Form_Edit_Question_Group_Help_Tour'), |
|
275 | 275 | 'require_nonce' => FALSE |
276 | 276 | ), |
277 | 277 | |
@@ -283,19 +283,19 @@ discard block |
||
283 | 283 | 'labels' => array( |
284 | 284 | 'publishbox' => esc_html__('Update Settings', 'event_espresso') |
285 | 285 | ), |
286 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
286 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
287 | 287 | 'help_tabs' => array( |
288 | 288 | 'registration_form_reg_form_settings_help_tab' => array( |
289 | 289 | 'title' => esc_html__('Registration Form Settings', 'event_espresso'), |
290 | 290 | 'filename' => 'registration_form_reg_form_settings' |
291 | 291 | ), |
292 | 292 | ), |
293 | - 'help_tour' => array( 'Registration_Form_Settings_Help_Tour'), |
|
293 | + 'help_tour' => array('Registration_Form_Settings_Help_Tour'), |
|
294 | 294 | 'require_nonce' => FALSE |
295 | 295 | ) |
296 | 296 | |
297 | 297 | ); |
298 | - $this->_page_config = array_merge( $this->_page_config, $new_page_config ); |
|
298 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
299 | 299 | |
300 | 300 | //change the list table we're going to use so it's the NEW list table! |
301 | 301 | $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table'; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
310 | 310 | 'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'), |
311 | 311 | ); |
312 | - $this->_labels['buttons'] = array_merge( $this->_labels['buttons'], $new_labels ); |
|
312 | + $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels); |
|
313 | 313 | |
314 | 314 | } |
315 | 315 | |
@@ -318,14 +318,14 @@ discard block |
||
318 | 318 | |
319 | 319 | |
320 | 320 | protected function _ajax_hooks() { |
321 | - add_action('wp_ajax_espresso_update_question_group_order', array( $this, 'update_question_group_order' )); |
|
321 | + add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order')); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | |
325 | 325 | |
326 | 326 | |
327 | 327 | public function load_scripts_styles_question_groups() { |
328 | - wp_enqueue_script( 'espresso_ajax_table_sorting' ); |
|
328 | + wp_enqueue_script('espresso_ajax_table_sorting'); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | * @return void |
347 | 347 | */ |
348 | 348 | public function load_sortable_question_script() { |
349 | - wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
349 | + wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL.'ee_question_order.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
350 | 350 | wp_enqueue_script('ee-question-sortable'); |
351 | 351 | } |
352 | 352 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | ) |
366 | 366 | ); |
367 | 367 | |
368 | - if ( EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions' ) ) { |
|
368 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions')) { |
|
369 | 369 | $this->_views['trash'] = array( |
370 | 370 | 'slug' => 'trash', |
371 | 371 | 'label' => esc_html__('Trash', 'event_espresso'), |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | ) |
396 | 396 | ); |
397 | 397 | |
398 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_question_groups', 'espresso_registration_form_trash_question_groups' ) ) { |
|
398 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_question_groups', 'espresso_registration_form_trash_question_groups')) { |
|
399 | 399 | $this->_views['trash'] = array( |
400 | 400 | 'slug' => 'trash', |
401 | 401 | 'label' => esc_html__('Trash', 'event_espresso'), |
@@ -421,8 +421,8 @@ discard block |
||
421 | 421 | *_forms_overview_list_table |
422 | 422 | */ |
423 | 423 | protected function _forms_overview_list_table() { |
424 | - $this->_search_btn_label = __( 'Forms', 'event_espresso' ); |
|
425 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
424 | + $this->_search_btn_label = __('Forms', 'event_espresso'); |
|
425 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
426 | 426 | 'add_question_group', |
427 | 427 | 'add_question_group', |
428 | 428 | array(), |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @param bool $trashed |
441 | 441 | * @return \EEM_Question_Group[]|int |
442 | 442 | */ |
443 | - public function get_form_sections( $per_page = 10, $current_page = 1, $count = false, $trashed = false ) { |
|
443 | + public function get_form_sections($per_page = 10, $current_page = 1, $count = false, $trashed = false) { |
|
444 | 444 | return $this->get_form_sections_or_inputs( |
445 | 445 | EEM_Question_Group::instance(), |
446 | 446 | $per_page, |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | * @param bool $trashed |
460 | 460 | * @return \EEM_Question_Group[]|int |
461 | 461 | */ |
462 | - public function get_form_inputs( $per_page = 10, $current_page = 1, $count = false, $trashed = false ) { |
|
462 | + public function get_form_inputs($per_page = 10, $current_page = 1, $count = false, $trashed = false) { |
|
463 | 463 | return $this->get_form_sections_or_inputs( |
464 | 464 | EEM_Question_Group::instance(), |
465 | 465 | $per_page, |
@@ -487,65 +487,65 @@ discard block |
||
487 | 487 | $trashed = false |
488 | 488 | ) { |
489 | 489 | $query_params = array(); |
490 | - $offset = ( $current_page - 1 ) * $per_page; |
|
491 | - $query_params[ 'limit' ] = array( $offset, $per_page ); |
|
492 | - $order = ( isset( $this->_req_data[ 'order' ] ) && ! empty( $this->_req_data[ 'order' ] ) ) |
|
493 | - ? $this->_req_data[ 'order' ] |
|
490 | + $offset = ($current_page - 1) * $per_page; |
|
491 | + $query_params['limit'] = array($offset, $per_page); |
|
492 | + $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) |
|
493 | + ? $this->_req_data['order'] |
|
494 | 494 | : 'ASC'; |
495 | 495 | $orderby_field = $model instanceof EEM_Question_Group |
496 | 496 | ? 'QSG_order' |
497 | 497 | : 'QST_order'; |
498 | - $field_to_order_by = empty( $this->_req_data[ 'orderby' ] ) |
|
498 | + $field_to_order_by = empty($this->_req_data['orderby']) |
|
499 | 499 | ? $orderby_field |
500 | - : $this->_req_data[ 'orderby' ]; |
|
501 | - $query_params[ 'order_by' ] = array( $field_to_order_by => $order ); |
|
502 | - $search_string = isset( $this->_req_data[ 's' ] ) |
|
503 | - ? $this->_req_data[ 's' ] |
|
500 | + : $this->_req_data['orderby']; |
|
501 | + $query_params['order_by'] = array($field_to_order_by => $order); |
|
502 | + $search_string = isset($this->_req_data['s']) |
|
503 | + ? $this->_req_data['s'] |
|
504 | 504 | : null; |
505 | - if ( ! empty( $search_string ) ) { |
|
506 | - if ( $model instanceof EEM_Question_Group ) { |
|
507 | - $query_params[ 0 ] = array( |
|
505 | + if ( ! empty($search_string)) { |
|
506 | + if ($model instanceof EEM_Question_Group) { |
|
507 | + $query_params[0] = array( |
|
508 | 508 | 'OR' => array( |
509 | - 'QSG_name' => array( 'LIKE', "%$search_string%" ), |
|
510 | - 'QSG_desc' => array( 'LIKE', "%$search_string%" ) |
|
509 | + 'QSG_name' => array('LIKE', "%$search_string%"), |
|
510 | + 'QSG_desc' => array('LIKE', "%$search_string%") |
|
511 | 511 | ) |
512 | 512 | ); |
513 | - } elseif ( $model instanceof EEM_Question ) { |
|
514 | - $query_params[ 0 ] = array( |
|
515 | - 'QST_display_text' => array( 'LIKE', "%$search_string%" ) |
|
513 | + } elseif ($model instanceof EEM_Question) { |
|
514 | + $query_params[0] = array( |
|
515 | + 'QST_display_text' => array('LIKE', "%$search_string%") |
|
516 | 516 | ); |
517 | 517 | } |
518 | 518 | } |
519 | - if ( $model instanceof EEM_Question_Group ) { |
|
520 | - $query_params[ 0 ][ 'QSG_parent' ] = array( 'IS NULL' ); |
|
519 | + if ($model instanceof EEM_Question_Group) { |
|
520 | + $query_params[0]['QSG_parent'] = array('IS NULL'); |
|
521 | 521 | } |
522 | - $where = isset( $query_params[ 0 ] ) ? array( $query_params[ 0 ] ) : array(); |
|
523 | - if ( $trashed ) { |
|
524 | - return $count ? $model->count_deleted( $where ) : $model->get_all_deleted( $query_params ); |
|
522 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
523 | + if ($trashed) { |
|
524 | + return $count ? $model->count_deleted($where) : $model->get_all_deleted($query_params); |
|
525 | 525 | } |
526 | - return $count ? $model->count( $where ) : $model->get_all( $query_params ); |
|
526 | + return $count ? $model->count($where) : $model->get_all($query_params); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | |
530 | 530 | |
531 | - protected function _delete_question(){ |
|
532 | - $success = $this->_delete_items( $this->_question_model ); |
|
531 | + protected function _delete_question() { |
|
532 | + $success = $this->_delete_items($this->_question_model); |
|
533 | 533 | $this->_redirect_after_action( |
534 | 534 | $success, |
535 | - $this->_question_model->item_name( $success ), |
|
535 | + $this->_question_model->item_name($success), |
|
536 | 536 | 'deleted', |
537 | - array( 'action' => 'default', 'status' => 'all' ) |
|
537 | + array('action' => 'default', 'status' => 'all') |
|
538 | 538 | ); |
539 | 539 | } |
540 | 540 | |
541 | 541 | |
542 | 542 | protected function _delete_questions() { |
543 | - $success = $this->_delete_items( $this->_question_model ); |
|
543 | + $success = $this->_delete_items($this->_question_model); |
|
544 | 544 | $this->_redirect_after_action( |
545 | 545 | $success, |
546 | - $this->_question_model->item_name( $success ), |
|
546 | + $this->_question_model->item_name($success), |
|
547 | 547 | 'deleted permanently', |
548 | - array( 'action' => 'default', 'status' => 'trash' ) |
|
548 | + array('action' => 'default', 'status' => 'trash') |
|
549 | 549 | ); |
550 | 550 | } |
551 | 551 | |
@@ -556,26 +556,26 @@ discard block |
||
556 | 556 | * @param EEM_Soft_Delete_Base $model |
557 | 557 | * @return int number of items deleted permanently |
558 | 558 | */ |
559 | - private function _delete_items(EEM_Soft_Delete_Base $model){ |
|
559 | + private function _delete_items(EEM_Soft_Delete_Base $model) { |
|
560 | 560 | $success = 0; |
561 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
562 | - if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
561 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
562 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
563 | 563 | // if array has more than one element than success message should be plural |
564 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
564 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
565 | 565 | // cycle thru bulk action checkboxes |
566 | - while (list( $ID, $value ) = each($this->_req_data['checkbox'])) { |
|
567 | - if ( ! $this->_delete_item( $ID, $model ) ) { |
|
566 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
567 | + if ( ! $this->_delete_item($ID, $model)) { |
|
568 | 568 | $success = 0; |
569 | 569 | } |
570 | 570 | } |
571 | 571 | |
572 | - }elseif( !empty($this->_req_data['QSG_ID'])){ |
|
573 | - $success = $this->_delete_item( $this->_req_data['QSG_ID'], $model ); |
|
572 | + }elseif ( ! empty($this->_req_data['QSG_ID'])) { |
|
573 | + $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
|
574 | 574 | |
575 | - }elseif( !empty($this->_req_data['QST_ID'])){ |
|
576 | - $success = $this->_delete_item( $this->_req_data['QST_ID'], $model ); |
|
577 | - }else{ |
|
578 | - EE_Error::add_error( sprintf(esc_html__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", "event_espresso")), __FILE__, __FUNCTION__, __LINE__ ); |
|
575 | + }elseif ( ! empty($this->_req_data['QST_ID'])) { |
|
576 | + $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
|
577 | + } else { |
|
578 | + EE_Error::add_error(sprintf(esc_html__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", "event_espresso")), __FILE__, __FUNCTION__, __LINE__); |
|
579 | 579 | } |
580 | 580 | return $success; |
581 | 581 | } |
@@ -586,11 +586,11 @@ discard block |
||
586 | 586 | * @param EEM_Soft_Delete_Base $model |
587 | 587 | * @return boolean |
588 | 588 | */ |
589 | - protected function _delete_item( $id, $model ) { |
|
590 | - if( $model instanceof EEM_Question ) { |
|
591 | - EEM_Question_Option::instance()->delete_permanently( array( array( 'QST_ID' => absint( $id ) ) ) ); |
|
589 | + protected function _delete_item($id, $model) { |
|
590 | + if ($model instanceof EEM_Question) { |
|
591 | + EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id)))); |
|
592 | 592 | } |
593 | - return $model->delete_permanently_by_ID( absint( $id ) ); |
|
593 | + return $model->delete_permanently_by_ID(absint($id)); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | |
@@ -602,41 +602,41 @@ discard block |
||
602 | 602 | |
603 | 603 | |
604 | 604 | |
605 | - protected function _edit_question_group( $type = 'add' ) { |
|
606 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
607 | - $ID=isset( $this->_req_data['QSG_ID'] ) && ! empty( $this->_req_data['QSG_ID'] ) ? absint( $this->_req_data['QSG_ID'] ) : FALSE; |
|
605 | + protected function _edit_question_group($type = 'add') { |
|
606 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
607 | + $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) ? absint($this->_req_data['QSG_ID']) : FALSE; |
|
608 | 608 | |
609 | - switch( $this->_req_action ) { |
|
609 | + switch ($this->_req_action) { |
|
610 | 610 | case 'add_question_group' : |
611 | - $this->_admin_page_title = esc_html__( 'Add Question Group', 'event_espresso' ); |
|
611 | + $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso'); |
|
612 | 612 | break; |
613 | 613 | case 'edit_question_group' : |
614 | - $this->_admin_page_title = esc_html__( 'Edit Question Group', 'event_espresso' ); |
|
614 | + $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso'); |
|
615 | 615 | break; |
616 | 616 | default : |
617 | - $this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action )); |
|
617 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
618 | 618 | } |
619 | 619 | // add ID to title if editing |
620 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
621 | - if($ID){ |
|
620 | + $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title; |
|
621 | + if ($ID) { |
|
622 | 622 | /** @var EE_Question_Group $questionGroup */ |
623 | - $questionGroup=$this->_question_group_model->get_one_by_ID( $ID); |
|
624 | - $additional_hidden_fields=array('QSG_ID'=>array('type'=>'hidden','value'=>$ID)); |
|
623 | + $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
|
624 | + $additional_hidden_fields = array('QSG_ID'=>array('type'=>'hidden', 'value'=>$ID)); |
|
625 | 625 | $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
626 | - }else{ |
|
626 | + } else { |
|
627 | 627 | /** @var EE_Question_Group $questionGroup */ |
628 | 628 | $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
629 | 629 | $questionGroup->set_order_to_latest(); |
630 | 630 | $this->_set_add_edit_form_tags('insert_question_group'); |
631 | 631 | } |
632 | 632 | $this->_template_args['values'] = $this->_yes_no_values; |
633 | - $this->_template_args['all_questions']=$questionGroup->questions_in_and_not_in_group(); |
|
634 | - $this->_template_args['QSG_ID']=$ID ? $ID : TRUE; |
|
635 | - $this->_template_args['question_group']=$questionGroup; |
|
633 | + $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group(); |
|
634 | + $this->_template_args['QSG_ID'] = $ID ? $ID : TRUE; |
|
635 | + $this->_template_args['question_group'] = $questionGroup; |
|
636 | 636 | |
637 | - $redirect_URL = add_query_arg( array( 'action' => 'question_groups'), $this->_admin_base_url ); |
|
638 | - $this->_set_publish_post_box_vars( 'id', $ID, FALSE, $redirect_URL ); |
|
639 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', $this->_template_args, TRUE ); |
|
637 | + $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
|
638 | + $this->_set_publish_post_box_vars('id', $ID, FALSE, $redirect_URL); |
|
639 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH.'question_groups_main_meta_box.template.php', $this->_template_args, TRUE); |
|
640 | 640 | |
641 | 641 | // the details template wrapper |
642 | 642 | $this->display_admin_page_with_sidebar(); |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | |
648 | 648 | protected function _delete_question_groups() { |
649 | 649 | $success = $this->_delete_items($this->_question_group_model); |
650 | - $this->_redirect_after_action( $success, $this->_question_group_model->item_name($success), 'deleted permanently', array( 'action'=>'question_groups', 'status'=>'trash' )); |
|
650 | + $this->_redirect_after_action($success, $this->_question_group_model->item_name($success), 'deleted permanently', array('action'=>'question_groups', 'status'=>'trash')); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | |
@@ -655,71 +655,71 @@ discard block |
||
655 | 655 | /** |
656 | 656 | * @param bool $new_question_group |
657 | 657 | */ |
658 | - protected function _insert_or_update_question_group( $new_question_group = TRUE) { |
|
659 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
660 | - $set_column_values=$this->_set_column_values_for($this->_question_group_model); |
|
661 | - if ( $new_question_group ){ |
|
658 | + protected function _insert_or_update_question_group($new_question_group = TRUE) { |
|
659 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
660 | + $set_column_values = $this->_set_column_values_for($this->_question_group_model); |
|
661 | + if ($new_question_group) { |
|
662 | 662 | $QSG_ID = $this->_question_group_model->insert($set_column_values); |
663 | 663 | $success = $QSG_ID ? 1 : 0; |
664 | 664 | } else { |
665 | 665 | $QSG_ID = absint($this->_req_data['QSG_ID']); |
666 | - unset( $set_column_values[ 'QSG_ID' ] ); |
|
667 | - $success= $this->_question_group_model->update( $set_column_values, array( array( 'QSG_ID' => $QSG_ID ))); |
|
666 | + unset($set_column_values['QSG_ID']); |
|
667 | + $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID))); |
|
668 | 668 | } |
669 | - $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( EEM_Attendee::system_question_phone ); |
|
669 | + $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(EEM_Attendee::system_question_phone); |
|
670 | 670 | // update the existing related questions |
671 | 671 | // BUT FIRST... delete the phone question from the Question_Group_Question if it is being added to this question group (therefore removed from the existing group) |
672 | - if ( isset( $this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ] )) { |
|
672 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) { |
|
673 | 673 | // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
674 | - EEM_Question_Group_Question::instance()->delete( array( array( 'QST_ID' => $phone_question_id, 'QSG_ID' => array( '!=', $QSG_ID )))); |
|
674 | + EEM_Question_Group_Question::instance()->delete(array(array('QST_ID' => $phone_question_id, 'QSG_ID' => array('!=', $QSG_ID)))); |
|
675 | 675 | } |
676 | 676 | /** @type EE_Question_Group $question_group */ |
677 | - $question_group=$this->_question_group_model->get_one_by_ID( $QSG_ID ); |
|
677 | + $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
|
678 | 678 | $questions = $question_group->questions(); |
679 | 679 | // make sure system phone question is added to list of questions for this group |
680 | - if ( ! isset( $questions[$phone_question_id ] )) { |
|
681 | - $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID( $phone_question_id ); |
|
680 | + if ( ! isset($questions[$phone_question_id])) { |
|
681 | + $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
682 | 682 | } |
683 | 683 | |
684 | - foreach( $questions as $question_ID => $question ){ |
|
684 | + foreach ($questions as $question_ID => $question) { |
|
685 | 685 | // first we always check for order. |
686 | - if ( ! empty( $this->_req_data['question_orders'][ $question_ID ] ) ){ |
|
686 | + if ( ! empty($this->_req_data['question_orders'][$question_ID])) { |
|
687 | 687 | //update question order |
688 | - $question_group->update_question_order( $question_ID, $this->_req_data['question_orders'][ $question_ID ] ); |
|
688 | + $question_group->update_question_order($question_ID, $this->_req_data['question_orders'][$question_ID]); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | // then we always check if adding or removing. |
692 | - if ( isset( $this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ] )) { |
|
693 | - $question_group->add_question( $question_ID ); |
|
692 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) { |
|
693 | + $question_group->add_question($question_ID); |
|
694 | 694 | } else { |
695 | 695 | // not found, remove it (but only if not a system question for the personal group with the exception of lname system question - we allow removal of it) |
696 | 696 | if ( |
697 | 697 | in_array( |
698 | 698 | $question->system_ID(), |
699 | - EEM_Question::instance()->required_system_questions_in_system_question_group( $question_group->system_group() ) |
|
699 | + EEM_Question::instance()->required_system_questions_in_system_question_group($question_group->system_group()) |
|
700 | 700 | ) |
701 | 701 | ) { |
702 | 702 | continue; |
703 | 703 | } else { |
704 | - $question_group->remove_question( $question_ID ); |
|
704 | + $question_group->remove_question($question_ID); |
|
705 | 705 | } |
706 | 706 | } |
707 | 707 | } |
708 | 708 | // save new related questions |
709 | - if ( isset( $this->_req_data['questions'] )) { |
|
710 | - foreach( $this->_req_data['questions'] as $QST_ID ){ |
|
711 | - $question_group->add_question( $QST_ID ); |
|
712 | - if ( isset( $this->_req_data['question_orders'][ $QST_ID ] )) { |
|
713 | - $question_group->update_question_order( $QST_ID, $this->_req_data['question_orders'][ $QST_ID ] ); |
|
709 | + if (isset($this->_req_data['questions'])) { |
|
710 | + foreach ($this->_req_data['questions'] as $QST_ID) { |
|
711 | + $question_group->add_question($QST_ID); |
|
712 | + if (isset($this->_req_data['question_orders'][$QST_ID])) { |
|
713 | + $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]); |
|
714 | 714 | } |
715 | 715 | } |
716 | 716 | } |
717 | 717 | |
718 | - if ( $success !== FALSE ) { |
|
719 | - $msg = $new_question_group ? sprintf( esc_html__('The %s has been created', 'event_espresso'), $this->_question_group_model->item_name() ) : sprintf( esc_html__('The %s has been updated', 'event_espresso' ), $this->_question_group_model->item_name() ); |
|
720 | - EE_Error::add_success( $msg ); |
|
718 | + if ($success !== FALSE) { |
|
719 | + $msg = $new_question_group ? sprintf(esc_html__('The %s has been created', 'event_espresso'), $this->_question_group_model->item_name()) : sprintf(esc_html__('The %s has been updated', 'event_espresso'), $this->_question_group_model->item_name()); |
|
720 | + EE_Error::add_success($msg); |
|
721 | 721 | } |
722 | - $this->_redirect_after_action(FALSE, '', '', array('action'=>'edit_question_group','QSG_ID'=>$QSG_ID), TRUE); |
|
722 | + $this->_redirect_after_action(FALSE, '', '', array('action'=>'edit_question_group', 'QSG_ID'=>$QSG_ID), TRUE); |
|
723 | 723 | |
724 | 724 | } |
725 | 725 | |
@@ -727,20 +727,20 @@ discard block |
||
727 | 727 | * duplicates a question and all its question options and redirects to the new question. |
728 | 728 | */ |
729 | 729 | public function _duplicate_question() { |
730 | - $question_ID = (int)$this->_req_data[ 'QST_ID' ]; |
|
731 | - $question = EEM_Question::instance()->get_one_by_ID( $question_ID ); |
|
732 | - if( $question instanceof EE_Question ) { |
|
730 | + $question_ID = (int) $this->_req_data['QST_ID']; |
|
731 | + $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
|
732 | + if ($question instanceof EE_Question) { |
|
733 | 733 | $new_question = $question->duplicate(); |
734 | - if( $new_question instanceof EE_Question ) { |
|
735 | - $this->_redirect_after_action( true, esc_html__( 'Question', 'event_espresso' ), esc_html__( 'Duplicated', 'event_espresso' ), array('action'=>'edit_question', 'QST_ID' => $new_question->ID() ), TRUE); |
|
734 | + if ($new_question instanceof EE_Question) { |
|
735 | + $this->_redirect_after_action(true, esc_html__('Question', 'event_espresso'), esc_html__('Duplicated', 'event_espresso'), array('action'=>'edit_question', 'QST_ID' => $new_question->ID()), TRUE); |
|
736 | 736 | } else { |
737 | 737 | global $wpdb; |
738 | - EE_Error::add_error( sprintf( esc_html__( 'Could not duplicate question with ID %1$d because: %2$s', 'event_espresso' ), $question_ID, $wpdb->last_error ), __FILE__, __FUNCTION__, __LINE__ ); |
|
739 | - $this->_redirect_after_action(false, '', '', array('action'=>'default'), false ); |
|
738 | + EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %1$d because: %2$s', 'event_espresso'), $question_ID, $wpdb->last_error), __FILE__, __FUNCTION__, __LINE__); |
|
739 | + $this->_redirect_after_action(false, '', '', array('action'=>'default'), false); |
|
740 | 740 | } |
741 | 741 | } else { |
742 | - EE_Error::add_error( sprintf( esc_html__( 'Could not duplicate question with ID %d because it didn\'t exist!', 'event_espresso' ), $question_ID ), __FILE__, __FUNCTION__, __LINE__ ); |
|
743 | - $this->_redirect_after_action( false, '', '', array( 'action' => 'default' ), false ); |
|
742 | + EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %d because it didn\'t exist!', 'event_espresso'), $question_ID), __FILE__, __FUNCTION__, __LINE__); |
|
743 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
744 | 744 | } |
745 | 745 | } |
746 | 746 | |
@@ -749,8 +749,8 @@ discard block |
||
749 | 749 | /** |
750 | 750 | * @param bool $trash |
751 | 751 | */ |
752 | - protected function _trash_or_restore_question_groups( $trash = TRUE) { |
|
753 | - $this->_trash_or_restore_items( $this->_question_group_model, $trash ); |
|
752 | + protected function _trash_or_restore_question_groups($trash = TRUE) { |
|
753 | + $this->_trash_or_restore_items($this->_question_group_model, $trash); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | |
@@ -758,9 +758,9 @@ discard block |
||
758 | 758 | /** |
759 | 759 | *_trash_question |
760 | 760 | */ |
761 | - protected function _trash_question(){ |
|
762 | - $success=$this->_question_model->delete_by_ID( (int)$this->_req_data['QST_ID'] ); |
|
763 | - $query_args=array('action'=>'default','status'=>'all'); |
|
761 | + protected function _trash_question() { |
|
762 | + $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']); |
|
763 | + $query_args = array('action'=>'default', 'status'=>'all'); |
|
764 | 764 | $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
765 | 765 | } |
766 | 766 | |
@@ -769,8 +769,8 @@ discard block |
||
769 | 769 | /** |
770 | 770 | * @param bool $trash |
771 | 771 | */ |
772 | - protected function _trash_or_restore_questions( $trash=TRUE){ |
|
773 | - $this->_trash_or_restore_items( $this->_question_model, $trash ); |
|
772 | + protected function _trash_or_restore_questions($trash = TRUE) { |
|
773 | + $this->_trash_or_restore_items($this->_question_model, $trash); |
|
774 | 774 | } |
775 | 775 | |
776 | 776 | |
@@ -782,21 +782,21 @@ discard block |
||
782 | 782 | *@param EEM_Soft_Delete_Base $model |
783 | 783 | * @param boolean $trash whether to trash or restore |
784 | 784 | */ |
785 | - private function _trash_or_restore_items( EEM_Soft_Delete_Base $model, $trash = TRUE ) { |
|
785 | + private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = TRUE) { |
|
786 | 786 | |
787 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
787 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
788 | 788 | |
789 | 789 | $success = 1; |
790 | 790 | //Checkboxes |
791 | 791 | //echo "trash $trash"; |
792 | 792 | //var_dump($this->_req_data['checkbox']);die; |
793 | - if ( isset( $this->_req_data['checkbox'] )) { |
|
794 | - if ( ! empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] )) { |
|
793 | + if (isset($this->_req_data['checkbox'])) { |
|
794 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
795 | 795 | // if array has more than one element than success message should be plural |
796 | - $success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1; |
|
796 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
797 | 797 | // cycle thru bulk action checkboxes |
798 | - while (list( $ID, $value ) = each($this->_req_data['checkbox'])) { |
|
799 | - if ( ! $model->delete_or_restore_by_ID($trash,absint($ID))) { |
|
798 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
799 | + if ( ! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
800 | 800 | $success = 0; |
801 | 801 | } |
802 | 802 | } |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | } else { |
805 | 805 | // grab single id and delete |
806 | 806 | $ID = absint($this->_req_data['checkbox']); |
807 | - if ( ! $model->delete_or_restore_by_ID($trash,$ID)) { |
|
807 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
808 | 808 | $success = 0; |
809 | 809 | } |
810 | 810 | } |
@@ -812,25 +812,25 @@ discard block |
||
812 | 812 | } else { |
813 | 813 | // delete via trash link |
814 | 814 | // grab single id and delete |
815 | - $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
816 | - if ( ! $model->delete_or_restore_by_ID($trash,$ID)) { |
|
815 | + $ID = absint($this->_req_data[$model->primary_key_name()]); |
|
816 | + if ( ! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
817 | 817 | $success = 0; |
818 | 818 | } |
819 | 819 | |
820 | 820 | } |
821 | 821 | |
822 | 822 | |
823 | - $action = $model instanceof EEM_Question ? 'default' : 'question_groups';//strtolower( $model->item_name(2) ); |
|
823 | + $action = $model instanceof EEM_Question ? 'default' : 'question_groups'; //strtolower( $model->item_name(2) ); |
|
824 | 824 | //echo "action :$action"; |
825 | 825 | //$action = 'questions' ? 'default' : $action; |
826 | - if($trash){ |
|
826 | + if ($trash) { |
|
827 | 827 | $action_desc = 'trashed'; |
828 | 828 | $status = 'trash'; |
829 | - }else{ |
|
829 | + } else { |
|
830 | 830 | $action_desc = 'restored'; |
831 | 831 | $status = 'all'; |
832 | 832 | } |
833 | - $this->_redirect_after_action( $success, $model->item_name($success), $action_desc, array( 'action' => $action, 'status'=>$status ) ); |
|
833 | + $this->_redirect_after_action($success, $model->item_name($success), $action_desc, array('action' => $action, 'status'=>$status)); |
|
834 | 834 | } |
835 | 835 | |
836 | 836 | |
@@ -841,16 +841,16 @@ discard block |
||
841 | 841 | * @param bool|false $count |
842 | 842 | * @return \EE_Soft_Delete_Base_Class[]|int |
843 | 843 | */ |
844 | - public function get_trashed_questions( $per_page, $current_page = 1, $count = FALSE ) { |
|
844 | + public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) { |
|
845 | 845 | $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
846 | 846 | |
847 | - if( $count ){ |
|
847 | + if ($count) { |
|
848 | 848 | //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
849 | - $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
|
850 | - $results=$this->_question_model->count_deleted($where); |
|
851 | - }else{ |
|
849 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
850 | + $results = $this->_question_model->count_deleted($where); |
|
851 | + } else { |
|
852 | 852 | //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
853 | - $results=$this->_question_model->get_all_deleted($query_params); |
|
853 | + $results = $this->_question_model->get_all_deleted($query_params); |
|
854 | 854 | } |
855 | 855 | return $results; |
856 | 856 | } |
@@ -863,13 +863,13 @@ discard block |
||
863 | 863 | * @param bool|false $count |
864 | 864 | * @return \EE_Soft_Delete_Base_Class[] |
865 | 865 | */ |
866 | - public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) { |
|
867 | - $questionGroupModel=EEM_Question_Group::instance(); |
|
868 | - $query_params=$this->get_query_params($questionGroupModel,$per_page,$current_page); |
|
869 | - if ($count){ |
|
870 | - $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
|
866 | + public function get_question_groups($per_page, $current_page = 1, $count = FALSE) { |
|
867 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
868 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
869 | + if ($count) { |
|
870 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
871 | 871 | $results = $questionGroupModel->count($where); |
872 | - }else{ |
|
872 | + } else { |
|
873 | 873 | $results = $questionGroupModel->get_all($query_params); |
874 | 874 | } |
875 | 875 | return $results; |
@@ -883,14 +883,14 @@ discard block |
||
883 | 883 | * @param bool $count |
884 | 884 | * @return \EE_Soft_Delete_Base_Class[]|int |
885 | 885 | */ |
886 | - public function get_trashed_question_groups( $per_page, $current_page = 1, $count = FALSE ) { |
|
887 | - $questionGroupModel=EEM_Question_Group::instance(); |
|
888 | - $query_params=$this->get_query_params($questionGroupModel,$per_page,$current_page); |
|
889 | - if($count){ |
|
890 | - $where = isset( $query_params[0] ) ? array($query_params[0]) : array(); |
|
886 | + public function get_trashed_question_groups($per_page, $current_page = 1, $count = FALSE) { |
|
887 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
888 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
889 | + if ($count) { |
|
890 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
891 | 891 | $query_params['limit'] = NULL; |
892 | 892 | $results = $questionGroupModel->count_deleted($where); |
893 | - }else{ |
|
893 | + } else { |
|
894 | 894 | $results = $questionGroupModel->get_all_deleted($query_params); |
895 | 895 | } |
896 | 896 | return $results; |
@@ -906,28 +906,28 @@ discard block |
||
906 | 906 | */ |
907 | 907 | public function update_question_group_order() { |
908 | 908 | |
909 | - $success = esc_html__( 'Question group order was updated successfully.', 'event_espresso' ); |
|
909 | + $success = esc_html__('Question group order was updated successfully.', 'event_espresso'); |
|
910 | 910 | |
911 | 911 | // grab our row IDs |
912 | - $row_ids = isset( $this->_req_data['row_ids'] ) && ! empty( $this->_req_data['row_ids'] ) |
|
913 | - ? explode( ',', rtrim( $this->_req_data['row_ids'], ',' )) |
|
912 | + $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) |
|
913 | + ? explode(',', rtrim($this->_req_data['row_ids'], ',')) |
|
914 | 914 | : array(); |
915 | 915 | |
916 | - $perpage = !empty( $this->_req_data['perpage'] ) |
|
916 | + $perpage = ! empty($this->_req_data['perpage']) |
|
917 | 917 | ? (int) $this->_req_data['perpage'] |
918 | 918 | : NULL; |
919 | - $curpage = !empty( $this->_req_data['curpage'] ) |
|
919 | + $curpage = ! empty($this->_req_data['curpage']) |
|
920 | 920 | ? (int) $this->_req_data['curpage'] |
921 | 921 | : NULL; |
922 | 922 | |
923 | - if ( ! empty( $row_ids ) ) { |
|
923 | + if ( ! empty($row_ids)) { |
|
924 | 924 | //figure out where we start the row_id count at for the current page. |
925 | - $qsg_count = empty( $curpage ) ? 0 : ($curpage - 1 ) * $perpage; |
|
926 | - foreach ( $row_ids as $row_id ) { |
|
925 | + $qsg_count = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
|
926 | + foreach ($row_ids as $row_id) { |
|
927 | 927 | //Update the questions when re-ordering |
928 | 928 | $updated = EEM_Question_Group::instance()->update( |
929 | - array( 'QSG_order' => $qsg_count ), |
|
930 | - array( array( 'QSG_ID' => $row_id ) ) |
|
929 | + array('QSG_order' => $qsg_count), |
|
930 | + array(array('QSG_ID' => $row_id)) |
|
931 | 931 | ); |
932 | 932 | $success = $updated === false ? false : $success; |
933 | 933 | $qsg_count++; |
@@ -937,10 +937,10 @@ discard block |
||
937 | 937 | } |
938 | 938 | |
939 | 939 | $errors = ! $success |
940 | - ? esc_html__( 'An error occurred. The question group order was not updated.', 'event_espresso' ) |
|
940 | + ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso') |
|
941 | 941 | : false; |
942 | 942 | |
943 | - echo json_encode( array( 'return_data' => false, 'success' => $success, 'errors' => $errors )); |
|
943 | + echo json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors)); |
|
944 | 944 | die(); |
945 | 945 | |
946 | 946 | } |
@@ -959,17 +959,17 @@ discard block |
||
959 | 959 | $this->_template_args['values'] = $this->_yes_no_values; |
960 | 960 | add_action( |
961 | 961 | 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
962 | - array( $this, 'email_validation_settings_form' ), |
|
962 | + array($this, 'email_validation_settings_form'), |
|
963 | 963 | 2 |
964 | 964 | ); |
965 | - $this->_template_args = (array)apply_filters( |
|
965 | + $this->_template_args = (array) apply_filters( |
|
966 | 966 | 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
967 | 967 | $this->_template_args |
968 | 968 | ); |
969 | - $this->_set_add_edit_form_tags( 'update_reg_form_settings' ); |
|
970 | - $this->_set_publish_post_box_vars( null, false, false, null, false ); |
|
969 | + $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
970 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
971 | 971 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
972 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
972 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH.'reg_form_settings.template.php', |
|
973 | 973 | $this->_template_args, |
974 | 974 | true |
975 | 975 | ); |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | EE_Registry::instance()->CFG, |
991 | 991 | __FILE__, __FUNCTION__, __LINE__ |
992 | 992 | ); |
993 | - $this->_redirect_after_action( $success, esc_html__('Registration Form Options', 'event_espresso'), 'updated', array( 'action' => 'view_reg_form_settings' ) ); |
|
993 | + $this->_redirect_after_action($success, esc_html__('Registration Form Options', 'event_espresso'), 'updated', array('action' => 'view_reg_form_settings')); |
|
994 | 994 | } |
995 | 995 | |
996 | 996 | |
@@ -1023,20 +1023,20 @@ discard block |
||
1023 | 1023 | 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
1024 | 1024 | 'subsections' => array( |
1025 | 1025 | 'email_validation_hdr' => new EE_Form_Section_HTML( |
1026 | - EEH_HTML::h2( esc_html__( 'Email Validation Settings', 'event_espresso' ) ) |
|
1026 | + EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso')) |
|
1027 | 1027 | ), |
1028 | 1028 | 'email_validation_level' => new EE_Select_Input( |
1029 | 1029 | array( |
1030 | - 'basic' => esc_html__( 'Basic', 'event_espresso' ), |
|
1031 | - 'wp_default' => esc_html__( 'WordPress Default', 'event_espresso' ), |
|
1032 | - 'i18n' => esc_html__( 'International', 'event_espresso' ), |
|
1033 | - 'i18n_dns' => esc_html__( 'International + DNS Check', 'event_espresso' ), |
|
1030 | + 'basic' => esc_html__('Basic', 'event_espresso'), |
|
1031 | + 'wp_default' => esc_html__('WordPress Default', 'event_espresso'), |
|
1032 | + 'i18n' => esc_html__('International', 'event_espresso'), |
|
1033 | + 'i18n_dns' => esc_html__('International + DNS Check', 'event_espresso'), |
|
1034 | 1034 | ), |
1035 | 1035 | array( |
1036 | - 'html_label_text' => esc_html__( 'Email Validation Level', 'event_espresso' ) |
|
1037 | - . EEH_Template::get_help_tab_link( 'email_validation_info' ), |
|
1038 | - 'html_help_text' => esc_html__( 'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', 'event_espresso'), |
|
1039 | - 'default' => isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
|
1036 | + 'html_label_text' => esc_html__('Email Validation Level', 'event_espresso') |
|
1037 | + . EEH_Template::get_help_tab_link('email_validation_info'), |
|
1038 | + 'html_help_text' => esc_html__('These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', 'event_espresso'), |
|
1039 | + 'default' => isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
1040 | 1040 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
1041 | 1041 | : 'wp_default', |
1042 | 1042 | 'required' => false |
@@ -1055,25 +1055,25 @@ discard block |
||
1055 | 1055 | * @param \EE_Registration_Config $EE_Registration_Config |
1056 | 1056 | * @return \EE_Registration_Config |
1057 | 1057 | */ |
1058 | - public function update_email_validation_settings_form( EE_Registration_Config $EE_Registration_Config ) { |
|
1058 | + public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) { |
|
1059 | 1059 | $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
1060 | 1060 | try { |
1061 | 1061 | $email_validation_settings_form = $this->_email_validation_settings_form(); |
1062 | 1062 | // if not displaying a form, then check for form submission |
1063 | - if ( $email_validation_settings_form->was_submitted() ) { |
|
1063 | + if ($email_validation_settings_form->was_submitted()) { |
|
1064 | 1064 | // capture form data |
1065 | 1065 | $email_validation_settings_form->receive_form_submission(); |
1066 | 1066 | // validate form data |
1067 | - if ( $email_validation_settings_form->is_valid() ) { |
|
1067 | + if ($email_validation_settings_form->is_valid()) { |
|
1068 | 1068 | // grab validated data from form |
1069 | 1069 | $valid_data = $email_validation_settings_form->valid_data(); |
1070 | - if ( isset( $valid_data['email_validation_level'] ) ) { |
|
1070 | + if (isset($valid_data['email_validation_level'])) { |
|
1071 | 1071 | $email_validation_level = $valid_data['email_validation_level']; |
1072 | 1072 | // now if they want to use international email addresses |
1073 | - if ( $email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns' ) { |
|
1073 | + if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') { |
|
1074 | 1074 | // in case we need to reset their email validation level, |
1075 | 1075 | // make sure that the previous value wasn't already set to one of the i18n options. |
1076 | - if ( $prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns' ) { |
|
1076 | + if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') { |
|
1077 | 1077 | // if so, then reset it back to "basic" since that is the only other option that, |
1078 | 1078 | // despite offering poor validation, supports i18n email addresses |
1079 | 1079 | $prev_email_validation_level = 'basic'; |
@@ -1095,7 +1095,7 @@ discard block |
||
1095 | 1095 | ); |
1096 | 1096 | } |
1097 | 1097 | } else { |
1098 | - if ( $email_validation_settings_form->submission_error_message() !== '' ) { |
|
1098 | + if ($email_validation_settings_form->submission_error_message() !== '') { |
|
1099 | 1099 | EE_Error::add_error( |
1100 | 1100 | $email_validation_settings_form->submission_error_message(), |
1101 | 1101 | __FILE__, __FUNCTION__, __LINE__ |
@@ -1103,7 +1103,7 @@ discard block |
||
1103 | 1103 | } |
1104 | 1104 | } |
1105 | 1105 | } |
1106 | - } catch ( EE_Error $e ) { |
|
1106 | + } catch (EE_Error $e) { |
|
1107 | 1107 | $e->get_error(); |
1108 | 1108 | } |
1109 | 1109 | return $EE_Registration_Config; |
@@ -512,7 +512,7 @@ |
||
512 | 512 | * Deletes the specified question (and its associated question options) or question group |
513 | 513 | * @param int $id |
514 | 514 | * @param EEM_Soft_Delete_Base $model |
515 | - * @return boolean |
|
515 | + * @return integer |
|
516 | 516 | */ |
517 | 517 | protected function _delete_item( $id, $model ) { |
518 | 518 | if( $model instanceof EEM_Question ) { |
@@ -230,13 +230,13 @@ discard block |
||
230 | 230 | 'persistent' => FALSE |
231 | 231 | ), |
232 | 232 | 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ), |
233 | - 'help_tabs' => array( |
|
233 | + 'help_tabs' => array( |
|
234 | 234 | 'registration_form_add_question_help_tab' => array( |
235 | 235 | 'title' => esc_html__('Add Question', 'event_espresso'), |
236 | 236 | 'filename' => 'registration_form_add_question' |
237 | 237 | ), |
238 | 238 | ), |
239 | - 'help_tour' => array( 'Registration_Form_Add_Question_Help_Tour'), |
|
239 | + 'help_tour' => array( 'Registration_Form_Add_Question_Help_Tour'), |
|
240 | 240 | 'require_nonce' => FALSE |
241 | 241 | ), |
242 | 242 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | 'filename' => 'registration_form_add_question_group' |
254 | 254 | ), |
255 | 255 | ), |
256 | - 'help_tour' => array( 'Registration_Form_Add_Question_Group_Help_Tour'), |
|
256 | + 'help_tour' => array( 'Registration_Form_Add_Question_Group_Help_Tour'), |
|
257 | 257 | 'require_nonce' => FALSE |
258 | 258 | ), |
259 | 259 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | 'filename' => 'registration_form_edit_question_group' |
272 | 272 | ), |
273 | 273 | ), |
274 | - 'help_tour' => array( 'Registration_Form_Edit_Question_Group_Help_Tour'), |
|
274 | + 'help_tour' => array( 'Registration_Form_Edit_Question_Group_Help_Tour'), |
|
275 | 275 | 'require_nonce' => FALSE |
276 | 276 | ), |
277 | 277 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | 'filename' => 'registration_form_reg_form_settings' |
291 | 291 | ), |
292 | 292 | ), |
293 | - 'help_tour' => array( 'Registration_Form_Settings_Help_Tour'), |
|
293 | + 'help_tour' => array( 'Registration_Form_Settings_Help_Tour'), |
|
294 | 294 | 'require_nonce' => FALSE |
295 | 295 | ) |
296 | 296 | |
@@ -1016,7 +1016,7 @@ discard block |
||
1016 | 1016 | * @throws \EE_Error |
1017 | 1017 | */ |
1018 | 1018 | protected function _email_validation_settings_form() { |
1019 | - return new EE_Form_Section_Proper( |
|
1019 | + return new EE_Form_Section_Proper( |
|
1020 | 1020 | array( |
1021 | 1021 | 'name' => 'email_validation_settings', |
1022 | 1022 | 'html_id' => 'email_validation_settings', |
@@ -1034,7 +1034,7 @@ discard block |
||
1034 | 1034 | ), |
1035 | 1035 | array( |
1036 | 1036 | 'html_label_text' => esc_html__( 'Email Validation Level', 'event_espresso' ) |
1037 | - . EEH_Template::get_help_tab_link( 'email_validation_info' ), |
|
1037 | + . EEH_Template::get_help_tab_link( 'email_validation_info' ), |
|
1038 | 1038 | 'html_help_text' => esc_html__( 'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', 'event_espresso'), |
1039 | 1039 | 'default' => isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
1040 | 1040 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
@@ -1056,8 +1056,8 @@ discard block |
||
1056 | 1056 | * @return \EE_Registration_Config |
1057 | 1057 | */ |
1058 | 1058 | public function update_email_validation_settings_form( EE_Registration_Config $EE_Registration_Config ) { |
1059 | - $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
1060 | - try { |
|
1059 | + $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
1060 | + try { |
|
1061 | 1061 | $email_validation_settings_form = $this->_email_validation_settings_form(); |
1062 | 1062 | // if not displaying a form, then check for form submission |
1063 | 1063 | if ( $email_validation_settings_form->was_submitted() ) { |
@@ -1068,38 +1068,38 @@ discard block |
||
1068 | 1068 | // grab validated data from form |
1069 | 1069 | $valid_data = $email_validation_settings_form->valid_data(); |
1070 | 1070 | if ( isset( $valid_data['email_validation_level'] ) ) { |
1071 | - $email_validation_level = $valid_data['email_validation_level']; |
|
1072 | - // now if they want to use international email addresses |
|
1073 | - if ( $email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns' ) { |
|
1074 | - // in case we need to reset their email validation level, |
|
1075 | - // make sure that the previous value wasn't already set to one of the i18n options. |
|
1076 | - if ( $prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns' ) { |
|
1077 | - // if so, then reset it back to "basic" since that is the only other option that, |
|
1078 | - // despite offering poor validation, supports i18n email addresses |
|
1079 | - $prev_email_validation_level = 'basic'; |
|
1080 | - } |
|
1081 | - // confirm our i18n email validation will work on the server |
|
1082 | - if ( ! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1083 | - // or reset email validation level to previous value |
|
1084 | - $email_validation_level = $prev_email_validation_level; |
|
1085 | - } |
|
1086 | - } |
|
1087 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1088 | - } else { |
|
1071 | + $email_validation_level = $valid_data['email_validation_level']; |
|
1072 | + // now if they want to use international email addresses |
|
1073 | + if ( $email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns' ) { |
|
1074 | + // in case we need to reset their email validation level, |
|
1075 | + // make sure that the previous value wasn't already set to one of the i18n options. |
|
1076 | + if ( $prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns' ) { |
|
1077 | + // if so, then reset it back to "basic" since that is the only other option that, |
|
1078 | + // despite offering poor validation, supports i18n email addresses |
|
1079 | + $prev_email_validation_level = 'basic'; |
|
1080 | + } |
|
1081 | + // confirm our i18n email validation will work on the server |
|
1082 | + if ( ! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1083 | + // or reset email validation level to previous value |
|
1084 | + $email_validation_level = $prev_email_validation_level; |
|
1085 | + } |
|
1086 | + } |
|
1087 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1088 | + } else { |
|
1089 | 1089 | EE_Error::add_error( |
1090 | 1090 | esc_html__( |
1091 | 1091 | 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
1092 | 1092 | 'event_espresso' |
1093 | 1093 | ), |
1094 | - __FILE__, __FUNCTION__, __LINE__ |
|
1095 | - ); |
|
1094 | + __FILE__, __FUNCTION__, __LINE__ |
|
1095 | + ); |
|
1096 | 1096 | } |
1097 | 1097 | } else { |
1098 | 1098 | if ( $email_validation_settings_form->submission_error_message() !== '' ) { |
1099 | 1099 | EE_Error::add_error( |
1100 | 1100 | $email_validation_settings_form->submission_error_message(), |
1101 | - __FILE__, __FUNCTION__, __LINE__ |
|
1102 | - ); |
|
1101 | + __FILE__, __FUNCTION__, __LINE__ |
|
1102 | + ); |
|
1103 | 1103 | } |
1104 | 1104 | } |
1105 | 1105 | } |
@@ -1111,61 +1111,61 @@ discard block |
||
1111 | 1111 | |
1112 | 1112 | |
1113 | 1113 | |
1114 | - /** |
|
1115 | - * confirms that the server's PHP version has the PCRE module enabled, |
|
1116 | - * and that the PCRE version works with our i18n email validation |
|
1117 | - * |
|
1118 | - * @param \EE_Registration_Config $EE_Registration_Config |
|
1119 | - * @param string $email_validation_level |
|
1120 | - * @return bool |
|
1121 | - */ |
|
1122 | - private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1123 | - { |
|
1124 | - // first check that PCRE is enabled |
|
1125 | - if ( ! defined('PREG_BAD_UTF8_ERROR')) { |
|
1126 | - EE_Error::add_error( |
|
1127 | - sprintf( |
|
1128 | - esc_html__( |
|
1129 | - 'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.', |
|
1130 | - 'event_espresso' |
|
1131 | - ), |
|
1132 | - '<br />' |
|
1133 | - ), |
|
1134 | - __FILE__, |
|
1135 | - __FUNCTION__, |
|
1136 | - __LINE__ |
|
1137 | - ); |
|
1138 | - return false; |
|
1139 | - } else { |
|
1140 | - // PCRE support is enabled, but let's still |
|
1141 | - // perform a test to see if the server will support it. |
|
1142 | - // but first, save the updated validation level to the config, |
|
1143 | - // so that the validation strategy picks it up. |
|
1144 | - // this will get bumped back down if it doesn't work |
|
1145 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1146 | - try { |
|
1147 | - $email_validator = new EE_Email_Validation_Strategy(); |
|
1148 | - $i18n_email_address = apply_filters( |
|
1149 | - 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1150 | - 'jägerjü[email protected]' |
|
1151 | - ); |
|
1152 | - $email_validator->validate($i18n_email_address); |
|
1153 | - } catch (Exception $e) { |
|
1154 | - EE_Error::add_error( |
|
1155 | - sprintf( |
|
1156 | - esc_html__( |
|
1157 | - 'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s', |
|
1158 | - 'event_espresso' |
|
1159 | - ), |
|
1160 | - '<br />', |
|
1161 | - '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank">http://php.net/manual/en/pcre.installation.php</a>' |
|
1162 | - ), |
|
1163 | - __FILE__, __FUNCTION__, __LINE__ |
|
1164 | - ); |
|
1165 | - return false; |
|
1166 | - } |
|
1167 | - } |
|
1168 | - return true; |
|
1169 | - } |
|
1114 | + /** |
|
1115 | + * confirms that the server's PHP version has the PCRE module enabled, |
|
1116 | + * and that the PCRE version works with our i18n email validation |
|
1117 | + * |
|
1118 | + * @param \EE_Registration_Config $EE_Registration_Config |
|
1119 | + * @param string $email_validation_level |
|
1120 | + * @return bool |
|
1121 | + */ |
|
1122 | + private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1123 | + { |
|
1124 | + // first check that PCRE is enabled |
|
1125 | + if ( ! defined('PREG_BAD_UTF8_ERROR')) { |
|
1126 | + EE_Error::add_error( |
|
1127 | + sprintf( |
|
1128 | + esc_html__( |
|
1129 | + 'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.', |
|
1130 | + 'event_espresso' |
|
1131 | + ), |
|
1132 | + '<br />' |
|
1133 | + ), |
|
1134 | + __FILE__, |
|
1135 | + __FUNCTION__, |
|
1136 | + __LINE__ |
|
1137 | + ); |
|
1138 | + return false; |
|
1139 | + } else { |
|
1140 | + // PCRE support is enabled, but let's still |
|
1141 | + // perform a test to see if the server will support it. |
|
1142 | + // but first, save the updated validation level to the config, |
|
1143 | + // so that the validation strategy picks it up. |
|
1144 | + // this will get bumped back down if it doesn't work |
|
1145 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1146 | + try { |
|
1147 | + $email_validator = new EE_Email_Validation_Strategy(); |
|
1148 | + $i18n_email_address = apply_filters( |
|
1149 | + 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1150 | + 'jägerjü[email protected]' |
|
1151 | + ); |
|
1152 | + $email_validator->validate($i18n_email_address); |
|
1153 | + } catch (Exception $e) { |
|
1154 | + EE_Error::add_error( |
|
1155 | + sprintf( |
|
1156 | + esc_html__( |
|
1157 | + 'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s', |
|
1158 | + 'event_espresso' |
|
1159 | + ), |
|
1160 | + '<br />', |
|
1161 | + '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank">http://php.net/manual/en/pcre.installation.php</a>' |
|
1162 | + ), |
|
1163 | + __FILE__, __FUNCTION__, __LINE__ |
|
1164 | + ); |
|
1165 | + return false; |
|
1166 | + } |
|
1167 | + } |
|
1168 | + return true; |
|
1169 | + } |
|
1170 | 1170 | |
1171 | 1171 | } |
@@ -497,12 +497,12 @@ discard block |
||
497 | 497 | } |
498 | 498 | } |
499 | 499 | |
500 | - }elseif( !empty($this->_req_data['QSG_ID'])){ |
|
500 | + } elseif( !empty($this->_req_data['QSG_ID'])){ |
|
501 | 501 | $success = $this->_delete_item( $this->_req_data['QSG_ID'], $model ); |
502 | 502 | |
503 | - }elseif( !empty($this->_req_data['QST_ID'])){ |
|
503 | + } elseif( !empty($this->_req_data['QST_ID'])){ |
|
504 | 504 | $success = $this->_delete_item( $this->_req_data['QST_ID'], $model ); |
505 | - }else{ |
|
505 | + } else{ |
|
506 | 506 | EE_Error::add_error( sprintf(esc_html__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", "event_espresso")), __FILE__, __FUNCTION__, __LINE__ ); |
507 | 507 | } |
508 | 508 | return $success; |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | $questionGroup=$this->_question_group_model->get_one_by_ID( $ID); |
552 | 552 | $additional_hidden_fields=array('QSG_ID'=>array('type'=>'hidden','value'=>$ID)); |
553 | 553 | $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
554 | - }else{ |
|
554 | + } else{ |
|
555 | 555 | /** @var EE_Question_Group $questionGroup */ |
556 | 556 | $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
557 | 557 | $questionGroup->set_order_to_latest(); |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | if($trash){ |
755 | 755 | $action_desc = 'trashed'; |
756 | 756 | $status = 'trash'; |
757 | - }else{ |
|
757 | + } else{ |
|
758 | 758 | $action_desc = 'restored'; |
759 | 759 | $status = 'all'; |
760 | 760 | } |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
777 | 777 | $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
778 | 778 | $results=$this->_question_model->count_deleted($where); |
779 | - }else{ |
|
779 | + } else{ |
|
780 | 780 | //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
781 | 781 | $results=$this->_question_model->get_all_deleted($query_params); |
782 | 782 | } |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | if ($count){ |
798 | 798 | $where = isset( $query_params[0] ) ? array( $query_params[0] ) : array(); |
799 | 799 | $results = $questionGroupModel->count($where); |
800 | - }else{ |
|
800 | + } else{ |
|
801 | 801 | $results = $questionGroupModel->get_all($query_params); |
802 | 802 | } |
803 | 803 | return $results; |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | $where = isset( $query_params[0] ) ? array($query_params[0]) : array(); |
819 | 819 | $query_params['limit'] = NULL; |
820 | 820 | $results = $questionGroupModel->count_deleted($where); |
821 | - }else{ |
|
821 | + } else{ |
|
822 | 822 | $results = $questionGroupModel->get_all_deleted($query_params); |
823 | 823 | } |
824 | 824 | return $results; |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\form_sections\strategies\validation; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -41,17 +41,17 @@ discard block |
||
41 | 41 | * @return array |
42 | 42 | * @throws \EE_Error |
43 | 43 | */ |
44 | - public static function get( $exclude = array(), $include = false ) { |
|
45 | - if ( empty( ValidationStrategiesLoader::$_loaded ) ) { |
|
44 | + public static function get($exclude = array(), $include = false) { |
|
45 | + if (empty(ValidationStrategiesLoader::$_loaded)) { |
|
46 | 46 | ValidationStrategiesLoader::load(); |
47 | 47 | } |
48 | 48 | // make sure $exclude is an array |
49 | - $exclude = is_array( $exclude ) ? $exclude : array( $exclude ); |
|
49 | + $exclude = is_array($exclude) ? $exclude : array($exclude); |
|
50 | 50 | // and not numerically indexed |
51 | - $exclude = array_key_exists( 0, $exclude ) ? array_flip( $exclude ) : $exclude; |
|
51 | + $exclude = array_key_exists(0, $exclude) ? array_flip($exclude) : $exclude; |
|
52 | 52 | return $include |
53 | - ? array_intersect_key( ValidationStrategiesLoader::$_loaded, $exclude ) |
|
54 | - : array_diff_key( ValidationStrategiesLoader::$_loaded, $exclude ); |
|
53 | + ? array_intersect_key(ValidationStrategiesLoader::$_loaded, $exclude) |
|
54 | + : array_diff_key(ValidationStrategiesLoader::$_loaded, $exclude); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | * @return array |
66 | 66 | * @throws \EE_Error |
67 | 67 | */ |
68 | - public static function add( $validation_strategy_slug = '', array $existing_validation_strategies = array() ) { |
|
69 | - ValidationStrategiesLoader::validateSlug( $validation_strategy_slug ); |
|
68 | + public static function add($validation_strategy_slug = '', array $existing_validation_strategies = array()) { |
|
69 | + ValidationStrategiesLoader::validateSlug($validation_strategy_slug); |
|
70 | 70 | return array_merge( |
71 | 71 | $existing_validation_strategies, |
72 | - array( $validation_strategy_slug => ValidationStrategiesLoader::$_loaded[ $validation_strategy_slug ] ) |
|
72 | + array($validation_strategy_slug => ValidationStrategiesLoader::$_loaded[$validation_strategy_slug]) |
|
73 | 73 | ); |
74 | 74 | } |
75 | 75 | |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * @return array |
85 | 85 | * @throws \EE_Error |
86 | 86 | */ |
87 | - public static function remove( $validation_strategy_slug = '', array $existing_validation_strategies = array() ) { |
|
88 | - ValidationStrategiesLoader::validateSlug( $validation_strategy_slug, false ); |
|
89 | - unset( $existing_validation_strategies[ $validation_strategy_slug ] ); |
|
87 | + public static function remove($validation_strategy_slug = '', array $existing_validation_strategies = array()) { |
|
88 | + ValidationStrategiesLoader::validateSlug($validation_strategy_slug, false); |
|
89 | + unset($existing_validation_strategies[$validation_strategy_slug]); |
|
90 | 90 | return $existing_validation_strategies; |
91 | 91 | } |
92 | 92 | |
@@ -100,12 +100,12 @@ discard block |
||
100 | 100 | * @return array |
101 | 101 | * @throws \EE_Error |
102 | 102 | */ |
103 | - public static function remove_missing_validation_strategies( array $existing_validation_strategies = array() ) { |
|
104 | - foreach ( $existing_validation_strategies as $validation_strategy_slug => $existing_validation_strategy ) { |
|
103 | + public static function remove_missing_validation_strategies(array $existing_validation_strategies = array()) { |
|
104 | + foreach ($existing_validation_strategies as $validation_strategy_slug => $existing_validation_strategy) { |
|
105 | 105 | try { |
106 | - ValidationStrategiesLoader::validateSlug( $validation_strategy_slug ); |
|
107 | - } catch ( \Exception $e ) { |
|
108 | - unset( $existing_validation_strategies[ $validation_strategy_slug ] ); |
|
106 | + ValidationStrategiesLoader::validateSlug($validation_strategy_slug); |
|
107 | + } catch (\Exception $e) { |
|
108 | + unset($existing_validation_strategies[$validation_strategy_slug]); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | return $existing_validation_strategies; |
@@ -119,22 +119,22 @@ discard block |
||
119 | 119 | * @return bool |
120 | 120 | * @throws \EE_Error |
121 | 121 | */ |
122 | - protected static function validateSlug( $validation_strategy_slug = '', $load_strategies = true ) { |
|
123 | - if ( empty( $validation_strategy_slug ) ) { |
|
122 | + protected static function validateSlug($validation_strategy_slug = '', $load_strategies = true) { |
|
123 | + if (empty($validation_strategy_slug)) { |
|
124 | 124 | throw new \EE_Error( |
125 | - __( 'You must supply a slug in order to add a validation strategy.', 'event_espresso' ) |
|
125 | + __('You must supply a slug in order to add a validation strategy.', 'event_espresso') |
|
126 | 126 | ); |
127 | 127 | } |
128 | - if ( ! $load_strategies ) { |
|
128 | + if ( ! $load_strategies) { |
|
129 | 129 | return true; |
130 | 130 | } |
131 | - if ( empty( ValidationStrategiesLoader::$_loaded ) ) { |
|
131 | + if (empty(ValidationStrategiesLoader::$_loaded)) { |
|
132 | 132 | ValidationStrategiesLoader::load(); |
133 | 133 | } |
134 | - if ( ! isset( ValidationStrategiesLoader::$_loaded[ $validation_strategy_slug ] ) ) { |
|
134 | + if ( ! isset(ValidationStrategiesLoader::$_loaded[$validation_strategy_slug])) { |
|
135 | 135 | throw new \EE_Error( |
136 | 136 | sprintf( |
137 | - __( 'The "%1$s" validation strategy was not found or could not be loaded.', 'event_espresso' ), |
|
137 | + __('The "%1$s" validation strategy was not found or could not be loaded.', 'event_espresso'), |
|
138 | 138 | $validation_strategy_slug |
139 | 139 | ) |
140 | 140 | ); |
@@ -151,21 +151,21 @@ discard block |
||
151 | 151 | // get all the files in that folder matching the mask |
152 | 152 | $filepaths = apply_filters( |
153 | 153 | 'FHEE__ValidationStrategiesLoader__load__validation_strategies', |
154 | - glob( __DIR__ . DS . 'EE_*_Validation_Strategy.strategy.php' ) |
|
154 | + glob(__DIR__.DS.'EE_*_Validation_Strategy.strategy.php') |
|
155 | 155 | ); |
156 | - if ( empty( $filepaths ) ) { |
|
156 | + if (empty($filepaths)) { |
|
157 | 157 | return; |
158 | 158 | } |
159 | - foreach ( (array)$filepaths as $file_path ) { |
|
159 | + foreach ((array) $filepaths as $file_path) { |
|
160 | 160 | // extract filename from path |
161 | - $file_path = basename( $file_path ); |
|
161 | + $file_path = basename($file_path); |
|
162 | 162 | // now remove any file extensions |
163 | - $validation_strategy_name = '\\' . substr( $file_path, 0, strpos( $file_path, '.' ) ); |
|
163 | + $validation_strategy_name = '\\'.substr($file_path, 0, strpos($file_path, '.')); |
|
164 | 164 | // first check to see if the class name represents an actual validation strategy class. |
165 | - if ( strpos( strtolower( $validation_strategy_name ), 'validation_strategy' ) === false ) { |
|
165 | + if (strpos(strtolower($validation_strategy_name), 'validation_strategy') === false) { |
|
166 | 166 | continue; |
167 | 167 | } |
168 | - if ( ! class_exists( $validation_strategy_name ) ) { |
|
168 | + if ( ! class_exists($validation_strategy_name)) { |
|
169 | 169 | throw new \EE_Error( |
170 | 170 | sprintf( |
171 | 171 | __( |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | ) |
178 | 178 | ); |
179 | 179 | } |
180 | - if ( ! is_subclass_of( $validation_strategy_name, 'EE_Validation_Strategy_Base' ) ) { |
|
180 | + if ( ! is_subclass_of($validation_strategy_name, 'EE_Validation_Strategy_Base')) { |
|
181 | 181 | throw new \EE_Error( |
182 | 182 | sprintf( |
183 | 183 | __( |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | ); |
190 | 190 | } |
191 | 191 | $slug = strtolower( |
192 | - str_replace( array( '\EE_', '_Validation_Strategy' ), array( '', '' ), $validation_strategy_name ) |
|
192 | + str_replace(array('\EE_', '_Validation_Strategy'), array('', ''), $validation_strategy_name) |
|
193 | 193 | ); |
194 | - ValidationStrategiesLoader::$_loaded[ $slug ] = $validation_strategy_name; |
|
194 | + ValidationStrategiesLoader::$_loaded[$slug] = $validation_strategy_name; |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 |