@@ -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 | |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | */ |
| 188 | 188 | public function prevent_maybe_process_form() { |
| 189 | 189 | |
| 190 | - if( ! $this->is_edit_entry_submission() ) { |
|
| 190 | + if( ! $this->is_edit_entry_submission() ) { |
|
| 191 | 191 | return; |
| 192 | 192 | } |
| 193 | 193 | |
@@ -221,14 +221,14 @@ discard block |
||
| 221 | 221 | * When Edit entry view is requested setup the vars |
| 222 | 222 | */ |
| 223 | 223 | private function setup_vars() { |
| 224 | - global $post; |
|
| 224 | + global $post; |
|
| 225 | 225 | |
| 226 | 226 | $gravityview_view = GravityView_View::getInstance(); |
| 227 | 227 | |
| 228 | 228 | |
| 229 | 229 | $entries = $gravityview_view->getEntries(); |
| 230 | - self::$original_entry = $entries[0]; |
|
| 231 | - $this->entry = $entries[0]; |
|
| 230 | + self::$original_entry = $entries[0]; |
|
| 231 | + $this->entry = $entries[0]; |
|
| 232 | 232 | |
| 233 | 233 | self::$original_form = $gravityview_view->getForm(); |
| 234 | 234 | $this->form = $gravityview_view->getForm(); |
@@ -370,8 +370,8 @@ discard block |
||
| 370 | 370 | |
| 371 | 371 | GFFormsModel::save_lead( $form, $this->entry ); |
| 372 | 372 | |
| 373 | - // Delete the values for hidden inputs |
|
| 374 | - $this->unset_hidden_field_values(); |
|
| 373 | + // Delete the values for hidden inputs |
|
| 374 | + $this->unset_hidden_field_values(); |
|
| 375 | 375 | |
| 376 | 376 | $this->entry['date_created'] = $date_created; |
| 377 | 377 | |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | // Perform actions normally performed after updating a lead |
| 382 | 382 | $this->after_update(); |
| 383 | 383 | |
| 384 | - /** |
|
| 384 | + /** |
|
| 385 | 385 | * Must be AFTER after_update()! |
| 386 | 386 | * @see https://github.com/gravityview/GravityView/issues/764 |
| 387 | 387 | */ |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | |
| 390 | 390 | /** |
| 391 | 391 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
| 392 | - * @since 2.1 Added $gv_data parameter |
|
| 392 | + * @since 2.1 Added $gv_data parameter |
|
| 393 | 393 | * @param array $form Gravity Forms form array |
| 394 | 394 | * @param string $entry_id Numeric ID of the entry that was updated |
| 395 | 395 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | * @return void |
| 414 | 414 | */ |
| 415 | 415 | private function unset_hidden_field_values() { |
| 416 | - global $wpdb; |
|
| 416 | + global $wpdb; |
|
| 417 | 417 | |
| 418 | 418 | /** |
| 419 | 419 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -437,17 +437,17 @@ discard block |
||
| 437 | 437 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
| 440 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
| 441 | 441 | |
| 442 | 442 | if ( ! is_numeric( $input_id ) ) { |
| 443 | 443 | continue; |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
| 446 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
| 447 | 447 | |
| 448 | - // Reset fields that are hidden |
|
| 449 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
| 450 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
| 448 | + // Reset fields that are hidden |
|
| 449 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
| 450 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
| 451 | 451 | |
| 452 | 452 | $empty_value = $field->get_value_save_entry( |
| 453 | 453 | is_array( $field->get_entry_inputs() ) ? array() : '', |
@@ -459,16 +459,16 @@ discard block |
||
| 459 | 459 | $empty_value = ''; |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 462 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 463 | 463 | |
| 464 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 464 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 465 | 465 | |
| 466 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 466 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 467 | 467 | // after submission |
| 468 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 469 | - $_POST[ $post_input_id ] = ''; |
|
| 470 | - } |
|
| 471 | - } |
|
| 468 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 469 | + $_POST[ $post_input_id ] = ''; |
|
| 470 | + } |
|
| 471 | + } |
|
| 472 | 472 | } |
| 473 | 473 | |
| 474 | 474 | /** |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | |
| 563 | 563 | $form = $this->filter_conditional_logic( $this->form ); |
| 564 | 564 | |
| 565 | - /** @var GF_Field $field */ |
|
| 565 | + /** @var GF_Field $field */ |
|
| 566 | 566 | foreach( $form['fields'] as $k => &$field ) { |
| 567 | 567 | |
| 568 | 568 | /** |
@@ -578,7 +578,7 @@ discard block |
||
| 578 | 578 | |
| 579 | 579 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
| 580 | 580 | foreach( $field->inputs as $key => $input ) { |
| 581 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 581 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 582 | 582 | } |
| 583 | 583 | } |
| 584 | 584 | } |
@@ -618,7 +618,7 @@ discard block |
||
| 618 | 618 | |
| 619 | 619 | $inputs = $field->get_entry_inputs(); |
| 620 | 620 | if ( is_array( $inputs ) ) { |
| 621 | - foreach ( $inputs as $input ) { |
|
| 621 | + foreach ( $inputs as $input ) { |
|
| 622 | 622 | list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
| 623 | 623 | |
| 624 | 624 | if ( 'product' === $field->type ) { |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
| 640 | - } |
|
| 640 | + } |
|
| 641 | 641 | } else { |
| 642 | 642 | // Set to what it previously was if it's not editable |
| 643 | 643 | if ( ! in_array( $field->id, $allowed_fields ) ) { |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
| 684 | 684 | |
| 685 | 685 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 686 | - $ary = stripslashes_deep( $ary ); |
|
| 686 | + $ary = stripslashes_deep( $ary ); |
|
| 687 | 687 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 688 | 688 | |
| 689 | 689 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | private function maybe_update_post_fields( $form ) { |
| 757 | 757 | |
| 758 | 758 | if( empty( $this->entry['post_id'] ) ) { |
| 759 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 759 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 760 | 760 | return; |
| 761 | 761 | } |
| 762 | 762 | |
@@ -791,49 +791,49 @@ discard block |
||
| 791 | 791 | |
| 792 | 792 | switch( $field->type ) { |
| 793 | 793 | |
| 794 | - case 'post_title': |
|
| 795 | - $post_title = $value; |
|
| 796 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 797 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 798 | - } |
|
| 799 | - $updated_post->post_title = $post_title; |
|
| 800 | - $updated_post->post_name = $post_title; |
|
| 801 | - unset( $post_title ); |
|
| 802 | - break; |
|
| 803 | - |
|
| 804 | - case 'post_content': |
|
| 805 | - $post_content = $value; |
|
| 806 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 807 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 808 | - } |
|
| 809 | - $updated_post->post_content = $post_content; |
|
| 810 | - unset( $post_content ); |
|
| 811 | - break; |
|
| 812 | - case 'post_excerpt': |
|
| 813 | - $updated_post->post_excerpt = $value; |
|
| 814 | - break; |
|
| 815 | - case 'post_tags': |
|
| 816 | - wp_set_post_tags( $post_id, $value, false ); |
|
| 817 | - break; |
|
| 818 | - case 'post_category': |
|
| 819 | - break; |
|
| 820 | - case 'post_custom_field': |
|
| 794 | + case 'post_title': |
|
| 795 | + $post_title = $value; |
|
| 796 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 797 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 798 | + } |
|
| 799 | + $updated_post->post_title = $post_title; |
|
| 800 | + $updated_post->post_name = $post_title; |
|
| 801 | + unset( $post_title ); |
|
| 802 | + break; |
|
| 803 | + |
|
| 804 | + case 'post_content': |
|
| 805 | + $post_content = $value; |
|
| 806 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 807 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 808 | + } |
|
| 809 | + $updated_post->post_content = $post_content; |
|
| 810 | + unset( $post_content ); |
|
| 811 | + break; |
|
| 812 | + case 'post_excerpt': |
|
| 813 | + $updated_post->post_excerpt = $value; |
|
| 814 | + break; |
|
| 815 | + case 'post_tags': |
|
| 816 | + wp_set_post_tags( $post_id, $value, false ); |
|
| 817 | + break; |
|
| 818 | + case 'post_category': |
|
| 819 | + break; |
|
| 820 | + case 'post_custom_field': |
|
| 821 | 821 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
| 822 | 822 | $value = $value[ $field_id ]; |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 826 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 827 | - } |
|
| 825 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 826 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 827 | + } |
|
| 828 | 828 | |
| 829 | 829 | $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
| 830 | 830 | |
| 831 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 832 | - break; |
|
| 831 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 832 | + break; |
|
| 833 | 833 | |
| 834 | - case 'post_image': |
|
| 835 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 836 | - break; |
|
| 834 | + case 'post_image': |
|
| 835 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 836 | + break; |
|
| 837 | 837 | |
| 838 | 838 | } |
| 839 | 839 | |
@@ -990,14 +990,14 @@ discard block |
||
| 990 | 990 | ?><h2 class="gv-edit-entry-title"> |
| 991 | 991 | <span><?php |
| 992 | 992 | |
| 993 | - /** |
|
| 994 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 995 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 996 | - * @param GravityView_Edit_Entry_Render $this This object |
|
| 997 | - */ |
|
| 998 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 993 | + /** |
|
| 994 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 995 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 996 | + * @param GravityView_Edit_Entry_Render $this This object |
|
| 997 | + */ |
|
| 998 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 999 | 999 | |
| 1000 | - echo esc_attr( $edit_entry_title ); |
|
| 1000 | + echo esc_attr( $edit_entry_title ); |
|
| 1001 | 1001 | ?></span> |
| 1002 | 1002 | </h2> |
| 1003 | 1003 | |
@@ -1060,26 +1060,26 @@ discard block |
||
| 1060 | 1060 | |
| 1061 | 1061 | switch ( $edit_redirect ) { |
| 1062 | 1062 | |
| 1063 | - case '0': |
|
| 1064 | - $redirect_url = $back_link; |
|
| 1065 | - $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
| 1066 | - break; |
|
| 1067 | - |
|
| 1068 | - case '1': |
|
| 1069 | - $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
| 1070 | - $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>' ); |
|
| 1071 | - break; |
|
| 1072 | - |
|
| 1073 | - case '2': |
|
| 1074 | - $redirect_url = $edit_redirect_url; |
|
| 1075 | - $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
| 1076 | - $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>' ); |
|
| 1077 | - break; |
|
| 1078 | - |
|
| 1079 | - case '': |
|
| 1080 | - default: |
|
| 1081 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 1082 | - break; |
|
| 1063 | + case '0': |
|
| 1064 | + $redirect_url = $back_link; |
|
| 1065 | + $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' ); |
|
| 1066 | + break; |
|
| 1067 | + |
|
| 1068 | + case '1': |
|
| 1069 | + $redirect_url = $directory_link = GravityView_API::directory_link(); |
|
| 1070 | + $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>' ); |
|
| 1071 | + break; |
|
| 1072 | + |
|
| 1073 | + case '2': |
|
| 1074 | + $redirect_url = $edit_redirect_url; |
|
| 1075 | + $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' ); |
|
| 1076 | + $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>' ); |
|
| 1077 | + break; |
|
| 1078 | + |
|
| 1079 | + case '': |
|
| 1080 | + default: |
|
| 1081 | + $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 1082 | + break; |
|
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | 1085 | if ( isset( $redirect_url ) ) { |
@@ -1145,13 +1145,13 @@ discard block |
||
| 1145 | 1145 | ); |
| 1146 | 1146 | |
| 1147 | 1147 | /** |
| 1148 | - * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1149 | - * @since 1.16.3 |
|
| 1150 | - * @param array $labels Default button labels associative array |
|
| 1151 | - * @param array $form The Gravity Forms form |
|
| 1152 | - * @param array $entry The Gravity Forms entry |
|
| 1153 | - * @param int $view_id The current View ID |
|
| 1154 | - */ |
|
| 1148 | + * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels |
|
| 1149 | + * @since 1.16.3 |
|
| 1150 | + * @param array $labels Default button labels associative array |
|
| 1151 | + * @param array $form The Gravity Forms form |
|
| 1152 | + * @param array $entry The Gravity Forms entry |
|
| 1153 | + * @param int $view_id The current View ID |
|
| 1154 | + */ |
|
| 1155 | 1155 | $labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id ); |
| 1156 | 1156 | |
| 1157 | 1157 | GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
@@ -1193,7 +1193,7 @@ discard block |
||
| 1193 | 1193 | |
| 1194 | 1194 | ob_get_clean(); |
| 1195 | 1195 | |
| 1196 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1196 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1197 | 1197 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
| 1198 | 1198 | remove_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
| 1199 | 1199 | remove_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
@@ -1249,7 +1249,7 @@ discard block |
||
| 1249 | 1249 | |
| 1250 | 1250 | // for now we don't support Save and Continue feature. |
| 1251 | 1251 | if( ! self::$supports_save_and_continue ) { |
| 1252 | - unset( $form['save'] ); |
|
| 1252 | + unset( $form['save'] ); |
|
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | 1255 | $form = $this->unselect_default_values( $form ); |
@@ -1276,30 +1276,30 @@ discard block |
||
| 1276 | 1276 | return $field_content; |
| 1277 | 1277 | } |
| 1278 | 1278 | |
| 1279 | - $message = null; |
|
| 1279 | + $message = null; |
|
| 1280 | 1280 | |
| 1281 | - // First, make sure they have the capability to edit the post. |
|
| 1282 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1281 | + // First, make sure they have the capability to edit the post. |
|
| 1282 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1283 | 1283 | |
| 1284 | - /** |
|
| 1285 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1286 | - * @param string $message The existing "You don't have permission..." text |
|
| 1287 | - */ |
|
| 1288 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1284 | + /** |
|
| 1285 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1286 | + * @param string $message The existing "You don't have permission..." text |
|
| 1287 | + */ |
|
| 1288 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1289 | 1289 | |
| 1290 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1291 | - /** |
|
| 1292 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1293 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1294 | - */ |
|
| 1295 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1296 | - } |
|
| 1290 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1291 | + /** |
|
| 1292 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1293 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1294 | + */ |
|
| 1295 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1296 | + } |
|
| 1297 | 1297 | |
| 1298 | - if( $message ) { |
|
| 1299 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1300 | - } |
|
| 1298 | + if( $message ) { |
|
| 1299 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1300 | + } |
|
| 1301 | 1301 | |
| 1302 | - return $field_content; |
|
| 1302 | + return $field_content; |
|
| 1303 | 1303 | } |
| 1304 | 1304 | |
| 1305 | 1305 | /** |
@@ -1327,7 +1327,7 @@ discard block |
||
| 1327 | 1327 | || ! empty( $field_content ) |
| 1328 | 1328 | || in_array( $field->type, array( 'honeypot' ) ) |
| 1329 | 1329 | ) { |
| 1330 | - return $field_content; |
|
| 1330 | + return $field_content; |
|
| 1331 | 1331 | } |
| 1332 | 1332 | |
| 1333 | 1333 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1335,24 +1335,24 @@ discard block |
||
| 1335 | 1335 | |
| 1336 | 1336 | $field_value = $this->get_field_value( $field ); |
| 1337 | 1337 | |
| 1338 | - // Prevent any PHP warnings, like undefined index |
|
| 1339 | - ob_start(); |
|
| 1338 | + // Prevent any PHP warnings, like undefined index |
|
| 1339 | + ob_start(); |
|
| 1340 | 1340 | |
| 1341 | - $return = null; |
|
| 1341 | + $return = null; |
|
| 1342 | 1342 | |
| 1343 | 1343 | /** @var GravityView_Field $gv_field */ |
| 1344 | 1344 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
| 1345 | 1345 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1346 | 1346 | } else { |
| 1347 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1348 | - } |
|
| 1347 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1348 | + } |
|
| 1349 | 1349 | |
| 1350 | - // If there was output, it's an error |
|
| 1351 | - $warnings = ob_get_clean(); |
|
| 1350 | + // If there was output, it's an error |
|
| 1351 | + $warnings = ob_get_clean(); |
|
| 1352 | 1352 | |
| 1353 | - if( !empty( $warnings ) ) { |
|
| 1354 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1355 | - } |
|
| 1353 | + if( !empty( $warnings ) ) { |
|
| 1354 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1355 | + } |
|
| 1356 | 1356 | |
| 1357 | 1357 | return $return; |
| 1358 | 1358 | } |
@@ -1387,8 +1387,8 @@ discard block |
||
| 1387 | 1387 | $input_id = strval( $input['id'] ); |
| 1388 | 1388 | |
| 1389 | 1389 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1390 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1391 | - $allow_pre_populated = false; |
|
| 1390 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1391 | + $allow_pre_populated = false; |
|
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | 1394 | } |
@@ -1412,7 +1412,7 @@ discard block |
||
| 1412 | 1412 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
| 1413 | 1413 | $categories = array(); |
| 1414 | 1414 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1415 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1415 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1416 | 1416 | } |
| 1417 | 1417 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1418 | 1418 | } |
@@ -1422,25 +1422,25 @@ discard block |
||
| 1422 | 1422 | // if value is empty get the default value if defined |
| 1423 | 1423 | $field_value = $field->get_value_default_if_empty( $field_value ); |
| 1424 | 1424 | |
| 1425 | - /** |
|
| 1426 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1427 | - * @since 1.11 |
|
| 1428 | - * @since 1.20 Added third param |
|
| 1429 | - * @param mixed $field_value field value used to populate the input |
|
| 1430 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1431 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1432 | - */ |
|
| 1433 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1434 | - |
|
| 1435 | - /** |
|
| 1436 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1437 | - * @since 1.17 |
|
| 1438 | - * @since 1.20 Added third param |
|
| 1439 | - * @param mixed $field_value field value used to populate the input |
|
| 1440 | - * @param GF_Field $field Gravity Forms field object |
|
| 1441 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1442 | - */ |
|
| 1443 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1425 | + /** |
|
| 1426 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1427 | + * @since 1.11 |
|
| 1428 | + * @since 1.20 Added third param |
|
| 1429 | + * @param mixed $field_value field value used to populate the input |
|
| 1430 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1431 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1432 | + */ |
|
| 1433 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1434 | + |
|
| 1435 | + /** |
|
| 1436 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1437 | + * @since 1.17 |
|
| 1438 | + * @since 1.20 Added third param |
|
| 1439 | + * @param mixed $field_value field value used to populate the input |
|
| 1440 | + * @param GF_Field $field Gravity Forms field object |
|
| 1441 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1442 | + */ |
|
| 1443 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1444 | 1444 | |
| 1445 | 1445 | return $field_value; |
| 1446 | 1446 | } |
@@ -1467,7 +1467,7 @@ discard block |
||
| 1467 | 1467 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1468 | 1468 | // expects certain field array items to be set. |
| 1469 | 1469 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
| 1470 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1470 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | 1473 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1481,61 +1481,61 @@ discard block |
||
| 1481 | 1481 | */ |
| 1482 | 1482 | case 'fileupload': |
| 1483 | 1483 | |
| 1484 | - // Set the previous value |
|
| 1485 | - $entry = $this->get_entry(); |
|
| 1484 | + // Set the previous value |
|
| 1485 | + $entry = $this->get_entry(); |
|
| 1486 | 1486 | |
| 1487 | - $input_name = 'input_'.$field->id; |
|
| 1488 | - $form_id = $form['id']; |
|
| 1487 | + $input_name = 'input_'.$field->id; |
|
| 1488 | + $form_id = $form['id']; |
|
| 1489 | 1489 | |
| 1490 | - $value = NULL; |
|
| 1490 | + $value = NULL; |
|
| 1491 | 1491 | |
| 1492 | - // Use the previous entry value as the default. |
|
| 1493 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1494 | - $value = $entry[ $field->id ]; |
|
| 1495 | - } |
|
| 1492 | + // Use the previous entry value as the default. |
|
| 1493 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1494 | + $value = $entry[ $field->id ]; |
|
| 1495 | + } |
|
| 1496 | 1496 | |
| 1497 | - // If this is a single upload file |
|
| 1498 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1499 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1500 | - $value = $file_path['url']; |
|
| 1497 | + // If this is a single upload file |
|
| 1498 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1499 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1500 | + $value = $file_path['url']; |
|
| 1501 | 1501 | |
| 1502 | - } else { |
|
| 1502 | + } else { |
|
| 1503 | 1503 | |
| 1504 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1505 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1506 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1504 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1505 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1506 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1507 | 1507 | |
| 1508 | - } |
|
| 1508 | + } |
|
| 1509 | 1509 | |
| 1510 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1510 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1511 | 1511 | |
| 1512 | - // If there are fresh uploads, process and merge them. |
|
| 1513 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1514 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1515 | - $value = empty( $value ) ? '[]' : $value; |
|
| 1516 | - $value = stripslashes_deep( $value ); |
|
| 1517 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1518 | - } |
|
| 1512 | + // If there are fresh uploads, process and merge them. |
|
| 1513 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1514 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1515 | + $value = empty( $value ) ? '[]' : $value; |
|
| 1516 | + $value = stripslashes_deep( $value ); |
|
| 1517 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1518 | + } |
|
| 1519 | 1519 | |
| 1520 | - } else { |
|
| 1520 | + } else { |
|
| 1521 | 1521 | |
| 1522 | - // A file already exists when editing an entry |
|
| 1523 | - // We set this to solve issue when file upload fields are required. |
|
| 1524 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1522 | + // A file already exists when editing an entry |
|
| 1523 | + // We set this to solve issue when file upload fields are required. |
|
| 1524 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1525 | 1525 | |
| 1526 | - } |
|
| 1526 | + } |
|
| 1527 | 1527 | |
| 1528 | - $this->entry[ $input_name ] = $value; |
|
| 1529 | - $_POST[ $input_name ] = $value; |
|
| 1528 | + $this->entry[ $input_name ] = $value; |
|
| 1529 | + $_POST[ $input_name ] = $value; |
|
| 1530 | 1530 | |
| 1531 | - break; |
|
| 1531 | + break; |
|
| 1532 | 1532 | |
| 1533 | 1533 | case 'number': |
| 1534 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1535 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1536 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1537 | - } |
|
| 1538 | - break; |
|
| 1534 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1535 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1536 | + $_POST['input_'.$field->id ] = NULL; |
|
| 1537 | + } |
|
| 1538 | + break; |
|
| 1539 | 1539 | } |
| 1540 | 1540 | |
| 1541 | 1541 | } |
@@ -1620,43 +1620,43 @@ discard block |
||
| 1620 | 1620 | case 'fileupload' : |
| 1621 | 1621 | case 'post_image': |
| 1622 | 1622 | |
| 1623 | - // in case nothing is uploaded but there are already files saved |
|
| 1624 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1625 | - $field->failed_validation = false; |
|
| 1626 | - unset( $field->validation_message ); |
|
| 1627 | - } |
|
| 1623 | + // in case nothing is uploaded but there are already files saved |
|
| 1624 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1625 | + $field->failed_validation = false; |
|
| 1626 | + unset( $field->validation_message ); |
|
| 1627 | + } |
|
| 1628 | 1628 | |
| 1629 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1630 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1629 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1630 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1631 | 1631 | |
| 1632 | - $input_name = 'input_' . $field->id; |
|
| 1633 | - //uploaded |
|
| 1634 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1632 | + $input_name = 'input_' . $field->id; |
|
| 1633 | + //uploaded |
|
| 1634 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1635 | 1635 | |
| 1636 | - //existent |
|
| 1637 | - $entry = $this->get_entry(); |
|
| 1638 | - $value = NULL; |
|
| 1639 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1640 | - $value = json_decode( $entry[ $field->id ], true ); |
|
| 1641 | - } |
|
| 1636 | + //existent |
|
| 1637 | + $entry = $this->get_entry(); |
|
| 1638 | + $value = NULL; |
|
| 1639 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1640 | + $value = json_decode( $entry[ $field->id ], true ); |
|
| 1641 | + } |
|
| 1642 | 1642 | |
| 1643 | - // count uploaded files and existent entry files |
|
| 1644 | - $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
| 1645 | - ( is_array( $value ) ? count( $value ) : 0 ); |
|
| 1643 | + // count uploaded files and existent entry files |
|
| 1644 | + $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
| 1645 | + ( is_array( $value ) ? count( $value ) : 0 ); |
|
| 1646 | 1646 | |
| 1647 | - if( $count_files > $field->maxFiles ) { |
|
| 1648 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1649 | - $field->failed_validation = 1; |
|
| 1650 | - $gv_valid = false; |
|
| 1647 | + if( $count_files > $field->maxFiles ) { |
|
| 1648 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1649 | + $field->failed_validation = 1; |
|
| 1650 | + $gv_valid = false; |
|
| 1651 | 1651 | |
| 1652 | - // in case of error make sure the newest upload files are removed from the upload input |
|
| 1653 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1654 | - } |
|
| 1652 | + // in case of error make sure the newest upload files are removed from the upload input |
|
| 1653 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1654 | + } |
|
| 1655 | 1655 | |
| 1656 | - } |
|
| 1656 | + } |
|
| 1657 | 1657 | |
| 1658 | 1658 | |
| 1659 | - break; |
|
| 1659 | + break; |
|
| 1660 | 1660 | |
| 1661 | 1661 | } |
| 1662 | 1662 | |
@@ -1667,47 +1667,47 @@ discard block |
||
| 1667 | 1667 | |
| 1668 | 1668 | switch ( $field_type ) { |
| 1669 | 1669 | |
| 1670 | - // Captchas don't need to be re-entered. |
|
| 1671 | - case 'captcha': |
|
| 1670 | + // Captchas don't need to be re-entered. |
|
| 1671 | + case 'captcha': |
|
| 1672 | 1672 | |
| 1673 | - // Post Image fields aren't editable, so we un-fail them. |
|
| 1674 | - case 'post_image': |
|
| 1675 | - $field->failed_validation = false; |
|
| 1676 | - unset( $field->validation_message ); |
|
| 1677 | - break; |
|
| 1673 | + // Post Image fields aren't editable, so we un-fail them. |
|
| 1674 | + case 'post_image': |
|
| 1675 | + $field->failed_validation = false; |
|
| 1676 | + unset( $field->validation_message ); |
|
| 1677 | + break; |
|
| 1678 | 1678 | |
| 1679 | 1679 | } |
| 1680 | 1680 | |
| 1681 | 1681 | // You can't continue inside a switch, so we do it after. |
| 1682 | 1682 | if( empty( $field->failed_validation ) ) { |
| 1683 | - continue; |
|
| 1683 | + continue; |
|
| 1684 | 1684 | } |
| 1685 | 1685 | |
| 1686 | 1686 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1687 | 1687 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1688 | 1688 | if( !empty( $field->noDuplicates ) ) { |
| 1689 | 1689 | |
| 1690 | - $entry = $this->get_entry(); |
|
| 1690 | + $entry = $this->get_entry(); |
|
| 1691 | 1691 | |
| 1692 | - // If the value of the entry is the same as the stored value |
|
| 1693 | - // Then we can assume it's not a duplicate, it's the same. |
|
| 1694 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1695 | - //if value submitted was not changed, then don't validate |
|
| 1696 | - $field->failed_validation = false; |
|
| 1692 | + // If the value of the entry is the same as the stored value |
|
| 1693 | + // Then we can assume it's not a duplicate, it's the same. |
|
| 1694 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1695 | + //if value submitted was not changed, then don't validate |
|
| 1696 | + $field->failed_validation = false; |
|
| 1697 | 1697 | |
| 1698 | - unset( $field->validation_message ); |
|
| 1698 | + unset( $field->validation_message ); |
|
| 1699 | 1699 | |
| 1700 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1700 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1701 | 1701 | |
| 1702 | - continue; |
|
| 1703 | - } |
|
| 1702 | + continue; |
|
| 1703 | + } |
|
| 1704 | 1704 | } |
| 1705 | 1705 | |
| 1706 | 1706 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1707 | 1707 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
| 1708 | - unset( $field->validation_message ); |
|
| 1709 | - $field->validation_message = false; |
|
| 1710 | - continue; |
|
| 1708 | + unset( $field->validation_message ); |
|
| 1709 | + $field->validation_message = false; |
|
| 1710 | + continue; |
|
| 1711 | 1711 | } |
| 1712 | 1712 | |
| 1713 | 1713 | $gv_valid = false; |
@@ -1771,8 +1771,8 @@ discard block |
||
| 1771 | 1771 | // Hide fields depending on admin settings |
| 1772 | 1772 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
| 1773 | 1773 | |
| 1774 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1775 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1774 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1775 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1776 | 1776 | |
| 1777 | 1777 | /** |
| 1778 | 1778 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1851,11 +1851,11 @@ discard block |
||
| 1851 | 1851 | // The edit tab has been configured, so we loop through to configured settings |
| 1852 | 1852 | foreach ( $configured_fields as $configured_field ) { |
| 1853 | 1853 | |
| 1854 | - /** @var GF_Field $field */ |
|
| 1855 | - foreach ( $fields as $field ) { |
|
| 1854 | + /** @var GF_Field $field */ |
|
| 1855 | + foreach ( $fields as $field ) { |
|
| 1856 | 1856 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
| 1857 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1858 | - break; |
|
| 1857 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1858 | + break; |
|
| 1859 | 1859 | } |
| 1860 | 1860 | |
| 1861 | 1861 | } |
@@ -1911,28 +1911,28 @@ discard block |
||
| 1911 | 1911 | */ |
| 1912 | 1912 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
| 1913 | 1913 | |
| 1914 | - /** |
|
| 1914 | + /** |
|
| 1915 | 1915 | * @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 |
| 1916 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1917 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1918 | - * @since 1.9.1 |
|
| 1919 | - * @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. |
|
| 1920 | - * @param array $form GF Form array |
|
| 1921 | - * @param int $view_id View ID |
|
| 1922 | - */ |
|
| 1923 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1924 | - |
|
| 1925 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1916 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1917 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1918 | + * @since 1.9.1 |
|
| 1919 | + * @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. |
|
| 1920 | + * @param array $form GF Form array |
|
| 1921 | + * @param int $view_id View ID |
|
| 1922 | + */ |
|
| 1923 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1924 | + |
|
| 1925 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1926 | 1926 | foreach( $fields as $k => $field ) { |
| 1927 | 1927 | if( $field->adminOnly ) { |
| 1928 | - unset( $fields[ $k ] ); |
|
| 1928 | + unset( $fields[ $k ] ); |
|
| 1929 | 1929 | } |
| 1930 | 1930 | } |
| 1931 | 1931 | return array_values( $fields ); |
| 1932 | 1932 | } |
| 1933 | 1933 | |
| 1934 | - foreach( $fields as &$field ) { |
|
| 1935 | - $field->adminOnly = false; |
|
| 1934 | + foreach( $fields as &$field ) { |
|
| 1935 | + $field->adminOnly = false; |
|
| 1936 | 1936 | } |
| 1937 | 1937 | |
| 1938 | 1938 | return $fields; |
@@ -1952,13 +1952,13 @@ discard block |
||
| 1952 | 1952 | */ |
| 1953 | 1953 | private function unselect_default_values( $form ) { |
| 1954 | 1954 | |
| 1955 | - foreach ( $form['fields'] as &$field ) { |
|
| 1955 | + foreach ( $form['fields'] as &$field ) { |
|
| 1956 | 1956 | |
| 1957 | 1957 | if ( empty( $field->choices ) ) { |
| 1958 | - continue; |
|
| 1958 | + continue; |
|
| 1959 | 1959 | } |
| 1960 | 1960 | |
| 1961 | - foreach ( $field->choices as &$choice ) { |
|
| 1961 | + foreach ( $field->choices as &$choice ) { |
|
| 1962 | 1962 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 1963 | 1963 | $choice['isSelected'] = false; |
| 1964 | 1964 | } |
@@ -1995,36 +1995,36 @@ discard block |
||
| 1995 | 1995 | |
| 1996 | 1996 | if( 'checkbox' === $field->type ) { |
| 1997 | 1997 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1998 | - $input_id = $input['id']; |
|
| 1999 | - $choice = $field->choices[ $key ]; |
|
| 2000 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 2001 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 2002 | - if( $match ) { |
|
| 2003 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 2004 | - } |
|
| 1998 | + $input_id = $input['id']; |
|
| 1999 | + $choice = $field->choices[ $key ]; |
|
| 2000 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 2001 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 2002 | + if( $match ) { |
|
| 2003 | + $field->choices[ $key ]['isSelected'] = true; |
|
| 2004 | + } |
|
| 2005 | 2005 | } |
| 2006 | 2006 | } else { |
| 2007 | 2007 | |
| 2008 | 2008 | // We need to run through each field to set the default values |
| 2009 | 2009 | foreach ( $this->entry as $field_id => $field_value ) { |
| 2010 | 2010 | |
| 2011 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 2011 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 2012 | 2012 | |
| 2013 | - if( 'list' === $field->type ) { |
|
| 2014 | - $list_rows = maybe_unserialize( $field_value ); |
|
| 2013 | + if( 'list' === $field->type ) { |
|
| 2014 | + $list_rows = maybe_unserialize( $field_value ); |
|
| 2015 | 2015 | |
| 2016 | - $list_field_value = array(); |
|
| 2017 | - foreach ( (array) $list_rows as $row ) { |
|
| 2018 | - foreach ( (array) $row as $column ) { |
|
| 2019 | - $list_field_value[] = $column; |
|
| 2020 | - } |
|
| 2021 | - } |
|
| 2016 | + $list_field_value = array(); |
|
| 2017 | + foreach ( (array) $list_rows as $row ) { |
|
| 2018 | + foreach ( (array) $row as $column ) { |
|
| 2019 | + $list_field_value[] = $column; |
|
| 2020 | + } |
|
| 2021 | + } |
|
| 2022 | 2022 | |
| 2023 | - $field->defaultValue = serialize( $list_field_value ); |
|
| 2024 | - } else { |
|
| 2025 | - $field->defaultValue = $field_value; |
|
| 2026 | - } |
|
| 2027 | - } |
|
| 2023 | + $field->defaultValue = serialize( $list_field_value ); |
|
| 2024 | + } else { |
|
| 2025 | + $field->defaultValue = $field_value; |
|
| 2026 | + } |
|
| 2027 | + } |
|
| 2028 | 2028 | } |
| 2029 | 2029 | } |
| 2030 | 2030 | } |
@@ -2085,7 +2085,7 @@ discard block |
||
| 2085 | 2085 | foreach ( $form['fields'] as &$field ) { |
| 2086 | 2086 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
| 2087 | 2087 | |
| 2088 | - list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
| 2088 | + list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
| 2089 | 2089 | |
| 2090 | 2090 | if ( $field['id'] == $rule_field_id ) { |
| 2091 | 2091 | unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
@@ -2136,7 +2136,7 @@ discard block |
||
| 2136 | 2136 | return $has_conditional_logic; |
| 2137 | 2137 | } |
| 2138 | 2138 | |
| 2139 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 2139 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 2140 | 2140 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
| 2141 | 2141 | } |
| 2142 | 2142 | |
@@ -2203,14 +2203,14 @@ discard block |
||
| 2203 | 2203 | |
| 2204 | 2204 | if( $echo && $error !== true ) { |
| 2205 | 2205 | |
| 2206 | - $error = esc_html( $error ); |
|
| 2206 | + $error = esc_html( $error ); |
|
| 2207 | 2207 | |
| 2208 | - /** |
|
| 2209 | - * @since 1.9 |
|
| 2210 | - */ |
|
| 2211 | - if ( ! empty( $this->entry ) ) { |
|
| 2212 | - $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;" ) ); |
|
| 2213 | - } |
|
| 2208 | + /** |
|
| 2209 | + * @since 1.9 |
|
| 2210 | + */ |
|
| 2211 | + if ( ! empty( $this->entry ) ) { |
|
| 2212 | + $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;" ) ); |
|
| 2213 | + } |
|
| 2214 | 2214 | |
| 2215 | 2215 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
| 2216 | 2216 | } |