@@ -135,16 +135,16 @@ discard block |
||
135 | 135 | function load() { |
136 | 136 | |
137 | 137 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
138 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
138 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
139 | 139 | |
140 | 140 | // Don't display an embedded form when editing an entry |
141 | 141 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
142 | 142 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
143 | 143 | |
144 | 144 | // Stop Gravity Forms processing what is ours! |
145 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
145 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
146 | 146 | |
147 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
147 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
148 | 148 | |
149 | 149 | add_action( 'gravityview_edit_entry', array( $this, 'init' ), 10, 4 ); |
150 | 150 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
156 | 156 | |
157 | 157 | // Add fields expected by GFFormDisplay::validate() |
158 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
158 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
159 | 159 | |
160 | 160 | // Fix multiselect value for GF 2.2 |
161 | 161 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | * @return void |
173 | 173 | */ |
174 | 174 | public function prevent_render_form() { |
175 | - if( $this->is_edit_entry() ) { |
|
176 | - if( 'wp_head' === current_filter() ) { |
|
175 | + if ( $this->is_edit_entry() ) { |
|
176 | + if ( 'wp_head' === current_filter() ) { |
|
177 | 177 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
178 | 178 | } else { |
179 | 179 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -188,14 +188,14 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public function prevent_maybe_process_form() { |
190 | 190 | |
191 | - if( ! $this->is_edit_entry_submission() ) { |
|
191 | + if ( ! $this->is_edit_entry_submission() ) { |
|
192 | 192 | return; |
193 | 193 | } |
194 | 194 | |
195 | 195 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] Removing GFForms::maybe_process_form() action.' ); |
196 | 196 | |
197 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
198 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
197 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
198 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | */ |
205 | 205 | public function is_edit_entry() { |
206 | 206 | |
207 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
207 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
208 | 208 | |
209 | 209 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
210 | 210 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @return boolean |
216 | 216 | */ |
217 | 217 | public function is_edit_entry_submission() { |
218 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
218 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -228,16 +228,16 @@ discard block |
||
228 | 228 | |
229 | 229 | |
230 | 230 | $entries = $gravityview_view->getEntries(); |
231 | - self::$original_entry = $entries[0]; |
|
232 | - $this->entry = $entries[0]; |
|
231 | + self::$original_entry = $entries[ 0 ]; |
|
232 | + $this->entry = $entries[ 0 ]; |
|
233 | 233 | |
234 | 234 | self::$original_form = $gravityview_view->getForm(); |
235 | 235 | $this->form = $gravityview_view->getForm(); |
236 | - $this->form_id = $this->entry['form_id']; |
|
236 | + $this->form_id = $this->entry[ 'form_id' ]; |
|
237 | 237 | $this->view_id = $gravityview_view->getViewId(); |
238 | 238 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
239 | 239 | |
240 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
240 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | private function print_scripts() { |
297 | 297 | $gravityview_view = GravityView_View::getInstance(); |
298 | 298 | |
299 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
299 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
300 | 300 | |
301 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
301 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
302 | 302 | |
303 | 303 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
304 | 304 | |
@@ -314,19 +314,19 @@ discard block |
||
314 | 314 | */ |
315 | 315 | private function process_save( $gv_data ) { |
316 | 316 | |
317 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
317 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
318 | 318 | return; |
319 | 319 | } |
320 | 320 | |
321 | 321 | // Make sure the entry, view, and form IDs are all correct |
322 | 322 | $valid = $this->verify_nonce(); |
323 | 323 | |
324 | - if ( !$valid ) { |
|
324 | + if ( ! $valid ) { |
|
325 | 325 | gravityview()->log->error( 'Nonce validation failed.' ); |
326 | 326 | return; |
327 | 327 | } |
328 | 328 | |
329 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
329 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
330 | 330 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
331 | 331 | return; |
332 | 332 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | |
338 | 338 | $this->validate(); |
339 | 339 | |
340 | - if( $this->is_valid ) { |
|
340 | + if ( $this->is_valid ) { |
|
341 | 341 | |
342 | 342 | gravityview()->log->debug( 'Submission is valid.' ); |
343 | 343 | |
@@ -349,15 +349,15 @@ discard block |
||
349 | 349 | /** |
350 | 350 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
351 | 351 | */ |
352 | - unset( $_GET['page'] ); |
|
352 | + unset( $_GET[ 'page' ] ); |
|
353 | 353 | |
354 | - $date_created = $this->entry['date_created']; |
|
354 | + $date_created = $this->entry[ 'date_created' ]; |
|
355 | 355 | |
356 | 356 | /** |
357 | 357 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
358 | 358 | * @since 1.17.2 |
359 | 359 | */ |
360 | - unset( $this->entry['date_created'] ); |
|
360 | + unset( $this->entry[ 'date_created' ] ); |
|
361 | 361 | |
362 | 362 | /** |
363 | 363 | * @action `gravityview/edit_entry/before_update` Perform an action after the entry has been updated using Edit Entry |
@@ -367,14 +367,14 @@ discard block |
||
367 | 367 | * @param GravityView_Edit_Entry_Render $this This object |
368 | 368 | * @param GravityView_View_Data $gv_data The View data |
369 | 369 | */ |
370 | - do_action( 'gravityview/edit_entry/before_update', $form, $this->entry['id'], $this, $gv_data ); |
|
370 | + do_action( 'gravityview/edit_entry/before_update', $form, $this->entry[ 'id' ], $this, $gv_data ); |
|
371 | 371 | |
372 | 372 | GFFormsModel::save_lead( $form, $this->entry ); |
373 | 373 | |
374 | 374 | // Delete the values for hidden inputs |
375 | 375 | $this->unset_hidden_field_values(); |
376 | 376 | |
377 | - $this->entry['date_created'] = $date_created; |
|
377 | + $this->entry[ 'date_created' ] = $date_created; |
|
378 | 378 | |
379 | 379 | // Process calculation fields |
380 | 380 | $this->update_calculation_fields(); |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | * @param GravityView_Edit_Entry_Render $this This object |
397 | 397 | * @param GravityView_View_Data $gv_data The View data |
398 | 398 | */ |
399 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
399 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
400 | 400 | |
401 | 401 | } else { |
402 | 402 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -432,10 +432,10 @@ discard block |
||
432 | 432 | |
433 | 433 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
434 | 434 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
435 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
435 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
436 | 436 | } else { |
437 | 437 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
438 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
438 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -453,11 +453,11 @@ discard block |
||
453 | 453 | |
454 | 454 | $empty_value = $field->get_value_save_entry( |
455 | 455 | is_array( $field->get_entry_inputs() ) ? array() : '', |
456 | - $this->form, '', $this->entry['id'], $this->entry |
|
456 | + $this->form, '', $this->entry[ 'id' ], $this->entry |
|
457 | 457 | ); |
458 | 458 | |
459 | 459 | if ( $field->has_calculation() ) { |
460 | - $this->unset_hidden_calculations[] = $field->id; // Unset |
|
460 | + $this->unset_hidden_calculations[ ] = $field->id; // Unset |
|
461 | 461 | $empty_value = ''; |
462 | 462 | } |
463 | 463 | |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | } |
529 | 529 | |
530 | 530 | /** No file is being uploaded. */ |
531 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
531 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
532 | 532 | /** So return the original upload */ |
533 | 533 | return $entry[ $input_id ]; |
534 | 534 | } |
@@ -546,11 +546,11 @@ discard block |
||
546 | 546 | * @return mixed |
547 | 547 | */ |
548 | 548 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
549 | - if( ! $this->is_edit_entry() ) { |
|
549 | + if ( ! $this->is_edit_entry() ) { |
|
550 | 550 | return $plupload_init; |
551 | 551 | } |
552 | 552 | |
553 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
553 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
554 | 554 | |
555 | 555 | return $plupload_init; |
556 | 556 | } |
@@ -565,27 +565,27 @@ discard block |
||
565 | 565 | $form = $this->filter_conditional_logic( $this->form ); |
566 | 566 | |
567 | 567 | /** @var GF_Field $field */ |
568 | - foreach( $form['fields'] as $k => &$field ) { |
|
568 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
569 | 569 | |
570 | 570 | /** |
571 | 571 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
572 | 572 | * @since 1.16.3 |
573 | 573 | * @var GF_Field $field |
574 | 574 | */ |
575 | - if( $field->has_calculation() ) { |
|
576 | - unset( $form['fields'][ $k ] ); |
|
575 | + if ( $field->has_calculation() ) { |
|
576 | + unset( $form[ 'fields' ][ $k ] ); |
|
577 | 577 | } |
578 | 578 | |
579 | 579 | $field->adminOnly = false; |
580 | 580 | |
581 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
582 | - foreach( $field->inputs as $key => $input ) { |
|
583 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
581 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
582 | + foreach ( $field->inputs as $key => $input ) { |
|
583 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | } |
587 | 587 | |
588 | - $form['fields'] = array_values( $form['fields'] ); |
|
588 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
589 | 589 | |
590 | 590 | return $form; |
591 | 591 | } |
@@ -597,14 +597,14 @@ discard block |
||
597 | 597 | $update = false; |
598 | 598 | |
599 | 599 | // get the most up to date entry values |
600 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
600 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
601 | 601 | |
602 | 602 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
603 | 603 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
604 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
604 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
605 | 605 | } else { |
606 | 606 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
607 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) ); |
|
607 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) ); |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | |
@@ -621,24 +621,24 @@ discard block |
||
621 | 621 | $inputs = $field->get_entry_inputs(); |
622 | 622 | if ( is_array( $inputs ) ) { |
623 | 623 | foreach ( $inputs as $input ) { |
624 | - list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
|
624 | + list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 ); |
|
625 | 625 | |
626 | 626 | if ( 'product' === $field->type ) { |
627 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
627 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
628 | 628 | |
629 | 629 | // Only allow quantity to be set if it's allowed to be edited |
630 | 630 | if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) { |
631 | 631 | } else { // otherwise set to what it previously was |
632 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
632 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
633 | 633 | } |
634 | 634 | } else { |
635 | 635 | // Set to what it previously was if it's not editable |
636 | 636 | if ( ! in_array( $field_id, $allowed_fields ) ) { |
637 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
637 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
638 | 638 | } |
639 | 639 | } |
640 | 640 | |
641 | - GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
|
641 | + GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] ); |
|
642 | 642 | } |
643 | 643 | } else { |
644 | 644 | // Set to what it previously was if it's not editable |
@@ -678,19 +678,19 @@ discard block |
||
678 | 678 | |
679 | 679 | $input_name = 'input_' . $field_id; |
680 | 680 | |
681 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
681 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
682 | 682 | |
683 | 683 | // We have a new image |
684 | 684 | |
685 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
685 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
686 | 686 | |
687 | 687 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
688 | 688 | $ary = stripslashes_deep( $ary ); |
689 | 689 | $img_url = \GV\Utils::get( $ary, 0 ); |
690 | 690 | |
691 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
692 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
693 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
691 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
692 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
693 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
694 | 694 | |
695 | 695 | $image_meta = array( |
696 | 696 | 'post_excerpt' => $img_caption, |
@@ -699,7 +699,7 @@ discard block |
||
699 | 699 | |
700 | 700 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
701 | 701 | if ( ! empty( $img_title ) ) { |
702 | - $image_meta['post_title'] = $img_title; |
|
702 | + $image_meta[ 'post_title' ] = $img_title; |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | /** |
@@ -757,15 +757,15 @@ discard block |
||
757 | 757 | */ |
758 | 758 | private function maybe_update_post_fields( $form ) { |
759 | 759 | |
760 | - if( empty( $this->entry['post_id'] ) ) { |
|
760 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
761 | 761 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
762 | 762 | return; |
763 | 763 | } |
764 | 764 | |
765 | - $post_id = $this->entry['post_id']; |
|
765 | + $post_id = $this->entry[ 'post_id' ]; |
|
766 | 766 | |
767 | 767 | // Security check |
768 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
768 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
769 | 769 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
770 | 770 | return; |
771 | 771 | } |
@@ -778,25 +778,25 @@ discard block |
||
778 | 778 | |
779 | 779 | $field = RGFormsModel::get_field( $form, $field_id ); |
780 | 780 | |
781 | - if( ! $field ) { |
|
781 | + if ( ! $field ) { |
|
782 | 782 | continue; |
783 | 783 | } |
784 | 784 | |
785 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
785 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
786 | 786 | |
787 | 787 | // Get the value of the field, including $_POSTed value |
788 | 788 | $value = RGFormsModel::get_field_value( $field ); |
789 | 789 | |
790 | 790 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
791 | 791 | $entry_tmp = $this->entry; |
792 | - $entry_tmp["{$field_id}"] = $value; |
|
792 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
793 | 793 | |
794 | - switch( $field->type ) { |
|
794 | + switch ( $field->type ) { |
|
795 | 795 | |
796 | 796 | case 'post_title': |
797 | 797 | $post_title = $value; |
798 | 798 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
799 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
799 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
800 | 800 | } |
801 | 801 | $updated_post->post_title = $post_title; |
802 | 802 | $updated_post->post_name = $post_title; |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | case 'post_content': |
807 | 807 | $post_content = $value; |
808 | 808 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
809 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
809 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
810 | 810 | } |
811 | 811 | $updated_post->post_content = $post_content; |
812 | 812 | unset( $post_content ); |
@@ -824,11 +824,11 @@ discard block |
||
824 | 824 | $value = $value[ $field_id ]; |
825 | 825 | } |
826 | 826 | |
827 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
827 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
828 | 828 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
829 | 829 | } |
830 | 830 | |
831 | - $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
|
831 | + $value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry ); |
|
832 | 832 | |
833 | 833 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
834 | 834 | break; |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | } |
841 | 841 | |
842 | 842 | // update entry after |
843 | - $this->entry["{$field_id}"] = $value; |
|
843 | + $this->entry[ "{$field_id}" ] = $value; |
|
844 | 844 | |
845 | 845 | $update_entry = true; |
846 | 846 | |
@@ -849,11 +849,11 @@ discard block |
||
849 | 849 | |
850 | 850 | } |
851 | 851 | |
852 | - if( $update_entry ) { |
|
852 | + if ( $update_entry ) { |
|
853 | 853 | |
854 | 854 | $return_entry = GFAPI::update_entry( $this->entry ); |
855 | 855 | |
856 | - if( is_wp_error( $return_entry ) ) { |
|
856 | + if ( is_wp_error( $return_entry ) ) { |
|
857 | 857 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
858 | 858 | } else { |
859 | 859 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | |
864 | 864 | $return_post = wp_update_post( $updated_post, true ); |
865 | 865 | |
866 | - if( is_wp_error( $return_post ) ) { |
|
866 | + if ( is_wp_error( $return_post ) ) { |
|
867 | 867 | $return_post->add_data( $updated_post, '$updated_post' ); |
868 | 868 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
869 | 869 | } else { |
@@ -897,7 +897,7 @@ discard block |
||
897 | 897 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
898 | 898 | |
899 | 899 | // replace conditional shortcodes |
900 | - if( $do_shortcode ) { |
|
900 | + if ( $do_shortcode ) { |
|
901 | 901 | $output = do_shortcode( $output ); |
902 | 902 | } |
903 | 903 | |
@@ -916,19 +916,19 @@ discard block |
||
916 | 916 | */ |
917 | 917 | private function after_update() { |
918 | 918 | |
919 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
920 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
919 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
920 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
921 | 921 | |
922 | 922 | // Re-define the entry now that we've updated it. |
923 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
923 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
924 | 924 | |
925 | 925 | $entry = GFFormsModel::set_entry_meta( $entry, self::$original_form ); |
926 | 926 | |
927 | 927 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
928 | 928 | // We need to clear the cache because Gravity Forms caches the field values, which |
929 | 929 | // we have just updated. |
930 | - foreach ($this->form['fields'] as $key => $field) { |
|
931 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
930 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
931 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
932 | 932 | } |
933 | 933 | } |
934 | 934 | |
@@ -938,11 +938,11 @@ discard block |
||
938 | 938 | * @since develop |
939 | 939 | */ |
940 | 940 | if ( $allowed_feeds = $this->view->settings->get( 'edit_feeds', array() ) ) { |
941 | - $feeds = GFAPI::get_feeds( null, $entry['form_id'] ); |
|
941 | + $feeds = GFAPI::get_feeds( null, $entry[ 'form_id' ] ); |
|
942 | 942 | if ( ! is_wp_error( $feeds ) ) { |
943 | 943 | $registered_feeds = array(); |
944 | 944 | foreach ( GFAddOn::get_registered_addons() as $registered_feed ) { |
945 | - if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
945 | + if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
946 | 946 | if ( method_exists( $registered_feed, 'get_instance' ) ) { |
947 | 947 | $registered_feed = call_user_func( array( $registered_feed, 'get_instance' ) ); |
948 | 948 | $registered_feeds[ $registered_feed->get_slug() ] = $registered_feed; |
@@ -950,8 +950,8 @@ discard block |
||
950 | 950 | } |
951 | 951 | } |
952 | 952 | foreach ( $feeds as $feed ) { |
953 | - if ( in_array( $feed['id'], $allowed_feeds ) ) { |
|
954 | - if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed['addon_slug'] ) ) { |
|
953 | + if ( in_array( $feed[ 'id' ], $allowed_feeds ) ) { |
|
954 | + if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed[ 'addon_slug' ] ) ) { |
|
955 | 955 | $returned_entry = $feed_object->process_feed( $feed, $entry, self::$original_form ); |
956 | 956 | if ( is_array( $returned_entry ) && rgar( $returned_entry, 'id' ) ) { |
957 | 957 | $entry = $returned_entry; |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | |
982 | 982 | <div class="gv-edit-entry-wrapper"><?php |
983 | 983 | |
984 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
984 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
985 | 985 | |
986 | 986 | /** |
987 | 987 | * Fixes weird wpautop() issue |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | * @param string $edit_entry_title Modify the "Edit Entry" title |
998 | 998 | * @param GravityView_Edit_Entry_Render $this This object |
999 | 999 | */ |
1000 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
1000 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
1001 | 1001 | |
1002 | 1002 | echo esc_attr( $edit_entry_title ); |
1003 | 1003 | ?></span> |
@@ -1063,18 +1063,18 @@ discard block |
||
1063 | 1063 | */ |
1064 | 1064 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1065 | 1065 | |
1066 | - $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit']; |
|
1066 | + $this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels[ 'submit' ]; |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
1070 | 1070 | |
1071 | - if( ! $this->is_valid ){ |
|
1071 | + if ( ! $this->is_valid ) { |
|
1072 | 1072 | |
1073 | 1073 | // Keeping this compatible with Gravity Forms. |
1074 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
1075 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
1074 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
1075 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
1076 | 1076 | |
1077 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
1077 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
1078 | 1078 | |
1079 | 1079 | } elseif ( false === $this->is_paged_submitted ) { |
1080 | 1080 | // Paged form that hasn't been submitted on the last page yet |
@@ -1087,7 +1087,7 @@ discard block |
||
1087 | 1087 | * @param int $view_id View ID |
1088 | 1088 | * @param array $entry Gravity Forms entry array |
1089 | 1089 | */ |
1090 | - $message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message , $this->view_id, $this->entry ); |
|
1090 | + $message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message, $this->view_id, $this->entry ); |
|
1091 | 1091 | |
1092 | 1092 | echo GVCommon::generate_notice( $message ); |
1093 | 1093 | } else { |
@@ -1099,23 +1099,23 @@ discard block |
||
1099 | 1099 | |
1100 | 1100 | case '0': |
1101 | 1101 | $redirect_url = $back_link; |
1102 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1102 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' ); |
|
1103 | 1103 | break; |
1104 | 1104 | |
1105 | 1105 | case '1': |
1106 | 1106 | $redirect_url = $directory_link = GravityView_API::directory_link(); |
1107 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
1107 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' ); |
|
1108 | 1108 | break; |
1109 | 1109 | |
1110 | 1110 | case '2': |
1111 | 1111 | $redirect_url = $edit_redirect_url; |
1112 | 1112 | $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
1113 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
1113 | + $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' ); |
|
1114 | 1114 | break; |
1115 | 1115 | |
1116 | 1116 | case '': |
1117 | 1117 | default: |
1118 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1118 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
1119 | 1119 | break; |
1120 | 1120 | } |
1121 | 1121 | |
@@ -1131,7 +1131,7 @@ discard block |
||
1131 | 1131 | * @param array $entry Gravity Forms entry array |
1132 | 1132 | * @param string $back_link URL to return to the original entry. @since 1.6 |
1133 | 1133 | */ |
1134 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
1134 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
1135 | 1135 | |
1136 | 1136 | echo GVCommon::generate_notice( $message ); |
1137 | 1137 | } |
@@ -1155,8 +1155,8 @@ discard block |
||
1155 | 1155 | */ |
1156 | 1156 | do_action( 'gravityview/edit-entry/render/before', $this ); |
1157 | 1157 | |
1158 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
1159 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
1158 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
1159 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
1160 | 1160 | add_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
1161 | 1161 | add_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
1162 | 1162 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
@@ -1165,14 +1165,14 @@ discard block |
||
1165 | 1165 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
1166 | 1166 | |
1167 | 1167 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
1168 | - unset( $_GET['page'] ); |
|
1168 | + unset( $_GET[ 'page' ] ); |
|
1169 | 1169 | |
1170 | 1170 | $this->show_next_button = false; |
1171 | 1171 | $this->show_previous_button = false; |
1172 | 1172 | |
1173 | 1173 | // TODO: Verify multiple-page forms |
1174 | 1174 | if ( GFCommon::has_pages( $this->form ) && apply_filters( 'gravityview/features/paged-edit', false ) ) { |
1175 | - if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form['id'], 0 ) ) ) { |
|
1175 | + if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form[ 'id' ], 0 ) ) ) { |
|
1176 | 1176 | |
1177 | 1177 | $labels = array( |
1178 | 1178 | 'cancel' => __( 'Cancel', 'gravityview' ), |
@@ -1191,16 +1191,16 @@ discard block |
||
1191 | 1191 | */ |
1192 | 1192 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
1193 | 1193 | |
1194 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
|
1195 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'is_valid' ] = true; |
|
1194 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'form' ] = $this->form; |
|
1195 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'is_valid' ] = true; |
|
1196 | 1196 | |
1197 | - if ( \GV\Utils::_POST( 'save' ) === $labels['next'] ) { |
|
1197 | + if ( \GV\Utils::_POST( 'save' ) === $labels[ 'next' ] ) { |
|
1198 | 1198 | $page_number++; |
1199 | - } elseif ( \GV\Utils::_POST( 'save' ) === $labels['previous'] ) { |
|
1199 | + } elseif ( \GV\Utils::_POST( 'save' ) === $labels[ 'previous' ] ) { |
|
1200 | 1200 | $page_number--; |
1201 | 1201 | } |
1202 | 1202 | |
1203 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'page_number' ] = $page_number; |
|
1203 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'page_number' ] = $page_number; |
|
1204 | 1204 | } |
1205 | 1205 | |
1206 | 1206 | if ( ( $page_number = intval( $page_number ) ) < 2 ) { |
@@ -1226,7 +1226,7 @@ discard block |
||
1226 | 1226 | |
1227 | 1227 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
1228 | 1228 | |
1229 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
1229 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
1230 | 1230 | |
1231 | 1231 | ob_get_clean(); |
1232 | 1232 | |
@@ -1254,7 +1254,7 @@ discard block |
||
1254 | 1254 | * @return string |
1255 | 1255 | */ |
1256 | 1256 | public function render_form_buttons() { |
1257 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
1257 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
1258 | 1258 | } |
1259 | 1259 | |
1260 | 1260 | |
@@ -1273,15 +1273,15 @@ discard block |
||
1273 | 1273 | */ |
1274 | 1274 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
1275 | 1275 | |
1276 | - if( $form['id'] != $this->form_id ) { |
|
1276 | + if ( $form[ 'id' ] != $this->form_id ) { |
|
1277 | 1277 | return $form; |
1278 | 1278 | } |
1279 | 1279 | |
1280 | 1280 | // In case we have validated the form, use it to inject the validation results into the form render |
1281 | - if( isset( $this->form_after_validation ) && $this->form_after_validation['id'] === $form['id'] ) { |
|
1281 | + if ( isset( $this->form_after_validation ) && $this->form_after_validation[ 'id' ] === $form[ 'id' ] ) { |
|
1282 | 1282 | $form = $this->form_after_validation; |
1283 | 1283 | } else { |
1284 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1284 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
1285 | 1285 | } |
1286 | 1286 | |
1287 | 1287 | $form = $this->filter_conditional_logic( $form ); |
@@ -1289,8 +1289,8 @@ discard block |
||
1289 | 1289 | $form = $this->prefill_conditional_logic( $form ); |
1290 | 1290 | |
1291 | 1291 | // for now we don't support Save and Continue feature. |
1292 | - if( ! self::$supports_save_and_continue ) { |
|
1293 | - unset( $form['save'] ); |
|
1292 | + if ( ! self::$supports_save_and_continue ) { |
|
1293 | + unset( $form[ 'save' ] ); |
|
1294 | 1294 | } |
1295 | 1295 | |
1296 | 1296 | $form = $this->unselect_default_values( $form ); |
@@ -1313,31 +1313,31 @@ discard block |
||
1313 | 1313 | */ |
1314 | 1314 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
1315 | 1315 | |
1316 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
1316 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
1317 | 1317 | return $field_content; |
1318 | 1318 | } |
1319 | 1319 | |
1320 | 1320 | $message = null; |
1321 | 1321 | |
1322 | 1322 | // First, make sure they have the capability to edit the post. |
1323 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1323 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
1324 | 1324 | |
1325 | 1325 | /** |
1326 | 1326 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
1327 | 1327 | * @param string $message The existing "You don't have permission..." text |
1328 | 1328 | */ |
1329 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1329 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
1330 | 1330 | |
1331 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1331 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
1332 | 1332 | /** |
1333 | 1333 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
1334 | 1334 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
1335 | 1335 | */ |
1336 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1336 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1337 | 1337 | } |
1338 | 1338 | |
1339 | - if( $message ) { |
|
1340 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1339 | + if ( $message ) { |
|
1340 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1341 | 1341 | } |
1342 | 1342 | |
1343 | 1343 | return $field_content; |
@@ -1361,8 +1361,8 @@ discard block |
||
1361 | 1361 | |
1362 | 1362 | // If the form has been submitted, then we don't need to pre-fill the values, |
1363 | 1363 | // Except for fileupload type and when a field input is overridden- run always!! |
1364 | - if( |
|
1365 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1364 | + if ( |
|
1365 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
1366 | 1366 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
1367 | 1367 | && ! GFCommon::is_product_field( $field->type ) |
1368 | 1368 | || ! empty( $field_content ) |
@@ -1382,7 +1382,7 @@ discard block |
||
1382 | 1382 | $return = null; |
1383 | 1383 | |
1384 | 1384 | /** @var GravityView_Field $gv_field */ |
1385 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1385 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
1386 | 1386 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1387 | 1387 | } else { |
1388 | 1388 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1391,7 +1391,7 @@ discard block |
||
1391 | 1391 | // If there was output, it's an error |
1392 | 1392 | $warnings = ob_get_clean(); |
1393 | 1393 | |
1394 | - if( !empty( $warnings ) ) { |
|
1394 | + if ( ! empty( $warnings ) ) { |
|
1395 | 1395 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
1396 | 1396 | } |
1397 | 1397 | |
@@ -1416,7 +1416,7 @@ discard block |
||
1416 | 1416 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
1417 | 1417 | |
1418 | 1418 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
1419 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1419 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
1420 | 1420 | |
1421 | 1421 | $field_value = array(); |
1422 | 1422 | |
@@ -1425,10 +1425,10 @@ discard block |
||
1425 | 1425 | |
1426 | 1426 | foreach ( (array)$field->inputs as $input ) { |
1427 | 1427 | |
1428 | - $input_id = strval( $input['id'] ); |
|
1428 | + $input_id = strval( $input[ 'id' ] ); |
|
1429 | 1429 | |
1430 | 1430 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1431 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1431 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1432 | 1432 | $allow_pre_populated = false; |
1433 | 1433 | } |
1434 | 1434 | |
@@ -1436,7 +1436,7 @@ discard block |
||
1436 | 1436 | |
1437 | 1437 | $pre_value = $field->get_value_submission( array(), false ); |
1438 | 1438 | |
1439 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1439 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
1440 | 1440 | |
1441 | 1441 | } else { |
1442 | 1442 | |
@@ -1447,13 +1447,13 @@ discard block |
||
1447 | 1447 | |
1448 | 1448 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
1449 | 1449 | // or pre-populated value if not empty and set to override saved value |
1450 | - $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1450 | + $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
1451 | 1451 | |
1452 | 1452 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
1453 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
1453 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
1454 | 1454 | $categories = array(); |
1455 | 1455 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1456 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1456 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
1457 | 1457 | } |
1458 | 1458 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1459 | 1459 | } |
@@ -1481,7 +1481,7 @@ discard block |
||
1481 | 1481 | * @param GF_Field $field Gravity Forms field object |
1482 | 1482 | * @param GravityView_Edit_Entry_Render $this Current object |
1483 | 1483 | */ |
1484 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1484 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
1485 | 1485 | |
1486 | 1486 | return $field_value; |
1487 | 1487 | } |
@@ -1498,12 +1498,12 @@ discard block |
||
1498 | 1498 | */ |
1499 | 1499 | public function gform_pre_validation( $form ) { |
1500 | 1500 | |
1501 | - if( ! $this->verify_nonce() ) { |
|
1501 | + if ( ! $this->verify_nonce() ) { |
|
1502 | 1502 | return $form; |
1503 | 1503 | } |
1504 | 1504 | |
1505 | 1505 | // Fix PHP warning regarding undefined index. |
1506 | - foreach ( $form['fields'] as &$field) { |
|
1506 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1507 | 1507 | |
1508 | 1508 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1509 | 1509 | // expects certain field array items to be set. |
@@ -1511,7 +1511,7 @@ discard block |
||
1511 | 1511 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
1512 | 1512 | } |
1513 | 1513 | |
1514 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
1514 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
1515 | 1515 | |
1516 | 1516 | /** |
1517 | 1517 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -1525,26 +1525,26 @@ discard block |
||
1525 | 1525 | // Set the previous value |
1526 | 1526 | $entry = $this->get_entry(); |
1527 | 1527 | |
1528 | - $input_name = 'input_'.$field->id; |
|
1529 | - $form_id = $form['id']; |
|
1528 | + $input_name = 'input_' . $field->id; |
|
1529 | + $form_id = $form[ 'id' ]; |
|
1530 | 1530 | |
1531 | 1531 | $value = NULL; |
1532 | 1532 | |
1533 | 1533 | // Use the previous entry value as the default. |
1534 | - if( isset( $entry[ $field->id ] ) ) { |
|
1534 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1535 | 1535 | $value = $entry[ $field->id ]; |
1536 | 1536 | } |
1537 | 1537 | |
1538 | 1538 | // If this is a single upload file |
1539 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1540 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1541 | - $value = $file_path['url']; |
|
1539 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
1540 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
1541 | + $value = $file_path[ 'url' ]; |
|
1542 | 1542 | |
1543 | 1543 | } else { |
1544 | 1544 | |
1545 | 1545 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
1546 | 1546 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
1547 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1547 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
1548 | 1548 | |
1549 | 1549 | } |
1550 | 1550 | |
@@ -1552,10 +1552,10 @@ discard block |
||
1552 | 1552 | |
1553 | 1553 | // If there are fresh uploads, process and merge them. |
1554 | 1554 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
1555 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1555 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
1556 | 1556 | $value = empty( $value ) ? '[]' : $value; |
1557 | 1557 | $value = stripslashes_deep( $value ); |
1558 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1558 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
1559 | 1559 | } |
1560 | 1560 | |
1561 | 1561 | } else { |
@@ -1573,8 +1573,8 @@ discard block |
||
1573 | 1573 | |
1574 | 1574 | case 'number': |
1575 | 1575 | // Fix "undefined index" issue at line 1286 in form_display.php |
1576 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1577 | - $_POST['input_'.$field->id ] = NULL; |
|
1576 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
1577 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
1578 | 1578 | } |
1579 | 1579 | break; |
1580 | 1580 | } |
@@ -1611,7 +1611,7 @@ discard block |
||
1611 | 1611 | * You can enter whatever you want! |
1612 | 1612 | * We try validating, and customize the results using `self::custom_validation()` |
1613 | 1613 | */ |
1614 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
1614 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
1615 | 1615 | |
1616 | 1616 | // Needed by the validate funtion |
1617 | 1617 | $failed_validation_page = NULL; |
@@ -1619,14 +1619,14 @@ discard block |
||
1619 | 1619 | |
1620 | 1620 | // Prevent entry limit from running when editing an entry, also |
1621 | 1621 | // prevent form scheduling from preventing editing |
1622 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
1622 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
1623 | 1623 | |
1624 | 1624 | // Hide fields depending on Edit Entry settings |
1625 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1625 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
1626 | 1626 | |
1627 | 1627 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
1628 | 1628 | |
1629 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1629 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
1630 | 1630 | } |
1631 | 1631 | |
1632 | 1632 | |
@@ -1649,7 +1649,7 @@ discard block |
||
1649 | 1649 | |
1650 | 1650 | $gv_valid = true; |
1651 | 1651 | |
1652 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
1652 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
1653 | 1653 | |
1654 | 1654 | $value = RGFormsModel::get_field_value( $field ); |
1655 | 1655 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1662,22 +1662,22 @@ discard block |
||
1662 | 1662 | case 'post_image': |
1663 | 1663 | |
1664 | 1664 | // in case nothing is uploaded but there are already files saved |
1665 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1665 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
1666 | 1666 | $field->failed_validation = false; |
1667 | 1667 | unset( $field->validation_message ); |
1668 | 1668 | } |
1669 | 1669 | |
1670 | 1670 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
1671 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1671 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
1672 | 1672 | |
1673 | 1673 | $input_name = 'input_' . $field->id; |
1674 | 1674 | //uploaded |
1675 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1675 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
1676 | 1676 | |
1677 | 1677 | //existent |
1678 | 1678 | $entry = $this->get_entry(); |
1679 | 1679 | $value = NULL; |
1680 | - if( isset( $entry[ $field->id ] ) ) { |
|
1680 | + if ( isset( $entry[ $field->id ] ) ) { |
|
1681 | 1681 | $value = json_decode( $entry[ $field->id ], true ); |
1682 | 1682 | } |
1683 | 1683 | |
@@ -1685,13 +1685,13 @@ discard block |
||
1685 | 1685 | $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
1686 | 1686 | ( is_array( $value ) ? count( $value ) : 0 ); |
1687 | 1687 | |
1688 | - if( $count_files > $field->maxFiles ) { |
|
1688 | + if ( $count_files > $field->maxFiles ) { |
|
1689 | 1689 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
1690 | 1690 | $field->failed_validation = 1; |
1691 | 1691 | $gv_valid = false; |
1692 | 1692 | |
1693 | 1693 | // in case of error make sure the newest upload files are removed from the upload input |
1694 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1694 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
1695 | 1695 | } |
1696 | 1696 | |
1697 | 1697 | } |
@@ -1702,7 +1702,7 @@ discard block |
||
1702 | 1702 | } |
1703 | 1703 | |
1704 | 1704 | // This field has failed validation. |
1705 | - if( !empty( $field->failed_validation ) ) { |
|
1705 | + if ( ! empty( $field->failed_validation ) ) { |
|
1706 | 1706 | |
1707 | 1707 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
1708 | 1708 | |
@@ -1720,19 +1720,19 @@ discard block |
||
1720 | 1720 | } |
1721 | 1721 | |
1722 | 1722 | // You can't continue inside a switch, so we do it after. |
1723 | - if( empty( $field->failed_validation ) ) { |
|
1723 | + if ( empty( $field->failed_validation ) ) { |
|
1724 | 1724 | continue; |
1725 | 1725 | } |
1726 | 1726 | |
1727 | 1727 | // checks if the No Duplicates option is not validating entry against itself, since |
1728 | 1728 | // we're editing a stored entry, it would also assume it's a duplicate. |
1729 | - if( !empty( $field->noDuplicates ) ) { |
|
1729 | + if ( ! empty( $field->noDuplicates ) ) { |
|
1730 | 1730 | |
1731 | 1731 | $entry = $this->get_entry(); |
1732 | 1732 | |
1733 | 1733 | // If the value of the entry is the same as the stored value |
1734 | 1734 | // Then we can assume it's not a duplicate, it's the same. |
1735 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1735 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1736 | 1736 | //if value submitted was not changed, then don't validate |
1737 | 1737 | $field->failed_validation = false; |
1738 | 1738 | |
@@ -1745,7 +1745,7 @@ discard block |
||
1745 | 1745 | } |
1746 | 1746 | |
1747 | 1747 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1748 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1748 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
1749 | 1749 | unset( $field->validation_message ); |
1750 | 1750 | $field->validation_message = false; |
1751 | 1751 | continue; |
@@ -1757,12 +1757,12 @@ discard block |
||
1757 | 1757 | |
1758 | 1758 | } |
1759 | 1759 | |
1760 | - $validation_results['is_valid'] = $gv_valid; |
|
1760 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
1761 | 1761 | |
1762 | 1762 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
1763 | 1763 | |
1764 | 1764 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
1765 | - $this->form_after_validation = $validation_results['form']; |
|
1765 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
1766 | 1766 | |
1767 | 1767 | return $validation_results; |
1768 | 1768 | } |
@@ -1775,7 +1775,7 @@ discard block |
||
1775 | 1775 | */ |
1776 | 1776 | public function get_entry() { |
1777 | 1777 | |
1778 | - if( empty( $this->entry ) ) { |
|
1778 | + if ( empty( $this->entry ) ) { |
|
1779 | 1779 | // Get the database value of the entry that's being edited |
1780 | 1780 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
1781 | 1781 | } |
@@ -1807,10 +1807,10 @@ discard block |
||
1807 | 1807 | } |
1808 | 1808 | |
1809 | 1809 | // If edit tab not yet configured, show all fields |
1810 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
1810 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
1811 | 1811 | |
1812 | 1812 | // Hide fields depending on admin settings |
1813 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
1813 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
1814 | 1814 | |
1815 | 1815 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
1816 | 1816 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1843,7 +1843,7 @@ discard block |
||
1843 | 1843 | */ |
1844 | 1844 | private function filter_fields( $fields, $configured_fields ) { |
1845 | 1845 | |
1846 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
1846 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
1847 | 1847 | return $fields; |
1848 | 1848 | } |
1849 | 1849 | |
@@ -1860,12 +1860,12 @@ discard block |
||
1860 | 1860 | |
1861 | 1861 | // Remove the fields that have calculation properties and keep them to be used later |
1862 | 1862 | // @since 1.16.2 |
1863 | - if( $field->has_calculation() ) { |
|
1864 | - $this->fields_with_calculation[] = $field; |
|
1863 | + if ( $field->has_calculation() ) { |
|
1864 | + $this->fields_with_calculation[ ] = $field; |
|
1865 | 1865 | // don't remove the calculation fields on form render. |
1866 | 1866 | } |
1867 | 1867 | |
1868 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
1868 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
1869 | 1869 | unset( $fields[ $key ] ); |
1870 | 1870 | } |
1871 | 1871 | } |
@@ -1883,7 +1883,7 @@ discard block |
||
1883 | 1883 | continue; // Same |
1884 | 1884 | } |
1885 | 1885 | |
1886 | - $out_fields[] = $field; |
|
1886 | + $out_fields[ ] = $field; |
|
1887 | 1887 | } |
1888 | 1888 | |
1889 | 1889 | return array_values( $out_fields ); |
@@ -1894,8 +1894,8 @@ discard block |
||
1894 | 1894 | |
1895 | 1895 | /** @var GF_Field $field */ |
1896 | 1896 | foreach ( $fields as $field ) { |
1897 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1898 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1897 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
1898 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
1899 | 1899 | break; |
1900 | 1900 | } |
1901 | 1901 | |
@@ -1918,14 +1918,14 @@ discard block |
||
1918 | 1918 | |
1919 | 1919 | $return_field = $field; |
1920 | 1920 | |
1921 | - if( empty( $field_setting['show_label'] ) ) { |
|
1921 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
1922 | 1922 | $return_field->label = ''; |
1923 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
1924 | - $return_field->label = $field_setting['custom_label']; |
|
1923 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
1924 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
1925 | 1925 | } |
1926 | 1926 | |
1927 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
1928 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
1927 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
1928 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
1929 | 1929 | } |
1930 | 1930 | |
1931 | 1931 | /** |
@@ -1963,16 +1963,16 @@ discard block |
||
1963 | 1963 | */ |
1964 | 1964 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
1965 | 1965 | |
1966 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1967 | - foreach( $fields as $k => $field ) { |
|
1968 | - if( $field->adminOnly ) { |
|
1966 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
1967 | + foreach ( $fields as $k => $field ) { |
|
1968 | + if ( $field->adminOnly ) { |
|
1969 | 1969 | unset( $fields[ $k ] ); |
1970 | 1970 | } |
1971 | 1971 | } |
1972 | 1972 | return array_values( $fields ); |
1973 | 1973 | } |
1974 | 1974 | |
1975 | - foreach( $fields as &$field ) { |
|
1975 | + foreach ( $fields as &$field ) { |
|
1976 | 1976 | $field->adminOnly = false; |
1977 | 1977 | } |
1978 | 1978 | |
@@ -1993,7 +1993,7 @@ discard block |
||
1993 | 1993 | */ |
1994 | 1994 | private function unselect_default_values( $form ) { |
1995 | 1995 | |
1996 | - foreach ( $form['fields'] as &$field ) { |
|
1996 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
1997 | 1997 | |
1998 | 1998 | if ( empty( $field->choices ) ) { |
1999 | 1999 | continue; |
@@ -2001,7 +2001,7 @@ discard block |
||
2001 | 2001 | |
2002 | 2002 | foreach ( $field->choices as &$choice ) { |
2003 | 2003 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
2004 | - $choice['isSelected'] = false; |
|
2004 | + $choice[ 'isSelected' ] = false; |
|
2005 | 2005 | } |
2006 | 2006 | } |
2007 | 2007 | } |
@@ -2026,22 +2026,22 @@ discard block |
||
2026 | 2026 | */ |
2027 | 2027 | function prefill_conditional_logic( $form ) { |
2028 | 2028 | |
2029 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
2029 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
2030 | 2030 | return $form; |
2031 | 2031 | } |
2032 | 2032 | |
2033 | 2033 | // Have Conditional Logic pre-fill fields as if the data were default values |
2034 | 2034 | /** @var GF_Field $field */ |
2035 | - foreach ( $form['fields'] as &$field ) { |
|
2035 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2036 | 2036 | |
2037 | - if( 'checkbox' === $field->type ) { |
|
2037 | + if ( 'checkbox' === $field->type ) { |
|
2038 | 2038 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
2039 | - $input_id = $input['id']; |
|
2039 | + $input_id = $input[ 'id' ]; |
|
2040 | 2040 | $choice = $field->choices[ $key ]; |
2041 | 2041 | $value = \GV\Utils::get( $this->entry, $input_id ); |
2042 | 2042 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
2043 | - if( $match ) { |
|
2044 | - $field->choices[ $key ]['isSelected'] = true; |
|
2043 | + if ( $match ) { |
|
2044 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
2045 | 2045 | } |
2046 | 2046 | } |
2047 | 2047 | } else { |
@@ -2049,15 +2049,15 @@ discard block |
||
2049 | 2049 | // We need to run through each field to set the default values |
2050 | 2050 | foreach ( $this->entry as $field_id => $field_value ) { |
2051 | 2051 | |
2052 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2052 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
2053 | 2053 | |
2054 | - if( 'list' === $field->type ) { |
|
2054 | + if ( 'list' === $field->type ) { |
|
2055 | 2055 | $list_rows = maybe_unserialize( $field_value ); |
2056 | 2056 | |
2057 | 2057 | $list_field_value = array(); |
2058 | - foreach ( (array) $list_rows as $row ) { |
|
2059 | - foreach ( (array) $row as $column ) { |
|
2060 | - $list_field_value[] = $column; |
|
2058 | + foreach ( (array)$list_rows as $row ) { |
|
2059 | + foreach ( (array)$row as $column ) { |
|
2060 | + $list_field_value[ ] = $column; |
|
2061 | 2061 | } |
2062 | 2062 | } |
2063 | 2063 | |
@@ -2090,32 +2090,32 @@ discard block |
||
2090 | 2090 | * @see https://github.com/gravityview/GravityView/issues/840 |
2091 | 2091 | * @since develop |
2092 | 2092 | */ |
2093 | - $the_form = GFAPI::get_form( $form['id'] ); |
|
2093 | + $the_form = GFAPI::get_form( $form[ 'id' ] ); |
|
2094 | 2094 | $editable_ids = array(); |
2095 | - foreach ( $form['fields'] as $field ) { |
|
2096 | - $editable_ids[] = $field['id']; // wp_list_pluck is destructive in this context |
|
2095 | + foreach ( $form[ 'fields' ] as $field ) { |
|
2096 | + $editable_ids[ ] = $field[ 'id' ]; // wp_list_pluck is destructive in this context |
|
2097 | 2097 | } |
2098 | 2098 | $remove_conditions_rule = array(); |
2099 | - foreach ( $the_form['fields'] as $field ) { |
|
2100 | - if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic['rules'] ) ) { |
|
2101 | - foreach ( $field->conditionalLogic['rules'] as $i => $rule ) { |
|
2102 | - if ( ! in_array( $rule['fieldId'], $editable_ids ) ) { |
|
2099 | + foreach ( $the_form[ 'fields' ] as $field ) { |
|
2100 | + if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic[ 'rules' ] ) ) { |
|
2101 | + foreach ( $field->conditionalLogic[ 'rules' ] as $i => $rule ) { |
|
2102 | + if ( ! in_array( $rule[ 'fieldId' ], $editable_ids ) ) { |
|
2103 | 2103 | /** |
2104 | 2104 | * This conditional field is not editable in this View. |
2105 | 2105 | * We need to remove the rule, but only if it matches. |
2106 | 2106 | */ |
2107 | - if ( $_field = GFAPI::get_field( $the_form, $rule['fieldId'] ) ) { |
|
2107 | + if ( $_field = GFAPI::get_field( $the_form, $rule[ 'fieldId' ] ) ) { |
|
2108 | 2108 | $value = $_field->get_value_export( $this->entry ); |
2109 | - } elseif ( isset( $this->entry[ $rule['fieldId'] ] ) ) { |
|
2110 | - $value = $this->entry[ $rule['fieldId'] ]; |
|
2109 | + } elseif ( isset( $this->entry[ $rule[ 'fieldId' ] ] ) ) { |
|
2110 | + $value = $this->entry[ $rule[ 'fieldId' ] ]; |
|
2111 | 2111 | } else { |
2112 | - $value = gform_get_meta( $this->entry['id'], $rule['fieldId'] ); |
|
2112 | + $value = gform_get_meta( $this->entry[ 'id' ], $rule[ 'fieldId' ] ); |
|
2113 | 2113 | } |
2114 | 2114 | |
2115 | - $match = GFFormsModel::matches_operation( $value, $rule['value'], $rule['operator'] ); |
|
2115 | + $match = GFFormsModel::matches_operation( $value, $rule[ 'value' ], $rule[ 'operator' ] ); |
|
2116 | 2116 | |
2117 | 2117 | if ( $match ) { |
2118 | - $remove_conditions_rule[] = array( $field['id'], $i ); |
|
2118 | + $remove_conditions_rule[ ] = array( $field[ 'id' ], $i ); |
|
2119 | 2119 | } |
2120 | 2120 | } |
2121 | 2121 | } |
@@ -2123,21 +2123,21 @@ discard block |
||
2123 | 2123 | } |
2124 | 2124 | |
2125 | 2125 | if ( $remove_conditions_rule ) { |
2126 | - foreach ( $form['fields'] as &$field ) { |
|
2126 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2127 | 2127 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
2128 | 2128 | |
2129 | 2129 | list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
2130 | 2130 | |
2131 | - if ( $field['id'] == $rule_field_id ) { |
|
2132 | - unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
|
2133 | - gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field['id'] ) ); |
|
2131 | + if ( $field[ 'id' ] == $rule_field_id ) { |
|
2132 | + unset( $field->conditionalLogic[ 'rules' ][ $rule_i ] ); |
|
2133 | + gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field[ 'id' ] ) ); |
|
2134 | 2134 | } |
2135 | 2135 | } |
2136 | 2136 | } |
2137 | 2137 | } |
2138 | 2138 | |
2139 | 2139 | /** Normalize the indices... */ |
2140 | - $form['fields'] = array_values( $form['fields'] ); |
|
2140 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
2141 | 2141 | |
2142 | 2142 | /** |
2143 | 2143 | * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields? |
@@ -2147,16 +2147,16 @@ discard block |
||
2147 | 2147 | */ |
2148 | 2148 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
2149 | 2149 | |
2150 | - if( $use_conditional_logic ) { |
|
2150 | + if ( $use_conditional_logic ) { |
|
2151 | 2151 | return $form; |
2152 | 2152 | } |
2153 | 2153 | |
2154 | - foreach( $form['fields'] as &$field ) { |
|
2154 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
2155 | 2155 | /* @var GF_Field $field */ |
2156 | 2156 | $field->conditionalLogic = null; |
2157 | 2157 | } |
2158 | 2158 | |
2159 | - unset( $form['button']['conditionalLogic'] ); |
|
2159 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
2160 | 2160 | |
2161 | 2161 | return $form; |
2162 | 2162 | |
@@ -2173,7 +2173,7 @@ discard block |
||
2173 | 2173 | */ |
2174 | 2174 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
2175 | 2175 | |
2176 | - if( ! $this->is_edit_entry() ) { |
|
2176 | + if ( ! $this->is_edit_entry() ) { |
|
2177 | 2177 | return $has_conditional_logic; |
2178 | 2178 | } |
2179 | 2179 | |
@@ -2205,44 +2205,44 @@ discard block |
||
2205 | 2205 | * 2. There are two entries embedded using oEmbed |
2206 | 2206 | * 3. One of the entries has just been saved |
2207 | 2207 | */ |
2208 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
2208 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
2209 | 2209 | |
2210 | 2210 | $error = true; |
2211 | 2211 | |
2212 | 2212 | } |
2213 | 2213 | |
2214 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
2214 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
2215 | 2215 | |
2216 | 2216 | $error = true; |
2217 | 2217 | |
2218 | - } elseif( ! $this->verify_nonce() ) { |
|
2218 | + } elseif ( ! $this->verify_nonce() ) { |
|
2219 | 2219 | |
2220 | 2220 | /** |
2221 | 2221 | * If the Entry is embedded, there may be two entries on the same page. |
2222 | 2222 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
2223 | 2223 | */ |
2224 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
2224 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
2225 | 2225 | $error = true; |
2226 | 2226 | } else { |
2227 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
2227 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
2228 | 2228 | } |
2229 | 2229 | |
2230 | 2230 | } |
2231 | 2231 | |
2232 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
2233 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
2232 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
2233 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
2234 | 2234 | } |
2235 | 2235 | |
2236 | - if( $this->entry['status'] === 'trash' ) { |
|
2237 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
2236 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
2237 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
2238 | 2238 | } |
2239 | 2239 | |
2240 | 2240 | // No errors; everything's fine here! |
2241 | - if( empty( $error ) ) { |
|
2241 | + if ( empty( $error ) ) { |
|
2242 | 2242 | return true; |
2243 | 2243 | } |
2244 | 2244 | |
2245 | - if( $echo && $error !== true ) { |
|
2245 | + if ( $echo && $error !== true ) { |
|
2246 | 2246 | |
2247 | 2247 | $error = esc_html( $error ); |
2248 | 2248 | |
@@ -2250,10 +2250,10 @@ discard block |
||
2250 | 2250 | * @since 1.9 |
2251 | 2251 | */ |
2252 | 2252 | if ( ! empty( $this->entry ) ) { |
2253 | - $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
2253 | + $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) ); |
|
2254 | 2254 | } |
2255 | 2255 | |
2256 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
2256 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
2257 | 2257 | } |
2258 | 2258 | |
2259 | 2259 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2273,17 +2273,17 @@ discard block |
||
2273 | 2273 | |
2274 | 2274 | $error = NULL; |
2275 | 2275 | |
2276 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2277 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
2276 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
2277 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
2278 | 2278 | } |
2279 | 2279 | |
2280 | 2280 | // No errors; everything's fine here! |
2281 | - if( empty( $error ) ) { |
|
2281 | + if ( empty( $error ) ) { |
|
2282 | 2282 | return true; |
2283 | 2283 | } |
2284 | 2284 | |
2285 | - if( $echo ) { |
|
2286 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
2285 | + if ( $echo ) { |
|
2286 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
2287 | 2287 | } |
2288 | 2288 | |
2289 | 2289 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2304,14 +2304,14 @@ discard block |
||
2304 | 2304 | private function check_user_cap_edit_field( $field ) { |
2305 | 2305 | |
2306 | 2306 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
2307 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2307 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
2308 | 2308 | return true; |
2309 | 2309 | } |
2310 | 2310 | |
2311 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
2311 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
2312 | 2312 | |
2313 | - if( $field_cap ) { |
|
2314 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
2313 | + if ( $field_cap ) { |
|
2314 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
2315 | 2315 | } |
2316 | 2316 | |
2317 | 2317 | return false; |
@@ -2325,17 +2325,17 @@ discard block |
||
2325 | 2325 | public function verify_nonce() { |
2326 | 2326 | |
2327 | 2327 | // Verify form submitted for editing single |
2328 | - if( $this->is_edit_entry_submission() ) { |
|
2328 | + if ( $this->is_edit_entry_submission() ) { |
|
2329 | 2329 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
2330 | 2330 | } |
2331 | 2331 | |
2332 | 2332 | // Verify |
2333 | - else if( ! $this->is_edit_entry() ) { |
|
2333 | + else if ( ! $this->is_edit_entry() ) { |
|
2334 | 2334 | $valid = false; |
2335 | 2335 | } |
2336 | 2336 | |
2337 | 2337 | else { |
2338 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
2338 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
2339 | 2339 | } |
2340 | 2340 | |
2341 | 2341 | /** |