@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | |
103 | 103 | /** |
104 | 104 | * ID of the current post. May also be ID of the current View. |
105 | - * |
|
106 | - * @since 2.0.13 |
|
107 | - * |
|
108 | - * @var int |
|
105 | + * |
|
106 | + * @since 2.0.13 |
|
107 | + * |
|
108 | + * @var int |
|
109 | 109 | */ |
110 | 110 | public $post_id; |
111 | 111 | |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | public function prevent_maybe_process_form() { |
178 | 178 | |
179 | 179 | if( ! empty( $_POST ) ) { |
180 | - gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
180 | + gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | if( $this->is_edit_entry_submission() ) { |
184 | 184 | remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
185 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
185 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
@@ -210,14 +210,14 @@ discard block |
||
210 | 210 | * When Edit entry view is requested setup the vars |
211 | 211 | */ |
212 | 212 | private function setup_vars() { |
213 | - global $post; |
|
213 | + global $post; |
|
214 | 214 | |
215 | 215 | $gravityview_view = GravityView_View::getInstance(); |
216 | 216 | |
217 | 217 | |
218 | 218 | $entries = $gravityview_view->getEntries(); |
219 | - self::$original_entry = $entries[0]; |
|
220 | - $this->entry = $entries[0]; |
|
219 | + self::$original_entry = $entries[0]; |
|
220 | + $this->entry = $entries[0]; |
|
221 | 221 | |
222 | 222 | self::$original_form = $gravityview_view->getForm(); |
223 | 223 | $this->form = $gravityview_view->getForm(); |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | |
360 | 360 | GFFormsModel::save_lead( $form, $this->entry ); |
361 | 361 | |
362 | - // Delete the values for hidden inputs |
|
363 | - $this->unset_hidden_field_values(); |
|
362 | + // Delete the values for hidden inputs |
|
363 | + $this->unset_hidden_field_values(); |
|
364 | 364 | |
365 | 365 | $this->entry['date_created'] = $date_created; |
366 | 366 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | // Perform actions normally performed after updating a lead |
371 | 371 | $this->after_update(); |
372 | 372 | |
373 | - /** |
|
373 | + /** |
|
374 | 374 | * Must be AFTER after_update()! |
375 | 375 | * @see https://github.com/gravityview/GravityView/issues/764 |
376 | 376 | */ |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | |
379 | 379 | /** |
380 | 380 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
381 | - * @since 2.1 Added $gv_data parameter |
|
381 | + * @since 2.1 Added $gv_data parameter |
|
382 | 382 | * @param array $form Gravity Forms form array |
383 | 383 | * @param string $entry_id Numeric ID of the entry that was updated |
384 | 384 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * @return void |
403 | 403 | */ |
404 | 404 | private function unset_hidden_field_values() { |
405 | - global $wpdb; |
|
405 | + global $wpdb; |
|
406 | 406 | |
407 | 407 | /** |
408 | 408 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -424,29 +424,29 @@ discard block |
||
424 | 424 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
425 | 425 | } |
426 | 426 | |
427 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
427 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
428 | 428 | |
429 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
429 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
430 | 430 | |
431 | - // Reset fields that are hidden |
|
432 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
433 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
431 | + // Reset fields that are hidden |
|
432 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
433 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
434 | 434 | |
435 | 435 | $empty_value = $field->get_value_save_entry( |
436 | 436 | is_array( $field->get_entry_inputs() ) ? array() : '', |
437 | 437 | $this->form, '', $this->entry['id'], $this->entry |
438 | 438 | ); |
439 | 439 | |
440 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
440 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
441 | 441 | |
442 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
442 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
443 | 443 | |
444 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
444 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
445 | 445 | // after submission |
446 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
447 | - $_POST[ $post_input_id ] = ''; |
|
448 | - } |
|
449 | - } |
|
446 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
447 | + $_POST[ $post_input_id ] = ''; |
|
448 | + } |
|
449 | + } |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | |
543 | 543 | $non_submitted_fields = array(); |
544 | 544 | |
545 | - /** @var GF_Field $field */ |
|
545 | + /** @var GF_Field $field */ |
|
546 | 546 | foreach( $form['fields'] as $k => &$field ) { |
547 | 547 | |
548 | 548 | /** |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | |
559 | 559 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
560 | 560 | foreach( $field->inputs as $key => $input ) { |
561 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
561 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
562 | 562 | } |
563 | 563 | } |
564 | 564 | |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | foreach ( $this->fields_with_calculation as $field ) { |
620 | 620 | $inputs = $field->get_entry_inputs(); |
621 | 621 | if ( is_array( $inputs ) ) { |
622 | - foreach ( $inputs as $input ) { |
|
622 | + foreach ( $inputs as $input ) { |
|
623 | 623 | list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
624 | 624 | |
625 | 625 | if ( 'product' === $field->type ) { |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | } |
639 | 639 | |
640 | 640 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
641 | - } |
|
641 | + } |
|
642 | 642 | } else { |
643 | 643 | // Set to what it previously was if it's not editable |
644 | 644 | if ( ! in_array( $field->id, $allowed_fields ) ) { |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
685 | 685 | |
686 | 686 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
687 | - $ary = stripslashes_deep( $ary ); |
|
687 | + $ary = stripslashes_deep( $ary ); |
|
688 | 688 | $img_url = \GV\Utils::get( $ary, 0 ); |
689 | 689 | |
690 | 690 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | private function maybe_update_post_fields( $form ) { |
758 | 758 | |
759 | 759 | if( empty( $this->entry['post_id'] ) ) { |
760 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
760 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
761 | 761 | return; |
762 | 762 | } |
763 | 763 | |
@@ -792,49 +792,49 @@ discard block |
||
792 | 792 | |
793 | 793 | switch( $field->type ) { |
794 | 794 | |
795 | - case 'post_title': |
|
796 | - $post_title = $value; |
|
797 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
798 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
799 | - } |
|
800 | - $updated_post->post_title = $post_title; |
|
801 | - $updated_post->post_name = $post_title; |
|
802 | - unset( $post_title ); |
|
803 | - break; |
|
804 | - |
|
805 | - case 'post_content': |
|
806 | - $post_content = $value; |
|
807 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
808 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
809 | - } |
|
810 | - $updated_post->post_content = $post_content; |
|
811 | - unset( $post_content ); |
|
812 | - break; |
|
813 | - case 'post_excerpt': |
|
814 | - $updated_post->post_excerpt = $value; |
|
815 | - break; |
|
816 | - case 'post_tags': |
|
817 | - wp_set_post_tags( $post_id, $value, false ); |
|
818 | - break; |
|
819 | - case 'post_category': |
|
820 | - break; |
|
821 | - case 'post_custom_field': |
|
795 | + case 'post_title': |
|
796 | + $post_title = $value; |
|
797 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
798 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
799 | + } |
|
800 | + $updated_post->post_title = $post_title; |
|
801 | + $updated_post->post_name = $post_title; |
|
802 | + unset( $post_title ); |
|
803 | + break; |
|
804 | + |
|
805 | + case 'post_content': |
|
806 | + $post_content = $value; |
|
807 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
808 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
809 | + } |
|
810 | + $updated_post->post_content = $post_content; |
|
811 | + unset( $post_content ); |
|
812 | + break; |
|
813 | + case 'post_excerpt': |
|
814 | + $updated_post->post_excerpt = $value; |
|
815 | + break; |
|
816 | + case 'post_tags': |
|
817 | + wp_set_post_tags( $post_id, $value, false ); |
|
818 | + break; |
|
819 | + case 'post_category': |
|
820 | + break; |
|
821 | + case 'post_custom_field': |
|
822 | 822 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
823 | 823 | $value = $value[ $field_id ]; |
824 | 824 | } |
825 | 825 | |
826 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
827 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
828 | - } |
|
826 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
827 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
828 | + } |
|
829 | 829 | |
830 | 830 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
831 | 831 | |
832 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
833 | - break; |
|
832 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
833 | + break; |
|
834 | 834 | |
835 | - case 'post_image': |
|
836 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
837 | - break; |
|
835 | + case 'post_image': |
|
836 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
837 | + break; |
|
838 | 838 | |
839 | 839 | } |
840 | 840 | |
@@ -991,14 +991,14 @@ discard block |
||
991 | 991 | ?><h2 class="gv-edit-entry-title"> |
992 | 992 | <span><?php |
993 | 993 | |
994 | - /** |
|
995 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
996 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
997 | - * @param GravityView_Edit_Entry_Render $this This object |
|
998 | - */ |
|
999 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
994 | + /** |
|
995 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
996 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
997 | + * @param GravityView_Edit_Entry_Render $this This object |
|
998 | + */ |
|
999 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
1000 | 1000 | |
1001 | - echo esc_attr( $edit_entry_title ); |
|
1001 | + echo esc_attr( $edit_entry_title ); |
|
1002 | 1002 | ?></span> |
1003 | 1003 | </h2> |
1004 | 1004 | |
@@ -1061,26 +1061,26 @@ discard block |
||
1061 | 1061 | |
1062 | 1062 | switch ( $edit_redirect ) { |
1063 | 1063 | |
1064 | - case '0': |
|
1065 | - $redirect_url = $back_link; |
|
1066 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1067 | - break; |
|
1068 | - |
|
1069 | - case '1': |
|
1070 | - $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
1071 | - $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>' ); |
|
1072 | - break; |
|
1073 | - |
|
1074 | - case '2': |
|
1075 | - $redirect_url = $edit_redirect_url; |
|
1076 | - $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
1077 | - $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>' ); |
|
1078 | - break; |
|
1079 | - |
|
1080 | - case '': |
|
1081 | - default: |
|
1082 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1083 | - break; |
|
1064 | + case '0': |
|
1065 | + $redirect_url = $back_link; |
|
1066 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
1067 | + break; |
|
1068 | + |
|
1069 | + case '1': |
|
1070 | + $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
1071 | + $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>' ); |
|
1072 | + break; |
|
1073 | + |
|
1074 | + case '2': |
|
1075 | + $redirect_url = $edit_redirect_url; |
|
1076 | + $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
1077 | + $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>' ); |
|
1078 | + break; |
|
1079 | + |
|
1080 | + case '': |
|
1081 | + default: |
|
1082 | + $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
1083 | + break; |
|
1084 | 1084 | } |
1085 | 1085 | |
1086 | 1086 | if ( isset( $redirect_url ) ) { |
@@ -1137,7 +1137,7 @@ discard block |
||
1137 | 1137 | |
1138 | 1138 | ob_get_clean(); |
1139 | 1139 | |
1140 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1140 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
1141 | 1141 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
1142 | 1142 | remove_filter( 'gform_disable_view_counter', '__return_true' ); |
1143 | 1143 | remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 ); |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | |
1192 | 1192 | // for now we don't support Save and Continue feature. |
1193 | 1193 | if( ! self::$supports_save_and_continue ) { |
1194 | - unset( $form['save'] ); |
|
1194 | + unset( $form['save'] ); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | $form = $this->unselect_default_values( $form ); |
@@ -1218,30 +1218,30 @@ discard block |
||
1218 | 1218 | return $field_content; |
1219 | 1219 | } |
1220 | 1220 | |
1221 | - $message = null; |
|
1221 | + $message = null; |
|
1222 | 1222 | |
1223 | - // First, make sure they have the capability to edit the post. |
|
1224 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1223 | + // First, make sure they have the capability to edit the post. |
|
1224 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
1225 | 1225 | |
1226 | - /** |
|
1227 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1228 | - * @param string $message The existing "You don't have permission..." text |
|
1229 | - */ |
|
1230 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1226 | + /** |
|
1227 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
1228 | + * @param string $message The existing "You don't have permission..." text |
|
1229 | + */ |
|
1230 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
1231 | 1231 | |
1232 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1233 | - /** |
|
1234 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1235 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1236 | - */ |
|
1237 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1238 | - } |
|
1232 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
1233 | + /** |
|
1234 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
1235 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
1236 | + */ |
|
1237 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
1238 | + } |
|
1239 | 1239 | |
1240 | - if( $message ) { |
|
1241 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1242 | - } |
|
1240 | + if( $message ) { |
|
1241 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
1242 | + } |
|
1243 | 1243 | |
1244 | - return $field_content; |
|
1244 | + return $field_content; |
|
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | /** |
@@ -1269,7 +1269,7 @@ discard block |
||
1269 | 1269 | || ! empty( $field_content ) |
1270 | 1270 | || in_array( $field->type, array( 'honeypot' ) ) |
1271 | 1271 | ) { |
1272 | - return $field_content; |
|
1272 | + return $field_content; |
|
1273 | 1273 | } |
1274 | 1274 | |
1275 | 1275 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1277,24 +1277,24 @@ discard block |
||
1277 | 1277 | |
1278 | 1278 | $field_value = $this->get_field_value( $field ); |
1279 | 1279 | |
1280 | - // Prevent any PHP warnings, like undefined index |
|
1281 | - ob_start(); |
|
1280 | + // Prevent any PHP warnings, like undefined index |
|
1281 | + ob_start(); |
|
1282 | 1282 | |
1283 | - $return = null; |
|
1283 | + $return = null; |
|
1284 | 1284 | |
1285 | 1285 | /** @var GravityView_Field $gv_field */ |
1286 | 1286 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
1287 | 1287 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
1288 | 1288 | } else { |
1289 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1290 | - } |
|
1289 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
1290 | + } |
|
1291 | 1291 | |
1292 | - // If there was output, it's an error |
|
1293 | - $warnings = ob_get_clean(); |
|
1292 | + // If there was output, it's an error |
|
1293 | + $warnings = ob_get_clean(); |
|
1294 | 1294 | |
1295 | - if( !empty( $warnings ) ) { |
|
1296 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1297 | - } |
|
1295 | + if( !empty( $warnings ) ) { |
|
1296 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
1297 | + } |
|
1298 | 1298 | |
1299 | 1299 | return $return; |
1300 | 1300 | } |
@@ -1329,8 +1329,8 @@ discard block |
||
1329 | 1329 | $input_id = strval( $input['id'] ); |
1330 | 1330 | |
1331 | 1331 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
1332 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1333 | - $allow_pre_populated = false; |
|
1332 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
1333 | + $allow_pre_populated = false; |
|
1334 | 1334 | } |
1335 | 1335 | |
1336 | 1336 | } |
@@ -1354,7 +1354,7 @@ discard block |
||
1354 | 1354 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
1355 | 1355 | $categories = array(); |
1356 | 1356 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
1357 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1357 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
1358 | 1358 | } |
1359 | 1359 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
1360 | 1360 | } |
@@ -1364,25 +1364,25 @@ discard block |
||
1364 | 1364 | // if value is empty get the default value if defined |
1365 | 1365 | $field_value = $field->get_value_default_if_empty( $field_value ); |
1366 | 1366 | |
1367 | - /** |
|
1368 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1369 | - * @since 1.11 |
|
1370 | - * @since 1.20 Added third param |
|
1371 | - * @param mixed $field_value field value used to populate the input |
|
1372 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1373 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1374 | - */ |
|
1375 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1376 | - |
|
1377 | - /** |
|
1378 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1379 | - * @since 1.17 |
|
1380 | - * @since 1.20 Added third param |
|
1381 | - * @param mixed $field_value field value used to populate the input |
|
1382 | - * @param GF_Field $field Gravity Forms field object |
|
1383 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
1384 | - */ |
|
1385 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1367 | + /** |
|
1368 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
1369 | + * @since 1.11 |
|
1370 | + * @since 1.20 Added third param |
|
1371 | + * @param mixed $field_value field value used to populate the input |
|
1372 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
1373 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1374 | + */ |
|
1375 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
1376 | + |
|
1377 | + /** |
|
1378 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
1379 | + * @since 1.17 |
|
1380 | + * @since 1.20 Added third param |
|
1381 | + * @param mixed $field_value field value used to populate the input |
|
1382 | + * @param GF_Field $field Gravity Forms field object |
|
1383 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
1384 | + */ |
|
1385 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
1386 | 1386 | |
1387 | 1387 | return $field_value; |
1388 | 1388 | } |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
1410 | 1410 | // expects certain field array items to be set. |
1411 | 1411 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
1412 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1412 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
1413 | 1413 | } |
1414 | 1414 | |
1415 | 1415 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1423,61 +1423,61 @@ discard block |
||
1423 | 1423 | */ |
1424 | 1424 | case 'fileupload': |
1425 | 1425 | |
1426 | - // Set the previous value |
|
1427 | - $entry = $this->get_entry(); |
|
1426 | + // Set the previous value |
|
1427 | + $entry = $this->get_entry(); |
|
1428 | 1428 | |
1429 | - $input_name = 'input_'.$field->id; |
|
1430 | - $form_id = $form['id']; |
|
1429 | + $input_name = 'input_'.$field->id; |
|
1430 | + $form_id = $form['id']; |
|
1431 | 1431 | |
1432 | - $value = NULL; |
|
1432 | + $value = NULL; |
|
1433 | 1433 | |
1434 | - // Use the previous entry value as the default. |
|
1435 | - if( isset( $entry[ $field->id ] ) ) { |
|
1436 | - $value = $entry[ $field->id ]; |
|
1437 | - } |
|
1434 | + // Use the previous entry value as the default. |
|
1435 | + if( isset( $entry[ $field->id ] ) ) { |
|
1436 | + $value = $entry[ $field->id ]; |
|
1437 | + } |
|
1438 | 1438 | |
1439 | - // If this is a single upload file |
|
1440 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1441 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1442 | - $value = $file_path['url']; |
|
1439 | + // If this is a single upload file |
|
1440 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
1441 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
1442 | + $value = $file_path['url']; |
|
1443 | 1443 | |
1444 | - } else { |
|
1444 | + } else { |
|
1445 | 1445 | |
1446 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1447 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1448 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1446 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
1447 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
1448 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
1449 | 1449 | |
1450 | - } |
|
1450 | + } |
|
1451 | 1451 | |
1452 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1452 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
1453 | 1453 | |
1454 | - // If there are fresh uploads, process and merge them. |
|
1455 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1456 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1457 | - $value = empty( $value ) ? '[]' : $value; |
|
1458 | - $value = stripslashes_deep( $value ); |
|
1459 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1460 | - } |
|
1454 | + // If there are fresh uploads, process and merge them. |
|
1455 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
1456 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
1457 | + $value = empty( $value ) ? '[]' : $value; |
|
1458 | + $value = stripslashes_deep( $value ); |
|
1459 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
1460 | + } |
|
1461 | 1461 | |
1462 | - } else { |
|
1462 | + } else { |
|
1463 | 1463 | |
1464 | - // A file already exists when editing an entry |
|
1465 | - // We set this to solve issue when file upload fields are required. |
|
1466 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1464 | + // A file already exists when editing an entry |
|
1465 | + // We set this to solve issue when file upload fields are required. |
|
1466 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
1467 | 1467 | |
1468 | - } |
|
1468 | + } |
|
1469 | 1469 | |
1470 | - $this->entry[ $input_name ] = $value; |
|
1471 | - $_POST[ $input_name ] = $value; |
|
1470 | + $this->entry[ $input_name ] = $value; |
|
1471 | + $_POST[ $input_name ] = $value; |
|
1472 | 1472 | |
1473 | - break; |
|
1473 | + break; |
|
1474 | 1474 | |
1475 | 1475 | case 'number': |
1476 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
1477 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1478 | - $_POST['input_'.$field->id ] = NULL; |
|
1479 | - } |
|
1480 | - break; |
|
1476 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
1477 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
1478 | + $_POST['input_'.$field->id ] = NULL; |
|
1479 | + } |
|
1480 | + break; |
|
1481 | 1481 | } |
1482 | 1482 | |
1483 | 1483 | } |
@@ -1562,43 +1562,43 @@ discard block |
||
1562 | 1562 | case 'fileupload' : |
1563 | 1563 | case 'post_image': |
1564 | 1564 | |
1565 | - // in case nothing is uploaded but there are already files saved |
|
1566 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1567 | - $field->failed_validation = false; |
|
1568 | - unset( $field->validation_message ); |
|
1569 | - } |
|
1565 | + // in case nothing is uploaded but there are already files saved |
|
1566 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
1567 | + $field->failed_validation = false; |
|
1568 | + unset( $field->validation_message ); |
|
1569 | + } |
|
1570 | 1570 | |
1571 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1572 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1571 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
1572 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
1573 | 1573 | |
1574 | - $input_name = 'input_' . $field->id; |
|
1575 | - //uploaded |
|
1576 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1574 | + $input_name = 'input_' . $field->id; |
|
1575 | + //uploaded |
|
1576 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
1577 | 1577 | |
1578 | - //existent |
|
1579 | - $entry = $this->get_entry(); |
|
1580 | - $value = NULL; |
|
1581 | - if( isset( $entry[ $field->id ] ) ) { |
|
1582 | - $value = json_decode( $entry[ $field->id ], true ); |
|
1583 | - } |
|
1578 | + //existent |
|
1579 | + $entry = $this->get_entry(); |
|
1580 | + $value = NULL; |
|
1581 | + if( isset( $entry[ $field->id ] ) ) { |
|
1582 | + $value = json_decode( $entry[ $field->id ], true ); |
|
1583 | + } |
|
1584 | 1584 | |
1585 | - // count uploaded files and existent entry files |
|
1586 | - $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
1587 | - ( is_array( $value ) ? count( $value ) : 0 ); |
|
1585 | + // count uploaded files and existent entry files |
|
1586 | + $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
1587 | + ( is_array( $value ) ? count( $value ) : 0 ); |
|
1588 | 1588 | |
1589 | - if( $count_files > $field->maxFiles ) { |
|
1590 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1591 | - $field->failed_validation = 1; |
|
1592 | - $gv_valid = false; |
|
1589 | + if( $count_files > $field->maxFiles ) { |
|
1590 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
1591 | + $field->failed_validation = 1; |
|
1592 | + $gv_valid = false; |
|
1593 | 1593 | |
1594 | - // in case of error make sure the newest upload files are removed from the upload input |
|
1595 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1596 | - } |
|
1594 | + // in case of error make sure the newest upload files are removed from the upload input |
|
1595 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
1596 | + } |
|
1597 | 1597 | |
1598 | - } |
|
1598 | + } |
|
1599 | 1599 | |
1600 | 1600 | |
1601 | - break; |
|
1601 | + break; |
|
1602 | 1602 | |
1603 | 1603 | } |
1604 | 1604 | |
@@ -1609,47 +1609,47 @@ discard block |
||
1609 | 1609 | |
1610 | 1610 | switch ( $field_type ) { |
1611 | 1611 | |
1612 | - // Captchas don't need to be re-entered. |
|
1613 | - case 'captcha': |
|
1612 | + // Captchas don't need to be re-entered. |
|
1613 | + case 'captcha': |
|
1614 | 1614 | |
1615 | - // Post Image fields aren't editable, so we un-fail them. |
|
1616 | - case 'post_image': |
|
1617 | - $field->failed_validation = false; |
|
1618 | - unset( $field->validation_message ); |
|
1619 | - break; |
|
1615 | + // Post Image fields aren't editable, so we un-fail them. |
|
1616 | + case 'post_image': |
|
1617 | + $field->failed_validation = false; |
|
1618 | + unset( $field->validation_message ); |
|
1619 | + break; |
|
1620 | 1620 | |
1621 | 1621 | } |
1622 | 1622 | |
1623 | 1623 | // You can't continue inside a switch, so we do it after. |
1624 | 1624 | if( empty( $field->failed_validation ) ) { |
1625 | - continue; |
|
1625 | + continue; |
|
1626 | 1626 | } |
1627 | 1627 | |
1628 | 1628 | // checks if the No Duplicates option is not validating entry against itself, since |
1629 | 1629 | // we're editing a stored entry, it would also assume it's a duplicate. |
1630 | 1630 | if( !empty( $field->noDuplicates ) ) { |
1631 | 1631 | |
1632 | - $entry = $this->get_entry(); |
|
1632 | + $entry = $this->get_entry(); |
|
1633 | 1633 | |
1634 | - // If the value of the entry is the same as the stored value |
|
1635 | - // Then we can assume it's not a duplicate, it's the same. |
|
1636 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1637 | - //if value submitted was not changed, then don't validate |
|
1638 | - $field->failed_validation = false; |
|
1634 | + // If the value of the entry is the same as the stored value |
|
1635 | + // Then we can assume it's not a duplicate, it's the same. |
|
1636 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
1637 | + //if value submitted was not changed, then don't validate |
|
1638 | + $field->failed_validation = false; |
|
1639 | 1639 | |
1640 | - unset( $field->validation_message ); |
|
1640 | + unset( $field->validation_message ); |
|
1641 | 1641 | |
1642 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1642 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
1643 | 1643 | |
1644 | - continue; |
|
1645 | - } |
|
1644 | + continue; |
|
1645 | + } |
|
1646 | 1646 | } |
1647 | 1647 | |
1648 | 1648 | // if here then probably we are facing the validation 'At least one field must be filled out' |
1649 | 1649 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
1650 | - unset( $field->validation_message ); |
|
1651 | - $field->validation_message = false; |
|
1652 | - continue; |
|
1650 | + unset( $field->validation_message ); |
|
1651 | + $field->validation_message = false; |
|
1652 | + continue; |
|
1653 | 1653 | } |
1654 | 1654 | |
1655 | 1655 | $gv_valid = false; |
@@ -1713,8 +1713,8 @@ discard block |
||
1713 | 1713 | // Hide fields depending on admin settings |
1714 | 1714 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
1715 | 1715 | |
1716 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1717 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1716 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
1717 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
1718 | 1718 | |
1719 | 1719 | /** |
1720 | 1720 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1774,11 +1774,11 @@ discard block |
||
1774 | 1774 | // The edit tab has been configured, so we loop through to configured settings |
1775 | 1775 | foreach ( $configured_fields as $configured_field ) { |
1776 | 1776 | |
1777 | - /** @var GF_Field $field */ |
|
1778 | - foreach ( $fields as $field ) { |
|
1777 | + /** @var GF_Field $field */ |
|
1778 | + foreach ( $fields as $field ) { |
|
1779 | 1779 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
1780 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1781 | - break; |
|
1780 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
1781 | + break; |
|
1782 | 1782 | } |
1783 | 1783 | |
1784 | 1784 | } |
@@ -1834,28 +1834,28 @@ discard block |
||
1834 | 1834 | */ |
1835 | 1835 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
1836 | 1836 | |
1837 | - /** |
|
1837 | + /** |
|
1838 | 1838 | * @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 |
1839 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1840 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1841 | - * @since 1.9.1 |
|
1842 | - * @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. |
|
1843 | - * @param array $form GF Form array |
|
1844 | - * @param int $view_id View ID |
|
1845 | - */ |
|
1846 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1847 | - |
|
1848 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1839 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
1840 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
1841 | + * @since 1.9.1 |
|
1842 | + * @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. |
|
1843 | + * @param array $form GF Form array |
|
1844 | + * @param int $view_id View ID |
|
1845 | + */ |
|
1846 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
1847 | + |
|
1848 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
1849 | 1849 | foreach( $fields as $k => $field ) { |
1850 | 1850 | if( $field->adminOnly ) { |
1851 | - unset( $fields[ $k ] ); |
|
1851 | + unset( $fields[ $k ] ); |
|
1852 | 1852 | } |
1853 | 1853 | } |
1854 | 1854 | return array_values( $fields ); |
1855 | 1855 | } |
1856 | 1856 | |
1857 | - foreach( $fields as &$field ) { |
|
1858 | - $field->adminOnly = false; |
|
1857 | + foreach( $fields as &$field ) { |
|
1858 | + $field->adminOnly = false; |
|
1859 | 1859 | } |
1860 | 1860 | |
1861 | 1861 | return $fields; |
@@ -1875,13 +1875,13 @@ discard block |
||
1875 | 1875 | */ |
1876 | 1876 | private function unselect_default_values( $form ) { |
1877 | 1877 | |
1878 | - foreach ( $form['fields'] as &$field ) { |
|
1878 | + foreach ( $form['fields'] as &$field ) { |
|
1879 | 1879 | |
1880 | 1880 | if ( empty( $field->choices ) ) { |
1881 | - continue; |
|
1881 | + continue; |
|
1882 | 1882 | } |
1883 | 1883 | |
1884 | - foreach ( $field->choices as &$choice ) { |
|
1884 | + foreach ( $field->choices as &$choice ) { |
|
1885 | 1885 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
1886 | 1886 | $choice['isSelected'] = false; |
1887 | 1887 | } |
@@ -1918,36 +1918,36 @@ discard block |
||
1918 | 1918 | |
1919 | 1919 | if( 'checkbox' === $field->type ) { |
1920 | 1920 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
1921 | - $input_id = $input['id']; |
|
1922 | - $choice = $field->choices[ $key ]; |
|
1923 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1924 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1925 | - if( $match ) { |
|
1926 | - $field->choices[ $key ]['isSelected'] = true; |
|
1927 | - } |
|
1921 | + $input_id = $input['id']; |
|
1922 | + $choice = $field->choices[ $key ]; |
|
1923 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
1924 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
1925 | + if( $match ) { |
|
1926 | + $field->choices[ $key ]['isSelected'] = true; |
|
1927 | + } |
|
1928 | 1928 | } |
1929 | 1929 | } else { |
1930 | 1930 | |
1931 | 1931 | // We need to run through each field to set the default values |
1932 | 1932 | foreach ( $this->entry as $field_id => $field_value ) { |
1933 | 1933 | |
1934 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1934 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
1935 | 1935 | |
1936 | - if( 'list' === $field->type ) { |
|
1937 | - $list_rows = maybe_unserialize( $field_value ); |
|
1936 | + if( 'list' === $field->type ) { |
|
1937 | + $list_rows = maybe_unserialize( $field_value ); |
|
1938 | 1938 | |
1939 | - $list_field_value = array(); |
|
1940 | - foreach ( (array) $list_rows as $row ) { |
|
1941 | - foreach ( (array) $row as $column ) { |
|
1942 | - $list_field_value[] = $column; |
|
1943 | - } |
|
1944 | - } |
|
1939 | + $list_field_value = array(); |
|
1940 | + foreach ( (array) $list_rows as $row ) { |
|
1941 | + foreach ( (array) $row as $column ) { |
|
1942 | + $list_field_value[] = $column; |
|
1943 | + } |
|
1944 | + } |
|
1945 | 1945 | |
1946 | - $field->defaultValue = serialize( $list_field_value ); |
|
1947 | - } else { |
|
1948 | - $field->defaultValue = $field_value; |
|
1949 | - } |
|
1950 | - } |
|
1946 | + $field->defaultValue = serialize( $list_field_value ); |
|
1947 | + } else { |
|
1948 | + $field->defaultValue = $field_value; |
|
1949 | + } |
|
1950 | + } |
|
1951 | 1951 | } |
1952 | 1952 | } |
1953 | 1953 | } |
@@ -2004,7 +2004,7 @@ discard block |
||
2004 | 2004 | return $has_conditional_logic; |
2005 | 2005 | } |
2006 | 2006 | |
2007 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2007 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
2008 | 2008 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
2009 | 2009 | } |
2010 | 2010 | |
@@ -2071,14 +2071,14 @@ discard block |
||
2071 | 2071 | |
2072 | 2072 | if( $echo && $error !== true ) { |
2073 | 2073 | |
2074 | - $error = esc_html( $error ); |
|
2074 | + $error = esc_html( $error ); |
|
2075 | 2075 | |
2076 | - /** |
|
2077 | - * @since 1.9 |
|
2078 | - */ |
|
2079 | - if ( ! empty( $this->entry ) ) { |
|
2080 | - $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;" ) ); |
|
2081 | - } |
|
2076 | + /** |
|
2077 | + * @since 1.9 |
|
2078 | + */ |
|
2079 | + if ( ! empty( $this->entry ) ) { |
|
2080 | + $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;" ) ); |
|
2081 | + } |
|
2082 | 2082 | |
2083 | 2083 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
2084 | 2084 | } |