@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts). |
| 8 | 8 | * However, you may output the form (usually by calling get_html) anywhere you like. |
| 9 | 9 | */ |
| 10 | -class EE_Form_Section_Proper extends EE_Form_Section_Validatable{ |
|
| 10 | +class EE_Form_Section_Proper extends EE_Form_Section_Validatable { |
|
| 11 | 11 | |
| 12 | 12 | const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data'; |
| 13 | 13 | |
@@ -71,52 +71,52 @@ discard block |
||
| 71 | 71 | * } @see EE_Form_Section_Validatable::__construct() |
| 72 | 72 | * @throws \EE_Error |
| 73 | 73 | */ |
| 74 | - public function __construct( $options_array = array() ){ |
|
| 75 | - $options_array = (array) apply_filters( 'FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this ); |
|
| 74 | + public function __construct($options_array = array()) { |
|
| 75 | + $options_array = (array) apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this); |
|
| 76 | 76 | //call parent first, as it may be setting the name |
| 77 | 77 | parent::__construct($options_array); |
| 78 | 78 | //if they've included subsections in the constructor, add them now |
| 79 | - if( isset( $options_array['include'] )){ |
|
| 79 | + if (isset($options_array['include'])) { |
|
| 80 | 80 | //we are going to make sure we ONLY have those subsections to include |
| 81 | 81 | //AND we are going to make sure they're in that specified order |
| 82 | 82 | $reordered_subsections = array(); |
| 83 | - foreach($options_array['include'] as $input_name){ |
|
| 84 | - if(isset($this->_subsections[$input_name])){ |
|
| 83 | + foreach ($options_array['include'] as $input_name) { |
|
| 84 | + if (isset($this->_subsections[$input_name])) { |
|
| 85 | 85 | $reordered_subsections[$input_name] = $this->_subsections[$input_name]; |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | $this->_subsections = $reordered_subsections; |
| 89 | 89 | } |
| 90 | - if(isset($options_array['exclude'])){ |
|
| 90 | + if (isset($options_array['exclude'])) { |
|
| 91 | 91 | $exclude = $options_array['exclude']; |
| 92 | 92 | $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude)); |
| 93 | 93 | } |
| 94 | - if(isset($options_array['layout_strategy'])){ |
|
| 94 | + if (isset($options_array['layout_strategy'])) { |
|
| 95 | 95 | $this->_layout_strategy = $options_array['layout_strategy']; |
| 96 | 96 | } |
| 97 | - if( ! $this->_layout_strategy){ |
|
| 97 | + if ( ! $this->_layout_strategy) { |
|
| 98 | 98 | $this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout(); |
| 99 | 99 | } |
| 100 | 100 | $this->_layout_strategy->_construct_finalize($this); |
| 101 | 101 | |
| 102 | 102 | //ok so we are definitely going to want the forms JS, |
| 103 | 103 | //so enqueue it or remember to enqueue it during wp_enqueue_scripts |
| 104 | - if( did_action( 'wp_enqueue_scripts' ) |
|
| 105 | - || did_action( 'admin_enqueue_scripts' ) ) { |
|
| 104 | + if (did_action('wp_enqueue_scripts') |
|
| 105 | + || did_action('admin_enqueue_scripts')) { |
|
| 106 | 106 | //ok so they've constructed this object after when they should have. |
| 107 | 107 | //just enqueue the generic form scripts and initialize the form immediately in the JS |
| 108 | - \EE_Form_Section_Proper::wp_enqueue_scripts( true ); |
|
| 108 | + \EE_Form_Section_Proper::wp_enqueue_scripts(true); |
|
| 109 | 109 | \EE_Form_Section_Proper::wp_deregister_conflicting_scripts(); |
| 110 | 110 | } else { |
| 111 | - add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
| 112 | - add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' )); |
|
| 113 | - add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_deregister_conflicting_scripts' ), 100 ); |
|
| 114 | - add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_deregister_conflicting_scripts' ), 100 ); |
|
| 111 | + add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
| 112 | + add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts')); |
|
| 113 | + add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_deregister_conflicting_scripts'), 100); |
|
| 114 | + add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_deregister_conflicting_scripts'), 100); |
|
| 115 | 115 | } |
| 116 | - add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 ); |
|
| 116 | + add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1); |
|
| 117 | 117 | |
| 118 | - if( isset( $options_array[ 'name' ] ) ) { |
|
| 119 | - $this->_construct_finalize( null, $options_array[ 'name' ] ); |
|
| 118 | + if (isset($options_array['name'])) { |
|
| 119 | + $this->_construct_finalize(null, $options_array['name']); |
|
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
@@ -129,25 +129,25 @@ discard block |
||
| 129 | 129 | * @param string $name |
| 130 | 130 | * @throws \EE_Error |
| 131 | 131 | */ |
| 132 | - public function _construct_finalize( $parent_form_section, $name ) { |
|
| 132 | + public function _construct_finalize($parent_form_section, $name) { |
|
| 133 | 133 | parent::_construct_finalize($parent_form_section, $name); |
| 134 | 134 | $this->_set_default_name_if_empty(); |
| 135 | 135 | $this->_set_default_html_id_if_empty(); |
| 136 | - foreach( $this->_subsections as $subsection_name => $subsection ){ |
|
| 137 | - if ( $subsection instanceof EE_Form_Section_Base ) { |
|
| 138 | - $subsection->_construct_finalize( $this, $subsection_name ); |
|
| 136 | + foreach ($this->_subsections as $subsection_name => $subsection) { |
|
| 137 | + if ($subsection instanceof EE_Form_Section_Base) { |
|
| 138 | + $subsection->_construct_finalize($this, $subsection_name); |
|
| 139 | 139 | } else { |
| 140 | 140 | throw new EE_Error( |
| 141 | 141 | sprintf( |
| 142 | - __( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ), |
|
| 142 | + __('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'), |
|
| 143 | 143 | $subsection_name, |
| 144 | 144 | get_class($this), |
| 145 | - $subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' ) |
|
| 145 | + $subsection ? get_class($subsection) : __('NULL', 'event_espresso') |
|
| 146 | 146 | ) |
| 147 | 147 | ); |
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | - do_action( 'AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name ); |
|
| 150 | + do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * Gets the layout strategy for this form section |
| 157 | 157 | * @return EE_Form_Section_Layout_Base |
| 158 | 158 | */ |
| 159 | - public function get_layout_strategy(){ |
|
| 159 | + public function get_layout_strategy() { |
|
| 160 | 160 | return $this->_layout_strategy; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @param EE_Form_Input_Base $input |
| 169 | 169 | * @return string |
| 170 | 170 | */ |
| 171 | - public function get_html_for_input($input){ |
|
| 171 | + public function get_html_for_input($input) { |
|
| 172 | 172 | return $this->_layout_strategy->layout_input($input); |
| 173 | 173 | } |
| 174 | 174 | |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @param null $form_data |
| 182 | 182 | * @return boolean |
| 183 | 183 | */ |
| 184 | - public function was_submitted($form_data = NULL){ |
|
| 184 | + public function was_submitted($form_data = NULL) { |
|
| 185 | 185 | return $this->form_data_present_in($form_data); |
| 186 | 186 | } |
| 187 | 187 | |
@@ -206,21 +206,21 @@ discard block |
||
| 206 | 206 | * (eg you validated the data then stored it in the DB) |
| 207 | 207 | * you may want to skip this step. |
| 208 | 208 | */ |
| 209 | - public function receive_form_submission( $req_data = null, $validate = true ){ |
|
| 210 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate ); |
|
| 211 | - if( $req_data === null ){ |
|
| 212 | - $req_data = array_merge( $_GET, $_POST ); |
|
| 209 | + public function receive_form_submission($req_data = null, $validate = true) { |
|
| 210 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate); |
|
| 211 | + if ($req_data === null) { |
|
| 212 | + $req_data = array_merge($_GET, $_POST); |
|
| 213 | 213 | } |
| 214 | - $req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this ); |
|
| 215 | - $this->_normalize( $req_data ); |
|
| 216 | - if( $validate ){ |
|
| 214 | + $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this); |
|
| 215 | + $this->_normalize($req_data); |
|
| 216 | + if ($validate) { |
|
| 217 | 217 | $this->_validate(); |
| 218 | 218 | //if it's invalid, we're going to want to re-display so remember what they submitted |
| 219 | - if ( ! $this->is_valid() ) { |
|
| 219 | + if ( ! $this->is_valid()) { |
|
| 220 | 220 | $this->store_submitted_form_data_in_session(); |
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | - do_action( 'AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate ); |
|
| 223 | + do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | protected function store_submitted_form_data_in_session() { |
| 235 | 235 | return EE_Registry::instance()->SSN->set_session_data( |
| 236 | 236 | array( |
| 237 | - \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values( true ) |
|
| 237 | + \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values(true) |
|
| 238 | 238 | ) |
| 239 | 239 | ); |
| 240 | 240 | } |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | */ |
| 263 | 263 | protected function flush_submitted_form_data_from_session() { |
| 264 | 264 | return EE_Registry::instance()->SSN->reset_data( |
| 265 | - array( \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY ) |
|
| 265 | + array(\EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY) |
|
| 266 | 266 | ); |
| 267 | 267 | } |
| 268 | 268 | |
@@ -278,12 +278,12 @@ discard block |
||
| 278 | 278 | */ |
| 279 | 279 | public function populate_from_session() { |
| 280 | 280 | $form_data_in_session = $this->get_submitted_form_data_from_session(); |
| 281 | - if ( empty( $form_data_in_session ) ) { |
|
| 281 | + if (empty($form_data_in_session)) { |
|
| 282 | 282 | return false; |
| 283 | 283 | } |
| 284 | - $this->receive_form_submission( $form_data_in_session ); |
|
| 284 | + $this->receive_form_submission($form_data_in_session); |
|
| 285 | 285 | $this->flush_submitted_form_data_from_session(); |
| 286 | - if ( $this->form_data_present_in( $form_data_in_session ) ) { |
|
| 286 | + if ($this->form_data_present_in($form_data_in_session)) { |
|
| 287 | 287 | return true; |
| 288 | 288 | } else { |
| 289 | 289 | return false; |
@@ -300,12 +300,12 @@ discard block |
||
| 300 | 300 | * the value being an array formatted in teh same way |
| 301 | 301 | * @param array $default_data |
| 302 | 302 | */ |
| 303 | - public function populate_defaults($default_data){ |
|
| 304 | - foreach($this->subsections() as $subsection_name => $subsection){ |
|
| 305 | - if(isset($default_data[$subsection_name])){ |
|
| 306 | - if($subsection instanceof EE_Form_Input_Base){ |
|
| 303 | + public function populate_defaults($default_data) { |
|
| 304 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
| 305 | + if (isset($default_data[$subsection_name])) { |
|
| 306 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
| 307 | 307 | $subsection->set_default($default_data[$subsection_name]); |
| 308 | - }elseif($subsection instanceof EE_Form_Section_Proper){ |
|
| 308 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
| 309 | 309 | $subsection->populate_defaults($default_data[$subsection_name]); |
| 310 | 310 | } |
| 311 | 311 | } |
@@ -320,8 +320,8 @@ discard block |
||
| 320 | 320 | * @param string $name |
| 321 | 321 | * @return boolean |
| 322 | 322 | */ |
| 323 | - public function subsection_exists( $name ){ |
|
| 324 | - return isset( $this->_subsections[ $name ] ) ? true : false; |
|
| 323 | + public function subsection_exists($name) { |
|
| 324 | + return isset($this->_subsections[$name]) ? true : false; |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | * @return EE_Form_Section_Base |
| 340 | 340 | * @throws \EE_Error |
| 341 | 341 | */ |
| 342 | - public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
| 343 | - if( $require_construction_to_be_finalized ){ |
|
| 342 | + public function get_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
| 343 | + if ($require_construction_to_be_finalized) { |
|
| 344 | 344 | $this->ensure_construct_finalized_called(); |
| 345 | 345 | } |
| 346 | - return $this->subsection_exists( $name ) ? $this->_subsections[$name] : NULL; |
|
| 346 | + return $this->subsection_exists($name) ? $this->_subsections[$name] : NULL; |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | |
@@ -352,10 +352,10 @@ discard block |
||
| 352 | 352 | * Gets all the validatable subsections of this form section |
| 353 | 353 | * @return EE_Form_Section_Validatable[] |
| 354 | 354 | */ |
| 355 | - public function get_validatable_subsections(){ |
|
| 355 | + public function get_validatable_subsections() { |
|
| 356 | 356 | $validatable_subsections = array(); |
| 357 | - foreach($this->subsections() as $name=>$obj){ |
|
| 358 | - if($obj instanceof EE_Form_Section_Validatable){ |
|
| 357 | + foreach ($this->subsections() as $name=>$obj) { |
|
| 358 | + if ($obj instanceof EE_Form_Section_Validatable) { |
|
| 359 | 359 | $validatable_subsections[$name] = $obj; |
| 360 | 360 | } |
| 361 | 361 | } |
@@ -375,9 +375,9 @@ discard block |
||
| 375 | 375 | * @return EE_Form_Input_Base |
| 376 | 376 | * @throws EE_Error |
| 377 | 377 | */ |
| 378 | - public function get_input($name, $require_construction_to_be_finalized = TRUE ){ |
|
| 378 | + public function get_input($name, $require_construction_to_be_finalized = TRUE) { |
|
| 379 | 379 | $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
| 380 | - if( ! $subsection instanceof EE_Form_Input_Base){ |
|
| 380 | + if ( ! $subsection instanceof EE_Form_Input_Base) { |
|
| 381 | 381 | throw new EE_Error( |
| 382 | 382 | sprintf( |
| 383 | 383 | __( |
@@ -385,8 +385,8 @@ discard block |
||
| 385 | 385 | 'event_espresso' |
| 386 | 386 | ), |
| 387 | 387 | $name, |
| 388 | - get_class( $this ), |
|
| 389 | - $subsection ? get_class( $subsection ) : __( "NULL", 'event_espresso' ) |
|
| 388 | + get_class($this), |
|
| 389 | + $subsection ? get_class($subsection) : __("NULL", 'event_espresso') |
|
| 390 | 390 | ) |
| 391 | 391 | ); |
| 392 | 392 | } |
@@ -406,14 +406,14 @@ discard block |
||
| 406 | 406 | * @return EE_Form_Section_Proper |
| 407 | 407 | * @throws EE_Error |
| 408 | 408 | */ |
| 409 | - public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){ |
|
| 410 | - $subsection = $this->get_subsection( $name, $require_construction_to_be_finalized ); |
|
| 411 | - if( ! $subsection instanceof EE_Form_Section_Proper){ |
|
| 409 | + public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) { |
|
| 410 | + $subsection = $this->get_subsection($name, $require_construction_to_be_finalized); |
|
| 411 | + if ( ! $subsection instanceof EE_Form_Section_Proper) { |
|
| 412 | 412 | throw new EE_Error( |
| 413 | 413 | sprintf( |
| 414 | - __( "Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso' ), |
|
| 414 | + __("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), |
|
| 415 | 415 | $name, |
| 416 | - get_class( $this ) |
|
| 416 | + get_class($this) |
|
| 417 | 417 | ) |
| 418 | 418 | ); |
| 419 | 419 | } |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | * @return mixed depending on the input's type and its normalization strategy |
| 431 | 431 | * @throws \EE_Error |
| 432 | 432 | */ |
| 433 | - public function get_input_value($name){ |
|
| 433 | + public function get_input_value($name) { |
|
| 434 | 434 | $input = $this->get_input($name); |
| 435 | 435 | return $input->normalized_value(); |
| 436 | 436 | } |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | * @return boolean |
| 444 | 444 | */ |
| 445 | 445 | public function is_valid() { |
| 446 | - if( ! $this->has_received_submission()){ |
|
| 446 | + if ( ! $this->has_received_submission()) { |
|
| 447 | 447 | throw new EE_Error( |
| 448 | 448 | sprintf( |
| 449 | 449 | __( |
@@ -453,16 +453,16 @@ discard block |
||
| 453 | 453 | ) |
| 454 | 454 | ); |
| 455 | 455 | } |
| 456 | - if( ! parent::is_valid() ) { |
|
| 456 | + if ( ! parent::is_valid()) { |
|
| 457 | 457 | return false; |
| 458 | 458 | } |
| 459 | 459 | // ok so no general errors to this entire form section. |
| 460 | 460 | // so let's check the subsections, but only set errors if that hasn't been done yet |
| 461 | 461 | $set_submission_errors = $this->submission_error_message() === '' ? true : false; |
| 462 | - foreach( $this->get_validatable_subsections() as $subsection ){ |
|
| 463 | - if( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '' ){ |
|
| 464 | - if ( $set_submission_errors ) { |
|
| 465 | - $this->set_submission_error_message( $subsection->get_validation_error_string() ); |
|
| 462 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 463 | + if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '') { |
|
| 464 | + if ($set_submission_errors) { |
|
| 465 | + $this->set_submission_error_message($subsection->get_validation_error_string()); |
|
| 466 | 466 | } |
| 467 | 467 | return false; |
| 468 | 468 | } |
@@ -476,11 +476,11 @@ discard block |
||
| 476 | 476 | * gets teh default name of this form section if none is specified |
| 477 | 477 | * @return string |
| 478 | 478 | */ |
| 479 | - protected function _set_default_name_if_empty(){ |
|
| 480 | - if( ! $this->_name ){ |
|
| 479 | + protected function _set_default_name_if_empty() { |
|
| 480 | + if ( ! $this->_name) { |
|
| 481 | 481 | $classname = get_class($this); |
| 482 | 482 | $default_name = str_replace("EE_", "", $classname); |
| 483 | - $this->_name = $default_name; |
|
| 483 | + $this->_name = $default_name; |
|
| 484 | 484 | } |
| 485 | 485 | } |
| 486 | 486 | |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | * and get_html when you are about to display the form. |
| 497 | 497 | * @throws \EE_Error |
| 498 | 498 | */ |
| 499 | - public function get_html_and_js(){ |
|
| 499 | + public function get_html_and_js() { |
|
| 500 | 500 | //no doing_it_wrong yet because we ourselves are still doing it wrong... |
| 501 | 501 | //and theoretically this CAN be used properly, provided its used during "wp_enqueue_scripts" |
| 502 | 502 | $this->enqueue_js(); |
@@ -511,9 +511,9 @@ discard block |
||
| 511 | 511 | * @param bool $display_previously_submitted_data |
| 512 | 512 | * @return string |
| 513 | 513 | */ |
| 514 | - public function get_html( $display_previously_submitted_data = true ){ |
|
| 514 | + public function get_html($display_previously_submitted_data = true) { |
|
| 515 | 515 | $this->ensure_construct_finalized_called(); |
| 516 | - if ( $display_previously_submitted_data ) { |
|
| 516 | + if ($display_previously_submitted_data) { |
|
| 517 | 517 | $this->populate_from_session(); |
| 518 | 518 | } |
| 519 | 519 | return $this->_layout_strategy->layout_form(); |
@@ -527,9 +527,9 @@ discard block |
||
| 527 | 527 | * @return string |
| 528 | 528 | * @throws \EE_Error |
| 529 | 529 | */ |
| 530 | - public function enqueue_js(){ |
|
| 530 | + public function enqueue_js() { |
|
| 531 | 531 | $this->_enqueue_and_localize_form_js(); |
| 532 | - foreach( $this->subsections() as $subsection ) { |
|
| 532 | + foreach ($this->subsections() as $subsection) { |
|
| 533 | 533 | $subsection->enqueue_js(); |
| 534 | 534 | } |
| 535 | 535 | } |
@@ -548,19 +548,19 @@ discard block |
||
| 548 | 548 | * to be triggered automatically or not |
| 549 | 549 | * @return void |
| 550 | 550 | */ |
| 551 | - public static function wp_enqueue_scripts( $init_form_validation_automatically = true ){ |
|
| 552 | - add_filter( 'FHEE_load_jquery_validate', '__return_true' ); |
|
| 551 | + public static function wp_enqueue_scripts($init_form_validation_automatically = true) { |
|
| 552 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
| 553 | 553 | wp_register_script( |
| 554 | 554 | 'ee_form_section_validation', |
| 555 | - EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', |
|
| 556 | - array( 'jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods' ), |
|
| 555 | + EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', |
|
| 556 | + array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'), |
|
| 557 | 557 | EVENT_ESPRESSO_VERSION, |
| 558 | 558 | true |
| 559 | 559 | ); |
| 560 | 560 | wp_localize_script( |
| 561 | 561 | 'ee_form_section_validation', |
| 562 | 562 | 'ee_form_section_validation_init', |
| 563 | - array( 'init' => $init_form_validation_automatically ? true : false ) |
|
| 563 | + array('init' => $init_form_validation_automatically ? true : false) |
|
| 564 | 564 | ); |
| 565 | 565 | } |
| 566 | 566 | |
@@ -571,7 +571,7 @@ discard block |
||
| 571 | 571 | public static function wp_deregister_conflicting_scripts() { |
| 572 | 572 | //jquery-form (included in WP core, but deprecated) also declares some of the same methods |
| 573 | 573 | //as jquery validate |
| 574 | - wp_deregister_script( 'jquery-form' ); |
|
| 574 | + wp_deregister_script('jquery-form'); |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | |
@@ -583,14 +583,14 @@ discard block |
||
| 583 | 583 | * |
| 584 | 584 | * @throws \EE_Error |
| 585 | 585 | */ |
| 586 | - public function _enqueue_and_localize_form_js(){ |
|
| 586 | + public function _enqueue_and_localize_form_js() { |
|
| 587 | 587 | $this->ensure_construct_finalized_called(); |
| 588 | 588 | //actually, we don't want to localize just yet. There may be other forms on the page. |
| 589 | 589 | //so we need to add our form section data to a static variable accessible by all form sections |
| 590 | 590 | //and localize it just before the footer |
| 591 | 591 | $this->localize_validation_rules(); |
| 592 | - add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 ); |
|
| 593 | - add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) ); |
|
| 592 | + add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2); |
|
| 593 | + add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms')); |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | |
@@ -602,12 +602,12 @@ discard block |
||
| 602 | 602 | * @return void |
| 603 | 603 | * @throws \EE_Error |
| 604 | 604 | */ |
| 605 | - public function localize_validation_rules( $return_for_subsection = FALSE ){ |
|
| 605 | + public function localize_validation_rules($return_for_subsection = FALSE) { |
|
| 606 | 606 | // we only want to localize vars ONCE for the entire form, |
| 607 | 607 | // so if the form section doesn't have a parent, then it must be the top dog |
| 608 | - if ( $return_for_subsection || ! $this->parent_section() ) { |
|
| 609 | - EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array( |
|
| 610 | - 'form_section_id'=> $this->html_id( TRUE ), |
|
| 608 | + if ($return_for_subsection || ! $this->parent_section()) { |
|
| 609 | + EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array( |
|
| 610 | + 'form_section_id'=> $this->html_id(TRUE), |
|
| 611 | 611 | 'validation_rules'=> $this->get_jquery_validation_rules(), |
| 612 | 612 | 'other_data' => $this->get_other_js_data(), |
| 613 | 613 | 'errors'=> $this->subsection_validation_errors_by_html_name() |
@@ -623,9 +623,9 @@ discard block |
||
| 623 | 623 | * @param array $form_other_js_data |
| 624 | 624 | * @return array |
| 625 | 625 | */ |
| 626 | - public function get_other_js_data( $form_other_js_data = array() ) { |
|
| 627 | - foreach( $this->subsections() as $subsection ) { |
|
| 628 | - $form_other_js_data = $subsection->get_other_js_data( $form_other_js_data ); |
|
| 626 | + public function get_other_js_data($form_other_js_data = array()) { |
|
| 627 | + foreach ($this->subsections() as $subsection) { |
|
| 628 | + $form_other_js_data = $subsection->get_other_js_data($form_other_js_data); |
|
| 629 | 629 | } |
| 630 | 630 | return $form_other_js_data; |
| 631 | 631 | } |
@@ -636,12 +636,12 @@ discard block |
||
| 636 | 636 | * Keys are their form names, and values are the inputs themselves |
| 637 | 637 | * @return EE_Form_Input_Base |
| 638 | 638 | */ |
| 639 | - public function inputs_in_subsections(){ |
|
| 639 | + public function inputs_in_subsections() { |
|
| 640 | 640 | $inputs = array(); |
| 641 | - foreach($this->subsections() as $subsection){ |
|
| 642 | - if( $subsection instanceof EE_Form_Input_Base ){ |
|
| 643 | - $inputs[ $subsection->html_name() ] = $subsection; |
|
| 644 | - }elseif($subsection instanceof EE_Form_Section_Proper ){ |
|
| 641 | + foreach ($this->subsections() as $subsection) { |
|
| 642 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
| 643 | + $inputs[$subsection->html_name()] = $subsection; |
|
| 644 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
| 645 | 645 | $inputs += $subsection->inputs_in_subsections(); |
| 646 | 646 | } |
| 647 | 647 | } |
@@ -654,12 +654,12 @@ discard block |
||
| 654 | 654 | * and values are a string of all their validation errors |
| 655 | 655 | * @return string[] |
| 656 | 656 | */ |
| 657 | - public function subsection_validation_errors_by_html_name(){ |
|
| 657 | + public function subsection_validation_errors_by_html_name() { |
|
| 658 | 658 | $inputs = $this->inputs(); |
| 659 | 659 | $errors = array(); |
| 660 | - foreach( $inputs as $form_input ){ |
|
| 661 | - if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){ |
|
| 662 | - $errors[ $form_input->html_name() ] = $form_input->get_validation_error_string(); |
|
| 660 | + foreach ($inputs as $form_input) { |
|
| 661 | + if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) { |
|
| 662 | + $errors[$form_input->html_name()] = $form_input->get_validation_error_string(); |
|
| 663 | 663 | } |
| 664 | 664 | } |
| 665 | 665 | return $errors; |
@@ -671,15 +671,15 @@ discard block |
||
| 671 | 671 | * passes all the form data required by the JS to the JS, and enqueues the few required JS files. |
| 672 | 672 | * Should be setup by each form during the _enqueues_and_localize_form_js |
| 673 | 673 | */ |
| 674 | - public static function localize_script_for_all_forms(){ |
|
| 674 | + public static function localize_script_for_all_forms() { |
|
| 675 | 675 | //allow inputs and stuff to hook in their JS and stuff here |
| 676 | - do_action( 'AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin' ); |
|
| 676 | + do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin'); |
|
| 677 | 677 | EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages(); |
| 678 | - $email_validation_level = isset( EE_Registry::instance()->CFG->registration->email_validation_level ) |
|
| 678 | + $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level) |
|
| 679 | 679 | ? EE_Registry::instance()->CFG->registration->email_validation_level |
| 680 | 680 | : 'wp_default'; |
| 681 | 681 | EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level; |
| 682 | - wp_enqueue_script( 'ee_form_section_validation' ); |
|
| 682 | + wp_enqueue_script('ee_form_section_validation'); |
|
| 683 | 683 | wp_localize_script( |
| 684 | 684 | 'ee_form_section_validation', |
| 685 | 685 | 'ee_form_section_vars', |
@@ -692,8 +692,8 @@ discard block |
||
| 692 | 692 | /** |
| 693 | 693 | * ensure_scripts_localized |
| 694 | 694 | */ |
| 695 | - public function ensure_scripts_localized(){ |
|
| 696 | - if ( ! EE_Form_Section_Proper::$_scripts_localized ) { |
|
| 695 | + public function ensure_scripts_localized() { |
|
| 696 | + if ( ! EE_Form_Section_Proper::$_scripts_localized) { |
|
| 697 | 697 | $this->_enqueue_and_localize_form_js(); |
| 698 | 698 | } |
| 699 | 699 | } |
@@ -705,10 +705,10 @@ discard block |
||
| 705 | 705 | * is that the key here should be the same as the custom validation rule put in the JS file |
| 706 | 706 | * @return array keys are custom validation rules, and values are internationalized strings |
| 707 | 707 | */ |
| 708 | - private static function _get_localized_error_messages(){ |
|
| 708 | + private static function _get_localized_error_messages() { |
|
| 709 | 709 | return array( |
| 710 | 710 | 'validUrl'=> __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"), |
| 711 | - 'regex' => __( 'Please check your input', 'event_espresso' ), |
|
| 711 | + 'regex' => __('Please check your input', 'event_espresso'), |
|
| 712 | 712 | ); |
| 713 | 713 | } |
| 714 | 714 | |
@@ -738,9 +738,9 @@ discard block |
||
| 738 | 738 | * |
| 739 | 739 | * @return array |
| 740 | 740 | */ |
| 741 | - public function get_jquery_validation_rules(){ |
|
| 741 | + public function get_jquery_validation_rules() { |
|
| 742 | 742 | $jquery_validation_rules = array(); |
| 743 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
| 743 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 744 | 744 | $jquery_validation_rules = array_merge( |
| 745 | 745 | $jquery_validation_rules, |
| 746 | 746 | $subsection->get_jquery_validation_rules() |
@@ -757,14 +757,14 @@ discard block |
||
| 757 | 757 | * @param array $req_data like $_POST |
| 758 | 758 | * @return void |
| 759 | 759 | */ |
| 760 | - protected function _normalize( $req_data ) { |
|
| 760 | + protected function _normalize($req_data) { |
|
| 761 | 761 | $this->_received_submission = true; |
| 762 | 762 | $this->_validation_errors = array(); |
| 763 | - foreach ( $this->get_validatable_subsections() as $subsection ) { |
|
| 763 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 764 | 764 | try { |
| 765 | - $subsection->_normalize( $req_data ); |
|
| 766 | - } catch ( EE_Validation_Error $e ) { |
|
| 767 | - $subsection->add_validation_error( $e ); |
|
| 765 | + $subsection->_normalize($req_data); |
|
| 766 | + } catch (EE_Validation_Error $e) { |
|
| 767 | + $subsection->add_validation_error($e); |
|
| 768 | 768 | } |
| 769 | 769 | } |
| 770 | 770 | } |
@@ -781,9 +781,9 @@ discard block |
||
| 781 | 781 | * calling parent::_validate() first. |
| 782 | 782 | */ |
| 783 | 783 | protected function _validate() { |
| 784 | - foreach($this->get_validatable_subsections() as $subsection_name => $subsection){ |
|
| 785 | - if(method_exists($this,'_validate_'.$subsection_name)){ |
|
| 786 | - call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection)); |
|
| 784 | + foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) { |
|
| 785 | + if (method_exists($this, '_validate_'.$subsection_name)) { |
|
| 786 | + call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection)); |
|
| 787 | 787 | } |
| 788 | 788 | $subsection->_validate(); |
| 789 | 789 | } |
@@ -795,13 +795,13 @@ discard block |
||
| 795 | 795 | * Gets all the validated inputs for the form section |
| 796 | 796 | * @return array |
| 797 | 797 | */ |
| 798 | - public function valid_data(){ |
|
| 798 | + public function valid_data() { |
|
| 799 | 799 | $inputs = array(); |
| 800 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
| 801 | - if ( $subsection instanceof EE_Form_Section_Proper ) { |
|
| 802 | - $inputs[ $subsection_name ] = $subsection->valid_data(); |
|
| 803 | - } else if ( $subsection instanceof EE_Form_Input_Base ){ |
|
| 804 | - $inputs[ $subsection_name ] = $subsection->normalized_value(); |
|
| 800 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
| 801 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
| 802 | + $inputs[$subsection_name] = $subsection->valid_data(); |
|
| 803 | + } else if ($subsection instanceof EE_Form_Input_Base) { |
|
| 804 | + $inputs[$subsection_name] = $subsection->normalized_value(); |
|
| 805 | 805 | } |
| 806 | 806 | } |
| 807 | 807 | return $inputs; |
@@ -813,11 +813,11 @@ discard block |
||
| 813 | 813 | * Gets all the inputs on this form section |
| 814 | 814 | * @return EE_Form_Input_Base[] |
| 815 | 815 | */ |
| 816 | - public function inputs(){ |
|
| 816 | + public function inputs() { |
|
| 817 | 817 | $inputs = array(); |
| 818 | - foreach( $this->subsections() as $subsection_name =>$subsection ){ |
|
| 819 | - if ( $subsection instanceof EE_Form_Input_Base ){ |
|
| 820 | - $inputs[ $subsection_name ] = $subsection; |
|
| 818 | + foreach ($this->subsections() as $subsection_name =>$subsection) { |
|
| 819 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
| 820 | + $inputs[$subsection_name] = $subsection; |
|
| 821 | 821 | } |
| 822 | 822 | } |
| 823 | 823 | return $inputs; |
@@ -829,10 +829,10 @@ discard block |
||
| 829 | 829 | * Gets all the subsections which are a proper form |
| 830 | 830 | * @return EE_Form_Section_Proper[] |
| 831 | 831 | */ |
| 832 | - public function subforms(){ |
|
| 832 | + public function subforms() { |
|
| 833 | 833 | $form_sections = array(); |
| 834 | - foreach($this->subsections() as $name=>$obj){ |
|
| 835 | - if($obj instanceof EE_Form_Section_Proper){ |
|
| 834 | + foreach ($this->subsections() as $name=>$obj) { |
|
| 835 | + if ($obj instanceof EE_Form_Section_Proper) { |
|
| 836 | 836 | $form_sections[$name] = $obj; |
| 837 | 837 | } |
| 838 | 838 | } |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | * if you only want form inputs or proper form sections. |
| 848 | 848 | * @return EE_Form_Section_Proper[] |
| 849 | 849 | */ |
| 850 | - public function subsections(){ |
|
| 850 | + public function subsections() { |
|
| 851 | 851 | $this->ensure_construct_finalized_called(); |
| 852 | 852 | return $this->_subsections; |
| 853 | 853 | } |
@@ -869,8 +869,8 @@ discard block |
||
| 869 | 869 | * where keys are always subsection names and values are either |
| 870 | 870 | * the input's normalized value, or an array like the top-level array |
| 871 | 871 | */ |
| 872 | - public function input_values( $include_subform_inputs = false, $flatten = false ){ |
|
| 873 | - return $this->_input_values( false, $include_subform_inputs, $flatten ); |
|
| 872 | + public function input_values($include_subform_inputs = false, $flatten = false) { |
|
| 873 | + return $this->_input_values(false, $include_subform_inputs, $flatten); |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | /** |
@@ -890,8 +890,8 @@ discard block |
||
| 890 | 890 | * where keys are always subsection names and values are either |
| 891 | 891 | * the input's normalized value, or an array like the top-level array |
| 892 | 892 | */ |
| 893 | - public function input_pretty_values( $include_subform_inputs = false, $flatten = false ){ |
|
| 894 | - return $this->_input_values( true, $include_subform_inputs, $flatten ); |
|
| 893 | + public function input_pretty_values($include_subform_inputs = false, $flatten = false) { |
|
| 894 | + return $this->_input_values(true, $include_subform_inputs, $flatten); |
|
| 895 | 895 | } |
| 896 | 896 | |
| 897 | 897 | /** |
@@ -909,19 +909,19 @@ discard block |
||
| 909 | 909 | * where keys are always subsection names and values are either |
| 910 | 910 | * the input's normalized value, or an array like the top-level array |
| 911 | 911 | */ |
| 912 | - public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) { |
|
| 912 | + public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) { |
|
| 913 | 913 | $input_values = array(); |
| 914 | - foreach( $this->subsections() as $subsection_name => $subsection ) { |
|
| 915 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
| 916 | - $input_values[ $subsection_name ] = $pretty |
|
| 914 | + foreach ($this->subsections() as $subsection_name => $subsection) { |
|
| 915 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
| 916 | + $input_values[$subsection_name] = $pretty |
|
| 917 | 917 | ? $subsection->pretty_value() |
| 918 | 918 | : $subsection->normalized_value(); |
| 919 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) { |
|
| 920 | - $subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten ); |
|
| 921 | - if( $flatten ) { |
|
| 922 | - $input_values = array_merge( $input_values, $subform_input_values ); |
|
| 919 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) { |
|
| 920 | + $subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten); |
|
| 921 | + if ($flatten) { |
|
| 922 | + $input_values = array_merge($input_values, $subform_input_values); |
|
| 923 | 923 | } else { |
| 924 | - $input_values[ $subsection_name ] = $subform_input_values; |
|
| 924 | + $input_values[$subsection_name] = $subform_input_values; |
|
| 925 | 925 | } |
| 926 | 926 | } |
| 927 | 927 | } |
@@ -942,23 +942,23 @@ discard block |
||
| 942 | 942 | * where keys are always subsection names and values are either |
| 943 | 943 | * the input's normalized value, or an array like the top-level array |
| 944 | 944 | */ |
| 945 | - public function submitted_values( $include_subforms = false ) { |
|
| 945 | + public function submitted_values($include_subforms = false) { |
|
| 946 | 946 | $submitted_values = array(); |
| 947 | - foreach( $this->subsections() as $subsection ) { |
|
| 948 | - if( $subsection instanceof EE_Form_Input_Base ) { |
|
| 947 | + foreach ($this->subsections() as $subsection) { |
|
| 948 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
| 949 | 949 | // is this input part of an array of inputs? |
| 950 | - if ( strpos( $subsection->html_name(), '[' ) !== false ) { |
|
| 950 | + if (strpos($subsection->html_name(), '[') !== false) { |
|
| 951 | 951 | $full_input_name = \EEH_Array::convert_array_values_to_keys( |
| 952 | - explode( '[', str_replace( ']', '', $subsection->html_name() ) ), |
|
| 952 | + explode('[', str_replace(']', '', $subsection->html_name())), |
|
| 953 | 953 | $subsection->raw_value() |
| 954 | 954 | ); |
| 955 | - $submitted_values = array_replace_recursive( $submitted_values, $full_input_name ); |
|
| 955 | + $submitted_values = array_replace_recursive($submitted_values, $full_input_name); |
|
| 956 | 956 | } else { |
| 957 | - $submitted_values[ $subsection->html_name() ] = $subsection->raw_value(); |
|
| 957 | + $submitted_values[$subsection->html_name()] = $subsection->raw_value(); |
|
| 958 | 958 | } |
| 959 | - } else if( $subsection instanceof EE_Form_Section_Proper && $include_subforms ) { |
|
| 960 | - $subform_input_values = $subsection->submitted_values( $include_subforms ); |
|
| 961 | - $submitted_values = array_replace_recursive( $submitted_values, $subform_input_values ); |
|
| 959 | + } else if ($subsection instanceof EE_Form_Section_Proper && $include_subforms) { |
|
| 960 | + $subform_input_values = $subsection->submitted_values($include_subforms); |
|
| 961 | + $submitted_values = array_replace_recursive($submitted_values, $subform_input_values); |
|
| 962 | 962 | } |
| 963 | 963 | } |
| 964 | 964 | return $submitted_values; |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | * @return boolean |
| 974 | 974 | * @throws \EE_Error |
| 975 | 975 | */ |
| 976 | - public function has_received_submission(){ |
|
| 976 | + public function has_received_submission() { |
|
| 977 | 977 | $this->ensure_construct_finalized_called(); |
| 978 | 978 | return $this->_received_submission; |
| 979 | 979 | } |
@@ -986,8 +986,8 @@ discard block |
||
| 986 | 986 | * @param array $inputs_to_exclude values are the input names |
| 987 | 987 | * @return void |
| 988 | 988 | */ |
| 989 | - public function exclude($inputs_to_exclude = array()){ |
|
| 990 | - foreach($inputs_to_exclude as $input_to_exclude_name){ |
|
| 989 | + public function exclude($inputs_to_exclude = array()) { |
|
| 990 | + foreach ($inputs_to_exclude as $input_to_exclude_name) { |
|
| 991 | 991 | unset($this->_subsections[$input_to_exclude_name]); |
| 992 | 992 | } |
| 993 | 993 | } |
@@ -998,8 +998,8 @@ discard block |
||
| 998 | 998 | * @param array $inputs_to_hide |
| 999 | 999 | * @throws \EE_Error |
| 1000 | 1000 | */ |
| 1001 | - public function hide($inputs_to_hide= array()){ |
|
| 1002 | - foreach($inputs_to_hide as $input_to_hide){ |
|
| 1001 | + public function hide($inputs_to_hide = array()) { |
|
| 1002 | + foreach ($inputs_to_hide as $input_to_hide) { |
|
| 1003 | 1003 | $input = $this->get_input($input_to_hide); |
| 1004 | 1004 | |
| 1005 | 1005 | $input->set_display_strategy(new EE_Hidden_Display_Strategy()); |
@@ -1029,21 +1029,21 @@ discard block |
||
| 1029 | 1029 | * @return void |
| 1030 | 1030 | * @throws \EE_Error |
| 1031 | 1031 | */ |
| 1032 | - public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){ |
|
| 1033 | - foreach( $new_subsections as $subsection_name => $subsection ){ |
|
| 1034 | - if( ! $subsection instanceof EE_Form_Section_Base ){ |
|
| 1032 | + public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) { |
|
| 1033 | + foreach ($new_subsections as $subsection_name => $subsection) { |
|
| 1034 | + if ( ! $subsection instanceof EE_Form_Section_Base) { |
|
| 1035 | 1035 | EE_Error::add_error( |
| 1036 | 1036 | sprintf( |
| 1037 | 1037 | __( |
| 1038 | 1038 | "Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", |
| 1039 | 1039 | "event_espresso" |
| 1040 | 1040 | ), |
| 1041 | - get_class( $subsection ), |
|
| 1041 | + get_class($subsection), |
|
| 1042 | 1042 | $subsection_name, |
| 1043 | 1043 | $this->name() |
| 1044 | 1044 | ) |
| 1045 | 1045 | ); |
| 1046 | - unset( $new_subsections[ $subsection_name ] ); |
|
| 1046 | + unset($new_subsections[$subsection_name]); |
|
| 1047 | 1047 | } |
| 1048 | 1048 | } |
| 1049 | 1049 | $this->_subsections = EEH_Array::insert_into_array( |
@@ -1054,8 +1054,8 @@ discard block |
||
| 1054 | 1054 | ); |
| 1055 | 1055 | |
| 1056 | 1056 | |
| 1057 | - if( $this->_construction_finalized ){ |
|
| 1058 | - foreach($this->_subsections as $name => $subsection){ |
|
| 1057 | + if ($this->_construction_finalized) { |
|
| 1058 | + foreach ($this->_subsections as $name => $subsection) { |
|
| 1059 | 1059 | $subsection->_construct_finalize($this, $name); |
| 1060 | 1060 | } |
| 1061 | 1061 | } |
@@ -1066,8 +1066,8 @@ discard block |
||
| 1066 | 1066 | /** |
| 1067 | 1067 | * Just gets all validatable subsections to clean their sensitive data |
| 1068 | 1068 | */ |
| 1069 | - public function clean_sensitive_data(){ |
|
| 1070 | - foreach($this->get_validatable_subsections() as $subsection){ |
|
| 1069 | + public function clean_sensitive_data() { |
|
| 1070 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 1071 | 1071 | $subsection->clean_sensitive_data(); |
| 1072 | 1072 | } |
| 1073 | 1073 | } |
@@ -1077,10 +1077,10 @@ discard block |
||
| 1077 | 1077 | /** |
| 1078 | 1078 | * @param string $form_submission_error_message |
| 1079 | 1079 | */ |
| 1080 | - public function set_submission_error_message( $form_submission_error_message = '' ) { |
|
| 1081 | - $this->_form_submission_error_message .= ! empty( $form_submission_error_message ) |
|
| 1080 | + public function set_submission_error_message($form_submission_error_message = '') { |
|
| 1081 | + $this->_form_submission_error_message .= ! empty($form_submission_error_message) |
|
| 1082 | 1082 | ? $form_submission_error_message |
| 1083 | - : __( 'Form submission failed due to errors', 'event_espresso' ); |
|
| 1083 | + : __('Form submission failed due to errors', 'event_espresso'); |
|
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | 1086 | |
@@ -1097,10 +1097,10 @@ discard block |
||
| 1097 | 1097 | /** |
| 1098 | 1098 | * @param string $form_submission_success_message |
| 1099 | 1099 | */ |
| 1100 | - public function set_submission_success_message( $form_submission_success_message ) { |
|
| 1101 | - $this->_form_submission_success_message .= ! empty( $form_submission_success_message ) |
|
| 1100 | + public function set_submission_success_message($form_submission_success_message) { |
|
| 1101 | + $this->_form_submission_success_message .= ! empty($form_submission_success_message) |
|
| 1102 | 1102 | ? $form_submission_success_message |
| 1103 | - : __( 'Form submitted successfully', 'event_espresso' ); |
|
| 1103 | + : __('Form submitted successfully', 'event_espresso'); |
|
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | 1106 | |
@@ -1123,10 +1123,10 @@ discard block |
||
| 1123 | 1123 | * @return string |
| 1124 | 1124 | * @throws \EE_Error |
| 1125 | 1125 | */ |
| 1126 | - public function html_name_prefix(){ |
|
| 1127 | - if( $this->parent_section() instanceof EE_Form_Section_Proper ){ |
|
| 1128 | - return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']'; |
|
| 1129 | - }else{ |
|
| 1126 | + public function html_name_prefix() { |
|
| 1127 | + if ($this->parent_section() instanceof EE_Form_Section_Proper) { |
|
| 1128 | + return $this->parent_section()->html_name_prefix().'['.$this->name().']'; |
|
| 1129 | + } else { |
|
| 1130 | 1130 | return $this->name(); |
| 1131 | 1131 | } |
| 1132 | 1132 | } |
@@ -1141,7 +1141,7 @@ discard block |
||
| 1141 | 1141 | * @return string |
| 1142 | 1142 | * @throws \EE_Error |
| 1143 | 1143 | */ |
| 1144 | - public function name(){ |
|
| 1144 | + public function name() { |
|
| 1145 | 1145 | $this->ensure_construct_finalized_called(); |
| 1146 | 1146 | return parent::name(); |
| 1147 | 1147 | } |
@@ -1152,7 +1152,7 @@ discard block |
||
| 1152 | 1152 | * @return EE_Form_Section_Proper |
| 1153 | 1153 | * @throws \EE_Error |
| 1154 | 1154 | */ |
| 1155 | - public function parent_section(){ |
|
| 1155 | + public function parent_section() { |
|
| 1156 | 1156 | $this->ensure_construct_finalized_called(); |
| 1157 | 1157 | return parent::parent_section(); |
| 1158 | 1158 | } |
@@ -1165,9 +1165,9 @@ discard block |
||
| 1165 | 1165 | * @return void |
| 1166 | 1166 | * @throws \EE_Error |
| 1167 | 1167 | */ |
| 1168 | - public function ensure_construct_finalized_called(){ |
|
| 1169 | - if( ! $this->_construction_finalized ){ |
|
| 1170 | - $this->_construct_finalize($this->_parent_section, $this->_name ); |
|
| 1168 | + public function ensure_construct_finalized_called() { |
|
| 1169 | + if ( ! $this->_construction_finalized) { |
|
| 1170 | + $this->_construct_finalize($this->_parent_section, $this->_name); |
|
| 1171 | 1171 | } |
| 1172 | 1172 | } |
| 1173 | 1173 | |
@@ -1179,17 +1179,17 @@ discard block |
||
| 1179 | 1179 | * @param array $req_data |
| 1180 | 1180 | * @return boolean |
| 1181 | 1181 | */ |
| 1182 | - public function form_data_present_in( $req_data = NULL ) { |
|
| 1183 | - if( $req_data === NULL){ |
|
| 1182 | + public function form_data_present_in($req_data = NULL) { |
|
| 1183 | + if ($req_data === NULL) { |
|
| 1184 | 1184 | $req_data = $_POST; |
| 1185 | 1185 | } |
| 1186 | - foreach( $this->subsections() as $subsection ) { |
|
| 1187 | - if($subsection instanceof EE_Form_Input_Base ) { |
|
| 1188 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
| 1186 | + foreach ($this->subsections() as $subsection) { |
|
| 1187 | + if ($subsection instanceof EE_Form_Input_Base) { |
|
| 1188 | + if ($subsection->form_data_present_in($req_data)) { |
|
| 1189 | 1189 | return TRUE; |
| 1190 | 1190 | } |
| 1191 | - }elseif( $subsection instanceof EE_Form_Section_Proper ) { |
|
| 1192 | - if( $subsection->form_data_present_in( $req_data ) ) { |
|
| 1191 | + }elseif ($subsection instanceof EE_Form_Section_Proper) { |
|
| 1192 | + if ($subsection->form_data_present_in($req_data)) { |
|
| 1193 | 1193 | return TRUE; |
| 1194 | 1194 | } |
| 1195 | 1195 | } |
@@ -1206,14 +1206,14 @@ discard block |
||
| 1206 | 1206 | */ |
| 1207 | 1207 | public function get_validation_errors_accumulated() { |
| 1208 | 1208 | $validation_errors = $this->get_validation_errors(); |
| 1209 | - foreach($this->get_validatable_subsections() as $subsection ) { |
|
| 1210 | - if( $subsection instanceof EE_Form_Section_Proper ) { |
|
| 1209 | + foreach ($this->get_validatable_subsections() as $subsection) { |
|
| 1210 | + if ($subsection instanceof EE_Form_Section_Proper) { |
|
| 1211 | 1211 | $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated(); |
| 1212 | 1212 | } else { |
| 1213 | - $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
| 1213 | + $validation_errors_on_this_subsection = $subsection->get_validation_errors(); |
|
| 1214 | 1214 | } |
| 1215 | - if( $validation_errors_on_this_subsection ){ |
|
| 1216 | - $validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection ); |
|
| 1215 | + if ($validation_errors_on_this_subsection) { |
|
| 1216 | + $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection); |
|
| 1217 | 1217 | } |
| 1218 | 1218 | } |
| 1219 | 1219 | return $validation_errors; |
@@ -1235,24 +1235,24 @@ discard block |
||
| 1235 | 1235 | * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false |
| 1236 | 1236 | * @return EE_Form_Section_Base |
| 1237 | 1237 | */ |
| 1238 | - public function find_section_from_path( $form_section_path ) { |
|
| 1238 | + public function find_section_from_path($form_section_path) { |
|
| 1239 | 1239 | //check if we can find the input from purely going straight up the tree |
| 1240 | - $input = parent::find_section_from_path( $form_section_path ); |
|
| 1241 | - if( $input instanceof EE_Form_Section_Base ) { |
|
| 1240 | + $input = parent::find_section_from_path($form_section_path); |
|
| 1241 | + if ($input instanceof EE_Form_Section_Base) { |
|
| 1242 | 1242 | return $input; |
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | - $next_slash_pos = strpos( $form_section_path, '/' ); |
|
| 1246 | - if( $next_slash_pos !== false ) { |
|
| 1247 | - $child_section_name = substr( $form_section_path, 0, $next_slash_pos ); |
|
| 1248 | - $subpath = substr( $form_section_path, $next_slash_pos + 1 ); |
|
| 1245 | + $next_slash_pos = strpos($form_section_path, '/'); |
|
| 1246 | + if ($next_slash_pos !== false) { |
|
| 1247 | + $child_section_name = substr($form_section_path, 0, $next_slash_pos); |
|
| 1248 | + $subpath = substr($form_section_path, $next_slash_pos + 1); |
|
| 1249 | 1249 | } else { |
| 1250 | 1250 | $child_section_name = $form_section_path; |
| 1251 | 1251 | $subpath = ''; |
| 1252 | 1252 | } |
| 1253 | - $child_section = $this->get_subsection( $child_section_name ); |
|
| 1254 | - if ( $child_section instanceof EE_Form_Section_Base ) { |
|
| 1255 | - return $child_section->find_section_from_path( $subpath ); |
|
| 1253 | + $child_section = $this->get_subsection($child_section_name); |
|
| 1254 | + if ($child_section instanceof EE_Form_Section_Base) { |
|
| 1255 | + return $child_section->find_section_from_path($subpath); |
|
| 1256 | 1256 | } else { |
| 1257 | 1257 | return null; |
| 1258 | 1258 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | -<?php if ( ! defined( 'ABSPATH' ) ) { |
|
| 2 | - exit( 'No direct script access allowed' ); |
|
| 1 | +<?php if ( ! defined('ABSPATH')) { |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | /* |
| 5 | 5 | Plugin Name: Event Espresso |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | */ |
| 44 | 44 | |
| 45 | -if ( function_exists( 'espresso_version' ) ) { |
|
| 45 | +if (function_exists('espresso_version')) { |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * espresso_duplicate_plugin_error |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | function espresso_duplicate_plugin_error() { |
| 52 | 52 | ?> |
| 53 | 53 | <div class="error"> |
| 54 | - <p><?php _e( 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso' ); ?></p> |
|
| 54 | + <p><?php _e('Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso'); ?></p> |
|
| 55 | 55 | </div> |
| 56 | 56 | <?php |
| 57 | - espresso_deactivate_plugin( plugin_basename( __FILE__ ) ); |
|
| 57 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 58 | 58 | } |
| 59 | - add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 ); |
|
| 59 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 60 | 60 | |
| 61 | 61 | } else { |
| 62 | 62 | |
@@ -67,103 +67,103 @@ discard block |
||
| 67 | 67 | * @return string |
| 68 | 68 | */ |
| 69 | 69 | function espresso_version() { |
| 70 | - return apply_filters( 'FHEE__espresso__espresso_version', '4.9.13.rc.002' ); |
|
| 70 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.13.rc.002'); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | // define versions |
| 74 | - define( 'EVENT_ESPRESSO_VERSION', espresso_version() ); |
|
| 75 | - define( 'EE_MIN_WP_VER_REQUIRED', '4.1' ); |
|
| 76 | - define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' ); |
|
| 77 | - define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' ); |
|
| 78 | - define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' ); |
|
| 79 | - define( 'EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - ' . EVENT_ESPRESSO_VERSION ); |
|
| 80 | - define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ ); |
|
| 74 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
| 75 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
| 76 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
| 77 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.0'); |
|
| 78 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
| 79 | + define('EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - '.EVENT_ESPRESSO_VERSION); |
|
| 80 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 81 | 81 | //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
| 82 | - if ( ! defined( 'DS' ) ) { |
|
| 83 | - define( 'DS', '/' ); |
|
| 82 | + if ( ! defined('DS')) { |
|
| 83 | + define('DS', '/'); |
|
| 84 | 84 | } |
| 85 | - if ( ! defined( 'PS' ) ) { |
|
| 86 | - define( 'PS', PATH_SEPARATOR ); |
|
| 85 | + if ( ! defined('PS')) { |
|
| 86 | + define('PS', PATH_SEPARATOR); |
|
| 87 | 87 | } |
| 88 | - if ( ! defined( 'SP' ) ) { |
|
| 89 | - define( 'SP', ' ' ); |
|
| 88 | + if ( ! defined('SP')) { |
|
| 89 | + define('SP', ' '); |
|
| 90 | 90 | } |
| 91 | - if ( ! defined( 'EENL' ) ) { |
|
| 92 | - define( 'EENL', "\n" ); |
|
| 91 | + if ( ! defined('EENL')) { |
|
| 92 | + define('EENL', "\n"); |
|
| 93 | 93 | } |
| 94 | - define( 'EE_SUPPORT_EMAIL', '[email protected]' ); |
|
| 94 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
| 95 | 95 | // define the plugin directory and URL |
| 96 | - define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
| 97 | - define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
| 98 | - define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) ); |
|
| 96 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 97 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 98 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
| 99 | 99 | // main root folder paths |
| 100 | - define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS ); |
|
| 101 | - define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS ); |
|
| 102 | - define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS ); |
|
| 103 | - define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS ); |
|
| 104 | - define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS ); |
|
| 105 | - define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS ); |
|
| 106 | - define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS ); |
|
| 107 | - define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS ); |
|
| 100 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS); |
|
| 101 | + define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS); |
|
| 102 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS); |
|
| 103 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS); |
|
| 104 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS); |
|
| 105 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS); |
|
| 106 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS); |
|
| 107 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS); |
|
| 108 | 108 | // core system paths |
| 109 | - define( 'EE_ADMIN', EE_CORE . 'admin' . DS ); |
|
| 110 | - define( 'EE_CPTS', EE_CORE . 'CPTs' . DS ); |
|
| 111 | - define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS ); |
|
| 112 | - define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS ); |
|
| 113 | - define( 'EE_BUSINESS', EE_CORE . 'business' . DS ); |
|
| 114 | - define( 'EE_MODELS', EE_CORE . 'db_models' . DS ); |
|
| 115 | - define( 'EE_HELPERS', EE_CORE . 'helpers' . DS ); |
|
| 116 | - define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS ); |
|
| 117 | - define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS ); |
|
| 118 | - define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS ); |
|
| 119 | - define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS ); |
|
| 120 | - define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS ); |
|
| 109 | + define('EE_ADMIN', EE_CORE.'admin'.DS); |
|
| 110 | + define('EE_CPTS', EE_CORE.'CPTs'.DS); |
|
| 111 | + define('EE_CLASSES', EE_CORE.'db_classes'.DS); |
|
| 112 | + define('EE_INTERFACES', EE_CORE.'interfaces'.DS); |
|
| 113 | + define('EE_BUSINESS', EE_CORE.'business'.DS); |
|
| 114 | + define('EE_MODELS', EE_CORE.'db_models'.DS); |
|
| 115 | + define('EE_HELPERS', EE_CORE.'helpers'.DS); |
|
| 116 | + define('EE_LIBRARIES', EE_CORE.'libraries'.DS); |
|
| 117 | + define('EE_TEMPLATES', EE_CORE.'templates'.DS); |
|
| 118 | + define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS); |
|
| 119 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS); |
|
| 120 | + define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS); |
|
| 121 | 121 | // gateways |
| 122 | - define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS ); |
|
| 123 | - define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS ); |
|
| 122 | + define('EE_GATEWAYS', EE_MODULES.'gateways'.DS); |
|
| 123 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS); |
|
| 124 | 124 | // asset URL paths |
| 125 | - define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS ); |
|
| 126 | - define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS ); |
|
| 127 | - define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS ); |
|
| 128 | - define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS ); |
|
| 129 | - define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' ); |
|
| 130 | - define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' ); |
|
| 125 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS); |
|
| 126 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS); |
|
| 127 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS); |
|
| 128 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS); |
|
| 129 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/'); |
|
| 130 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/'); |
|
| 131 | 131 | // define upload paths |
| 132 | 132 | $uploads = wp_upload_dir(); |
| 133 | 133 | // define the uploads directory and URL |
| 134 | - define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS ); |
|
| 135 | - define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS ); |
|
| 134 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS); |
|
| 135 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS); |
|
| 136 | 136 | // define the templates directory and URL |
| 137 | - define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
| 138 | - define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'templates' . DS ); |
|
| 137 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS); |
|
| 138 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS); |
|
| 139 | 139 | // define the gateway directory and URL |
| 140 | - define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
| 141 | - define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'gateways' . DS ); |
|
| 140 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS); |
|
| 141 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS); |
|
| 142 | 142 | // languages folder/path |
| 143 | - define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS ); |
|
| 144 | - define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS ); |
|
| 143 | + define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS); |
|
| 144 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS); |
|
| 145 | 145 | //check for dompdf fonts in uploads |
| 146 | - if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) { |
|
| 147 | - define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ); |
|
| 146 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) { |
|
| 147 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS); |
|
| 148 | 148 | } |
| 149 | 149 | //ajax constants |
| 150 | - define( 'EE_FRONT_AJAX', isset( $_REQUEST[ 'ee_front_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_front_ajax' ] ) ? true : false ); |
|
| 151 | - define( 'EE_ADMIN_AJAX', isset( $_REQUEST[ 'ee_admin_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_admin_ajax' ] ) ? true : false ); |
|
| 150 | + define('EE_FRONT_AJAX', isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false); |
|
| 151 | + define('EE_ADMIN_AJAX', isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false); |
|
| 152 | 152 | //just a handy constant occasionally needed for finding values representing infinity in the DB |
| 153 | 153 | //you're better to use this than its straight value (currently -1) in case you ever |
| 154 | 154 | //want to change its default value! or find when -1 means infinity |
| 155 | - define( 'EE_INF_IN_DB', -1 ); |
|
| 156 | - define( 'EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX ); |
|
| 157 | - define( 'EE_DEBUG', false ); |
|
| 155 | + define('EE_INF_IN_DB', -1); |
|
| 156 | + define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
| 157 | + define('EE_DEBUG', false); |
|
| 158 | 158 | |
| 159 | 159 | /** |
| 160 | 160 | * espresso_plugin_activation |
| 161 | 161 | * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
| 162 | 162 | */ |
| 163 | 163 | function espresso_plugin_activation() { |
| 164 | - update_option( 'ee_espresso_activation', true ); |
|
| 164 | + update_option('ee_espresso_activation', true); |
|
| 165 | 165 | } |
| 166 | - register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' ); |
|
| 166 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 167 | 167 | |
| 168 | 168 | |
| 169 | 169 | |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | // } |
| 178 | 178 | // |
| 179 | 179 | } |
| 180 | - register_deactivation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation' ); |
|
| 180 | + register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation'); |
|
| 181 | 181 | |
| 182 | 182 | |
| 183 | 183 | |
@@ -187,15 +187,15 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | function espresso_load_error_handling() { |
| 189 | 189 | // load debugging tools |
| 190 | - if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) { |
|
| 191 | - require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ); |
|
| 190 | + if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) { |
|
| 191 | + require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php'); |
|
| 192 | 192 | EEH_Debug_Tools::instance(); |
| 193 | 193 | } |
| 194 | 194 | // load error handling |
| 195 | - if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) { |
|
| 196 | - require_once( EE_CORE . 'EE_Error.core.php' ); |
|
| 195 | + if (is_readable(EE_CORE.'EE_Error.core.php')) { |
|
| 196 | + require_once(EE_CORE.'EE_Error.core.php'); |
|
| 197 | 197 | } else { |
| 198 | - wp_die( __( 'The EE_Error core class could not be loaded.', 'event_espresso' ) ); |
|
| 198 | + wp_die(__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | |
@@ -209,25 +209,25 @@ discard block |
||
| 209 | 209 | * @param string $full_path_to_file |
| 210 | 210 | * @throws EE_Error |
| 211 | 211 | */ |
| 212 | - function espresso_load_required( $classname, $full_path_to_file ) { |
|
| 212 | + function espresso_load_required($classname, $full_path_to_file) { |
|
| 213 | 213 | static $error_handling_loaded = false; |
| 214 | - if ( ! $error_handling_loaded ) { |
|
| 214 | + if ( ! $error_handling_loaded) { |
|
| 215 | 215 | espresso_load_error_handling(); |
| 216 | 216 | $error_handling_loaded = true; |
| 217 | 217 | } |
| 218 | - if ( is_readable( $full_path_to_file ) ) { |
|
| 219 | - require_once( $full_path_to_file ); |
|
| 218 | + if (is_readable($full_path_to_file)) { |
|
| 219 | + require_once($full_path_to_file); |
|
| 220 | 220 | } else { |
| 221 | - throw new EE_Error ( sprintf( |
|
| 222 | - __( 'The %s class file could not be located or is not readable due to file permissions.', 'event_espresso' ), |
|
| 221 | + throw new EE_Error(sprintf( |
|
| 222 | + __('The %s class file could not be located or is not readable due to file permissions.', 'event_espresso'), |
|
| 223 | 223 | $classname |
| 224 | - ) ); |
|
| 224 | + )); |
|
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' ); |
|
| 229 | - espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' ); |
|
| 230 | - espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' ); |
|
| 228 | + espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php'); |
|
| 229 | + espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php'); |
|
| 230 | + espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php'); |
|
| 231 | 231 | new EE_Bootstrap(); |
| 232 | 232 | |
| 233 | 233 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | |
| 238 | 238 | |
| 239 | -if ( ! function_exists( 'espresso_deactivate_plugin' ) ) { |
|
| 239 | +if ( ! function_exists('espresso_deactivate_plugin')) { |
|
| 240 | 240 | /** |
| 241 | 241 | * deactivate_plugin |
| 242 | 242 | * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
@@ -245,11 +245,11 @@ discard block |
||
| 245 | 245 | * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
| 246 | 246 | * @return void |
| 247 | 247 | */ |
| 248 | - function espresso_deactivate_plugin( $plugin_basename = '' ) { |
|
| 249 | - if ( ! function_exists( 'deactivate_plugins' ) ) { |
|
| 250 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
| 248 | + function espresso_deactivate_plugin($plugin_basename = '') { |
|
| 249 | + if ( ! function_exists('deactivate_plugins')) { |
|
| 250 | + require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
| 251 | 251 | } |
| 252 | - unset( $_GET[ 'activate' ], $_REQUEST[ 'activate' ] ); |
|
| 253 | - deactivate_plugins( $plugin_basename ); |
|
| 252 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 253 | + deactivate_plugins($plugin_basename); |
|
| 254 | 254 | } |
| 255 | 255 | } |