@@ -94,10 +94,10 @@ discard block |
||
94 | 94 | |
95 | 95 | /** |
96 | 96 | * ID of the current post. May also be ID of the current View. |
97 | - * |
|
98 | - * @since 2.0.13 |
|
99 | - * |
|
100 | - * @var int |
|
97 | + * |
|
98 | + * @since 2.0.13 |
|
99 | + * |
|
100 | + * @var int |
|
101 | 101 | */ |
102 | 102 | public $post_id; |
103 | 103 | |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | public function prevent_maybe_process_form() { |
170 | 170 | |
171 | 171 | if( ! empty( $_POST ) ) { |
172 | - gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
172 | + gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | if( $this->is_edit_entry_submission() ) { |
176 | 176 | remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -202,14 +202,14 @@ discard block |
||
202 | 202 | * When Edit entry view is requested setup the vars |
203 | 203 | */ |
204 | 204 | private function setup_vars() { |
205 | - global $post; |
|
205 | + global $post; |
|
206 | 206 | |
207 | 207 | $gravityview_view = GravityView_View::getInstance(); |
208 | 208 | |
209 | 209 | |
210 | 210 | $entries = $gravityview_view->getEntries(); |
211 | - self::$original_entry = $entries[0]; |
|
212 | - $this->entry = $entries[0]; |
|
211 | + self::$original_entry = $entries[0]; |
|
212 | + $this->entry = $entries[0]; |
|
213 | 213 | |
214 | 214 | self::$original_form = $gravityview_view->getForm(); |
215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -333,8 +333,8 @@ discard block |
||
333 | 333 | |
334 | 334 | GFFormsModel::save_lead( $form, $this->entry ); |
335 | 335 | |
336 | - // Delete the values for hidden inputs |
|
337 | - $this->unset_hidden_field_values(); |
|
336 | + // Delete the values for hidden inputs |
|
337 | + $this->unset_hidden_field_values(); |
|
338 | 338 | |
339 | 339 | $this->entry['date_created'] = $date_created; |
340 | 340 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | // Perform actions normally performed after updating a lead |
345 | 345 | $this->after_update(); |
346 | 346 | |
347 | - /** |
|
347 | + /** |
|
348 | 348 | * Must be AFTER after_update()! |
349 | 349 | * @see https://github.com/gravityview/GravityView/issues/764 |
350 | 350 | */ |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | |
353 | 353 | /** |
354 | 354 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
355 | - * @since 2.1 Added $gv_data parameter |
|
355 | + * @since 2.1 Added $gv_data parameter |
|
356 | 356 | * @param array $form Gravity Forms form array |
357 | 357 | * @param string $entry_id Numeric ID of the entry that was updated |
358 | 358 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | * @return void |
377 | 377 | */ |
378 | 378 | private function unset_hidden_field_values() { |
379 | - global $wpdb; |
|
379 | + global $wpdb; |
|
380 | 380 | |
381 | 381 | /** |
382 | 382 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -398,29 +398,29 @@ discard block |
||
398 | 398 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
399 | 399 | } |
400 | 400 | |
401 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
401 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
402 | 402 | |
403 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
403 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
404 | 404 | |
405 | - // Reset fields that are hidden |
|
406 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
407 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
405 | + // Reset fields that are hidden |
|
406 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
407 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
408 | 408 | |
409 | 409 | $empty_value = $field->get_value_save_entry( |
410 | 410 | is_array( $field->get_entry_inputs() ) ? array() : '', |
411 | 411 | $this->form, '', $this->entry['id'], $this->entry |
412 | 412 | ); |
413 | 413 | |
414 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
414 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
415 | 415 | |
416 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
416 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
417 | 417 | |
418 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
418 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
419 | 419 | // after submission |
420 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
421 | - $_POST[ $post_input_id ] = ''; |
|
422 | - } |
|
423 | - } |
|
420 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
421 | + $_POST[ $post_input_id ] = ''; |
|
422 | + } |
|
423 | + } |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | /** |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | |
515 | 515 | $form = $this->form; |
516 | 516 | |
517 | - /** @var GF_Field $field */ |
|
517 | + /** @var GF_Field $field */ |
|
518 | 518 | foreach( $form['fields'] as $k => &$field ) { |
519 | 519 | |
520 | 520 | /** |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | |
531 | 531 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
532 | 532 | foreach( $field->inputs as $key => $input ) { |
533 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
533 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
534 | 534 | } |
535 | 535 | } |
536 | 536 | } |
@@ -563,9 +563,9 @@ discard block |
||
563 | 563 | foreach ( $this->fields_with_calculation as $field ) { |
564 | 564 | $inputs = $field->get_entry_inputs(); |
565 | 565 | if ( is_array( $inputs ) ) { |
566 | - foreach ( $inputs as $input ) { |
|
566 | + foreach ( $inputs as $input ) { |
|
567 | 567 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
568 | - } |
|
568 | + } |
|
569 | 569 | } else { |
570 | 570 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $field->id ); |
571 | 571 | } |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
608 | 608 | |
609 | 609 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
610 | - $ary = stripslashes_deep( $ary ); |
|
610 | + $ary = stripslashes_deep( $ary ); |
|
611 | 611 | $img_url = \GV\Utils::get( $ary, 0 ); |
612 | 612 | |
613 | 613 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | private function maybe_update_post_fields( $form ) { |
681 | 681 | |
682 | 682 | if( empty( $this->entry['post_id'] ) ) { |
683 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
683 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
684 | 684 | return; |
685 | 685 | } |
686 | 686 | |
@@ -715,49 +715,49 @@ discard block |
||
715 | 715 | |
716 | 716 | switch( $field->type ) { |
717 | 717 | |
718 | - case 'post_title': |
|
719 | - $post_title = $value; |
|
720 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
721 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
722 | - } |
|
723 | - $updated_post->post_title = $post_title; |
|
724 | - $updated_post->post_name = $post_title; |
|
725 | - unset( $post_title ); |
|
726 | - break; |
|
727 | - |
|
728 | - case 'post_content': |
|
729 | - $post_content = $value; |
|
730 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
731 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
732 | - } |
|
733 | - $updated_post->post_content = $post_content; |
|
734 | - unset( $post_content ); |
|
735 | - break; |
|
736 | - case 'post_excerpt': |
|
737 | - $updated_post->post_excerpt = $value; |
|
738 | - break; |
|
739 | - case 'post_tags': |
|
740 | - wp_set_post_tags( $post_id, $value, false ); |
|
741 | - break; |
|
742 | - case 'post_category': |
|
743 | - break; |
|
744 | - case 'post_custom_field': |
|
718 | + case 'post_title': |
|
719 | + $post_title = $value; |
|
720 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
721 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
722 | + } |
|
723 | + $updated_post->post_title = $post_title; |
|
724 | + $updated_post->post_name = $post_title; |
|
725 | + unset( $post_title ); |
|
726 | + break; |
|
727 | + |
|
728 | + case 'post_content': |
|
729 | + $post_content = $value; |
|
730 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
731 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
732 | + } |
|
733 | + $updated_post->post_content = $post_content; |
|
734 | + unset( $post_content ); |
|
735 | + break; |
|
736 | + case 'post_excerpt': |
|
737 | + $updated_post->post_excerpt = $value; |
|
738 | + break; |
|
739 | + case 'post_tags': |
|
740 | + wp_set_post_tags( $post_id, $value, false ); |
|
741 | + break; |
|
742 | + case 'post_category': |
|
743 | + break; |
|
744 | + case 'post_custom_field': |
|
745 | 745 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
746 | 746 | $value = $value[ $field_id ]; |
747 | 747 | } |
748 | 748 | |
749 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
750 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
751 | - } |
|
749 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
750 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
751 | + } |
|
752 | 752 | |
753 | 753 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
754 | 754 | |
755 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
756 | - break; |
|
755 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
756 | + break; |
|
757 | 757 | |
758 | - case 'post_image': |
|
759 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
760 | - break; |
|
758 | + case 'post_image': |
|
759 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
760 | + break; |
|
761 | 761 | |
762 | 762 | } |
763 | 763 | |
@@ -880,14 +880,14 @@ discard block |
||
880 | 880 | ?><h2 class="gv-edit-entry-title"> |
881 | 881 | <span><?php |
882 | 882 | |
883 | - /** |
|
884 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
885 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
886 | - * @param GravityView_Edit_Entry_Render $this This object |
|
887 | - */ |
|
888 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
883 | + /** |
|
884 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
885 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
886 | + * @param GravityView_Edit_Entry_Render $this This object |
|
887 | + */ |
|
888 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
889 | 889 | |
890 | - echo esc_attr( $edit_entry_title ); |
|
890 | + echo esc_attr( $edit_entry_title ); |
|
891 | 891 | ?></span> |
892 | 892 | </h2> |
893 | 893 | |
@@ -950,26 +950,26 @@ discard block |
||
950 | 950 | |
951 | 951 | switch ( $edit_redirect ) { |
952 | 952 | |
953 | - case '0': |
|
954 | - $redirect_url = $back_link; |
|
955 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
956 | - break; |
|
957 | - |
|
958 | - case '1': |
|
959 | - $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
960 | - $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>' ); |
|
961 | - break; |
|
962 | - |
|
963 | - case '2': |
|
964 | - $redirect_url = $edit_redirect_url; |
|
965 | - $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
966 | - $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>' ); |
|
967 | - break; |
|
968 | - |
|
969 | - case '': |
|
970 | - default: |
|
971 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
972 | - break; |
|
953 | + case '0': |
|
954 | + $redirect_url = $back_link; |
|
955 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
956 | + break; |
|
957 | + |
|
958 | + case '1': |
|
959 | + $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
960 | + $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>' ); |
|
961 | + break; |
|
962 | + |
|
963 | + case '2': |
|
964 | + $redirect_url = $edit_redirect_url; |
|
965 | + $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
966 | + $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>' ); |
|
967 | + break; |
|
968 | + |
|
969 | + case '': |
|
970 | + default: |
|
971 | + $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
972 | + break; |
|
973 | 973 | } |
974 | 974 | |
975 | 975 | if ( isset( $redirect_url ) ) { |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | |
1027 | 1027 | ob_get_clean(); |
1028 | 1028 | |
1029 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1029 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1030 | 1030 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
1031 | 1031 | remove_filter( 'gform_disable_view_counter', '__return_true' ); |
1032 | 1032 | remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 ); |
@@ -1080,7 +1080,7 @@ discard block |
||
1080 | 1080 | |
1081 | 1081 | // for now we don't support Save and Continue feature. |
1082 | 1082 | if( ! self::$supports_save_and_continue ) { |
1083 | - unset( $form['save'] ); |
|
1083 | + unset( $form['save'] ); |
|
1084 | 1084 | } |
1085 | 1085 | |
1086 | 1086 | $form = $this->unselect_default_values( $form ); |
@@ -1107,30 +1107,30 @@ discard block |
||
1107 | 1107 | return $field_content; |
1108 | 1108 | } |
1109 | 1109 | |
1110 | - $message = null; |
|
1110 | + $message = null; |
|
1111 | 1111 | |
1112 | - // First, make sure they have the capability to edit the post. |
|
1113 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1112 | + // First, make sure they have the capability to edit the post. |
|
1113 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1114 | 1114 | |
1115 | - /** |
|
1116 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1117 | - * @param string $message The existing "You don't have permission..." text |
|
1118 | - */ |
|
1119 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1115 | + /** |
|
1116 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1117 | + * @param string $message The existing "You don't have permission..." text |
|
1118 | + */ |
|
1119 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1120 | 1120 | |
1121 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1122 | - /** |
|
1123 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1124 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1125 | - */ |
|
1126 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1127 | - } |
|
1121 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1122 | + /** |
|
1123 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1124 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1125 | + */ |
|
1126 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1127 | + } |
|
1128 | 1128 | |
1129 | - if( $message ) { |
|
1130 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1131 | - } |
|
1129 | + if( $message ) { |
|
1130 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1131 | + } |
|
1132 | 1132 | |
1133 | - return $field_content; |
|
1133 | + return $field_content; |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | /** |
@@ -1158,7 +1158,7 @@ discard block |
||
1158 | 1158 | || ! empty( $field_content ) |
1159 | 1159 | || in_array( $field->type, array( 'honeypot' ) ) |
1160 | 1160 | ) { |
1161 | - return $field_content; |
|
1161 | + return $field_content; |
|
1162 | 1162 | } |
1163 | 1163 | |
1164 | 1164 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1166,24 +1166,24 @@ discard block |
||
1166 | 1166 | |
1167 | 1167 | $field_value = $this->get_field_value( $field ); |
1168 | 1168 | |
1169 | - // Prevent any PHP warnings, like undefined index |
|
1170 | - ob_start(); |
|
1169 | + // Prevent any PHP warnings, like undefined index |
|
1170 | + ob_start(); |
|
1171 | 1171 | |
1172 | - $return = null; |
|
1172 | + $return = null; |
|
1173 | 1173 | |
1174 | 1174 | /** @var GravityView_Field $gv_field */ |
1175 | 1175 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
1176 | 1176 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1177 | 1177 | } else { |
1178 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1179 | - } |
|
1178 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1179 | + } |
|
1180 | 1180 | |
1181 | - // If there was output, it's an error |
|
1182 | - $warnings = ob_get_clean(); |
|
1181 | + // If there was output, it's an error |
|
1182 | + $warnings = ob_get_clean(); |
|
1183 | 1183 | |
1184 | - if( !empty( $warnings ) ) { |
|
1185 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1186 | - } |
|
1184 | + if( !empty( $warnings ) ) { |
|
1185 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1186 | + } |
|
1187 | 1187 | |
1188 | 1188 | return $return; |
1189 | 1189 | } |
@@ -1218,8 +1218,8 @@ discard block |
||
1218 | 1218 | $input_id = strval( $input['id'] ); |
1219 | 1219 | |
1220 | 1220 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1221 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1222 | - $allow_pre_populated = false; |
|
1221 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1222 | + $allow_pre_populated = false; |
|
1223 | 1223 | } |
1224 | 1224 | |
1225 | 1225 | } |
@@ -1243,7 +1243,7 @@ discard block |
||
1243 | 1243 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
1244 | 1244 | $categories = array(); |
1245 | 1245 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1246 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1246 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1247 | 1247 | } |
1248 | 1248 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1249 | 1249 | } |
@@ -1253,25 +1253,25 @@ discard block |
||
1253 | 1253 | // if value is empty get the default value if defined |
1254 | 1254 | $field_value = $field->get_value_default_if_empty( $field_value ); |
1255 | 1255 | |
1256 | - /** |
|
1257 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1258 | - * @since 1.11 |
|
1259 | - * @since 1.20 Added third param |
|
1260 | - * @param mixed $field_value field value used to populate the input |
|
1261 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1262 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1263 | - */ |
|
1264 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1265 | - |
|
1266 | - /** |
|
1267 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1268 | - * @since 1.17 |
|
1269 | - * @since 1.20 Added third param |
|
1270 | - * @param mixed $field_value field value used to populate the input |
|
1271 | - * @param GF_Field $field Gravity Forms field object |
|
1272 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1273 | - */ |
|
1274 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1256 | + /** |
|
1257 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1258 | + * @since 1.11 |
|
1259 | + * @since 1.20 Added third param |
|
1260 | + * @param mixed $field_value field value used to populate the input |
|
1261 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1262 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1263 | + */ |
|
1264 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1265 | + |
|
1266 | + /** |
|
1267 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1268 | + * @since 1.17 |
|
1269 | + * @since 1.20 Added third param |
|
1270 | + * @param mixed $field_value field value used to populate the input |
|
1271 | + * @param GF_Field $field Gravity Forms field object |
|
1272 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1273 | + */ |
|
1274 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1275 | 1275 | |
1276 | 1276 | return $field_value; |
1277 | 1277 | } |
@@ -1298,7 +1298,7 @@ discard block |
||
1298 | 1298 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1299 | 1299 | // expects certain field array items to be set. |
1300 | 1300 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
1301 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1301 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1302 | 1302 | } |
1303 | 1303 | |
1304 | 1304 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1312,61 +1312,61 @@ discard block |
||
1312 | 1312 | */ |
1313 | 1313 | case 'fileupload': |
1314 | 1314 | |
1315 | - // Set the previous value |
|
1316 | - $entry = $this->get_entry(); |
|
1315 | + // Set the previous value |
|
1316 | + $entry = $this->get_entry(); |
|
1317 | 1317 | |
1318 | - $input_name = 'input_'.$field->id; |
|
1319 | - $form_id = $form['id']; |
|
1318 | + $input_name = 'input_'.$field->id; |
|
1319 | + $form_id = $form['id']; |
|
1320 | 1320 | |
1321 | - $value = NULL; |
|
1321 | + $value = NULL; |
|
1322 | 1322 | |
1323 | - // Use the previous entry value as the default. |
|
1324 | - if( isset( $entry[ $field->id ] ) ) { |
|
1325 | - $value = $entry[ $field->id ]; |
|
1326 | - } |
|
1323 | + // Use the previous entry value as the default. |
|
1324 | + if( isset( $entry[ $field->id ] ) ) { |
|
1325 | + $value = $entry[ $field->id ]; |
|
1326 | + } |
|
1327 | 1327 | |
1328 | - // If this is a single upload file |
|
1329 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1330 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1331 | - $value = $file_path['url']; |
|
1328 | + // If this is a single upload file |
|
1329 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1330 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1331 | + $value = $file_path['url']; |
|
1332 | 1332 | |
1333 | - } else { |
|
1333 | + } else { |
|
1334 | 1334 | |
1335 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1336 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1337 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1335 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1336 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1337 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1338 | 1338 | |
1339 | - } |
|
1339 | + } |
|
1340 | 1340 | |
1341 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1341 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1342 | 1342 | |
1343 | - // If there are fresh uploads, process and merge them. |
|
1344 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1345 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1346 | - $value = empty( $value ) ? '[]' : $value; |
|
1347 | - $value = stripslashes_deep( $value ); |
|
1348 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1349 | - } |
|
1343 | + // If there are fresh uploads, process and merge them. |
|
1344 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1345 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1346 | + $value = empty( $value ) ? '[]' : $value; |
|
1347 | + $value = stripslashes_deep( $value ); |
|
1348 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1349 | + } |
|
1350 | 1350 | |
1351 | - } else { |
|
1351 | + } else { |
|
1352 | 1352 | |
1353 | - // A file already exists when editing an entry |
|
1354 | - // We set this to solve issue when file upload fields are required. |
|
1355 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1353 | + // A file already exists when editing an entry |
|
1354 | + // We set this to solve issue when file upload fields are required. |
|
1355 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1356 | 1356 | |
1357 | - } |
|
1357 | + } |
|
1358 | 1358 | |
1359 | - $this->entry[ $input_name ] = $value; |
|
1360 | - $_POST[ $input_name ] = $value; |
|
1359 | + $this->entry[ $input_name ] = $value; |
|
1360 | + $_POST[ $input_name ] = $value; |
|
1361 | 1361 | |
1362 | - break; |
|
1362 | + break; |
|
1363 | 1363 | |
1364 | 1364 | case 'number': |
1365 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
1366 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1367 | - $_POST['input_'.$field->id ] = NULL; |
|
1368 | - } |
|
1369 | - break; |
|
1365 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
1366 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1367 | + $_POST['input_'.$field->id ] = NULL; |
|
1368 | + } |
|
1369 | + break; |
|
1370 | 1370 | } |
1371 | 1371 | |
1372 | 1372 | } |
@@ -1451,42 +1451,42 @@ discard block |
||
1451 | 1451 | case 'fileupload' : |
1452 | 1452 | case 'post_image': |
1453 | 1453 | |
1454 | - // in case nothing is uploaded but there are already files saved |
|
1455 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1456 | - $field->failed_validation = false; |
|
1457 | - unset( $field->validation_message ); |
|
1458 | - } |
|
1454 | + // in case nothing is uploaded but there are already files saved |
|
1455 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1456 | + $field->failed_validation = false; |
|
1457 | + unset( $field->validation_message ); |
|
1458 | + } |
|
1459 | 1459 | |
1460 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1461 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1460 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1461 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1462 | 1462 | |
1463 | - $input_name = 'input_' . $field->id; |
|
1464 | - //uploaded |
|
1465 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1463 | + $input_name = 'input_' . $field->id; |
|
1464 | + //uploaded |
|
1465 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1466 | 1466 | |
1467 | - //existent |
|
1468 | - $entry = $this->get_entry(); |
|
1469 | - $value = NULL; |
|
1470 | - if( isset( $entry[ $field->id ] ) ) { |
|
1471 | - $value = json_decode( $entry[ $field->id ], true ); |
|
1472 | - } |
|
1467 | + //existent |
|
1468 | + $entry = $this->get_entry(); |
|
1469 | + $value = NULL; |
|
1470 | + if( isset( $entry[ $field->id ] ) ) { |
|
1471 | + $value = json_decode( $entry[ $field->id ], true ); |
|
1472 | + } |
|
1473 | 1473 | |
1474 | - // count uploaded files and existent entry files |
|
1475 | - $count_files = count( $file_names ) + count( $value ); |
|
1474 | + // count uploaded files and existent entry files |
|
1475 | + $count_files = count( $file_names ) + count( $value ); |
|
1476 | 1476 | |
1477 | - if( $count_files > $field->maxFiles ) { |
|
1478 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1479 | - $field->failed_validation = 1; |
|
1480 | - $gv_valid = false; |
|
1477 | + if( $count_files > $field->maxFiles ) { |
|
1478 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1479 | + $field->failed_validation = 1; |
|
1480 | + $gv_valid = false; |
|
1481 | 1481 | |
1482 | - // in case of error make sure the newest upload files are removed from the upload input |
|
1483 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1484 | - } |
|
1482 | + // in case of error make sure the newest upload files are removed from the upload input |
|
1483 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1484 | + } |
|
1485 | 1485 | |
1486 | - } |
|
1486 | + } |
|
1487 | 1487 | |
1488 | 1488 | |
1489 | - break; |
|
1489 | + break; |
|
1490 | 1490 | |
1491 | 1491 | } |
1492 | 1492 | |
@@ -1497,47 +1497,47 @@ discard block |
||
1497 | 1497 | |
1498 | 1498 | switch ( $field_type ) { |
1499 | 1499 | |
1500 | - // Captchas don't need to be re-entered. |
|
1501 | - case 'captcha': |
|
1500 | + // Captchas don't need to be re-entered. |
|
1501 | + case 'captcha': |
|
1502 | 1502 | |
1503 | - // Post Image fields aren't editable, so we un-fail them. |
|
1504 | - case 'post_image': |
|
1505 | - $field->failed_validation = false; |
|
1506 | - unset( $field->validation_message ); |
|
1507 | - break; |
|
1503 | + // Post Image fields aren't editable, so we un-fail them. |
|
1504 | + case 'post_image': |
|
1505 | + $field->failed_validation = false; |
|
1506 | + unset( $field->validation_message ); |
|
1507 | + break; |
|
1508 | 1508 | |
1509 | 1509 | } |
1510 | 1510 | |
1511 | 1511 | // You can't continue inside a switch, so we do it after. |
1512 | 1512 | if( empty( $field->failed_validation ) ) { |
1513 | - continue; |
|
1513 | + continue; |
|
1514 | 1514 | } |
1515 | 1515 | |
1516 | 1516 | // checks if the No Duplicates option is not validating entry against itself, since |
1517 | 1517 | // we're editing a stored entry, it would also assume it's a duplicate. |
1518 | 1518 | if( !empty( $field->noDuplicates ) ) { |
1519 | 1519 | |
1520 | - $entry = $this->get_entry(); |
|
1520 | + $entry = $this->get_entry(); |
|
1521 | 1521 | |
1522 | - // If the value of the entry is the same as the stored value |
|
1523 | - // Then we can assume it's not a duplicate, it's the same. |
|
1524 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1525 | - //if value submitted was not changed, then don't validate |
|
1526 | - $field->failed_validation = false; |
|
1522 | + // If the value of the entry is the same as the stored value |
|
1523 | + // Then we can assume it's not a duplicate, it's the same. |
|
1524 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1525 | + //if value submitted was not changed, then don't validate |
|
1526 | + $field->failed_validation = false; |
|
1527 | 1527 | |
1528 | - unset( $field->validation_message ); |
|
1528 | + unset( $field->validation_message ); |
|
1529 | 1529 | |
1530 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1530 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1531 | 1531 | |
1532 | - continue; |
|
1533 | - } |
|
1532 | + continue; |
|
1533 | + } |
|
1534 | 1534 | } |
1535 | 1535 | |
1536 | 1536 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1537 | 1537 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
1538 | - unset( $field->validation_message ); |
|
1539 | - $field->validation_message = false; |
|
1540 | - continue; |
|
1538 | + unset( $field->validation_message ); |
|
1539 | + $field->validation_message = false; |
|
1540 | + continue; |
|
1541 | 1541 | } |
1542 | 1542 | |
1543 | 1543 | $gv_valid = false; |
@@ -1601,8 +1601,8 @@ discard block |
||
1601 | 1601 | // Hide fields depending on admin settings |
1602 | 1602 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
1603 | 1603 | |
1604 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1605 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1604 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1605 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1606 | 1606 | |
1607 | 1607 | /** |
1608 | 1608 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1662,11 +1662,11 @@ discard block |
||
1662 | 1662 | // The edit tab has been configured, so we loop through to configured settings |
1663 | 1663 | foreach ( $configured_fields as $configured_field ) { |
1664 | 1664 | |
1665 | - /** @var GF_Field $field */ |
|
1666 | - foreach ( $fields as $field ) { |
|
1665 | + /** @var GF_Field $field */ |
|
1666 | + foreach ( $fields as $field ) { |
|
1667 | 1667 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
1668 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1669 | - break; |
|
1668 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1669 | + break; |
|
1670 | 1670 | } |
1671 | 1671 | |
1672 | 1672 | } |
@@ -1722,28 +1722,28 @@ discard block |
||
1722 | 1722 | */ |
1723 | 1723 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
1724 | 1724 | |
1725 | - /** |
|
1725 | + /** |
|
1726 | 1726 | * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true |
1727 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1728 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1729 | - * @since 1.9.1 |
|
1730 | - * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
1731 | - * @param array $form GF Form array |
|
1732 | - * @param int $view_id View ID |
|
1733 | - */ |
|
1734 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1735 | - |
|
1736 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1727 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1728 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1729 | + * @since 1.9.1 |
|
1730 | + * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions. |
|
1731 | + * @param array $form GF Form array |
|
1732 | + * @param int $view_id View ID |
|
1733 | + */ |
|
1734 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1735 | + |
|
1736 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1737 | 1737 | foreach( $fields as $k => $field ) { |
1738 | 1738 | if( $field->adminOnly ) { |
1739 | - unset( $fields[ $k ] ); |
|
1739 | + unset( $fields[ $k ] ); |
|
1740 | 1740 | } |
1741 | 1741 | } |
1742 | 1742 | return array_values( $fields ); |
1743 | 1743 | } |
1744 | 1744 | |
1745 | - foreach( $fields as &$field ) { |
|
1746 | - $field->adminOnly = false; |
|
1745 | + foreach( $fields as &$field ) { |
|
1746 | + $field->adminOnly = false; |
|
1747 | 1747 | } |
1748 | 1748 | |
1749 | 1749 | return $fields; |
@@ -1763,13 +1763,13 @@ discard block |
||
1763 | 1763 | */ |
1764 | 1764 | private function unselect_default_values( $form ) { |
1765 | 1765 | |
1766 | - foreach ( $form['fields'] as &$field ) { |
|
1766 | + foreach ( $form['fields'] as &$field ) { |
|
1767 | 1767 | |
1768 | 1768 | if ( empty( $field->choices ) ) { |
1769 | - continue; |
|
1769 | + continue; |
|
1770 | 1770 | } |
1771 | 1771 | |
1772 | - foreach ( $field->choices as &$choice ) { |
|
1772 | + foreach ( $field->choices as &$choice ) { |
|
1773 | 1773 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
1774 | 1774 | $choice['isSelected'] = false; |
1775 | 1775 | } |
@@ -1806,36 +1806,36 @@ discard block |
||
1806 | 1806 | |
1807 | 1807 | if( 'checkbox' === $field->type ) { |
1808 | 1808 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1809 | - $input_id = $input['id']; |
|
1810 | - $choice = $field->choices[ $key ]; |
|
1811 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1812 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1813 | - if( $match ) { |
|
1814 | - $field->choices[ $key ]['isSelected'] = true; |
|
1815 | - } |
|
1809 | + $input_id = $input['id']; |
|
1810 | + $choice = $field->choices[ $key ]; |
|
1811 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1812 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1813 | + if( $match ) { |
|
1814 | + $field->choices[ $key ]['isSelected'] = true; |
|
1815 | + } |
|
1816 | 1816 | } |
1817 | 1817 | } else { |
1818 | 1818 | |
1819 | 1819 | // We need to run through each field to set the default values |
1820 | 1820 | foreach ( $this->entry as $field_id => $field_value ) { |
1821 | 1821 | |
1822 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1822 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1823 | 1823 | |
1824 | - if( 'list' === $field->type ) { |
|
1825 | - $list_rows = maybe_unserialize( $field_value ); |
|
1824 | + if( 'list' === $field->type ) { |
|
1825 | + $list_rows = maybe_unserialize( $field_value ); |
|
1826 | 1826 | |
1827 | - $list_field_value = array(); |
|
1828 | - foreach ( (array) $list_rows as $row ) { |
|
1829 | - foreach ( (array) $row as $column ) { |
|
1830 | - $list_field_value[] = $column; |
|
1831 | - } |
|
1832 | - } |
|
1827 | + $list_field_value = array(); |
|
1828 | + foreach ( (array) $list_rows as $row ) { |
|
1829 | + foreach ( (array) $row as $column ) { |
|
1830 | + $list_field_value[] = $column; |
|
1831 | + } |
|
1832 | + } |
|
1833 | 1833 | |
1834 | - $field->defaultValue = serialize( $list_field_value ); |
|
1835 | - } else { |
|
1836 | - $field->defaultValue = $field_value; |
|
1837 | - } |
|
1838 | - } |
|
1834 | + $field->defaultValue = serialize( $list_field_value ); |
|
1835 | + } else { |
|
1836 | + $field->defaultValue = $field_value; |
|
1837 | + } |
|
1838 | + } |
|
1839 | 1839 | } |
1840 | 1840 | } |
1841 | 1841 | } |
@@ -1892,7 +1892,7 @@ discard block |
||
1892 | 1892 | return $has_conditional_logic; |
1893 | 1893 | } |
1894 | 1894 | |
1895 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
1895 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
1896 | 1896 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
1897 | 1897 | } |
1898 | 1898 | |
@@ -1959,14 +1959,14 @@ discard block |
||
1959 | 1959 | |
1960 | 1960 | if( $echo && $error !== true ) { |
1961 | 1961 | |
1962 | - $error = esc_html( $error ); |
|
1962 | + $error = esc_html( $error ); |
|
1963 | 1963 | |
1964 | - /** |
|
1965 | - * @since 1.9 |
|
1966 | - */ |
|
1967 | - if ( ! empty( $this->entry ) ) { |
|
1968 | - $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;" ) ); |
|
1969 | - } |
|
1964 | + /** |
|
1965 | + * @since 1.9 |
|
1966 | + */ |
|
1967 | + if ( ! empty( $this->entry ) ) { |
|
1968 | + $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;" ) ); |
|
1969 | + } |
|
1970 | 1970 | |
1971 | 1971 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
1972 | 1972 | } |