@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit( 'No direct script access allowed' ); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * Class EE_Select_Input |
4 | 4 | * |
@@ -10,22 +10,22 @@ discard block |
||
10 | 10 | * @since 4.6 |
11 | 11 | * |
12 | 12 | */ |
13 | -class EE_Select_Input extends EE_Form_Input_With_Options_Base{ |
|
13 | +class EE_Select_Input extends EE_Form_Input_With_Options_Base { |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * @param array $answer_options |
17 | 17 | * @param array $input_settings |
18 | 18 | */ |
19 | - public function __construct( $answer_options, $input_settings = array() ) { |
|
20 | - $this->_set_display_strategy( new EE_Select_Display_Strategy( $answer_options ) ); |
|
19 | + public function __construct($answer_options, $input_settings = array()) { |
|
20 | + $this->_set_display_strategy(new EE_Select_Display_Strategy($answer_options)); |
|
21 | 21 | $this->_add_validation_strategy( |
22 | 22 | new EE_Enum_Validation_Strategy( |
23 | - isset( $input_settings['validation_error_message'] ) |
|
23 | + isset($input_settings['validation_error_message']) |
|
24 | 24 | ? $input_settings['validation_error_message'] |
25 | 25 | : null |
26 | 26 | ) |
27 | 27 | ); |
28 | - parent::__construct( $answer_options, $input_settings ); |
|
28 | + parent::__construct($answer_options, $input_settings); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -810,8 +810,7 @@ |
||
810 | 810 | * (If that doesn't exist, we also check for this subsection's name |
811 | 811 | * at the TOP LEVEL of the request data. Eg $_REQUEST['form_input_1'].) |
812 | 812 | * This function finds its value in the form. |
813 | - |
|
814 | -* |
|
813 | + * |
|
815 | 814 | *@param array $req_data |
816 | 815 | * @return mixed whatever the raw value of this form section is in the request data |
817 | 816 | * @throws \EE_Error |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $this->html_id() |
244 | 244 | ) |
245 | 245 | ); |
246 | - }else{ |
|
246 | + } else{ |
|
247 | 247 | return $this->_display_strategy; |
248 | 248 | } |
249 | 249 | } |
@@ -458,14 +458,14 @@ discard block |
||
458 | 458 | if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
459 | 459 | try{ |
460 | 460 | $validation_strategy->validate($this->normalized_value()); |
461 | - }catch(EE_Validation_Error $e){ |
|
461 | + } catch(EE_Validation_Error $e){ |
|
462 | 462 | $this->add_validation_error($e); |
463 | 463 | } |
464 | 464 | } |
465 | 465 | } |
466 | 466 | if( $this->get_validation_errors()){ |
467 | 467 | return false; |
468 | - }else{ |
|
468 | + } else{ |
|
469 | 469 | return true; |
470 | 470 | } |
471 | 471 | } |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | |
653 | 653 | if(! empty($jquery_validation_rules)){ |
654 | 654 | $jquery_validation_js[ $this->html_id( TRUE ) ] = $jquery_validation_rules; |
655 | - }else{ |
|
655 | + } else{ |
|
656 | 656 | return array(); |
657 | 657 | } |
658 | 658 | return $jquery_validation_js; |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
829 | 829 | $name_parts = $matches[ 1 ]; |
830 | 830 | array_unshift($name_parts, $before_any_brackets); |
831 | - }else{ |
|
831 | + } else{ |
|
832 | 832 | $name_parts = array( $before_any_brackets ); |
833 | 833 | } |
834 | 834 | // now get the value for the input |
@@ -853,13 +853,13 @@ discard block |
||
853 | 853 | if( isset( $req_data[ $first_part_to_consider ] ) ){ |
854 | 854 | if( empty($html_name_parts ) ){ |
855 | 855 | return $req_data[ $first_part_to_consider ]; |
856 | - }else{ |
|
856 | + } else{ |
|
857 | 857 | return $this->_find_form_data_for_this_section_using_name_parts( |
858 | 858 | $html_name_parts, |
859 | 859 | $req_data[ $first_part_to_consider ] |
860 | 860 | ); |
861 | 861 | } |
862 | - }else{ |
|
862 | + } else{ |
|
863 | 863 | return NULL; |
864 | 864 | } |
865 | 865 | } |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | $checked_value = $this->find_form_data_for_this_section( $req_data ); |
881 | 881 | if( $checked_value !== null ){ |
882 | 882 | return TRUE; |
883 | - }else{ |
|
883 | + } else{ |
|
884 | 884 | return FALSE; |
885 | 885 | } |
886 | 886 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @subpackage |
9 | 9 | * @author Mike Nelson |
10 | 10 | */ |
11 | -abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable{ |
|
11 | +abstract class EE_Form_Input_Base extends EE_Form_Section_Validatable { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * the input's name attribute |
@@ -143,54 +143,54 @@ discard block |
||
143 | 143 | * @type EE_Validation_Strategy_Base[] $validation_strategies |
144 | 144 | * } |
145 | 145 | */ |
146 | - public function __construct( $input_args = array() ){ |
|
147 | - $input_args = (array) apply_filters( 'FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this ); |
|
146 | + public function __construct($input_args = array()) { |
|
147 | + $input_args = (array) apply_filters('FHEE__EE_Form_Input_Base___construct__input_args', $input_args, $this); |
|
148 | 148 | // the following properties must be cast as arrays |
149 | - if ( isset( $input_args['validation_strategies'] ) ) { |
|
150 | - foreach ( (array) $input_args['validation_strategies'] as $validation_strategy ) { |
|
151 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
152 | - $this->_validation_strategies[ get_class( $validation_strategy ) ] = $validation_strategy; |
|
149 | + if (isset($input_args['validation_strategies'])) { |
|
150 | + foreach ((array) $input_args['validation_strategies'] as $validation_strategy) { |
|
151 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
152 | + $this->_validation_strategies[get_class($validation_strategy)] = $validation_strategy; |
|
153 | 153 | } |
154 | 154 | } |
155 | - unset( $input_args['validation_strategies'] ); |
|
155 | + unset($input_args['validation_strategies']); |
|
156 | 156 | } |
157 | 157 | // loop thru incoming options |
158 | - foreach( $input_args as $key => $value ) { |
|
158 | + foreach ($input_args as $key => $value) { |
|
159 | 159 | // add underscore to $key to match property names |
160 | - $_key = '_' . $key; |
|
161 | - if ( property_exists( $this, $_key )) { |
|
160 | + $_key = '_'.$key; |
|
161 | + if (property_exists($this, $_key)) { |
|
162 | 162 | $this->{$_key} = $value; |
163 | 163 | } |
164 | 164 | } |
165 | 165 | // ensure that "required" is set correctly |
166 | 166 | $this->set_required( |
167 | - $this->_required, isset( $input_args[ 'required_validation_error_message' ] ) |
|
168 | - ? $input_args[ 'required_validation_error_message' ] |
|
167 | + $this->_required, isset($input_args['required_validation_error_message']) |
|
168 | + ? $input_args['required_validation_error_message'] |
|
169 | 169 | : null |
170 | 170 | ); |
171 | 171 | |
172 | 172 | //$this->_html_name_specified = isset( $input_args['html_name'] ) ? TRUE : FALSE; |
173 | 173 | |
174 | 174 | $this->_display_strategy->_construct_finalize($this); |
175 | - foreach( $this->_validation_strategies as $validation_strategy ){ |
|
175 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
176 | 176 | $validation_strategy->_construct_finalize($this); |
177 | 177 | } |
178 | 178 | |
179 | - if( ! $this->_normalization_strategy){ |
|
179 | + if ( ! $this->_normalization_strategy) { |
|
180 | 180 | $this->_normalization_strategy = new EE_Text_Normalization(); |
181 | 181 | } |
182 | 182 | $this->_normalization_strategy->_construct_finalize($this); |
183 | 183 | |
184 | 184 | //at least we can use the normalization strategy to populate the default |
185 | - if( isset( $input_args[ 'default' ] ) ) { |
|
186 | - $this->set_default( $input_args[ 'default' ] ); |
|
185 | + if (isset($input_args['default'])) { |
|
186 | + $this->set_default($input_args['default']); |
|
187 | 187 | } |
188 | 188 | |
189 | - if( ! $this->_sensitive_data_removal_strategy){ |
|
189 | + if ( ! $this->_sensitive_data_removal_strategy) { |
|
190 | 190 | $this->_sensitive_data_removal_strategy = new EE_No_Sensitive_Data_Removal(); |
191 | 191 | } |
192 | 192 | $this->_sensitive_data_removal_strategy->_construct_finalize($this); |
193 | - parent::__construct( $input_args ); |
|
193 | + parent::__construct($input_args); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | |
@@ -201,11 +201,11 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @throws \EE_Error |
203 | 203 | */ |
204 | - protected function _set_default_html_name_if_empty(){ |
|
205 | - if( ! $this->_html_name){ |
|
204 | + protected function _set_default_html_name_if_empty() { |
|
205 | + if ( ! $this->_html_name) { |
|
206 | 206 | $this->_html_name = $this->name(); |
207 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper){ |
|
208 | - $this->_html_name = $this->_parent_section->html_name_prefix() . "[{$this->name()}]"; |
|
207 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
208 | + $this->_html_name = $this->_parent_section->html_name_prefix()."[{$this->name()}]"; |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | } |
@@ -220,10 +220,10 @@ discard block |
||
220 | 220 | public function _construct_finalize($parent_form_section, $name) { |
221 | 221 | parent::_construct_finalize($parent_form_section, $name); |
222 | 222 | $this->_set_default_html_name_if_empty(); |
223 | - if( ! $this->_html_label && ! $this->_html_label_text){ |
|
224 | - $this->_html_label_text = ucwords( str_replace("_"," ",$name)); |
|
223 | + if ( ! $this->_html_label && ! $this->_html_label_text) { |
|
224 | + $this->_html_label_text = ucwords(str_replace("_", " ", $name)); |
|
225 | 225 | } |
226 | - do_action( 'AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name ); |
|
226 | + do_action('AHEE__EE_Form_Input_Base___construct_finalize__end', $this, $parent_form_section, $name); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | * @return EE_Display_Strategy_Base |
232 | 232 | * @throws EE_Error |
233 | 233 | */ |
234 | - protected function _get_display_strategy(){ |
|
235 | - if( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base){ |
|
234 | + protected function _get_display_strategy() { |
|
235 | + if ( ! $this->_display_strategy || ! $this->_display_strategy instanceof EE_Display_Strategy_Base) { |
|
236 | 236 | throw new EE_Error( |
237 | 237 | sprintf( |
238 | 238 | __( |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $this->html_id() |
244 | 244 | ) |
245 | 245 | ); |
246 | - }else{ |
|
246 | + } else { |
|
247 | 247 | return $this->_display_strategy; |
248 | 248 | } |
249 | 249 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * Sets the display strategy. |
252 | 252 | * @param EE_Display_Strategy_Base $strategy |
253 | 253 | */ |
254 | - protected function _set_display_strategy(EE_Display_Strategy_Base $strategy){ |
|
254 | + protected function _set_display_strategy(EE_Display_Strategy_Base $strategy) { |
|
255 | 255 | $this->_display_strategy = $strategy; |
256 | 256 | } |
257 | 257 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * Sets the sanitization strategy |
260 | 260 | * @param EE_Normalization_Strategy_Base $strategy |
261 | 261 | */ |
262 | - protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy){ |
|
262 | + protected function _set_normalization_strategy(EE_Normalization_Strategy_Base $strategy) { |
|
263 | 263 | $this->_normalization_strategy = $strategy; |
264 | 264 | } |
265 | 265 | |
@@ -285,14 +285,14 @@ discard block |
||
285 | 285 | * Gets the display strategy for this input |
286 | 286 | * @return EE_Display_Strategy_Base |
287 | 287 | */ |
288 | - public function get_display_strategy(){ |
|
288 | + public function get_display_strategy() { |
|
289 | 289 | return $this->_display_strategy; |
290 | 290 | } |
291 | 291 | /** |
292 | 292 | * Overwrites the display strategy |
293 | 293 | * @param EE_Display_Strategy_Base $display_strategy |
294 | 294 | */ |
295 | - public function set_display_strategy($display_strategy){ |
|
295 | + public function set_display_strategy($display_strategy) { |
|
296 | 296 | $this->_display_strategy = $display_strategy; |
297 | 297 | $this->_display_strategy->_construct_finalize($this); |
298 | 298 | } |
@@ -300,14 +300,14 @@ discard block |
||
300 | 300 | * Gets the normalization strategy set on this input |
301 | 301 | * @return EE_Normalization_Strategy_Base |
302 | 302 | */ |
303 | - public function get_normalization_strategy(){ |
|
303 | + public function get_normalization_strategy() { |
|
304 | 304 | return $this->_normalization_strategy; |
305 | 305 | } |
306 | 306 | /** |
307 | 307 | * Overwrites the normalization strategy |
308 | 308 | * @param EE_Normalization_Strategy_Base $normalization_strategy |
309 | 309 | */ |
310 | - public function set_normalization_strategy($normalization_strategy){ |
|
310 | + public function set_normalization_strategy($normalization_strategy) { |
|
311 | 311 | $this->_normalization_strategy = $normalization_strategy; |
312 | 312 | $this->_normalization_strategy->_construct_finalize($this); |
313 | 313 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * Returns all teh validation strategies which apply to this field, numerically indexed |
317 | 317 | * @return EE_Validation_Strategy_Base[] |
318 | 318 | */ |
319 | - public function get_validation_strategies(){ |
|
319 | + public function get_validation_strategies() { |
|
320 | 320 | return $this->_validation_strategies; |
321 | 321 | } |
322 | 322 | |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | * @param EE_Validation_Strategy_Base $validation_strategy |
328 | 328 | * @return void |
329 | 329 | */ |
330 | - protected function _add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ){ |
|
331 | - $validation_strategy->_construct_finalize( $this ); |
|
330 | + protected function _add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
331 | + $validation_strategy->_construct_finalize($this); |
|
332 | 332 | $this->_validation_strategies[] = $validation_strategy; |
333 | 333 | } |
334 | 334 | |
@@ -339,8 +339,8 @@ discard block |
||
339 | 339 | * @param EE_Validation_Strategy_Base $validation_strategy |
340 | 340 | * @return void |
341 | 341 | */ |
342 | - public function add_validation_strategy( EE_Validation_Strategy_Base $validation_strategy ) { |
|
343 | - $this->_add_validation_strategy( $validation_strategy ); |
|
342 | + public function add_validation_strategy(EE_Validation_Strategy_Base $validation_strategy) { |
|
343 | + $this->_add_validation_strategy($validation_strategy); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | |
@@ -350,13 +350,13 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @param string $validation_strategy_classname |
352 | 352 | */ |
353 | - public function remove_validation_strategy( $validation_strategy_classname ) { |
|
354 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
355 | - if( |
|
353 | + public function remove_validation_strategy($validation_strategy_classname) { |
|
354 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
355 | + if ( |
|
356 | 356 | $validation_strategy instanceof $validation_strategy_classname |
357 | - || is_subclass_of( $validation_strategy, $validation_strategy_classname ) |
|
357 | + || is_subclass_of($validation_strategy, $validation_strategy_classname) |
|
358 | 358 | ) { |
359 | - unset( $this->_validation_strategies[ $key ] ); |
|
359 | + unset($this->_validation_strategies[$key]); |
|
360 | 360 | } |
361 | 361 | } |
362 | 362 | } |
@@ -369,12 +369,12 @@ discard block |
||
369 | 369 | * @param array $validation_strategy_classnames |
370 | 370 | * @return bool |
371 | 371 | */ |
372 | - public function has_validation_strategy( $validation_strategy_classnames ) { |
|
373 | - $validation_strategy_classnames = is_array( $validation_strategy_classnames ) |
|
372 | + public function has_validation_strategy($validation_strategy_classnames) { |
|
373 | + $validation_strategy_classnames = is_array($validation_strategy_classnames) |
|
374 | 374 | ? $validation_strategy_classnames |
375 | - : array( $validation_strategy_classnames ); |
|
376 | - foreach( $this->_validation_strategies as $key => $validation_strategy ){ |
|
377 | - if( in_array( $key, $validation_strategy_classnames ) ) { |
|
375 | + : array($validation_strategy_classnames); |
|
376 | + foreach ($this->_validation_strategies as $key => $validation_strategy) { |
|
377 | + if (in_array($key, $validation_strategy_classnames)) { |
|
378 | 378 | return true; |
379 | 379 | } |
380 | 380 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * to the parent form's layout strategy |
389 | 389 | * @return string |
390 | 390 | */ |
391 | - public function get_html_and_js(){ |
|
391 | + public function get_html_and_js() { |
|
392 | 392 | return $this->_parent_section->get_html_for_input($this); |
393 | 393 | } |
394 | 394 | |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * @return string |
403 | 403 | * @throws \EE_Error |
404 | 404 | */ |
405 | - public function get_html_for_input(){ |
|
405 | + public function get_html_for_input() { |
|
406 | 406 | return $this->_get_display_strategy()->display(); |
407 | 407 | } |
408 | 408 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * @return string |
413 | 413 | */ |
414 | 414 | public function html_other_attributes() { |
415 | - return ! empty( $this->_html_other_attributes ) ? ' ' . $this->_html_other_attributes : ''; |
|
415 | + return ! empty($this->_html_other_attributes) ? ' '.$this->_html_other_attributes : ''; |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | /** |
421 | 421 | * @param string $html_other_attributes |
422 | 422 | */ |
423 | - public function set_html_other_attributes( $html_other_attributes ) { |
|
423 | + public function set_html_other_attributes($html_other_attributes) { |
|
424 | 424 | $this->_html_other_attributes = $html_other_attributes; |
425 | 425 | } |
426 | 426 | |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | * according to the form section's layout strategy |
430 | 430 | * @return string |
431 | 431 | */ |
432 | - public function get_html_for_label(){ |
|
432 | + public function get_html_for_label() { |
|
433 | 433 | return $this->_parent_section->get_layout_strategy()->display_label($this); |
434 | 434 | } |
435 | 435 | /** |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | * according to the form section's layout strategy |
438 | 438 | * @return string |
439 | 439 | */ |
440 | - public function get_html_for_errors(){ |
|
440 | + public function get_html_for_errors() { |
|
441 | 441 | return $this->_parent_section->get_layout_strategy()->display_errors($this); |
442 | 442 | } |
443 | 443 | /** |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | * according to the form section's layout strategy |
446 | 446 | * @return string |
447 | 447 | */ |
448 | - public function get_html_for_help(){ |
|
448 | + public function get_html_for_help() { |
|
449 | 449 | return $this->_parent_section->get_layout_strategy()->display_help_text($this); |
450 | 450 | } |
451 | 451 | /** |
@@ -454,18 +454,18 @@ discard block |
||
454 | 454 | * @return boolean |
455 | 455 | */ |
456 | 456 | protected function _validate() { |
457 | - foreach($this->_validation_strategies as $validation_strategy){ |
|
458 | - if ( $validation_strategy instanceof EE_Validation_Strategy_Base ) { |
|
459 | - try{ |
|
457 | + foreach ($this->_validation_strategies as $validation_strategy) { |
|
458 | + if ($validation_strategy instanceof EE_Validation_Strategy_Base) { |
|
459 | + try { |
|
460 | 460 | $validation_strategy->validate($this->normalized_value()); |
461 | - }catch(EE_Validation_Error $e){ |
|
461 | + } catch (EE_Validation_Error $e) { |
|
462 | 462 | $this->add_validation_error($e); |
463 | 463 | } |
464 | 464 | } |
465 | 465 | } |
466 | - if( $this->get_validation_errors()){ |
|
466 | + if ($this->get_validation_errors()) { |
|
467 | 467 | return false; |
468 | - }else{ |
|
468 | + } else { |
|
469 | 469 | return true; |
470 | 470 | } |
471 | 471 | } |
@@ -478,8 +478,8 @@ discard block |
||
478 | 478 | * @param string $value |
479 | 479 | * @return null|string |
480 | 480 | */ |
481 | - private function _sanitize($value){ |
|
482 | - return $value !== NULL ?stripslashes(html_entity_decode($value)) : NULL;//don't sanitize_text_field |
|
481 | + private function _sanitize($value) { |
|
482 | + return $value !== NULL ? stripslashes(html_entity_decode($value)) : NULL; //don't sanitize_text_field |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | |
@@ -493,24 +493,24 @@ discard block |
||
493 | 493 | * @return boolean whether or not there was an error |
494 | 494 | * @throws \EE_Error |
495 | 495 | */ |
496 | - protected function _normalize( $req_data ) { |
|
496 | + protected function _normalize($req_data) { |
|
497 | 497 | //any existing validation errors don't apply so clear them |
498 | 498 | $this->_validation_errors = array(); |
499 | 499 | try { |
500 | - $raw_input = $this->find_form_data_for_this_section( $req_data ); |
|
500 | + $raw_input = $this->find_form_data_for_this_section($req_data); |
|
501 | 501 | //super simple sanitization for now |
502 | - if ( is_array( $raw_input )) { |
|
502 | + if (is_array($raw_input)) { |
|
503 | 503 | $this->_raw_value = array(); |
504 | - foreach( $raw_input as $key => $value ) { |
|
505 | - $this->_raw_value[ $key ] = $this->_sanitize( $value ); |
|
504 | + foreach ($raw_input as $key => $value) { |
|
505 | + $this->_raw_value[$key] = $this->_sanitize($value); |
|
506 | 506 | } |
507 | 507 | } else { |
508 | - $this->_raw_value = $this->_sanitize( $raw_input ); |
|
508 | + $this->_raw_value = $this->_sanitize($raw_input); |
|
509 | 509 | } |
510 | 510 | //we want ot mostly leave the input alone in case we need to re-display it to the user |
511 | - $this->_normalized_value = $this->_normalization_strategy->normalize( $this->raw_value() ); |
|
512 | - } catch ( EE_Validation_Error $e ) { |
|
513 | - $this->add_validation_error( $e ); |
|
511 | + $this->_normalized_value = $this->_normalization_strategy->normalize($this->raw_value()); |
|
512 | + } catch (EE_Validation_Error $e) { |
|
513 | + $this->add_validation_error($e); |
|
514 | 514 | } |
515 | 515 | } |
516 | 516 | |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | /** |
520 | 520 | * @return string |
521 | 521 | */ |
522 | - public function html_name(){ |
|
522 | + public function html_name() { |
|
523 | 523 | return $this->_html_name; |
524 | 524 | } |
525 | 525 | |
@@ -528,8 +528,8 @@ discard block |
||
528 | 528 | /** |
529 | 529 | * @return string |
530 | 530 | */ |
531 | - public function html_label_id(){ |
|
532 | - return ! empty( $this->_html_label_id ) ? $this->_html_label_id : $this->_html_id . '-lbl'; |
|
531 | + public function html_label_id() { |
|
532 | + return ! empty($this->_html_label_id) ? $this->_html_label_id : $this->_html_id.'-lbl'; |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | /** |
538 | 538 | * @return string |
539 | 539 | */ |
540 | - public function html_label_class(){ |
|
540 | + public function html_label_class() { |
|
541 | 541 | return $this->_html_label_class; |
542 | 542 | } |
543 | 543 | |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | /** |
547 | 547 | * @return string |
548 | 548 | */ |
549 | - public function html_label_style(){ |
|
549 | + public function html_label_style() { |
|
550 | 550 | return $this->_html_label_style; |
551 | 551 | } |
552 | 552 | |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | /** |
556 | 556 | * @return string |
557 | 557 | */ |
558 | - public function html_label_text(){ |
|
558 | + public function html_label_text() { |
|
559 | 559 | return $this->_html_label_text; |
560 | 560 | } |
561 | 561 | |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | /** |
565 | 565 | * @return string |
566 | 566 | */ |
567 | - public function html_help_text(){ |
|
567 | + public function html_help_text() { |
|
568 | 568 | return $this->_html_help_text; |
569 | 569 | } |
570 | 570 | |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | /** |
574 | 574 | * @return string |
575 | 575 | */ |
576 | - public function html_help_class(){ |
|
576 | + public function html_help_class() { |
|
577 | 577 | return $this->_html_help_class; |
578 | 578 | } |
579 | 579 | |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | /** |
583 | 583 | * @return string |
584 | 584 | */ |
585 | - public function html_help_style(){ |
|
585 | + public function html_help_style() { |
|
586 | 586 | return $this->_html_style; |
587 | 587 | } |
588 | 588 | /** |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | * in which case, we would have stored the malicious content to our database. |
596 | 596 | * @return string |
597 | 597 | */ |
598 | - public function raw_value(){ |
|
598 | + public function raw_value() { |
|
599 | 599 | return $this->_raw_value; |
600 | 600 | } |
601 | 601 | /** |
@@ -603,15 +603,15 @@ discard block |
||
603 | 603 | * it escapes all html entities |
604 | 604 | * @return string |
605 | 605 | */ |
606 | - public function raw_value_in_form(){ |
|
607 | - return htmlentities($this->raw_value(),ENT_QUOTES, 'UTF-8'); |
|
606 | + public function raw_value_in_form() { |
|
607 | + return htmlentities($this->raw_value(), ENT_QUOTES, 'UTF-8'); |
|
608 | 608 | } |
609 | 609 | /** |
610 | 610 | * returns the value after it's been sanitized, and then converted into it's proper type |
611 | 611 | * in PHP. Eg, a string, an int, an array, |
612 | 612 | * @return mixed |
613 | 613 | */ |
614 | - public function normalized_value(){ |
|
614 | + public function normalized_value() { |
|
615 | 615 | return $this->_normalized_value; |
616 | 616 | } |
617 | 617 | |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | * the best thing to display |
622 | 622 | * @return string |
623 | 623 | */ |
624 | - public function pretty_value(){ |
|
624 | + public function pretty_value() { |
|
625 | 625 | return $this->_normalized_value; |
626 | 626 | } |
627 | 627 | /** |
@@ -640,19 +640,19 @@ discard block |
||
640 | 640 | }</code> |
641 | 641 | * @return array |
642 | 642 | */ |
643 | - public function get_jquery_validation_rules(){ |
|
643 | + public function get_jquery_validation_rules() { |
|
644 | 644 | |
645 | 645 | $jquery_validation_rules = array(); |
646 | - foreach($this->get_validation_strategies() as $validation_strategy){ |
|
646 | + foreach ($this->get_validation_strategies() as $validation_strategy) { |
|
647 | 647 | $jquery_validation_rules = array_replace_recursive( |
648 | 648 | $jquery_validation_rules, |
649 | 649 | $validation_strategy->get_jquery_validation_rule_array() |
650 | 650 | ); |
651 | 651 | } |
652 | 652 | |
653 | - if(! empty($jquery_validation_rules)){ |
|
654 | - $jquery_validation_js[ $this->html_id( TRUE ) ] = $jquery_validation_rules; |
|
655 | - }else{ |
|
653 | + if ( ! empty($jquery_validation_rules)) { |
|
654 | + $jquery_validation_js[$this->html_id(TRUE)] = $jquery_validation_rules; |
|
655 | + } else { |
|
656 | 656 | return array(); |
657 | 657 | } |
658 | 658 | return $jquery_validation_js; |
@@ -664,9 +664,9 @@ discard block |
||
664 | 664 | * @param mixed $value |
665 | 665 | * @return void |
666 | 666 | */ |
667 | - public function set_default($value){ |
|
667 | + public function set_default($value) { |
|
668 | 668 | $this->_normalized_value = $value; |
669 | - $this->_raw_value = $this->_normalization_strategy->unnormalize( $value ); |
|
669 | + $this->_raw_value = $this->_normalization_strategy->unnormalize($value); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | /** |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | * @param string $label |
675 | 675 | * @return void |
676 | 676 | */ |
677 | - public function set_html_label_text($label){ |
|
677 | + public function set_html_label_text($label) { |
|
678 | 678 | $this->_html_label_text = $label; |
679 | 679 | } |
680 | 680 | |
@@ -688,13 +688,13 @@ discard block |
||
688 | 688 | * @param boolean $required boolean |
689 | 689 | * @param null $required_text |
690 | 690 | */ |
691 | - public function set_required($required = true, $required_text = NULL ){ |
|
692 | - $required = filter_var( $required, FILTER_VALIDATE_BOOLEAN ); |
|
691 | + public function set_required($required = true, $required_text = NULL) { |
|
692 | + $required = filter_var($required, FILTER_VALIDATE_BOOLEAN); |
|
693 | 693 | //whether $required is a string or a boolean, we want to add a required validation strategy |
694 | - if ( $required ) { |
|
695 | - $this->_add_validation_strategy( new EE_Required_Validation_Strategy( $required_text ) ); |
|
694 | + if ($required) { |
|
695 | + $this->_add_validation_strategy(new EE_Required_Validation_Strategy($required_text)); |
|
696 | 696 | } else { |
697 | - unset( $this->_validation_strategies[ 'EE_Required_Validation_Strategy' ] ); |
|
697 | + unset($this->_validation_strategies['EE_Required_Validation_Strategy']); |
|
698 | 698 | } |
699 | 699 | $this->_required = $required; |
700 | 700 | } |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | * Returns whether or not this field is required |
703 | 703 | * @return boolean |
704 | 704 | */ |
705 | - public function required(){ |
|
705 | + public function required() { |
|
706 | 706 | return $this->_required; |
707 | 707 | } |
708 | 708 | |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | /** |
712 | 712 | * @param string $required_css_class |
713 | 713 | */ |
714 | - public function set_required_css_class( $required_css_class ) { |
|
714 | + public function set_required_css_class($required_css_class) { |
|
715 | 715 | $this->_required_css_class = $required_css_class; |
716 | 716 | } |
717 | 717 | |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | * Sets the help text, in case |
731 | 731 | * @param string $text |
732 | 732 | */ |
733 | - public function set_html_help_text($text){ |
|
733 | + public function set_html_help_text($text) { |
|
734 | 734 | $this->_html_help_text = $text; |
735 | 735 | } |
736 | 736 | /** |
@@ -742,8 +742,8 @@ discard block |
||
742 | 742 | public function clean_sensitive_data() { |
743 | 743 | //if we do ANY kind of sensitive data removal on this, then just clear out the raw value |
744 | 744 | //if we need more logic than this we'll make a strategy for it |
745 | - if( $this->_sensitive_data_removal_strategy && |
|
746 | - ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal ){ |
|
745 | + if ($this->_sensitive_data_removal_strategy && |
|
746 | + ! $this->_sensitive_data_removal_strategy instanceof EE_No_Sensitive_Data_Removal) { |
|
747 | 747 | $this->_raw_value = NULL; |
748 | 748 | } |
749 | 749 | //and clean the normalized value according to the appropriate strategy |
@@ -759,10 +759,10 @@ discard block |
||
759 | 759 | * @param string $button_size |
760 | 760 | * @param string $other_attributes |
761 | 761 | */ |
762 | - public function set_button_css_attributes( $primary = TRUE, $button_size = '', $other_attributes = '' ) { |
|
762 | + public function set_button_css_attributes($primary = TRUE, $button_size = '', $other_attributes = '') { |
|
763 | 763 | $button_css_attributes = 'button'; |
764 | 764 | $button_css_attributes .= $primary === TRUE ? ' button-primary' : ' button-secondary'; |
765 | - switch ( $button_size ) { |
|
765 | + switch ($button_size) { |
|
766 | 766 | case 'xs' : |
767 | 767 | case 'extra-small' : |
768 | 768 | $button_css_attributes .= ' button-xs'; |
@@ -783,8 +783,8 @@ discard block |
||
783 | 783 | default : |
784 | 784 | $button_css_attributes .= ''; |
785 | 785 | } |
786 | - $this->_button_css_attributes .= ! empty( $other_attributes ) |
|
787 | - ? $button_css_attributes . ' ' . $other_attributes |
|
786 | + $this->_button_css_attributes .= ! empty($other_attributes) |
|
787 | + ? $button_css_attributes.' '.$other_attributes |
|
788 | 788 | : $button_css_attributes; |
789 | 789 | } |
790 | 790 | |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | * @return string |
795 | 795 | */ |
796 | 796 | public function button_css_attributes() { |
797 | - if ( empty( $this->_button_css_attributes )) { |
|
797 | + if (empty($this->_button_css_attributes)) { |
|
798 | 798 | $this->set_button_css_attributes(); |
799 | 799 | } |
800 | 800 | return $this->_button_css_attributes; |
@@ -816,26 +816,26 @@ discard block |
||
816 | 816 | * @return mixed whatever the raw value of this form section is in the request data |
817 | 817 | * @throws \EE_Error |
818 | 818 | */ |
819 | - public function find_form_data_for_this_section( $req_data ){ |
|
819 | + public function find_form_data_for_this_section($req_data) { |
|
820 | 820 | // break up the html name by "[]" |
821 | - if ( strpos( $this->html_name(), '[' ) !== FALSE ) { |
|
822 | - $before_any_brackets = substr( $this->html_name(), 0, strpos($this->html_name(), '[') ); |
|
821 | + if (strpos($this->html_name(), '[') !== FALSE) { |
|
822 | + $before_any_brackets = substr($this->html_name(), 0, strpos($this->html_name(), '[')); |
|
823 | 823 | } else { |
824 | 824 | $before_any_brackets = $this->html_name(); |
825 | 825 | } |
826 | 826 | // grab all of the segments |
827 | - preg_match_all('~\[([^]]*)\]~',$this->html_name(), $matches); |
|
828 | - if( isset( $matches[ 1 ] ) && is_array( $matches[ 1 ] ) ){ |
|
829 | - $name_parts = $matches[ 1 ]; |
|
827 | + preg_match_all('~\[([^]]*)\]~', $this->html_name(), $matches); |
|
828 | + if (isset($matches[1]) && is_array($matches[1])) { |
|
829 | + $name_parts = $matches[1]; |
|
830 | 830 | array_unshift($name_parts, $before_any_brackets); |
831 | - }else{ |
|
832 | - $name_parts = array( $before_any_brackets ); |
|
831 | + } else { |
|
832 | + $name_parts = array($before_any_brackets); |
|
833 | 833 | } |
834 | 834 | // now get the value for the input |
835 | 835 | $value = $this->_find_form_data_for_this_section_using_name_parts($name_parts, $req_data); |
836 | 836 | // check if this thing's name is at the TOP level of the request data |
837 | - if( $value === null && isset( $req_data[ $this->name() ] ) ){ |
|
838 | - $value = $req_data[ $this->name() ]; |
|
837 | + if ($value === null && isset($req_data[$this->name()])) { |
|
838 | + $value = $req_data[$this->name()]; |
|
839 | 839 | } |
840 | 840 | return $value; |
841 | 841 | } |
@@ -848,18 +848,18 @@ discard block |
||
848 | 848 | * @param array $req_data |
849 | 849 | * @return array | NULL |
850 | 850 | */ |
851 | - public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data){ |
|
852 | - $first_part_to_consider = array_shift( $html_name_parts ); |
|
853 | - if( isset( $req_data[ $first_part_to_consider ] ) ){ |
|
854 | - if( empty($html_name_parts ) ){ |
|
855 | - return $req_data[ $first_part_to_consider ]; |
|
856 | - }else{ |
|
851 | + public function _find_form_data_for_this_section_using_name_parts($html_name_parts, $req_data) { |
|
852 | + $first_part_to_consider = array_shift($html_name_parts); |
|
853 | + if (isset($req_data[$first_part_to_consider])) { |
|
854 | + if (empty($html_name_parts)) { |
|
855 | + return $req_data[$first_part_to_consider]; |
|
856 | + } else { |
|
857 | 857 | return $this->_find_form_data_for_this_section_using_name_parts( |
858 | 858 | $html_name_parts, |
859 | - $req_data[ $first_part_to_consider ] |
|
859 | + $req_data[$first_part_to_consider] |
|
860 | 860 | ); |
861 | 861 | } |
862 | - }else{ |
|
862 | + } else { |
|
863 | 863 | return NULL; |
864 | 864 | } |
865 | 865 | } |
@@ -873,14 +873,14 @@ discard block |
||
873 | 873 | * @return boolean |
874 | 874 | * @throws \EE_Error |
875 | 875 | */ |
876 | - public function form_data_present_in($req_data = NULL){ |
|
877 | - if( $req_data === NULL ){ |
|
876 | + public function form_data_present_in($req_data = NULL) { |
|
877 | + if ($req_data === NULL) { |
|
878 | 878 | $req_data = $_POST; |
879 | 879 | } |
880 | - $checked_value = $this->find_form_data_for_this_section( $req_data ); |
|
881 | - if( $checked_value !== null ){ |
|
880 | + $checked_value = $this->find_form_data_for_this_section($req_data); |
|
881 | + if ($checked_value !== null) { |
|
882 | 882 | return TRUE; |
883 | - }else{ |
|
883 | + } else { |
|
884 | 884 | return FALSE; |
885 | 885 | } |
886 | 886 | } |
@@ -8,18 +8,18 @@ discard block |
||
8 | 8 | * @since 4.6 |
9 | 9 | * |
10 | 10 | */ |
11 | -class EE_Required_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
11 | +class EE_Required_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
12 | 12 | |
13 | 13 | |
14 | 14 | |
15 | 15 | /** |
16 | 16 | * @param string $validation_error_message |
17 | 17 | */ |
18 | - public function __construct( $validation_error_message = null ) { |
|
19 | - if( ! $validation_error_message ){ |
|
18 | + public function __construct($validation_error_message = null) { |
|
19 | + if ( ! $validation_error_message) { |
|
20 | 20 | $validation_error_message = __("This field is required.", "event_espresso"); |
21 | 21 | } |
22 | - parent::__construct( $validation_error_message ); |
|
22 | + parent::__construct($validation_error_message); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | * @throws \EE_Validation_Error |
35 | 35 | */ |
36 | 36 | public function validate($normalized_value) { |
37 | - if( |
|
37 | + if ( |
|
38 | 38 | $normalized_value === '' |
39 | 39 | || $normalized_value === null |
40 | 40 | || $normalized_value === array() |
41 | 41 | ) { |
42 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'required'); |
|
43 | - }else{ |
|
42 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
43 | + } else { |
|
44 | 44 | return true; |
45 | 45 | } |
46 | 46 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @return array |
52 | 52 | * @throws \EE_Error |
53 | 53 | */ |
54 | - public function get_jquery_validation_rule_array(){ |
|
54 | + public function get_jquery_validation_rule_array() { |
|
55 | 55 | return array( |
56 | 56 | 'required'=> true, |
57 | 57 | 'messages' => array( |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @param null $validation_error_message |
24 | 24 | */ |
25 | - public function __construct( $validation_error_message = null ) { |
|
25 | + public function __construct($validation_error_message = null) { |
|
26 | 26 | $this->_validation_error_message = $validation_error_message === null |
27 | - ? __( 'Input invalid', 'event_espresso' ) |
|
27 | + ? __('Input invalid', 'event_espresso') |
|
28 | 28 | : $validation_error_message; |
29 | 29 | parent::__construct(); |
30 | 30 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * this validation strategy is the 'required' validation strategy, |
42 | 42 | * most should be OK with a null, empty string, etc) |
43 | 43 | */ |
44 | - public function validate( $normalized_value ) { |
|
44 | + public function validate($normalized_value) { |
|
45 | 45 | //by default, the validation strategy does no validation. this should be implemented |
46 | 46 | } |
47 | 47 |
@@ -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 | /** |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | * @type $name string the name for this form section, if you want to explicitly define it |
80 | 80 | * } |
81 | 81 | */ |
82 | - public function __construct( $options_array = array() ) { |
|
82 | + public function __construct($options_array = array()) { |
|
83 | 83 | // used by display strategies |
84 | 84 | EE_Registry::instance()->load_helper('HTML'); |
85 | 85 | // assign incoming values to properties |
86 | - foreach( $options_array as $key => $value ) { |
|
87 | - $key = '_' . $key; |
|
88 | - if ( property_exists( $this, $key ) && empty( $this->{$key} )) { |
|
86 | + foreach ($options_array as $key => $value) { |
|
87 | + $key = '_'.$key; |
|
88 | + if (property_exists($this, $key) && empty($this->{$key} )) { |
|
89 | 89 | $this->{$key} = $value; |
90 | 90 | } |
91 | 91 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @param $name |
99 | 99 | * @throws \EE_Error |
100 | 100 | */ |
101 | - protected function _construct_finalize( $parent_form_section, $name ){ |
|
101 | + protected function _construct_finalize($parent_form_section, $name) { |
|
102 | 102 | $this->_construction_finalized = TRUE; |
103 | 103 | $this->_parent_section = $parent_form_section; |
104 | 104 | $this->_name = $name; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | /** |
120 | 120 | * @param string $action |
121 | 121 | */ |
122 | - public function set_action( $action ) { |
|
122 | + public function set_action($action) { |
|
123 | 123 | $this->_action = $action; |
124 | 124 | } |
125 | 125 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @return string |
130 | 130 | */ |
131 | 131 | public function method() { |
132 | - return ! empty( $this->_method ) ? $this->_method : 'POST'; |
|
132 | + return ! empty($this->_method) ? $this->_method : 'POST'; |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | |
@@ -137,8 +137,8 @@ discard block |
||
137 | 137 | /** |
138 | 138 | * @param string $method |
139 | 139 | */ |
140 | - public function set_method( $method ) { |
|
141 | - switch ( $method ) { |
|
140 | + public function set_method($method) { |
|
141 | + switch ($method) { |
|
142 | 142 | case 'get' : |
143 | 143 | case 'GET' : |
144 | 144 | $this->_method = 'GET'; |
@@ -157,12 +157,12 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @throws \EE_Error |
159 | 159 | */ |
160 | - protected function _set_default_html_id_if_empty(){ |
|
161 | - if( ! $this->_html_id ){ |
|
162 | - if( $this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper ){ |
|
163 | - $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id( $this->name() ); |
|
164 | - }else{ |
|
165 | - $this->_html_id = $this->_prep_name_for_html_id( $this->name() ); |
|
160 | + protected function _set_default_html_id_if_empty() { |
|
161 | + if ( ! $this->_html_id) { |
|
162 | + if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) { |
|
163 | + $this->_html_id = $this->_parent_section->html_id().'-'.$this->_prep_name_for_html_id($this->name()); |
|
164 | + } else { |
|
165 | + $this->_html_id = $this->_prep_name_for_html_id($this->name()); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | } |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | * @param $name |
175 | 175 | * @return string |
176 | 176 | */ |
177 | - private function _prep_name_for_html_id( $name ) { |
|
178 | - return sanitize_key( str_replace( array( ' ', ' ', '_' ), '-', $name )); |
|
177 | + private function _prep_name_for_html_id($name) { |
|
178 | + return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name)); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | * @param bool $add_pound_sign |
193 | 193 | * @return string |
194 | 194 | */ |
195 | - public function html_id( $add_pound_sign = FALSE ){ |
|
196 | - return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id; |
|
195 | + public function html_id($add_pound_sign = FALSE) { |
|
196 | + return $add_pound_sign ? '#'.$this->_html_id : $this->_html_id; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | /** |
202 | 202 | * @return string |
203 | 203 | */ |
204 | - public function html_class(){ |
|
204 | + public function html_class() { |
|
205 | 205 | return $this->_html_class; |
206 | 206 | } |
207 | 207 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | /** |
211 | 211 | * @return string |
212 | 212 | */ |
213 | - public function html_style(){ |
|
213 | + public function html_style() { |
|
214 | 214 | return $this->_html_style; |
215 | 215 | } |
216 | 216 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | /** |
220 | 220 | * @param mixed $html_class |
221 | 221 | */ |
222 | - public function set_html_class( $html_class ) { |
|
222 | + public function set_html_class($html_class) { |
|
223 | 223 | $this->_html_class = $html_class; |
224 | 224 | } |
225 | 225 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | /** |
229 | 229 | * @param mixed $html_id |
230 | 230 | */ |
231 | - public function set_html_id( $html_id ) { |
|
231 | + public function set_html_id($html_id) { |
|
232 | 232 | $this->_html_id = $html_id; |
233 | 233 | } |
234 | 234 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | /** |
238 | 238 | * @param mixed $html_style |
239 | 239 | */ |
240 | - public function set_html_style( $html_style ) { |
|
240 | + public function set_html_style($html_style) { |
|
241 | 241 | $this->_html_style = $html_style; |
242 | 242 | } |
243 | 243 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | /** |
247 | 247 | * @param string $other_html_attributes |
248 | 248 | */ |
249 | - public function set_other_html_attributes( $other_html_attributes ) { |
|
249 | + public function set_other_html_attributes($other_html_attributes) { |
|
250 | 250 | $this->_other_html_attributes = $other_html_attributes; |
251 | 251 | } |
252 | 252 | |
@@ -266,9 +266,9 @@ discard block |
||
266 | 266 | * @throws EE_Error |
267 | 267 | * @return string |
268 | 268 | */ |
269 | - public function name(){ |
|
270 | - if( ! $this->_construction_finalized ){ |
|
271 | - throw new EE_Error(sprintf( __( 'You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso' ), get_class($this) ) ); |
|
269 | + public function name() { |
|
270 | + if ( ! $this->_construction_finalized) { |
|
271 | + throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'', 'event_espresso'), get_class($this))); |
|
272 | 272 | } |
273 | 273 | return $this->_name; |
274 | 274 | } |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * Gets the parent section |
280 | 280 | * @return EE_Form_Section_Proper |
281 | 281 | */ |
282 | - public function parent_section(){ |
|
282 | + public function parent_section() { |
|
283 | 283 | return $this->_parent_section; |
284 | 284 | } |
285 | 285 | |
@@ -292,18 +292,18 @@ discard block |
||
292 | 292 | * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML |
293 | 293 | * @return string |
294 | 294 | */ |
295 | - public function form_open( $action = '', $method = '', $other_attributes = '' ) { |
|
296 | - if ( ! empty( $action )) { |
|
297 | - $this->set_action( $action ); |
|
295 | + public function form_open($action = '', $method = '', $other_attributes = '') { |
|
296 | + if ( ! empty($action)) { |
|
297 | + $this->set_action($action); |
|
298 | 298 | } |
299 | - if ( ! empty( $method )) { |
|
300 | - $this->set_method( $method ); |
|
299 | + if ( ! empty($method)) { |
|
300 | + $this->set_method($method); |
|
301 | 301 | } |
302 | - $html = EEH_HTML::nl( 1, 'form' ) . '<form'; |
|
303 | - $html .= $this->html_id() !== '' ? ' id="' . $this->html_id() . '"' : ''; |
|
304 | - $html .= ' action="' . $this->action() . '"'; |
|
305 | - $html .= ' method="' . $this->method() . '"'; |
|
306 | - $html .= $other_attributes . '>'; |
|
302 | + $html = EEH_HTML::nl(1, 'form').'<form'; |
|
303 | + $html .= $this->html_id() !== '' ? ' id="'.$this->html_id().'"' : ''; |
|
304 | + $html .= ' action="'.$this->action().'"'; |
|
305 | + $html .= ' method="'.$this->method().'"'; |
|
306 | + $html .= $other_attributes.'>'; |
|
307 | 307 | return $html; |
308 | 308 | } |
309 | 309 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | * @return string |
315 | 315 | */ |
316 | 316 | public function form_close() { |
317 | - return EEH_HTML::nl( -1, 'form' ) . '</form>' . EEH_HTML::nl() . '<!-- end of ee-' . $this->html_id() . '-form -->' . EEH_HTML::nl(); |
|
317 | + return EEH_HTML::nl( -1, 'form' ).'</form>'.EEH_HTML::nl().'<!-- end of ee-'.$this->html_id().'-form -->'.EEH_HTML::nl(); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * @param array $form_other_js_data |
330 | 330 | * @return array |
331 | 331 | */ |
332 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
332 | + public function get_other_js_data($form_other_js_data = array()) { |
|
333 | 333 | return $form_other_js_data; |
334 | 334 | } |
335 | 335 | |
@@ -347,20 +347,20 @@ discard block |
||
347 | 347 | * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
348 | 348 | * @return EE_Form_Section_Base |
349 | 349 | */ |
350 | - public function find_section_from_path( $form_section_path ) { |
|
351 | - if( strpos( $form_section_path, '/' ) === 0 ) { |
|
352 | - $form_section_path = substr( $form_section_path, strlen( '/' ) ); |
|
350 | + public function find_section_from_path($form_section_path) { |
|
351 | + if (strpos($form_section_path, '/') === 0) { |
|
352 | + $form_section_path = substr($form_section_path, strlen('/')); |
|
353 | 353 | } |
354 | - if( empty( $form_section_path ) ) { |
|
354 | + if (empty($form_section_path)) { |
|
355 | 355 | return $this; |
356 | 356 | } |
357 | - if( strpos( $form_section_path, '../' ) === 0 ) { |
|
357 | + if (strpos($form_section_path, '../') === 0) { |
|
358 | 358 | $parent = $this->parent_section(); |
359 | 359 | |
360 | - $form_section_path = substr( $form_section_path, strlen( '../' ) ); |
|
361 | - if( $parent instanceof EE_Form_Section_Base ) { |
|
362 | - return $parent->find_section_from_path( $form_section_path ); |
|
363 | - } elseif( empty( $form_section_path ) ) { |
|
360 | + $form_section_path = substr($form_section_path, strlen('../')); |
|
361 | + if ($parent instanceof EE_Form_Section_Base) { |
|
362 | + return $parent->find_section_from_path($form_section_path); |
|
363 | + } elseif (empty($form_section_path)) { |
|
364 | 364 | return $this; |
365 | 365 | } |
366 | 366 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | if( $normalized_value ){ |
34 | 34 | if (filter_var($normalized_value, FILTER_VALIDATE_URL) === false){ |
35 | 35 | throw new EE_Validation_Error( $this->get_validation_error_message(), 'invalid_url'); |
36 | - }else{ |
|
36 | + } else{ |
|
37 | 37 | EE_Registry::instance()->load_helper('URL'); |
38 | 38 | if( ! EEH_URL::remote_file_exists( |
39 | 39 | $normalized_value, |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 4.6 |
9 | 9 | * |
10 | 10 | */ |
11 | -class EE_Conditionally_Required_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
11 | +class EE_Conditionally_Required_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Array describing conditions necessary to make the input required. |
@@ -24,12 +24,12 @@ discard block |
||
24 | 24 | * @param string $validation_error_message |
25 | 25 | * @param array $requirement_conditions |
26 | 26 | */ |
27 | - public function __construct( $validation_error_message = null, $requirement_conditions = array() ) { |
|
28 | - if( ! $validation_error_message ){ |
|
27 | + public function __construct($validation_error_message = null, $requirement_conditions = array()) { |
|
28 | + if ( ! $validation_error_message) { |
|
29 | 29 | $validation_error_message = __("This field is required.", "event_espresso"); |
30 | 30 | } |
31 | - $this->set_requirement_conditions( $requirement_conditions ); |
|
32 | - parent::__construct( $validation_error_message ); |
|
31 | + $this->set_requirement_conditions($requirement_conditions); |
|
32 | + parent::__construct($validation_error_message); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @throws \EE_Validation_Error |
45 | 45 | */ |
46 | 46 | public function validate($normalized_value) { |
47 | - if( |
|
47 | + if ( |
|
48 | 48 | ( |
49 | 49 | $normalized_value === '' |
50 | 50 | || $normalized_value === null |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | ) |
53 | 53 | && $this->_input_is_required_server_side() |
54 | 54 | ) { |
55 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'required'); |
|
56 | - }else{ |
|
55 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'required'); |
|
56 | + } else { |
|
57 | 57 | return true; |
58 | 58 | } |
59 | 59 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @return array |
65 | 65 | * @throws \EE_Error |
66 | 66 | */ |
67 | - public function get_jquery_validation_rule_array(){ |
|
67 | + public function get_jquery_validation_rule_array() { |
|
68 | 68 | return array( |
69 | 69 | 'required'=> $this->_get_jquery_requirement_value(), |
70 | 70 | 'messages' => array( |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @param array $requirement_conditions |
84 | 84 | */ |
85 | - public function set_requirement_conditions( $requirement_conditions ) { |
|
85 | + public function set_requirement_conditions($requirement_conditions) { |
|
86 | 86 | $this->requirement_conditions = (array) $requirement_conditions; |
87 | 87 | } |
88 | 88 | |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | protected function _get_jquery_requirement_value() { |
109 | 109 | $requirement_value = ''; |
110 | 110 | $conditions = $this->get_requirement_conditions(); |
111 | - if( ! is_array( $conditions ) ){ |
|
111 | + if ( ! is_array($conditions)) { |
|
112 | 112 | EE_Error::throw_exception_if_debugging( |
113 | 113 | sprintf( |
114 | - __( 'Input requirement conditions must be an array. You provided %1$s', 'event_espresso' ), |
|
114 | + __('Input requirement conditions must be an array. You provided %1$s', 'event_espresso'), |
|
115 | 115 | $this->_input->name() |
116 | 116 | ), |
117 | 117 | __FILE__, |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | ); |
121 | 121 | return true; |
122 | 122 | } |
123 | - if( count( $conditions ) > 1 ) { |
|
123 | + if (count($conditions) > 1) { |
|
124 | 124 | EE_Error::throw_exception_if_debugging( |
125 | 125 | sprintf( |
126 | - __( 'Required Validation Strategy does not yet support multiple conditions. You should add it! The related input is %1$s', 'event_espresso' ), |
|
126 | + __('Required Validation Strategy does not yet support multiple conditions. You should add it! The related input is %1$s', 'event_espresso'), |
|
127 | 127 | $this->_input->name() |
128 | 128 | ), |
129 | 129 | __FILE__, |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | __LINE__ |
132 | 132 | ); |
133 | 133 | } |
134 | - foreach( $conditions as $input_path => $op_and_value ) { |
|
135 | - $input = $this->_input->find_section_from_path( $input_path ); |
|
136 | - if( ! $input instanceof EE_Form_Input_Base ) { |
|
134 | + foreach ($conditions as $input_path => $op_and_value) { |
|
135 | + $input = $this->_input->find_section_from_path($input_path); |
|
136 | + if ( ! $input instanceof EE_Form_Input_Base) { |
|
137 | 137 | EE_Error::throw_exception_if_debugging( |
138 | 138 | sprintf( |
139 | - __( 'Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input'), |
|
139 | + __('Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input'), |
|
140 | 140 | $this->_input->name(), |
141 | 141 | $input_path |
142 | 142 | ), |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | ); |
147 | 147 | return false; |
148 | 148 | } |
149 | - list( $op, $value ) = $this->_validate_op_and_value( $op_and_value ); |
|
149 | + list($op, $value) = $this->_validate_op_and_value($op_and_value); |
|
150 | 150 | //ok now the jquery dependency expression depends on the input's display strategy. |
151 | - if( ! $input->get_display_strategy() instanceof EE_Select_Display_Strategy ) { |
|
151 | + if ( ! $input->get_display_strategy() instanceof EE_Select_Display_Strategy) { |
|
152 | 152 | EE_Error::throw_exception_if_debugging( |
153 | 153 | sprintf( |
154 | - __( 'Required Validation Strategy can only depend on another input which uses the EE_Select_Display_Strategy, but you specified a field "%1$s" that uses display strategy "%2$s". If you need others, please add support for it! The related input is %3$s', 'event_espresso' ), |
|
154 | + __('Required Validation Strategy can only depend on another input which uses the EE_Select_Display_Strategy, but you specified a field "%1$s" that uses display strategy "%2$s". If you need others, please add support for it! The related input is %3$s', 'event_espresso'), |
|
155 | 155 | $input->name(), |
156 | - get_class( $input->get_display_strategy() ), |
|
156 | + get_class($input->get_display_strategy()), |
|
157 | 157 | $this->_input->name() |
158 | 158 | ), |
159 | 159 | __FILE__, |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | __LINE__ |
162 | 162 | ); |
163 | 163 | } |
164 | - $requirement_value = $input->html_id( true ) . ' option[value="' . $value . '"]:selected'; |
|
164 | + $requirement_value = $input->html_id(true).' option[value="'.$value.'"]:selected'; |
|
165 | 165 | } |
166 | 166 | return $requirement_value; |
167 | 167 | } |
@@ -179,12 +179,12 @@ discard block |
||
179 | 179 | protected function _input_is_required_server_side() { |
180 | 180 | $meets_all_requirements = true; |
181 | 181 | $conditions = $this->get_requirement_conditions(); |
182 | - foreach( $conditions as $input_path => $op_and_value ) { |
|
183 | - $input = $this->_input->find_section_from_path( $input_path ); |
|
184 | - if( ! $input instanceof EE_Form_Input_Base ) { |
|
182 | + foreach ($conditions as $input_path => $op_and_value) { |
|
183 | + $input = $this->_input->find_section_from_path($input_path); |
|
184 | + if ( ! $input instanceof EE_Form_Input_Base) { |
|
185 | 185 | EE_Error::throw_exception_if_debugging( |
186 | 186 | sprintf( |
187 | - __( 'Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input'), |
|
187 | + __('Error encountered while setting requirement condition for input %1$s. The path %2$s does not correspond to a valid input'), |
|
188 | 188 | $this->_input->name(), |
189 | 189 | $input_path |
190 | 190 | ), |
@@ -194,13 +194,13 @@ discard block |
||
194 | 194 | ); |
195 | 195 | return false; |
196 | 196 | } |
197 | - list( $op, $value ) = $this->_validate_op_and_value( $op_and_value ); |
|
198 | - switch( $op ) { |
|
197 | + list($op, $value) = $this->_validate_op_and_value($op_and_value); |
|
198 | + switch ($op) { |
|
199 | 199 | case '=': |
200 | 200 | default: |
201 | 201 | $meets_all_requirements = $input->normalized_value() === $value; |
202 | 202 | } |
203 | - if( ! $meets_all_requirements ) { |
|
203 | + if ( ! $meets_all_requirements) { |
|
204 | 204 | break; |
205 | 205 | } |
206 | 206 | } |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | * @return array |
218 | 218 | * @throws \EE_Error |
219 | 219 | */ |
220 | - protected function _validate_op_and_value( $op_and_value ) { |
|
221 | - if( ! isset( $op_and_value[ 0 ], $op_and_value[ 1 ] ) ) { |
|
220 | + protected function _validate_op_and_value($op_and_value) { |
|
221 | + if ( ! isset($op_and_value[0], $op_and_value[1])) { |
|
222 | 222 | EE_Error::throw_exception_if_debugging( |
223 | 223 | sprintf( |
224 | - __( 'Required Validation Strategy conditions array\'s value must be an array with two elements: an operator, and a value. It didn\'t. The related input is %1$s', 'event_espresso' ), |
|
224 | + __('Required Validation Strategy conditions array\'s value must be an array with two elements: an operator, and a value. It didn\'t. The related input is %1$s', 'event_espresso'), |
|
225 | 225 | $this->_input->name() |
226 | 226 | ), |
227 | 227 | __FILE__, |
@@ -229,12 +229,12 @@ discard block |
||
229 | 229 | __LINE__ |
230 | 230 | ); |
231 | 231 | } |
232 | - $operator = $op_and_value[ 0 ]; |
|
233 | - $value = (string) $op_and_value[ 1 ]; |
|
234 | - if( $operator !== '=' ) { |
|
232 | + $operator = $op_and_value[0]; |
|
233 | + $value = (string) $op_and_value[1]; |
|
234 | + if ($operator !== '=') { |
|
235 | 235 | EE_Error::throw_exception_if_debugging( |
236 | 236 | sprintf( |
237 | - __( 'Required Validation Strategy conditions can currently only use the equals operator. If you need others, please add support for it! The related input is %1$s', 'event_espresso' ), |
|
237 | + __('Required Validation Strategy conditions can currently only use the equals operator. If you need others, please add support for it! The related input is %1$s', 'event_espresso'), |
|
238 | 238 | $this->_input->name() |
239 | 239 | ), |
240 | 240 | __FILE__, |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | __LINE__ |
243 | 243 | ); |
244 | 244 | } |
245 | - return array( $operator, $value ); |
|
245 | + return array($operator, $value); |
|
246 | 246 | |
247 | 247 | } |
248 | 248 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit( 'No direct script access allowed' ); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * Class EE_Select_Reveal_Input |
4 | 4 | * |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @since 4.6 |
12 | 12 | * |
13 | 13 | */ |
14 | -class EE_Select_Reveal_Input extends EE_Select_Input{ |
|
14 | +class EE_Select_Reveal_Input extends EE_Select_Input { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @param array $answer_options Array keys which match a sibling section's name |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @param array $input_settings |
28 | 28 | */ |
29 | - public function __construct( $answer_options, $input_settings = array() ){ |
|
30 | - parent::__construct( $answer_options, $input_settings ); |
|
29 | + public function __construct($answer_options, $input_settings = array()) { |
|
30 | + parent::__construct($answer_options, $input_settings); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -36,17 +36,17 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function sibling_sections_controlled() { |
38 | 38 | $sibling_sections = array(); |
39 | - foreach( $this->options() as $sibling_section_name => $sibling_section ) { |
|
39 | + foreach ($this->options() as $sibling_section_name => $sibling_section) { |
|
40 | 40 | //if it's an empty string just leave it alone |
41 | - if( empty( $sibling_section_name ) ) { |
|
41 | + if (empty($sibling_section_name)) { |
|
42 | 42 | continue; |
43 | 43 | } |
44 | - $sibling_section = $this->find_section_from_path( '../' . $sibling_section_name ); |
|
45 | - if( |
|
44 | + $sibling_section = $this->find_section_from_path('../'.$sibling_section_name); |
|
45 | + if ( |
|
46 | 46 | $sibling_section instanceof EE_Form_Section_Base |
47 | - && ! empty( $sibling_section_name ) |
|
47 | + && ! empty($sibling_section_name) |
|
48 | 48 | ) { |
49 | - $sibling_sections[ $sibling_section_name ] = $sibling_section; |
|
49 | + $sibling_sections[$sibling_section_name] = $sibling_section; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | return $sibling_sections; |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | * @param array $form_other_js_data |
60 | 60 | * @return array |
61 | 61 | */ |
62 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
63 | - if( ! isset($form_other_js_data[ 'select_reveal_inputs' ] ) ) { |
|
64 | - $form_other_js_data[ 'select_reveal_inputs' ] = array(); |
|
62 | + public function get_other_js_data($form_other_js_data = array()) { |
|
63 | + if ( ! isset($form_other_js_data['select_reveal_inputs'])) { |
|
64 | + $form_other_js_data['select_reveal_inputs'] = array(); |
|
65 | 65 | } |
66 | 66 | $sibling_input_to_html_id_map = array(); |
67 | - foreach( $this->sibling_sections_controlled() as $sibling_section_path => $sibling_section ) { |
|
68 | - $sibling_input_to_html_id_map[ $sibling_section_path ] = $sibling_section->html_id(); |
|
67 | + foreach ($this->sibling_sections_controlled() as $sibling_section_path => $sibling_section) { |
|
68 | + $sibling_input_to_html_id_map[$sibling_section_path] = $sibling_section->html_id(); |
|
69 | 69 | } |
70 | - $form_other_js_data[ 'select_reveal_inputs' ][ $this->html_id() ] = $sibling_input_to_html_id_map; |
|
70 | + $form_other_js_data['select_reveal_inputs'][$this->html_id()] = $sibling_input_to_html_id_map; |
|
71 | 71 | return $form_other_js_data; |
72 | 72 | } |
73 | 73 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
2 | 2 | // if you're a dev and want to receive all errors via email add this to your wp-config.php: define( 'EE_ERROR_EMAILS', TRUE ); |
3 | -if ( defined( 'WP_DEBUG' ) && WP_DEBUG === TRUE && defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS === TRUE ) { |
|
4 | - set_error_handler( array( 'EE_Error', 'error_handler' )); |
|
5 | - register_shutdown_function( array( 'EE_Error', 'fatal_error_handler' )); |
|
3 | +if (defined('WP_DEBUG') && WP_DEBUG === TRUE && defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS === TRUE) { |
|
4 | + set_error_handler(array('EE_Error', 'error_handler')); |
|
5 | + register_shutdown_function(array('EE_Error', 'fatal_error_handler')); |
|
6 | 6 | } |
7 | 7 | /** |
8 | 8 | * |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @access private |
65 | 65 | * @var boolean |
66 | 66 | */ |
67 | - private static $_espresso_notices = array( 'success' => FALSE, 'errors' => FALSE, 'attention' => FALSE ); |
|
67 | + private static $_espresso_notices = array('success' => FALSE, 'errors' => FALSE, 'attention' => FALSE); |
|
68 | 68 | |
69 | 69 | |
70 | 70 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @access public |
76 | 76 | * @echo string |
77 | 77 | */ |
78 | - function __construct( $message, $code = 0, Exception $previous = NULL ) { |
|
79 | - if ( version_compare( phpversion(), '5.3.0', '<' )) { |
|
80 | - parent::__construct( $message, $code ); |
|
78 | + function __construct($message, $code = 0, Exception $previous = NULL) { |
|
79 | + if (version_compare(phpversion(), '5.3.0', '<')) { |
|
80 | + parent::__construct($message, $code); |
|
81 | 81 | } else { |
82 | - parent::__construct( $message, $code, $previous ); |
|
82 | + parent::__construct($message, $code, $previous); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | * @param $line |
95 | 95 | * @return void |
96 | 96 | */ |
97 | - public static function error_handler( $code, $message, $file, $line ) { |
|
98 | - $type = EE_Error::error_type( $code ); |
|
97 | + public static function error_handler($code, $message, $file, $line) { |
|
98 | + $type = EE_Error::error_type($code); |
|
99 | 99 | $site = site_url(); |
100 | - switch ( $site ) { |
|
100 | + switch ($site) { |
|
101 | 101 | case 'http://ee4.eventespresso.com/' : |
102 | 102 | case 'http://ee4decaf.eventespresso.com/' : |
103 | 103 | case 'http://ee4hf.eventespresso.com/' : |
@@ -110,16 +110,16 @@ discard block |
||
110 | 110 | $to = '[email protected]'; |
111 | 111 | break; |
112 | 112 | default : |
113 | - $to = get_option( 'admin_email' ); |
|
113 | + $to = get_option('admin_email'); |
|
114 | 114 | } |
115 | - $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url(); |
|
116 | - $msg = EE_Error::_format_error( $type, $message, $file, $line ); |
|
117 | - if ( function_exists( 'wp_mail' )) { |
|
118 | - add_filter( 'wp_mail_content_type', array( 'EE_Error', 'set_content_type' )); |
|
119 | - wp_mail( $to, $subject, $msg ); |
|
115 | + $subject = $type.' '.$message.' in '.EVENT_ESPRESSO_VERSION.' on '.site_url(); |
|
116 | + $msg = EE_Error::_format_error($type, $message, $file, $line); |
|
117 | + if (function_exists('wp_mail')) { |
|
118 | + add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type')); |
|
119 | + wp_mail($to, $subject, $msg); |
|
120 | 120 | } |
121 | 121 | echo '<div id="message" class="espresso-notices error"><p>'; |
122 | - echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line; |
|
122 | + echo $type.': '.$message.'<br />'.$file.' line '.$line; |
|
123 | 123 | echo '<br /></p></div>'; |
124 | 124 | } |
125 | 125 | |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | * @param $code |
133 | 133 | * @return string |
134 | 134 | */ |
135 | - public static function error_type( $code ) { |
|
136 | - switch( $code ) { |
|
135 | + public static function error_type($code) { |
|
136 | + switch ($code) { |
|
137 | 137 | case E_ERROR: // 1 // |
138 | 138 | return 'E_ERROR'; |
139 | 139 | case E_WARNING: // 2 // |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public static function fatal_error_handler() { |
181 | 181 | $last_error = error_get_last(); |
182 | - if ( $last_error['type'] === E_ERROR ) { |
|
183 | - EE_Error::error_handler( E_ERROR, $last_error['message'], $last_error['file'], $last_error['line'] ); |
|
182 | + if ($last_error['type'] === E_ERROR) { |
|
183 | + EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * @param $line |
196 | 196 | * @return string |
197 | 197 | */ |
198 | - private static function _format_error( $code, $message, $file, $line ) { |
|
198 | + private static function _format_error($code, $message, $file, $line) { |
|
199 | 199 | $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>"; |
200 | 200 | $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>"; |
201 | 201 | $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>"; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * @param $content_type |
214 | 214 | * @return string |
215 | 215 | */ |
216 | - public static function set_content_type( $content_type ) { |
|
216 | + public static function set_content_type($content_type) { |
|
217 | 217 | return 'text/html'; |
218 | 218 | } |
219 | 219 | |
@@ -227,24 +227,24 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function get_error() { |
229 | 229 | |
230 | - if( apply_filters( 'FHEE__EE_Error__get_error__show_normal_exceptions', FALSE ) ){ |
|
230 | + if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', FALSE)) { |
|
231 | 231 | throw $this; |
232 | 232 | } |
233 | 233 | // get separate user and developer messages if they exist |
234 | - $msg = explode( '||', $this->getMessage() ); |
|
234 | + $msg = explode('||', $this->getMessage()); |
|
235 | 235 | $user_msg = $msg[0]; |
236 | - $dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0]; |
|
236 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
237 | 237 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
238 | 238 | |
239 | 239 | // add details to _all_exceptions array |
240 | 240 | $x_time = time(); |
241 | - self::$_all_exceptions[ $x_time ]['name'] = get_class( $this ); |
|
242 | - self::$_all_exceptions[ $x_time ]['file'] = $this->getFile(); |
|
243 | - self::$_all_exceptions[ $x_time ]['line'] = $this->getLine(); |
|
244 | - self::$_all_exceptions[ $x_time ]['msg'] = $msg; |
|
245 | - self::$_all_exceptions[ $x_time ]['code'] = $this->getCode(); |
|
246 | - self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace(); |
|
247 | - self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString(); |
|
241 | + self::$_all_exceptions[$x_time]['name'] = get_class($this); |
|
242 | + self::$_all_exceptions[$x_time]['file'] = $this->getFile(); |
|
243 | + self::$_all_exceptions[$x_time]['line'] = $this->getLine(); |
|
244 | + self::$_all_exceptions[$x_time]['msg'] = $msg; |
|
245 | + self::$_all_exceptions[$x_time]['code'] = $this->getCode(); |
|
246 | + self::$_all_exceptions[$x_time]['trace'] = $this->getTrace(); |
|
247 | + self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString(); |
|
248 | 248 | self::$_error_count++; |
249 | 249 | |
250 | 250 | //add_action( 'shutdown', array( $this, 'display_errors' )); |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @access public |
260 | 260 | * @return boolean |
261 | 261 | */ |
262 | - public static function has_error(){ |
|
262 | + public static function has_error() { |
|
263 | 263 | return self::$_error_count ? TRUE : FALSE; |
264 | 264 | } |
265 | 265 | |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @access public |
271 | 271 | * @echo string |
272 | 272 | */ |
273 | - public function display_errors(){ |
|
273 | + public function display_errors() { |
|
274 | 274 | |
275 | 275 | $trace_details = ''; |
276 | 276 | |
@@ -331,18 +331,18 @@ discard block |
||
331 | 331 | </style> |
332 | 332 | <div id="ee-error-message" class="error">'; |
333 | 333 | |
334 | - if ( ! WP_DEBUG ) { |
|
334 | + if ( ! WP_DEBUG) { |
|
335 | 335 | $output .= ' |
336 | 336 | <p>'; |
337 | 337 | } |
338 | 338 | |
339 | 339 | // cycle thru errors |
340 | - foreach ( self::$_all_exceptions as $time => $ex ) { |
|
340 | + foreach (self::$_all_exceptions as $time => $ex) { |
|
341 | 341 | |
342 | 342 | // process trace info |
343 | - if ( empty( $ex['trace'] )) { |
|
343 | + if (empty($ex['trace'])) { |
|
344 | 344 | |
345 | - $trace_details .= __( 'Sorry, but no trace information was available for this exception.', 'event_espresso' ); |
|
345 | + $trace_details .= __('Sorry, but no trace information was available for this exception.', 'event_espresso'); |
|
346 | 346 | |
347 | 347 | } else { |
348 | 348 | |
@@ -357,50 +357,50 @@ discard block |
||
357 | 357 | <th scope="col" align="left">Method( arguments )</th> |
358 | 358 | </tr>'; |
359 | 359 | |
360 | - $last_on_stack = count( $ex['trace'] ) - 1; |
|
360 | + $last_on_stack = count($ex['trace']) - 1; |
|
361 | 361 | // reverse array so that stack is in proper chronological order |
362 | - $sorted_trace = array_reverse( $ex['trace'] ); |
|
362 | + $sorted_trace = array_reverse($ex['trace']); |
|
363 | 363 | |
364 | - foreach ( $sorted_trace as $nmbr => $trace ) { |
|
364 | + foreach ($sorted_trace as $nmbr => $trace) { |
|
365 | 365 | |
366 | - $file = isset( $trace['file'] ) ? $trace['file'] : '' ; |
|
367 | - $class = isset( $trace['class'] ) ? $trace['class'] : ''; |
|
368 | - $type = isset( $trace['type'] ) ? $trace['type'] : ''; |
|
369 | - $function = isset( $trace['function'] ) ? $trace['function'] : ''; |
|
370 | - $args = isset( $trace['args'] ) ? $this->_convert_args_to_string( $trace['args'] ) : ''; |
|
371 | - $line = isset( $trace['line'] ) ? $trace['line'] : ''; |
|
366 | + $file = isset($trace['file']) ? $trace['file'] : ''; |
|
367 | + $class = isset($trace['class']) ? $trace['class'] : ''; |
|
368 | + $type = isset($trace['type']) ? $trace['type'] : ''; |
|
369 | + $function = isset($trace['function']) ? $trace['function'] : ''; |
|
370 | + $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : ''; |
|
371 | + $line = isset($trace['line']) ? $trace['line'] : ''; |
|
372 | 372 | $zebra = $nmbr % 2 ? ' odd' : ''; |
373 | 373 | |
374 | - if ( empty( $file ) && ! empty( $class )) { |
|
375 | - $a = new ReflectionClass( $class ); |
|
374 | + if (empty($file) && ! empty($class)) { |
|
375 | + $a = new ReflectionClass($class); |
|
376 | 376 | $file = $a->getFileName(); |
377 | - if ( empty( $line ) && ! empty( $function )) { |
|
378 | - $b = new ReflectionMethod( $class, $function ); |
|
377 | + if (empty($line) && ! empty($function)) { |
|
378 | + $b = new ReflectionMethod($class, $function); |
|
379 | 379 | $line = $b->getStartLine(); |
380 | 380 | } |
381 | 381 | } |
382 | 382 | |
383 | - if ( $nmbr == $last_on_stack ) { |
|
383 | + if ($nmbr == $last_on_stack) { |
|
384 | 384 | $file = $ex['file'] != '' ? $ex['file'] : $file; |
385 | 385 | $line = $ex['line'] != '' ? $ex['line'] : $line; |
386 | - $error_code = self::generate_error_code ( $file, $trace['function'], $line ); |
|
386 | + $error_code = self::generate_error_code($file, $trace['function'], $line); |
|
387 | 387 | } |
388 | 388 | |
389 | - $nmbr_dsply = ! empty( $nmbr ) ? $nmbr : ' '; |
|
390 | - $line_dsply = ! empty( $line ) ? $line : ' '; |
|
391 | - $file_dsply = ! empty( $file ) ? $file : ' '; |
|
392 | - $class_dsply = ! empty( $class ) ? $class : ' '; |
|
393 | - $type_dsply = ! empty( $type ) ? $type : ' '; |
|
394 | - $function_dsply = ! empty( $function ) ? $function : ' '; |
|
395 | - $args_dsply = ! empty( $args ) ? '( ' . $args . ' )' : ''; |
|
389 | + $nmbr_dsply = ! empty($nmbr) ? $nmbr : ' '; |
|
390 | + $line_dsply = ! empty($line) ? $line : ' '; |
|
391 | + $file_dsply = ! empty($file) ? $file : ' '; |
|
392 | + $class_dsply = ! empty($class) ? $class : ' '; |
|
393 | + $type_dsply = ! empty($type) ? $type : ' '; |
|
394 | + $function_dsply = ! empty($function) ? $function : ' '; |
|
395 | + $args_dsply = ! empty($args) ? '( '.$args.' )' : ''; |
|
396 | 396 | |
397 | 397 | $trace_details .= ' |
398 | 398 | <tr> |
399 | - <td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td> |
|
400 | - <td align="right" class="' . $zebra . '">' . $line_dsply . '</td> |
|
401 | - <td align="left" class="' . $zebra . '">' . $file_dsply . '</td> |
|
402 | - <td align="left" class="' . $zebra . '">' . $class_dsply . '</td> |
|
403 | - <td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td> |
|
399 | + <td align="right" class="' . $zebra.'">'.$nmbr_dsply.'</td> |
|
400 | + <td align="right" class="' . $zebra.'">'.$line_dsply.'</td> |
|
401 | + <td align="left" class="' . $zebra.'">'.$file_dsply.'</td> |
|
402 | + <td align="left" class="' . $zebra.'">'.$class_dsply.'</td> |
|
403 | + <td align="left" class="' . $zebra.'">'.$type_dsply.$function_dsply.$args_dsply.'</td> |
|
404 | 404 | </tr>'; |
405 | 405 | |
406 | 406 | |
@@ -415,9 +415,9 @@ discard block |
||
415 | 415 | $ex['code'] = $ex['code'] ? $ex['code'] : $error_code; |
416 | 416 | |
417 | 417 | // add generic non-identifying messages for non-privileged uesrs |
418 | - if ( ! WP_DEBUG ) { |
|
418 | + if ( ! WP_DEBUG) { |
|
419 | 419 | |
420 | - $output .= '<span class="ee-error-user-msg-spn">' . trim( $ex['msg'] ) . '</span> <sup>' . $ex['code'] . '</sup><br />'; |
|
420 | + $output .= '<span class="ee-error-user-msg-spn">'.trim($ex['msg']).'</span> <sup>'.$ex['code'].'</sup><br />'; |
|
421 | 421 | |
422 | 422 | } else { |
423 | 423 | |
@@ -425,24 +425,24 @@ discard block |
||
425 | 425 | $output .= ' |
426 | 426 | <div class="ee-error-dev-msg-dv"> |
427 | 427 | <p class="ee-error-dev-msg-pg"> |
428 | - <strong class="ee-error-dev-msg-str">An ' . $ex['name'] . ' exception was thrown!</strong> <span>code: ' . $ex['code'] . '</span><br /> |
|
429 | - <span class="big-text">"' . trim( $ex['msg'] ) . '"</span><br/> |
|
430 | - <a id="display-ee-error-trace-' . self::$_error_count . $time . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-' . self::$_error_count . $time . '"> |
|
431 | - ' . __( 'click to view backtrace and class/method details', 'event_espresso' ) . ' |
|
428 | + <strong class="ee-error-dev-msg-str">An ' . $ex['name'].' exception was thrown!</strong> <span>code: '.$ex['code'].'</span><br /> |
|
429 | + <span class="big-text">"' . trim($ex['msg']).'"</span><br/> |
|
430 | + <a id="display-ee-error-trace-' . self::$_error_count.$time.'" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'.self::$_error_count.$time.'"> |
|
431 | + ' . __('click to view backtrace and class/method details', 'event_espresso').' |
|
432 | 432 | </a><br /> |
433 | 433 | <span class="small-text lt-grey-text">'.$ex['file'].' ( line no: '.$ex['line'].' )</span> |
434 | 434 | </p> |
435 | - <div id="ee-error-trace-' . self::$_error_count . $time . '-dv" class="ee-error-trace-dv" style="display: none;"> |
|
435 | + <div id="ee-error-trace-' . self::$_error_count.$time.'-dv" class="ee-error-trace-dv" style="display: none;"> |
|
436 | 436 | ' . $trace_details; |
437 | 437 | |
438 | - if ( ! empty( $class )) { |
|
438 | + if ( ! empty($class)) { |
|
439 | 439 | $output .= ' |
440 | 440 | <div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;"> |
441 | 441 | <div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;"> |
442 | 442 | <h3>Class Details</h3>'; |
443 | - $a = new ReflectionClass( $class ); |
|
443 | + $a = new ReflectionClass($class); |
|
444 | 444 | $output .= ' |
445 | - <pre>' . $a . '</pre> |
|
445 | + <pre>' . $a.'</pre> |
|
446 | 446 | </div> |
447 | 447 | </div>'; |
448 | 448 | } |
@@ -454,14 +454,14 @@ discard block |
||
454 | 454 | |
455 | 455 | } |
456 | 456 | |
457 | - $this->write_to_error_log( $time, $ex ); |
|
457 | + $this->write_to_error_log($time, $ex); |
|
458 | 458 | |
459 | 459 | } |
460 | 460 | |
461 | 461 | // remove last linebreak |
462 | - $output = substr( $output, 0, ( count( $output ) - 7 )); |
|
462 | + $output = substr($output, 0, (count($output) - 7)); |
|
463 | 463 | |
464 | - if ( ! WP_DEBUG ) { |
|
464 | + if ( ! WP_DEBUG) { |
|
465 | 465 | $output .= ' |
466 | 466 | </p>'; |
467 | 467 | } |
@@ -469,10 +469,10 @@ discard block |
||
469 | 469 | $output .= ' |
470 | 470 | </div>'; |
471 | 471 | |
472 | - $output .= self::_print_scripts( TRUE ); |
|
472 | + $output .= self::_print_scripts(TRUE); |
|
473 | 473 | |
474 | - if ( defined( 'DOING_AJAX' )) { |
|
475 | - echo json_encode( array( 'error' => $output )); |
|
474 | + if (defined('DOING_AJAX')) { |
|
475 | + echo json_encode(array('error' => $output)); |
|
476 | 476 | exit(); |
477 | 477 | } |
478 | 478 | |
@@ -492,29 +492,29 @@ discard block |
||
492 | 492 | * @ param array $arguments |
493 | 493 | * @ return string |
494 | 494 | */ |
495 | - private function _convert_args_to_string ( $arguments = array(), $array = FALSE ) { |
|
495 | + private function _convert_args_to_string($arguments = array(), $array = FALSE) { |
|
496 | 496 | |
497 | 497 | $arg_string = ''; |
498 | - if ( ! empty( $arguments )) { |
|
498 | + if ( ! empty($arguments)) { |
|
499 | 499 | |
500 | 500 | $args = array(); |
501 | 501 | |
502 | - foreach ( $arguments as $arg ) { |
|
502 | + foreach ($arguments as $arg) { |
|
503 | 503 | |
504 | - if ( ! empty( $arg )) { |
|
504 | + if ( ! empty($arg)) { |
|
505 | 505 | |
506 | - if ( is_string( $arg )) { |
|
507 | - $args[] = " '" . $arg . "'"; |
|
508 | - } elseif ( is_array( $arg )) { |
|
509 | - $args[] = 'ARRAY(' . $this->_convert_args_to_string( $arg, TRUE ); |
|
510 | - } elseif ( is_null( $arg )) { |
|
506 | + if (is_string($arg)) { |
|
507 | + $args[] = " '".$arg."'"; |
|
508 | + } elseif (is_array($arg)) { |
|
509 | + $args[] = 'ARRAY('.$this->_convert_args_to_string($arg, TRUE); |
|
510 | + } elseif (is_null($arg)) { |
|
511 | 511 | $args[] = ' NULL'; |
512 | - } elseif ( is_bool( $arg )) { |
|
513 | - $args[] = ( $arg ) ? ' TRUE' : ' FALSE'; |
|
514 | - } elseif ( is_object( $arg )) { |
|
515 | - $args[] = ' OBJECT ' . get_class( $arg ); |
|
516 | - } elseif ( is_resource( $arg )) { |
|
517 | - $args[] = get_resource_type( $arg ); |
|
512 | + } elseif (is_bool($arg)) { |
|
513 | + $args[] = ($arg) ? ' TRUE' : ' FALSE'; |
|
514 | + } elseif (is_object($arg)) { |
|
515 | + $args[] = ' OBJECT '.get_class($arg); |
|
516 | + } elseif (is_resource($arg)) { |
|
517 | + $args[] = get_resource_type($arg); |
|
518 | 518 | } else { |
519 | 519 | $args[] = $arg; |
520 | 520 | } |
@@ -522,9 +522,9 @@ discard block |
||
522 | 522 | } |
523 | 523 | |
524 | 524 | } |
525 | - $arg_string = implode( ', ', $args ); |
|
525 | + $arg_string = implode(', ', $args); |
|
526 | 526 | } |
527 | - if ( $array ) { |
|
527 | + if ($array) { |
|
528 | 528 | $arg_string .= ' )'; |
529 | 529 | } |
530 | 530 | return $arg_string; |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | * @param string $line the line number where the error occurred - just use __LINE__ |
545 | 545 | * @return void |
546 | 546 | */ |
547 | - public static function add_error( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
548 | - self::_add_notice ( 'errors', $msg, $file, $func, $line ); |
|
547 | + public static function add_error($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
548 | + self::_add_notice('errors', $msg, $file, $func, $line); |
|
549 | 549 | self::$_error_count++; |
550 | 550 | } |
551 | 551 | |
@@ -558,11 +558,11 @@ discard block |
||
558 | 558 | * @param string $line |
559 | 559 | * @throws EE_Error |
560 | 560 | */ |
561 | - public static function throw_exception_if_debugging( $msg = null, $file = null, $func = null, $line = null ) { |
|
562 | - if( WP_DEBUG ) { |
|
563 | - throw new EE_Error( $msg ); |
|
564 | - } else { |
|
565 | - EE_Error::add_error( $msg, $file, $func, $line ); |
|
561 | + public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null) { |
|
562 | + if (WP_DEBUG) { |
|
563 | + throw new EE_Error($msg); |
|
564 | + } else { |
|
565 | + EE_Error::add_error($msg, $file, $func, $line); |
|
566 | 566 | } |
567 | 567 | } |
568 | 568 | |
@@ -580,8 +580,8 @@ discard block |
||
580 | 580 | * @param string $line the line number where the error occurred - just use __LINE__ |
581 | 581 | * @return void |
582 | 582 | */ |
583 | - public static function add_success( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
584 | - self::_add_notice ( 'success', $msg, $file, $func, $line ); |
|
583 | + public static function add_success($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
584 | + self::_add_notice('success', $msg, $file, $func, $line); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | |
@@ -598,8 +598,8 @@ discard block |
||
598 | 598 | * @param string $line the line number where the error occurred - just use __LINE__ |
599 | 599 | * @return void |
600 | 600 | */ |
601 | - public static function add_attention( $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
602 | - self::_add_notice ( 'attention', $msg, $file, $func, $line ); |
|
601 | + public static function add_attention($msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
602 | + self::_add_notice('attention', $msg, $file, $func, $line); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | |
@@ -617,12 +617,12 @@ discard block |
||
617 | 617 | * @param string $line the line number where the error occurred - just use __LINE__ |
618 | 618 | * @return void |
619 | 619 | */ |
620 | - private static function _add_notice( $type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL ) { |
|
621 | - if ( empty( $msg )) { |
|
620 | + private static function _add_notice($type = 'success', $msg = NULL, $file = NULL, $func = NULL, $line = NULL) { |
|
621 | + if (empty($msg)) { |
|
622 | 622 | EE_Error::doing_it_wrong( |
623 | - 'EE_Error::add_' . $type . '()', |
|
623 | + 'EE_Error::add_'.$type.'()', |
|
624 | 624 | sprintf( |
625 | - __( 'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', 'event_espresso' ), |
|
625 | + __('Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d', 'event_espresso'), |
|
626 | 626 | $type, |
627 | 627 | $file, |
628 | 628 | $line |
@@ -630,32 +630,32 @@ discard block |
||
630 | 630 | EVENT_ESPRESSO_VERSION |
631 | 631 | ); |
632 | 632 | } |
633 | - if ( $type == 'errors' && ( empty( $file ) || empty( $func ) || empty( $line ))) { |
|
633 | + if ($type == 'errors' && (empty($file) || empty($func) || empty($line))) { |
|
634 | 634 | EE_Error::doing_it_wrong( |
635 | 635 | 'EE_Error::add_error()', |
636 | - __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', 'event_espresso' ), |
|
636 | + __('You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.', 'event_espresso'), |
|
637 | 637 | EVENT_ESPRESSO_VERSION |
638 | 638 | ); |
639 | 639 | } |
640 | 640 | // get separate user and developer messages if they exist |
641 | - $msg = explode( '||', $msg ); |
|
641 | + $msg = explode('||', $msg); |
|
642 | 642 | $user_msg = $msg[0]; |
643 | - $dev_msg = isset( $msg[1] ) ? $msg[1] : $msg[0]; |
|
643 | + $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0]; |
|
644 | 644 | $msg = WP_DEBUG ? $dev_msg : $user_msg; |
645 | 645 | // add notice if message exists |
646 | - if ( ! empty( $msg )) { |
|
646 | + if ( ! empty($msg)) { |
|
647 | 647 | // get error code |
648 | - $notice_code = EE_Error::generate_error_code( $file, $func, $line ); |
|
649 | - if ( WP_DEBUG && $type == 'errors' ) { |
|
650 | - $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>'; |
|
648 | + $notice_code = EE_Error::generate_error_code($file, $func, $line); |
|
649 | + if (WP_DEBUG && $type == 'errors') { |
|
650 | + $msg .= '<br/><span class="tiny-text">'.$notice_code.'</span>'; |
|
651 | 651 | } |
652 | 652 | // add notice. Index by code if it's not blank |
653 | - if( $notice_code ) { |
|
654 | - self::$_espresso_notices[ $type ][ $notice_code ] = $msg; |
|
653 | + if ($notice_code) { |
|
654 | + self::$_espresso_notices[$type][$notice_code] = $msg; |
|
655 | 655 | } else { |
656 | - self::$_espresso_notices[ $type ][] = $msg; |
|
656 | + self::$_espresso_notices[$type][] = $msg; |
|
657 | 657 | } |
658 | - add_action( 'wp_footer', array( 'EE_Error', 'enqueue_error_scripts' ), 1 ); |
|
658 | + add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | } |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | * @access private |
710 | 710 | * @return void |
711 | 711 | */ |
712 | - public static function reset_notices(){ |
|
712 | + public static function reset_notices() { |
|
713 | 713 | self::$_espresso_notices['success'] = FALSE; |
714 | 714 | self::$_espresso_notices['attention'] = FALSE; |
715 | 715 | self::$_espresso_notices['errors'] = FALSE; |
@@ -722,14 +722,14 @@ discard block |
||
722 | 722 | * @access public |
723 | 723 | * @return int |
724 | 724 | */ |
725 | - public static function has_notices(){ |
|
725 | + public static function has_notices() { |
|
726 | 726 | $has_notices = 0; |
727 | 727 | // check for success messages |
728 | - $has_notices = self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] ) ? 3 : $has_notices; |
|
728 | + $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success']) ? 3 : $has_notices; |
|
729 | 729 | // check for attention messages |
730 | - $has_notices = self::$_espresso_notices['attention'] && ! empty( self::$_espresso_notices['attention'] ) ? 2 : $has_notices; |
|
730 | + $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention']) ? 2 : $has_notices; |
|
731 | 731 | // check for error messages |
732 | - $has_notices = self::$_espresso_notices['errors'] && ! empty( self::$_espresso_notices['errors'] ) ? 1 : $has_notices; |
|
732 | + $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors']) ? 1 : $has_notices; |
|
733 | 733 | return $has_notices; |
734 | 734 | } |
735 | 735 | |
@@ -744,9 +744,9 @@ discard block |
||
744 | 744 | */ |
745 | 745 | public static function get_vanilla_notices() { |
746 | 746 | return array( |
747 | - 'success' => isset( self::$_espresso_notices['success'] ) ? self::$_espresso_notices['success'] : array(), |
|
748 | - 'attention' => isset( self::$_espresso_notices['attention'] ) ? self::$_espresso_notices['attention'] : array(), |
|
749 | - 'errors' => isset( self::$_espresso_notices['errors'] ) ? self::$_espresso_notices['errors'] : array(), |
|
747 | + 'success' => isset(self::$_espresso_notices['success']) ? self::$_espresso_notices['success'] : array(), |
|
748 | + 'attention' => isset(self::$_espresso_notices['attention']) ? self::$_espresso_notices['attention'] : array(), |
|
749 | + 'errors' => isset(self::$_espresso_notices['errors']) ? self::$_espresso_notices['errors'] : array(), |
|
750 | 750 | ); |
751 | 751 | } |
752 | 752 | |
@@ -762,8 +762,8 @@ discard block |
||
762 | 762 | * @param boolean $remove_empty whether or not to unset empty messages |
763 | 763 | * @return array |
764 | 764 | */ |
765 | - public static function get_notices( $format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE ) { |
|
766 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
765 | + public static function get_notices($format_output = TRUE, $save_to_transient = FALSE, $remove_empty = TRUE) { |
|
766 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
767 | 767 | |
768 | 768 | $success_messages = ''; |
769 | 769 | $attention_messages = ''; |
@@ -773,44 +773,44 @@ discard block |
||
773 | 773 | // EEH_Debug_Tools::printr( self::$_espresso_notices, 'espresso_notices <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); |
774 | 774 | |
775 | 775 | // either save notices to the db |
776 | - if ( $save_to_transient ) { |
|
777 | - update_option( 'ee_notices', self::$_espresso_notices ); |
|
776 | + if ($save_to_transient) { |
|
777 | + update_option('ee_notices', self::$_espresso_notices); |
|
778 | 778 | return; |
779 | 779 | } |
780 | 780 | // grab any notices that have been previously saved |
781 | - if ( $notices = get_option( 'ee_notices', FALSE )) { |
|
782 | - foreach ( $notices as $type => $notice ) { |
|
783 | - if ( is_array( $notice ) && ! empty( $notice )) { |
|
781 | + if ($notices = get_option('ee_notices', FALSE)) { |
|
782 | + foreach ($notices as $type => $notice) { |
|
783 | + if (is_array($notice) && ! empty($notice)) { |
|
784 | 784 | // make sure that existsing notice type is an array |
785 | - self::$_espresso_notices[ $type ] = is_array( self::$_espresso_notices[ $type ] ) && ! empty( self::$_espresso_notices[ $type ] ) ? self::$_espresso_notices[ $type ] : array(); |
|
785 | + self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type]) && ! empty(self::$_espresso_notices[$type]) ? self::$_espresso_notices[$type] : array(); |
|
786 | 786 | // merge stored notices with any newly created ones |
787 | - self::$_espresso_notices[ $type ] = array_merge( self::$_espresso_notices[ $type ], $notice ); |
|
787 | + self::$_espresso_notices[$type] = array_merge(self::$_espresso_notices[$type], $notice); |
|
788 | 788 | $print_scripts = TRUE; |
789 | 789 | } |
790 | 790 | } |
791 | 791 | // now clear any stored notices |
792 | - update_option( 'ee_notices', FALSE ); |
|
792 | + update_option('ee_notices', FALSE); |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | // check for success messages |
796 | - if ( self::$_espresso_notices['success'] && ! empty( self::$_espresso_notices['success'] )) { |
|
796 | + if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) { |
|
797 | 797 | // combine messages |
798 | - $success_messages .= implode( self::$_espresso_notices['success'], '<br />' ); |
|
798 | + $success_messages .= implode(self::$_espresso_notices['success'], '<br />'); |
|
799 | 799 | $print_scripts = TRUE; |
800 | 800 | } |
801 | 801 | |
802 | 802 | // check for attention messages |
803 | - if ( self::$_espresso_notices['attention'] && ! empty( self::$_espresso_notices['attention'] ) ) { |
|
803 | + if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) { |
|
804 | 804 | // combine messages |
805 | - $attention_messages .= implode( self::$_espresso_notices['attention'], '<br />' ); |
|
805 | + $attention_messages .= implode(self::$_espresso_notices['attention'], '<br />'); |
|
806 | 806 | $print_scripts = TRUE; |
807 | 807 | } |
808 | 808 | |
809 | 809 | // check for error messages |
810 | - if ( self::$_espresso_notices['errors'] && ! empty( self::$_espresso_notices['errors'] ) ) { |
|
811 | - $error_messages .= count( self::$_espresso_notices['errors'] ) > 1 ? __( 'The following errors have occurred:<br />', 'event_espresso' ) : __( 'An error has occurred:<br />', 'event_espresso' ); |
|
810 | + if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) { |
|
811 | + $error_messages .= count(self::$_espresso_notices['errors']) > 1 ? __('The following errors have occurred:<br />', 'event_espresso') : __('An error has occurred:<br />', 'event_espresso'); |
|
812 | 812 | // combine messages |
813 | - $error_messages .= implode( self::$_espresso_notices['errors'], '<br />' ); |
|
813 | + $error_messages .= implode(self::$_espresso_notices['errors'], '<br />'); |
|
814 | 814 | $print_scripts = TRUE; |
815 | 815 | } |
816 | 816 | |
@@ -824,21 +824,21 @@ discard block |
||
824 | 824 | $css_id = is_admin() ? 'message' : 'espresso-notices-success'; |
825 | 825 | $css_class = is_admin() ? 'updated fade' : 'success fade-away'; |
826 | 826 | //showMessage( $success_messages ); |
827 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $success_messages . '</p>' . $close . '</div>'; |
|
827 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$success_messages.'</p>'.$close.'</div>'; |
|
828 | 828 | } |
829 | 829 | |
830 | 830 | if ($attention_messages != '') { |
831 | 831 | $css_id = is_admin() ? 'message' : 'espresso-notices-attention'; |
832 | 832 | $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away'; |
833 | 833 | //showMessage( $error_messages, TRUE ); |
834 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $attention_messages . '</p>' . $close . '</div>'; |
|
834 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$attention_messages.'</p>'.$close.'</div>'; |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | if ($error_messages != '') { |
838 | 838 | $css_id = is_admin() ? 'message' : 'espresso-notices-error'; |
839 | 839 | $css_class = is_admin() ? 'error' : 'error fade-away'; |
840 | 840 | //showMessage( $error_messages, TRUE ); |
841 | - $notices .= '<div id="' . $css_id . '" class="espresso-notices ' . $css_class . '" style="display:none;"><p>' . $error_messages . '</p>' . $close . '</div>'; |
|
841 | + $notices .= '<div id="'.$css_id.'" class="espresso-notices '.$css_class.'" style="display:none;"><p>'.$error_messages.'</p>'.$close.'</div>'; |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | $notices .= '</div>'; |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | 'errors' => $error_messages |
852 | 852 | ); |
853 | 853 | |
854 | - if ( $remove_empty ) { |
|
854 | + if ($remove_empty) { |
|
855 | 855 | // remove empty notices |
856 | 856 | foreach ($notices as $type => $notice) { |
857 | 857 | if (empty($notice)) { |
@@ -861,7 +861,7 @@ discard block |
||
861 | 861 | } |
862 | 862 | } |
863 | 863 | |
864 | - if ( $print_scripts ) { |
|
864 | + if ($print_scripts) { |
|
865 | 865 | self::_print_scripts(); |
866 | 866 | } |
867 | 867 | |
@@ -881,17 +881,17 @@ discard block |
||
881 | 881 | * @param bool $force_update allows one to enforce the reappearance of a persistent message. |
882 | 882 | * @return void |
883 | 883 | */ |
884 | - public static function add_persistent_admin_notice( $pan_name = '', $pan_message, $force_update = FALSE ) { |
|
885 | - if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
|
886 | - $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
|
884 | + public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = FALSE) { |
|
885 | + if ( ! empty($pan_name) && ! empty($pan_message)) { |
|
886 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
887 | 887 | //maybe initialize persistent_admin_notices |
888 | - if ( empty( $persistent_admin_notices )) { |
|
889 | - add_option( 'ee_pers_admin_notices', array(), '', 'no' ); |
|
888 | + if (empty($persistent_admin_notices)) { |
|
889 | + add_option('ee_pers_admin_notices', array(), '', 'no'); |
|
890 | 890 | } |
891 | - $pan_name = sanitize_key( $pan_name ); |
|
892 | - if ( ! array_key_exists( $pan_name, $persistent_admin_notices ) || $force_update ) { |
|
893 | - $persistent_admin_notices[ $pan_name ] = $pan_message; |
|
894 | - update_option( 'ee_pers_admin_notices', $persistent_admin_notices ); |
|
891 | + $pan_name = sanitize_key($pan_name); |
|
892 | + if ( ! array_key_exists($pan_name, $persistent_admin_notices) || $force_update) { |
|
893 | + $persistent_admin_notices[$pan_name] = $pan_message; |
|
894 | + update_option('ee_pers_admin_notices', $persistent_admin_notices); |
|
895 | 895 | } |
896 | 896 | } |
897 | 897 | } |
@@ -907,34 +907,34 @@ discard block |
||
907 | 907 | * @param bool $return_immediately |
908 | 908 | * @return void |
909 | 909 | */ |
910 | - public static function dismiss_persistent_admin_notice( $pan_name = '', $purge = FALSE, $return_immediately = FALSE ) { |
|
911 | - $pan_name = EE_Registry::instance()->REQ->is_set( 'ee_nag_notice' ) ? EE_Registry::instance()->REQ->get( 'ee_nag_notice' ) : $pan_name; |
|
912 | - if ( ! empty( $pan_name )) { |
|
913 | - $persistent_admin_notices = get_option( 'ee_pers_admin_notices', array() ); |
|
910 | + public static function dismiss_persistent_admin_notice($pan_name = '', $purge = FALSE, $return_immediately = FALSE) { |
|
911 | + $pan_name = EE_Registry::instance()->REQ->is_set('ee_nag_notice') ? EE_Registry::instance()->REQ->get('ee_nag_notice') : $pan_name; |
|
912 | + if ( ! empty($pan_name)) { |
|
913 | + $persistent_admin_notices = get_option('ee_pers_admin_notices', array()); |
|
914 | 914 | // check if notice we wish to dismiss is actually in the $persistent_admin_notices array |
915 | - if ( is_array( $persistent_admin_notices ) && isset( $persistent_admin_notices[ $pan_name ] )) { |
|
915 | + if (is_array($persistent_admin_notices) && isset($persistent_admin_notices[$pan_name])) { |
|
916 | 916 | // completely delete nag notice, or just NULL message so that it can NOT be added again ? |
917 | - if ( $purge ) { |
|
918 | - unset( $persistent_admin_notices[ $pan_name ] ); |
|
917 | + if ($purge) { |
|
918 | + unset($persistent_admin_notices[$pan_name]); |
|
919 | 919 | } else { |
920 | - $persistent_admin_notices[ $pan_name ] = NULL; |
|
920 | + $persistent_admin_notices[$pan_name] = NULL; |
|
921 | 921 | } |
922 | - if ( update_option( 'ee_pers_admin_notices', $persistent_admin_notices ) === FALSE ) { |
|
923 | - EE_Error::add_error( sprintf( __( 'The persistent admin notice for "%s" could not be deleted.', 'event_espresso' ), $pan_name ), __FILE__, __FUNCTION__, __LINE__ ); |
|
922 | + if (update_option('ee_pers_admin_notices', $persistent_admin_notices) === FALSE) { |
|
923 | + EE_Error::add_error(sprintf(__('The persistent admin notice for "%s" could not be deleted.', 'event_espresso'), $pan_name), __FILE__, __FUNCTION__, __LINE__); |
|
924 | 924 | } |
925 | 925 | } |
926 | 926 | } |
927 | - if ( $return_immediately ) { |
|
927 | + if ($return_immediately) { |
|
928 | 928 | return; |
929 | - } else if ( EE_Registry::instance()->REQ->ajax ) { |
|
929 | + } else if (EE_Registry::instance()->REQ->ajax) { |
|
930 | 930 | // grab any notices and concatenate into string |
931 | - echo json_encode( array( 'errors' => implode( '<br />', EE_Error::get_notices( FALSE )))); |
|
931 | + echo json_encode(array('errors' => implode('<br />', EE_Error::get_notices(FALSE)))); |
|
932 | 932 | exit(); |
933 | 933 | } else { |
934 | 934 | // save errors to a transient to be displayed on next request (after redirect) |
935 | - EE_Error::get_notices( FALSE, TRUE ); |
|
936 | - $return_url = EE_Registry::instance()->REQ->is_set( 'return_url' ) ? EE_Registry::instance()->REQ->get( 'return_url' ) : ''; |
|
937 | - wp_safe_redirect( urldecode( $return_url )); |
|
935 | + EE_Error::get_notices(FALSE, TRUE); |
|
936 | + $return_url = EE_Registry::instance()->REQ->is_set('return_url') ? EE_Registry::instance()->REQ->get('return_url') : ''; |
|
937 | + wp_safe_redirect(urldecode($return_url)); |
|
938 | 938 | } |
939 | 939 | } |
940 | 940 | |
@@ -949,20 +949,20 @@ discard block |
||
949 | 949 | * @param string $return_url URL to go back to aftger nag notice is dismissed |
950 | 950 | * @return string |
951 | 951 | */ |
952 | - public static function display_persistent_admin_notices( $pan_name = '', $pan_message = '', $return_url = '' ) { |
|
953 | - if ( ! empty( $pan_name ) && ! empty( $pan_message )) { |
|
952 | + public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '') { |
|
953 | + if ( ! empty($pan_name) && ! empty($pan_message)) { |
|
954 | 954 | $args = array( |
955 | 955 | 'nag_notice' => $pan_name, |
956 | - 'return_url' => urlencode( $return_url ), |
|
956 | + 'return_url' => urlencode($return_url), |
|
957 | 957 | 'ajax_url' => WP_AJAX_URL, |
958 | - 'unknown_error' => __( 'An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso' ) |
|
958 | + 'unknown_error' => __('An unknown error has occurred on the server while attempting to dismiss this notice.', 'event_espresso') |
|
959 | 959 | ); |
960 | - wp_localize_script( 'espresso_core', 'ee_dismiss', $args ); |
|
960 | + wp_localize_script('espresso_core', 'ee_dismiss', $args); |
|
961 | 961 | return ' |
962 | - <div id="' . $pan_name . '" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
963 | - <p>' . $pan_message . '</p> |
|
964 | - <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name . '"> |
|
965 | - <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__( 'Dismiss', 'event_espresso' ) .' |
|
962 | + <div id="' . $pan_name.'" class="espresso-notices updated ee-nag-notice clearfix" style="border-left: 4px solid #fcb93c;"> |
|
963 | + <p>' . $pan_message.'</p> |
|
964 | + <a class="dismiss-ee-nag-notice hide-if-no-js" style="float: right; cursor: pointer; text-decoration:none;" rel="' . $pan_name.'"> |
|
965 | + <span class="dashicons dashicons-dismiss" style="position:relative; top:-1px; margin-right:.25em;"></span>'.__('Dismiss', 'event_espresso').' |
|
966 | 966 | </a> |
967 | 967 | <div style="clear:both;"></div> |
968 | 968 | </div>'; |
@@ -978,24 +978,24 @@ discard block |
||
978 | 978 | * @param string $return_url |
979 | 979 | * @return array |
980 | 980 | */ |
981 | - public static function get_persistent_admin_notices( $return_url = '' ) { |
|
981 | + public static function get_persistent_admin_notices($return_url = '') { |
|
982 | 982 | $notices = ''; |
983 | 983 | // check for persistent admin notices |
984 | 984 | //filter the list though so plugins can notify the admin in a different way if they want |
985 | 985 | $persistent_admin_notices = apply_filters( |
986 | 986 | 'FHEE__EE_Error__get_persistent_admin_notices', |
987 | - get_option( 'ee_pers_admin_notices', FALSE ), |
|
987 | + get_option('ee_pers_admin_notices', FALSE), |
|
988 | 988 | 'ee_pers_admin_notices', |
989 | 989 | $return_url |
990 | 990 | ); |
991 | - if ( $persistent_admin_notices ) { |
|
991 | + if ($persistent_admin_notices) { |
|
992 | 992 | // load scripts |
993 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
994 | - wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE ); |
|
995 | - wp_enqueue_script( 'ee_error_js' ); |
|
993 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE); |
|
994 | + wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, TRUE); |
|
995 | + wp_enqueue_script('ee_error_js'); |
|
996 | 996 | // and display notices |
997 | - foreach( $persistent_admin_notices as $pan_name => $pan_message ) { |
|
998 | - $notices .= self::display_persistent_admin_notices( $pan_name, $pan_message, $return_url ); |
|
997 | + foreach ($persistent_admin_notices as $pan_name => $pan_message) { |
|
998 | + $notices .= self::display_persistent_admin_notices($pan_name, $pan_message, $return_url); |
|
999 | 999 | } |
1000 | 1000 | } |
1001 | 1001 | return $notices; |
@@ -1010,26 +1010,26 @@ discard block |
||
1010 | 1010 | * @param bool $force_print |
1011 | 1011 | * @return void |
1012 | 1012 | */ |
1013 | - private static function _print_scripts( $force_print = FALSE ) { |
|
1014 | - if (( did_action( 'admin_enqueue_scripts' ) || did_action( 'wp_enqueue_scripts' )) && ! $force_print ) { |
|
1015 | - if ( wp_script_is( 'ee_error_js', 'enqueued' )) { |
|
1013 | + private static function _print_scripts($force_print = FALSE) { |
|
1014 | + if ((did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts')) && ! $force_print) { |
|
1015 | + if (wp_script_is('ee_error_js', 'enqueued')) { |
|
1016 | 1016 | return; |
1017 | - } else if ( wp_script_is( 'ee_error_js', 'registered' )) { |
|
1018 | - add_filter( 'FHEE_load_css', '__return_true' ); |
|
1019 | - add_filter( 'FHEE_load_js', '__return_true' ); |
|
1020 | - wp_enqueue_script( 'ee_error_js' ); |
|
1021 | - wp_localize_script( 'ee_error_js','ee_settings', array( 'wp_debug'=>WP_DEBUG )); |
|
1017 | + } else if (wp_script_is('ee_error_js', 'registered')) { |
|
1018 | + add_filter('FHEE_load_css', '__return_true'); |
|
1019 | + add_filter('FHEE_load_js', '__return_true'); |
|
1020 | + wp_enqueue_script('ee_error_js'); |
|
1021 | + wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug'=>WP_DEBUG)); |
|
1022 | 1022 | } |
1023 | 1023 | } else { |
1024 | 1024 | return ' |
1025 | 1025 | <script> |
1026 | 1026 | /* <![CDATA[ */ |
1027 | -var ee_settings = {"wp_debug":"' . WP_DEBUG . '"}; |
|
1027 | +var ee_settings = {"wp_debug":"' . WP_DEBUG.'"}; |
|
1028 | 1028 | /* ]]> */ |
1029 | 1029 | </script> |
1030 | -<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script> |
|
1031 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
1032 | -<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script> |
|
1030 | +<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script> |
|
1031 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
1032 | +<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script> |
|
1033 | 1033 | '; |
1034 | 1034 | |
1035 | 1035 | } |
@@ -1063,11 +1063,11 @@ discard block |
||
1063 | 1063 | * @ param string $line |
1064 | 1064 | * @ return string |
1065 | 1065 | */ |
1066 | - public static function generate_error_code ( $file = '', $func = '', $line = '' ) { |
|
1067 | - $file = explode( '.', basename( $file )); |
|
1068 | - $error_code = ! empty( $file[0] ) ? $file[0] : ''; |
|
1069 | - $error_code .= ! empty( $func ) ? ' - ' . $func : ''; |
|
1070 | - $error_code .= ! empty( $line ) ? ' - ' . $line : ''; |
|
1066 | + public static function generate_error_code($file = '', $func = '', $line = '') { |
|
1067 | + $file = explode('.', basename($file)); |
|
1068 | + $error_code = ! empty($file[0]) ? $file[0] : ''; |
|
1069 | + $error_code .= ! empty($func) ? ' - '.$func : ''; |
|
1070 | + $error_code .= ! empty($line) ? ' - '.$line : ''; |
|
1071 | 1071 | return $error_code; |
1072 | 1072 | } |
1073 | 1073 | |
@@ -1083,36 +1083,36 @@ discard block |
||
1083 | 1083 | * @ param object $ex |
1084 | 1084 | * @ return void |
1085 | 1085 | */ |
1086 | - public function write_to_error_log ( $time = FALSE, $ex = FALSE, $clear = FALSE ) { |
|
1086 | + public function write_to_error_log($time = FALSE, $ex = FALSE, $clear = FALSE) { |
|
1087 | 1087 | |
1088 | - if ( ! $ex ) { |
|
1088 | + if ( ! $ex) { |
|
1089 | 1089 | return; |
1090 | 1090 | } |
1091 | 1091 | |
1092 | - if ( ! $time ) { |
|
1092 | + if ( ! $time) { |
|
1093 | 1093 | $time = time(); |
1094 | 1094 | } |
1095 | 1095 | |
1096 | - $exception_log = '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
1097 | - $exception_log .= '[' . date( 'Y-m-d H:i:s', $time ) . '] Exception Details' . PHP_EOL; |
|
1098 | - $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL; |
|
1099 | - $exception_log .= 'Code: '. $ex['code'] . PHP_EOL; |
|
1100 | - $exception_log .= 'File: '. $ex['file'] . PHP_EOL; |
|
1101 | - $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL; |
|
1102 | - $exception_log .= 'Stack trace: ' . PHP_EOL; |
|
1103 | - $exception_log .= $ex['string'] . PHP_EOL; |
|
1104 | - $exception_log .= '----------------------------------------------------------------------------------------' . PHP_EOL; |
|
1096 | + $exception_log = '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
1097 | + $exception_log .= '['.date('Y-m-d H:i:s', $time).'] Exception Details'.PHP_EOL; |
|
1098 | + $exception_log .= 'Message: '.$ex['msg'].PHP_EOL; |
|
1099 | + $exception_log .= 'Code: '.$ex['code'].PHP_EOL; |
|
1100 | + $exception_log .= 'File: '.$ex['file'].PHP_EOL; |
|
1101 | + $exception_log .= 'Line No: '.$ex['line'].PHP_EOL; |
|
1102 | + $exception_log .= 'Stack trace: '.PHP_EOL; |
|
1103 | + $exception_log .= $ex['string'].PHP_EOL; |
|
1104 | + $exception_log .= '----------------------------------------------------------------------------------------'.PHP_EOL; |
|
1105 | 1105 | |
1106 | 1106 | try { |
1107 | - EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ); |
|
1108 | - EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' ); |
|
1109 | - if ( ! $clear ) { |
|
1107 | + EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file); |
|
1108 | + EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs'); |
|
1109 | + if ( ! $clear) { |
|
1110 | 1110 | //get existing log file and append new log info |
1111 | - $exception_log = EEH_File::get_file_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file ) . $exception_log; |
|
1111 | + $exception_log = EEH_File::get_file_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file).$exception_log; |
|
1112 | 1112 | } |
1113 | - EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . self::$_exception_log_file, $exception_log ); |
|
1114 | - } catch( EE_Error $e ){ |
|
1115 | - EE_Error::add_error( sprintf( __( 'Event Espresso error logging could not be setup because: %s', 'event_espresso' ), $e->getMessage() )); |
|
1113 | + EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.self::$_exception_log_file, $exception_log); |
|
1114 | + } catch (EE_Error $e) { |
|
1115 | + EE_Error::add_error(sprintf(__('Event Espresso error logging could not be setup because: %s', 'event_espresso'), $e->getMessage())); |
|
1116 | 1116 | return; |
1117 | 1117 | } |
1118 | 1118 | |
@@ -1136,9 +1136,9 @@ discard block |
||
1136 | 1136 | * @param int $error_type |
1137 | 1137 | * @return void |
1138 | 1138 | */ |
1139 | - public static function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) { |
|
1140 | - if ( defined('WP_DEBUG') && WP_DEBUG ) { |
|
1141 | - EEH_Debug_Tools::instance()->doing_it_wrong( $function, $message, $version, $error_type ); |
|
1139 | + public static function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) { |
|
1140 | + if (defined('WP_DEBUG') && WP_DEBUG) { |
|
1141 | + EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $error_type); |
|
1142 | 1142 | } |
1143 | 1143 | } |
1144 | 1144 | |
@@ -1170,13 +1170,13 @@ discard block |
||
1170 | 1170 | */ |
1171 | 1171 | function espresso_error_enqueue_scripts() { |
1172 | 1172 | // js for error handling |
1173 | - wp_register_script( 'espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
1174 | - wp_register_script( 'ee_error_js', EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE ); |
|
1173 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, FALSE); |
|
1174 | + wp_register_script('ee_error_js', EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js', array('espresso_core'), EVENT_ESPRESSO_VERSION, FALSE); |
|
1175 | 1175 | } |
1176 | -if ( is_admin() ) { |
|
1177 | - add_action( 'admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 ); |
|
1176 | +if (is_admin()) { |
|
1177 | + add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1178 | 1178 | } else { |
1179 | - add_action( 'wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2 ); |
|
1179 | + add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 2); |
|
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 |
@@ -22,32 +22,32 @@ discard block |
||
22 | 22 | * @param EE_Response $response |
23 | 23 | * @return EE_Response |
24 | 24 | */ |
25 | - public function handle_request( EE_Request $request, EE_Response $response ) { |
|
25 | + public function handle_request(EE_Request $request, EE_Response $response) { |
|
26 | 26 | $this->_request = $request; |
27 | 27 | $this->_response = $response; |
28 | 28 | //$this->_response->add_output( "\n\t IN >> " . __CLASS__ ); |
29 | 29 | //$this->_response->set_notice( 1, 'hey look at this' ); |
30 | 30 | // check required WP version |
31 | - if ( ! $this->_minimum_wp_version_required() ) { |
|
32 | - $this->_request->un_set( 'activate', true ); |
|
33 | - add_action( 'admin_notices', array( $this, 'minimum_wp_version_error' ), 1 ); |
|
31 | + if ( ! $this->_minimum_wp_version_required()) { |
|
32 | + $this->_request->un_set('activate', true); |
|
33 | + add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1); |
|
34 | 34 | //$this->_response->add_output( "\n<br />" . 'minimum_wp_version_error' ); |
35 | 35 | $this->_response->terminate_request(); |
36 | 36 | $this->_response->deactivate_plugin(); |
37 | 37 | } |
38 | 38 | // check required PHP version |
39 | - if ( ! $this->_minimum_php_version_required() ) { |
|
40 | - $this->_request->un_set( 'activate', true ); |
|
41 | - add_action( 'admin_notices', array( $this, 'minimum_php_version_error' ), 1 ); |
|
39 | + if ( ! $this->_minimum_php_version_required()) { |
|
40 | + $this->_request->un_set('activate', true); |
|
41 | + add_action('admin_notices', array($this, 'minimum_php_version_error'), 1); |
|
42 | 42 | //$this->_response->add_output( "\n<br />" . 'minimum_php_version_error' ); |
43 | 43 | $this->_response->terminate_request(); |
44 | 44 | $this->_response->deactivate_plugin(); |
45 | 45 | } |
46 | 46 | // check recommended PHP version |
47 | - if ( ! $this->_minimum_php_version_recommended() ) { |
|
47 | + if ( ! $this->_minimum_php_version_recommended()) { |
|
48 | 48 | $this->_display_minimum_recommended_php_version_notice(); |
49 | 49 | } |
50 | - $this->_response = $this->process_request_stack( $this->_request, $this->_response ); |
|
50 | + $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
51 | 51 | //$this->_response->add_output( "\n\t OUT << " . __CLASS__ ); |
52 | 52 | return $this->_response; |
53 | 53 | } |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | * @param string $min_version |
62 | 62 | * @return boolean |
63 | 63 | */ |
64 | - private function _check_wp_version( $min_version = EE_MIN_WP_VER_REQUIRED ) { |
|
64 | + private function _check_wp_version($min_version = EE_MIN_WP_VER_REQUIRED) { |
|
65 | 65 | global $wp_version; |
66 | - return version_compare( $wp_version, $min_version, '>=' ) ? true : false; |
|
66 | + return version_compare($wp_version, $min_version, '>=') ? true : false; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @return boolean |
76 | 76 | */ |
77 | 77 | private function _minimum_wp_version_required() { |
78 | - return $this->_check_wp_version( EE_MIN_WP_VER_REQUIRED ); |
|
78 | + return $this->_check_wp_version(EE_MIN_WP_VER_REQUIRED); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * @param string $min_version |
88 | 88 | * @return boolean |
89 | 89 | */ |
90 | - private function _check_php_version( $min_version = EE_MIN_PHP_VER_RECOMMENDED ) { |
|
91 | - return version_compare( PHP_VERSION, $min_version, '>=' ) ? true : false; |
|
90 | + private function _check_php_version($min_version = EE_MIN_PHP_VER_RECOMMENDED) { |
|
91 | + return version_compare(PHP_VERSION, $min_version, '>=') ? true : false; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @return boolean |
101 | 101 | */ |
102 | 102 | private function _minimum_php_version_required() { |
103 | - return $this->_check_php_version( EE_MIN_PHP_VER_REQUIRED ); |
|
103 | + return $this->_check_php_version(EE_MIN_PHP_VER_REQUIRED); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @return boolean |
113 | 113 | */ |
114 | 114 | private function _minimum_php_version_recommended() { |
115 | - return $this->_check_php_version( EE_MIN_PHP_VER_RECOMMENDED ); |
|
115 | + return $this->_check_php_version(EE_MIN_PHP_VER_RECOMMENDED); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | <p> |
130 | 130 | <?php |
131 | 131 | printf( |
132 | - __( 'We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso' ), |
|
132 | + __('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', 'event_espresso'), |
|
133 | 133 | EE_MIN_WP_VER_REQUIRED, |
134 | 134 | $wp_version, |
135 | 135 | '<br/>', |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | <p> |
155 | 155 | <?php |
156 | 156 | printf( |
157 | - __( 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso' ), |
|
157 | + __('We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso'), |
|
158 | 158 | EE_MIN_PHP_VER_REQUIRED, |
159 | 159 | PHP_VERSION, |
160 | 160 | '<br/>', |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | */ |
177 | 177 | private function _display_minimum_recommended_php_version_notice() { |
178 | 178 | EE_Error::add_persistent_admin_notice( |
179 | - 'php_version_' . str_replace( '.', '-', EE_MIN_PHP_VER_RECOMMENDED ) . '_recommended', |
|
179 | + 'php_version_'.str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED).'_recommended', |
|
180 | 180 | sprintf( |
181 | - __( 'Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso' ), |
|
181 | + __('Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', 'event_espresso'), |
|
182 | 182 | EE_MIN_PHP_VER_RECOMMENDED, |
183 | 183 | PHP_VERSION, |
184 | 184 | '<br/>', |