@@ -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 ) ) { |
@@ -1168,7 +1168,7 @@ discard block |
||
| 1168 | 1168 | |
| 1169 | 1169 | ob_get_clean(); |
| 1170 | 1170 | |
| 1171 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1171 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1172 | 1172 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
| 1173 | 1173 | remove_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
| 1174 | 1174 | remove_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
@@ -1224,7 +1224,7 @@ discard block |
||
| 1224 | 1224 | |
| 1225 | 1225 | // for now we don't support Save and Continue feature. |
| 1226 | 1226 | if( ! self::$supports_save_and_continue ) { |
| 1227 | - unset( $form['save'] ); |
|
| 1227 | + unset( $form['save'] ); |
|
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | 1230 | $form = $this->unselect_default_values( $form ); |
@@ -1251,30 +1251,30 @@ discard block |
||
| 1251 | 1251 | return $field_content; |
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | - $message = null; |
|
| 1254 | + $message = null; |
|
| 1255 | 1255 | |
| 1256 | - // First, make sure they have the capability to edit the post. |
|
| 1257 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1256 | + // First, make sure they have the capability to edit the post. |
|
| 1257 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1258 | 1258 | |
| 1259 | - /** |
|
| 1260 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1261 | - * @param string $message The existing "You don't have permission..." text |
|
| 1262 | - */ |
|
| 1263 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1259 | + /** |
|
| 1260 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1261 | + * @param string $message The existing "You don't have permission..." text |
|
| 1262 | + */ |
|
| 1263 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1264 | 1264 | |
| 1265 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1266 | - /** |
|
| 1267 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1268 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1269 | - */ |
|
| 1270 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1271 | - } |
|
| 1265 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1266 | + /** |
|
| 1267 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1268 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1269 | + */ |
|
| 1270 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1271 | + } |
|
| 1272 | 1272 | |
| 1273 | - if( $message ) { |
|
| 1274 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1275 | - } |
|
| 1273 | + if( $message ) { |
|
| 1274 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1275 | + } |
|
| 1276 | 1276 | |
| 1277 | - return $field_content; |
|
| 1277 | + return $field_content; |
|
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | 1280 | /** |
@@ -1302,7 +1302,7 @@ discard block |
||
| 1302 | 1302 | || ! empty( $field_content ) |
| 1303 | 1303 | || in_array( $field->type, array( 'honeypot' ) ) |
| 1304 | 1304 | ) { |
| 1305 | - return $field_content; |
|
| 1305 | + return $field_content; |
|
| 1306 | 1306 | } |
| 1307 | 1307 | |
| 1308 | 1308 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1310,24 +1310,24 @@ discard block |
||
| 1310 | 1310 | |
| 1311 | 1311 | $field_value = $this->get_field_value( $field ); |
| 1312 | 1312 | |
| 1313 | - // Prevent any PHP warnings, like undefined index |
|
| 1314 | - ob_start(); |
|
| 1313 | + // Prevent any PHP warnings, like undefined index |
|
| 1314 | + ob_start(); |
|
| 1315 | 1315 | |
| 1316 | - $return = null; |
|
| 1316 | + $return = null; |
|
| 1317 | 1317 | |
| 1318 | 1318 | /** @var GravityView_Field $gv_field */ |
| 1319 | 1319 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
| 1320 | 1320 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1321 | 1321 | } else { |
| 1322 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1323 | - } |
|
| 1322 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1323 | + } |
|
| 1324 | 1324 | |
| 1325 | - // If there was output, it's an error |
|
| 1326 | - $warnings = ob_get_clean(); |
|
| 1325 | + // If there was output, it's an error |
|
| 1326 | + $warnings = ob_get_clean(); |
|
| 1327 | 1327 | |
| 1328 | - if( !empty( $warnings ) ) { |
|
| 1329 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1330 | - } |
|
| 1328 | + if( !empty( $warnings ) ) { |
|
| 1329 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1330 | + } |
|
| 1331 | 1331 | |
| 1332 | 1332 | return $return; |
| 1333 | 1333 | } |
@@ -1362,8 +1362,8 @@ discard block |
||
| 1362 | 1362 | $input_id = strval( $input['id'] ); |
| 1363 | 1363 | |
| 1364 | 1364 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1365 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1366 | - $allow_pre_populated = false; |
|
| 1365 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1366 | + $allow_pre_populated = false; |
|
| 1367 | 1367 | } |
| 1368 | 1368 | |
| 1369 | 1369 | } |
@@ -1387,7 +1387,7 @@ discard block |
||
| 1387 | 1387 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
| 1388 | 1388 | $categories = array(); |
| 1389 | 1389 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1390 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1390 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1391 | 1391 | } |
| 1392 | 1392 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1393 | 1393 | } |
@@ -1397,25 +1397,25 @@ discard block |
||
| 1397 | 1397 | // if value is empty get the default value if defined |
| 1398 | 1398 | $field_value = $field->get_value_default_if_empty( $field_value ); |
| 1399 | 1399 | |
| 1400 | - /** |
|
| 1401 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1402 | - * @since 1.11 |
|
| 1403 | - * @since 1.20 Added third param |
|
| 1404 | - * @param mixed $field_value field value used to populate the input |
|
| 1405 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1406 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1407 | - */ |
|
| 1408 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1409 | - |
|
| 1410 | - /** |
|
| 1411 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1412 | - * @since 1.17 |
|
| 1413 | - * @since 1.20 Added third param |
|
| 1414 | - * @param mixed $field_value field value used to populate the input |
|
| 1415 | - * @param GF_Field $field Gravity Forms field object |
|
| 1416 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1417 | - */ |
|
| 1418 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1400 | + /** |
|
| 1401 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1402 | + * @since 1.11 |
|
| 1403 | + * @since 1.20 Added third param |
|
| 1404 | + * @param mixed $field_value field value used to populate the input |
|
| 1405 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1406 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1407 | + */ |
|
| 1408 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1409 | + |
|
| 1410 | + /** |
|
| 1411 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1412 | + * @since 1.17 |
|
| 1413 | + * @since 1.20 Added third param |
|
| 1414 | + * @param mixed $field_value field value used to populate the input |
|
| 1415 | + * @param GF_Field $field Gravity Forms field object |
|
| 1416 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1417 | + */ |
|
| 1418 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1419 | 1419 | |
| 1420 | 1420 | return $field_value; |
| 1421 | 1421 | } |
@@ -1442,7 +1442,7 @@ discard block |
||
| 1442 | 1442 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1443 | 1443 | // expects certain field array items to be set. |
| 1444 | 1444 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
| 1445 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1445 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1446 | 1446 | } |
| 1447 | 1447 | |
| 1448 | 1448 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1456,61 +1456,61 @@ discard block |
||
| 1456 | 1456 | */ |
| 1457 | 1457 | case 'fileupload': |
| 1458 | 1458 | |
| 1459 | - // Set the previous value |
|
| 1460 | - $entry = $this->get_entry(); |
|
| 1459 | + // Set the previous value |
|
| 1460 | + $entry = $this->get_entry(); |
|
| 1461 | 1461 | |
| 1462 | - $input_name = 'input_'.$field->id; |
|
| 1463 | - $form_id = $form['id']; |
|
| 1462 | + $input_name = 'input_'.$field->id; |
|
| 1463 | + $form_id = $form['id']; |
|
| 1464 | 1464 | |
| 1465 | - $value = NULL; |
|
| 1465 | + $value = NULL; |
|
| 1466 | 1466 | |
| 1467 | - // Use the previous entry value as the default. |
|
| 1468 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1469 | - $value = $entry[ $field->id ]; |
|
| 1470 | - } |
|
| 1467 | + // Use the previous entry value as the default. |
|
| 1468 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1469 | + $value = $entry[ $field->id ]; |
|
| 1470 | + } |
|
| 1471 | 1471 | |
| 1472 | - // If this is a single upload file |
|
| 1473 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1474 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1475 | - $value = $file_path['url']; |
|
| 1472 | + // If this is a single upload file |
|
| 1473 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1474 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1475 | + $value = $file_path['url']; |
|
| 1476 | 1476 | |
| 1477 | - } else { |
|
| 1477 | + } else { |
|
| 1478 | 1478 | |
| 1479 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1480 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1481 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1479 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1480 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1481 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1482 | 1482 | |
| 1483 | - } |
|
| 1483 | + } |
|
| 1484 | 1484 | |
| 1485 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1485 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1486 | 1486 | |
| 1487 | - // If there are fresh uploads, process and merge them. |
|
| 1488 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1489 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1490 | - $value = empty( $value ) ? '[]' : $value; |
|
| 1491 | - $value = stripslashes_deep( $value ); |
|
| 1492 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1493 | - } |
|
| 1487 | + // If there are fresh uploads, process and merge them. |
|
| 1488 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1489 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1490 | + $value = empty( $value ) ? '[]' : $value; |
|
| 1491 | + $value = stripslashes_deep( $value ); |
|
| 1492 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1493 | + } |
|
| 1494 | 1494 | |
| 1495 | - } else { |
|
| 1495 | + } else { |
|
| 1496 | 1496 | |
| 1497 | - // A file already exists when editing an entry |
|
| 1498 | - // We set this to solve issue when file upload fields are required. |
|
| 1499 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1497 | + // A file already exists when editing an entry |
|
| 1498 | + // We set this to solve issue when file upload fields are required. |
|
| 1499 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1500 | 1500 | |
| 1501 | - } |
|
| 1501 | + } |
|
| 1502 | 1502 | |
| 1503 | - $this->entry[ $input_name ] = $value; |
|
| 1504 | - $_POST[ $input_name ] = $value; |
|
| 1503 | + $this->entry[ $input_name ] = $value; |
|
| 1504 | + $_POST[ $input_name ] = $value; |
|
| 1505 | 1505 | |
| 1506 | - break; |
|
| 1506 | + break; |
|
| 1507 | 1507 | |
| 1508 | 1508 | case 'number': |
| 1509 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1510 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1511 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1512 | - } |
|
| 1513 | - break; |
|
| 1509 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1510 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1511 | + $_POST['input_'.$field->id ] = NULL; |
|
| 1512 | + } |
|
| 1513 | + break; |
|
| 1514 | 1514 | } |
| 1515 | 1515 | |
| 1516 | 1516 | } |
@@ -1595,43 +1595,43 @@ discard block |
||
| 1595 | 1595 | case 'fileupload' : |
| 1596 | 1596 | case 'post_image': |
| 1597 | 1597 | |
| 1598 | - // in case nothing is uploaded but there are already files saved |
|
| 1599 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1600 | - $field->failed_validation = false; |
|
| 1601 | - unset( $field->validation_message ); |
|
| 1602 | - } |
|
| 1598 | + // in case nothing is uploaded but there are already files saved |
|
| 1599 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1600 | + $field->failed_validation = false; |
|
| 1601 | + unset( $field->validation_message ); |
|
| 1602 | + } |
|
| 1603 | 1603 | |
| 1604 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1605 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1604 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1605 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1606 | 1606 | |
| 1607 | - $input_name = 'input_' . $field->id; |
|
| 1608 | - //uploaded |
|
| 1609 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1607 | + $input_name = 'input_' . $field->id; |
|
| 1608 | + //uploaded |
|
| 1609 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1610 | 1610 | |
| 1611 | - //existent |
|
| 1612 | - $entry = $this->get_entry(); |
|
| 1613 | - $value = NULL; |
|
| 1614 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1615 | - $value = json_decode( $entry[ $field->id ], true ); |
|
| 1616 | - } |
|
| 1611 | + //existent |
|
| 1612 | + $entry = $this->get_entry(); |
|
| 1613 | + $value = NULL; |
|
| 1614 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1615 | + $value = json_decode( $entry[ $field->id ], true ); |
|
| 1616 | + } |
|
| 1617 | 1617 | |
| 1618 | - // count uploaded files and existent entry files |
|
| 1619 | - $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
| 1620 | - ( is_array( $value ) ? count( $value ) : 0 ); |
|
| 1618 | + // count uploaded files and existent entry files |
|
| 1619 | + $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
|
| 1620 | + ( is_array( $value ) ? count( $value ) : 0 ); |
|
| 1621 | 1621 | |
| 1622 | - if( $count_files > $field->maxFiles ) { |
|
| 1623 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1624 | - $field->failed_validation = 1; |
|
| 1625 | - $gv_valid = false; |
|
| 1622 | + if( $count_files > $field->maxFiles ) { |
|
| 1623 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1624 | + $field->failed_validation = 1; |
|
| 1625 | + $gv_valid = false; |
|
| 1626 | 1626 | |
| 1627 | - // in case of error make sure the newest upload files are removed from the upload input |
|
| 1628 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1629 | - } |
|
| 1627 | + // in case of error make sure the newest upload files are removed from the upload input |
|
| 1628 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1629 | + } |
|
| 1630 | 1630 | |
| 1631 | - } |
|
| 1631 | + } |
|
| 1632 | 1632 | |
| 1633 | 1633 | |
| 1634 | - break; |
|
| 1634 | + break; |
|
| 1635 | 1635 | |
| 1636 | 1636 | } |
| 1637 | 1637 | |
@@ -1642,47 +1642,47 @@ discard block |
||
| 1642 | 1642 | |
| 1643 | 1643 | switch ( $field_type ) { |
| 1644 | 1644 | |
| 1645 | - // Captchas don't need to be re-entered. |
|
| 1646 | - case 'captcha': |
|
| 1645 | + // Captchas don't need to be re-entered. |
|
| 1646 | + case 'captcha': |
|
| 1647 | 1647 | |
| 1648 | - // Post Image fields aren't editable, so we un-fail them. |
|
| 1649 | - case 'post_image': |
|
| 1650 | - $field->failed_validation = false; |
|
| 1651 | - unset( $field->validation_message ); |
|
| 1652 | - break; |
|
| 1648 | + // Post Image fields aren't editable, so we un-fail them. |
|
| 1649 | + case 'post_image': |
|
| 1650 | + $field->failed_validation = false; |
|
| 1651 | + unset( $field->validation_message ); |
|
| 1652 | + break; |
|
| 1653 | 1653 | |
| 1654 | 1654 | } |
| 1655 | 1655 | |
| 1656 | 1656 | // You can't continue inside a switch, so we do it after. |
| 1657 | 1657 | if( empty( $field->failed_validation ) ) { |
| 1658 | - continue; |
|
| 1658 | + continue; |
|
| 1659 | 1659 | } |
| 1660 | 1660 | |
| 1661 | 1661 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1662 | 1662 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1663 | 1663 | if( !empty( $field->noDuplicates ) ) { |
| 1664 | 1664 | |
| 1665 | - $entry = $this->get_entry(); |
|
| 1665 | + $entry = $this->get_entry(); |
|
| 1666 | 1666 | |
| 1667 | - // If the value of the entry is the same as the stored value |
|
| 1668 | - // Then we can assume it's not a duplicate, it's the same. |
|
| 1669 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1670 | - //if value submitted was not changed, then don't validate |
|
| 1671 | - $field->failed_validation = false; |
|
| 1667 | + // If the value of the entry is the same as the stored value |
|
| 1668 | + // Then we can assume it's not a duplicate, it's the same. |
|
| 1669 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1670 | + //if value submitted was not changed, then don't validate |
|
| 1671 | + $field->failed_validation = false; |
|
| 1672 | 1672 | |
| 1673 | - unset( $field->validation_message ); |
|
| 1673 | + unset( $field->validation_message ); |
|
| 1674 | 1674 | |
| 1675 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1675 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1676 | 1676 | |
| 1677 | - continue; |
|
| 1678 | - } |
|
| 1677 | + continue; |
|
| 1678 | + } |
|
| 1679 | 1679 | } |
| 1680 | 1680 | |
| 1681 | 1681 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1682 | 1682 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
| 1683 | - unset( $field->validation_message ); |
|
| 1684 | - $field->validation_message = false; |
|
| 1685 | - continue; |
|
| 1683 | + unset( $field->validation_message ); |
|
| 1684 | + $field->validation_message = false; |
|
| 1685 | + continue; |
|
| 1686 | 1686 | } |
| 1687 | 1687 | |
| 1688 | 1688 | $gv_valid = false; |
@@ -1746,8 +1746,8 @@ discard block |
||
| 1746 | 1746 | // Hide fields depending on admin settings |
| 1747 | 1747 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
| 1748 | 1748 | |
| 1749 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1750 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1749 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1750 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1751 | 1751 | |
| 1752 | 1752 | /** |
| 1753 | 1753 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1826,11 +1826,11 @@ discard block |
||
| 1826 | 1826 | // The edit tab has been configured, so we loop through to configured settings |
| 1827 | 1827 | foreach ( $configured_fields as $configured_field ) { |
| 1828 | 1828 | |
| 1829 | - /** @var GF_Field $field */ |
|
| 1830 | - foreach ( $fields as $field ) { |
|
| 1829 | + /** @var GF_Field $field */ |
|
| 1830 | + foreach ( $fields as $field ) { |
|
| 1831 | 1831 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
| 1832 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1833 | - break; |
|
| 1832 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1833 | + break; |
|
| 1834 | 1834 | } |
| 1835 | 1835 | |
| 1836 | 1836 | } |
@@ -1886,28 +1886,28 @@ discard block |
||
| 1886 | 1886 | */ |
| 1887 | 1887 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
| 1888 | 1888 | |
| 1889 | - /** |
|
| 1889 | + /** |
|
| 1890 | 1890 | * @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 |
| 1891 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1892 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1893 | - * @since 1.9.1 |
|
| 1894 | - * @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. |
|
| 1895 | - * @param array $form GF Form array |
|
| 1896 | - * @param int $view_id View ID |
|
| 1897 | - */ |
|
| 1898 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1899 | - |
|
| 1900 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1891 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1892 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1893 | + * @since 1.9.1 |
|
| 1894 | + * @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. |
|
| 1895 | + * @param array $form GF Form array |
|
| 1896 | + * @param int $view_id View ID |
|
| 1897 | + */ |
|
| 1898 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1899 | + |
|
| 1900 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1901 | 1901 | foreach( $fields as $k => $field ) { |
| 1902 | 1902 | if( $field->adminOnly ) { |
| 1903 | - unset( $fields[ $k ] ); |
|
| 1903 | + unset( $fields[ $k ] ); |
|
| 1904 | 1904 | } |
| 1905 | 1905 | } |
| 1906 | 1906 | return array_values( $fields ); |
| 1907 | 1907 | } |
| 1908 | 1908 | |
| 1909 | - foreach( $fields as &$field ) { |
|
| 1910 | - $field->adminOnly = false; |
|
| 1909 | + foreach( $fields as &$field ) { |
|
| 1910 | + $field->adminOnly = false; |
|
| 1911 | 1911 | } |
| 1912 | 1912 | |
| 1913 | 1913 | return $fields; |
@@ -1927,13 +1927,13 @@ discard block |
||
| 1927 | 1927 | */ |
| 1928 | 1928 | private function unselect_default_values( $form ) { |
| 1929 | 1929 | |
| 1930 | - foreach ( $form['fields'] as &$field ) { |
|
| 1930 | + foreach ( $form['fields'] as &$field ) { |
|
| 1931 | 1931 | |
| 1932 | 1932 | if ( empty( $field->choices ) ) { |
| 1933 | - continue; |
|
| 1933 | + continue; |
|
| 1934 | 1934 | } |
| 1935 | 1935 | |
| 1936 | - foreach ( $field->choices as &$choice ) { |
|
| 1936 | + foreach ( $field->choices as &$choice ) { |
|
| 1937 | 1937 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 1938 | 1938 | $choice['isSelected'] = false; |
| 1939 | 1939 | } |
@@ -1970,36 +1970,36 @@ discard block |
||
| 1970 | 1970 | |
| 1971 | 1971 | if( 'checkbox' === $field->type ) { |
| 1972 | 1972 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1973 | - $input_id = $input['id']; |
|
| 1974 | - $choice = $field->choices[ $key ]; |
|
| 1975 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 1976 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 1977 | - if( $match ) { |
|
| 1978 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 1979 | - } |
|
| 1973 | + $input_id = $input['id']; |
|
| 1974 | + $choice = $field->choices[ $key ]; |
|
| 1975 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 1976 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 1977 | + if( $match ) { |
|
| 1978 | + $field->choices[ $key ]['isSelected'] = true; |
|
| 1979 | + } |
|
| 1980 | 1980 | } |
| 1981 | 1981 | } else { |
| 1982 | 1982 | |
| 1983 | 1983 | // We need to run through each field to set the default values |
| 1984 | 1984 | foreach ( $this->entry as $field_id => $field_value ) { |
| 1985 | 1985 | |
| 1986 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1986 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1987 | 1987 | |
| 1988 | - if( 'list' === $field->type ) { |
|
| 1989 | - $list_rows = maybe_unserialize( $field_value ); |
|
| 1988 | + if( 'list' === $field->type ) { |
|
| 1989 | + $list_rows = maybe_unserialize( $field_value ); |
|
| 1990 | 1990 | |
| 1991 | - $list_field_value = array(); |
|
| 1992 | - foreach ( (array) $list_rows as $row ) { |
|
| 1993 | - foreach ( (array) $row as $column ) { |
|
| 1994 | - $list_field_value[] = $column; |
|
| 1995 | - } |
|
| 1996 | - } |
|
| 1991 | + $list_field_value = array(); |
|
| 1992 | + foreach ( (array) $list_rows as $row ) { |
|
| 1993 | + foreach ( (array) $row as $column ) { |
|
| 1994 | + $list_field_value[] = $column; |
|
| 1995 | + } |
|
| 1996 | + } |
|
| 1997 | 1997 | |
| 1998 | - $field->defaultValue = serialize( $list_field_value ); |
|
| 1999 | - } else { |
|
| 2000 | - $field->defaultValue = $field_value; |
|
| 2001 | - } |
|
| 2002 | - } |
|
| 1998 | + $field->defaultValue = serialize( $list_field_value ); |
|
| 1999 | + } else { |
|
| 2000 | + $field->defaultValue = $field_value; |
|
| 2001 | + } |
|
| 2002 | + } |
|
| 2003 | 2003 | } |
| 2004 | 2004 | } |
| 2005 | 2005 | } |
@@ -2060,7 +2060,7 @@ discard block |
||
| 2060 | 2060 | foreach ( $form['fields'] as &$field ) { |
| 2061 | 2061 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
| 2062 | 2062 | |
| 2063 | - list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
| 2063 | + list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
|
| 2064 | 2064 | |
| 2065 | 2065 | if ( $field['id'] == $rule_field_id ) { |
| 2066 | 2066 | unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
@@ -2111,7 +2111,7 @@ discard block |
||
| 2111 | 2111 | return $has_conditional_logic; |
| 2112 | 2112 | } |
| 2113 | 2113 | |
| 2114 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 2114 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 2115 | 2115 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
| 2116 | 2116 | } |
| 2117 | 2117 | |
@@ -2178,14 +2178,14 @@ discard block |
||
| 2178 | 2178 | |
| 2179 | 2179 | if( $echo && $error !== true ) { |
| 2180 | 2180 | |
| 2181 | - $error = esc_html( $error ); |
|
| 2181 | + $error = esc_html( $error ); |
|
| 2182 | 2182 | |
| 2183 | - /** |
|
| 2184 | - * @since 1.9 |
|
| 2185 | - */ |
|
| 2186 | - if ( ! empty( $this->entry ) ) { |
|
| 2187 | - $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;" ) ); |
|
| 2188 | - } |
|
| 2183 | + /** |
|
| 2184 | + * @since 1.9 |
|
| 2185 | + */ |
|
| 2186 | + if ( ! empty( $this->entry ) ) { |
|
| 2187 | + $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;" ) ); |
|
| 2188 | + } |
|
| 2189 | 2189 | |
| 2190 | 2190 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
| 2191 | 2191 | } |
@@ -134,16 +134,16 @@ discard block |
||
| 134 | 134 | function load() { |
| 135 | 135 | |
| 136 | 136 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
| 137 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
| 137 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
| 138 | 138 | |
| 139 | 139 | // Don't display an embedded form when editing an entry |
| 140 | 140 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
| 141 | 141 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
| 142 | 142 | |
| 143 | 143 | // Stop Gravity Forms processing what is ours! |
| 144 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
| 144 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
| 145 | 145 | |
| 146 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
| 146 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
| 147 | 147 | |
| 148 | 148 | add_action( 'gravityview_edit_entry', array( $this, 'init' ), 10, 4 ); |
| 149 | 149 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
| 155 | 155 | |
| 156 | 156 | // Add fields expected by GFFormDisplay::validate() |
| 157 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
| 157 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
| 158 | 158 | |
| 159 | 159 | // Fix multiselect value for GF 2.2 |
| 160 | 160 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -171,8 +171,8 @@ discard block |
||
| 171 | 171 | * @return void |
| 172 | 172 | */ |
| 173 | 173 | public function prevent_render_form() { |
| 174 | - if( $this->is_edit_entry() ) { |
|
| 175 | - if( 'wp_head' === current_filter() ) { |
|
| 174 | + if ( $this->is_edit_entry() ) { |
|
| 175 | + if ( 'wp_head' === current_filter() ) { |
|
| 176 | 176 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
| 177 | 177 | } else { |
| 178 | 178 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -187,14 +187,14 @@ 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 | |
| 194 | 194 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] Removing GFForms::maybe_process_form() action.' ); |
| 195 | 195 | |
| 196 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
| 197 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 196 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
| 197 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | */ |
| 204 | 204 | public function is_edit_entry() { |
| 205 | 205 | |
| 206 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
| 206 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
| 207 | 207 | |
| 208 | 208 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
| 209 | 209 | } |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @return boolean |
| 215 | 215 | */ |
| 216 | 216 | public function is_edit_entry_submission() { |
| 217 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
| 217 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -227,16 +227,16 @@ discard block |
||
| 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(); |
| 235 | - $this->form_id = $this->entry['form_id']; |
|
| 235 | + $this->form_id = $this->entry[ 'form_id' ]; |
|
| 236 | 236 | $this->view_id = $gravityview_view->getViewId(); |
| 237 | 237 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
| 238 | 238 | |
| 239 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
| 239 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | |
@@ -295,9 +295,9 @@ discard block |
||
| 295 | 295 | private function print_scripts() { |
| 296 | 296 | $gravityview_view = GravityView_View::getInstance(); |
| 297 | 297 | |
| 298 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 298 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 299 | 299 | |
| 300 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
| 300 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
| 301 | 301 | |
| 302 | 302 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
| 303 | 303 | |
@@ -313,19 +313,19 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | private function process_save( $gv_data ) { |
| 315 | 315 | |
| 316 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
| 316 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
| 317 | 317 | return; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | // Make sure the entry, view, and form IDs are all correct |
| 321 | 321 | $valid = $this->verify_nonce(); |
| 322 | 322 | |
| 323 | - if ( !$valid ) { |
|
| 323 | + if ( ! $valid ) { |
|
| 324 | 324 | gravityview()->log->error( 'Nonce validation failed.' ); |
| 325 | 325 | return; |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
| 328 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
| 329 | 329 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
| 330 | 330 | return; |
| 331 | 331 | } |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | $this->validate(); |
| 338 | 338 | |
| 339 | - if( $this->is_valid ) { |
|
| 339 | + if ( $this->is_valid ) { |
|
| 340 | 340 | |
| 341 | 341 | gravityview()->log->debug( 'Submission is valid.' ); |
| 342 | 342 | |
@@ -348,15 +348,15 @@ discard block |
||
| 348 | 348 | /** |
| 349 | 349 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
| 350 | 350 | */ |
| 351 | - unset( $_GET['page'] ); |
|
| 351 | + unset( $_GET[ 'page' ] ); |
|
| 352 | 352 | |
| 353 | - $date_created = $this->entry['date_created']; |
|
| 353 | + $date_created = $this->entry[ 'date_created' ]; |
|
| 354 | 354 | |
| 355 | 355 | /** |
| 356 | 356 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
| 357 | 357 | * @since 1.17.2 |
| 358 | 358 | */ |
| 359 | - unset( $this->entry['date_created'] ); |
|
| 359 | + unset( $this->entry[ 'date_created' ] ); |
|
| 360 | 360 | |
| 361 | 361 | /** |
| 362 | 362 | * @action `gravityview/edit_entry/before_update` Perform an action after the entry has been updated using Edit Entry |
@@ -366,14 +366,14 @@ discard block |
||
| 366 | 366 | * @param GravityView_Edit_Entry_Render $this This object |
| 367 | 367 | * @param GravityView_View_Data $gv_data The View data |
| 368 | 368 | */ |
| 369 | - do_action( 'gravityview/edit_entry/before_update', $form, $this->entry['id'], $this, $gv_data ); |
|
| 369 | + do_action( 'gravityview/edit_entry/before_update', $form, $this->entry[ 'id' ], $this, $gv_data ); |
|
| 370 | 370 | |
| 371 | 371 | GFFormsModel::save_lead( $form, $this->entry ); |
| 372 | 372 | |
| 373 | 373 | // Delete the values for hidden inputs |
| 374 | 374 | $this->unset_hidden_field_values(); |
| 375 | 375 | |
| 376 | - $this->entry['date_created'] = $date_created; |
|
| 376 | + $this->entry[ 'date_created' ] = $date_created; |
|
| 377 | 377 | |
| 378 | 378 | // Process calculation fields |
| 379 | 379 | $this->update_calculation_fields(); |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | * @param GravityView_Edit_Entry_Render $this This object |
| 396 | 396 | * @param GravityView_View_Data $gv_data The View data |
| 397 | 397 | */ |
| 398 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
| 398 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
| 399 | 399 | |
| 400 | 400 | } else { |
| 401 | 401 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -425,16 +425,16 @@ discard block |
||
| 425 | 425 | |
| 426 | 426 | $this->unset_hidden_calculations = array(); |
| 427 | 427 | |
| 428 | - if( ! $unset_hidden_field_values ) { |
|
| 428 | + if ( ! $unset_hidden_field_values ) { |
|
| 429 | 429 | return; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 433 | 433 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 434 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
| 434 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
| 435 | 435 | } else { |
| 436 | 436 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 437 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
| 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 | 440 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -451,11 +451,11 @@ discard block |
||
| 451 | 451 | |
| 452 | 452 | $empty_value = $field->get_value_save_entry( |
| 453 | 453 | is_array( $field->get_entry_inputs() ) ? array() : '', |
| 454 | - $this->form, '', $this->entry['id'], $this->entry |
|
| 454 | + $this->form, '', $this->entry[ 'id' ], $this->entry |
|
| 455 | 455 | ); |
| 456 | 456 | |
| 457 | 457 | if ( $field->has_calculation() ) { |
| 458 | - $this->unset_hidden_calculations[] = $field->id; // Unset |
|
| 458 | + $this->unset_hidden_calculations[ ] = $field->id; // Unset |
|
| 459 | 459 | $empty_value = ''; |
| 460 | 460 | } |
| 461 | 461 | |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | /** No file is being uploaded. */ |
| 529 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 529 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 530 | 530 | /** So return the original upload */ |
| 531 | 531 | return $entry[ $input_id ]; |
| 532 | 532 | } |
@@ -544,11 +544,11 @@ discard block |
||
| 544 | 544 | * @return mixed |
| 545 | 545 | */ |
| 546 | 546 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
| 547 | - if( ! $this->is_edit_entry() ) { |
|
| 547 | + if ( ! $this->is_edit_entry() ) { |
|
| 548 | 548 | return $plupload_init; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
| 551 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
| 552 | 552 | |
| 553 | 553 | return $plupload_init; |
| 554 | 554 | } |
@@ -563,27 +563,27 @@ discard block |
||
| 563 | 563 | $form = $this->filter_conditional_logic( $this->form ); |
| 564 | 564 | |
| 565 | 565 | /** @var GF_Field $field */ |
| 566 | - foreach( $form['fields'] as $k => &$field ) { |
|
| 566 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
| 567 | 567 | |
| 568 | 568 | /** |
| 569 | 569 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
| 570 | 570 | * @since 1.16.3 |
| 571 | 571 | * @var GF_Field $field |
| 572 | 572 | */ |
| 573 | - if( $field->has_calculation() ) { |
|
| 574 | - unset( $form['fields'][ $k ] ); |
|
| 573 | + if ( $field->has_calculation() ) { |
|
| 574 | + unset( $form[ 'fields' ][ $k ] ); |
|
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | $field->adminOnly = false; |
| 578 | 578 | |
| 579 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 580 | - foreach( $field->inputs as $key => $input ) { |
|
| 581 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 579 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 580 | + foreach ( $field->inputs as $key => $input ) { |
|
| 581 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
| 582 | 582 | } |
| 583 | 583 | } |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | - $form['fields'] = array_values( $form['fields'] ); |
|
| 586 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
| 587 | 587 | |
| 588 | 588 | return $form; |
| 589 | 589 | } |
@@ -595,14 +595,14 @@ discard block |
||
| 595 | 595 | $update = false; |
| 596 | 596 | |
| 597 | 597 | // get the most up to date entry values |
| 598 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 598 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 599 | 599 | |
| 600 | 600 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 601 | 601 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 602 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
| 602 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
| 603 | 603 | } else { |
| 604 | 604 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 605 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) ); |
|
| 605 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) ); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | |
@@ -619,24 +619,24 @@ discard block |
||
| 619 | 619 | $inputs = $field->get_entry_inputs(); |
| 620 | 620 | if ( is_array( $inputs ) ) { |
| 621 | 621 | foreach ( $inputs as $input ) { |
| 622 | - list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 ); |
|
| 622 | + list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 ); |
|
| 623 | 623 | |
| 624 | 624 | if ( 'product' === $field->type ) { |
| 625 | - $input_name = 'input_' . str_replace( '.', '_', $input['id'] ); |
|
| 625 | + $input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] ); |
|
| 626 | 626 | |
| 627 | 627 | // Only allow quantity to be set if it's allowed to be edited |
| 628 | 628 | if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) { |
| 629 | 629 | } else { // otherwise set to what it previously was |
| 630 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
| 630 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
| 631 | 631 | } |
| 632 | 632 | } else { |
| 633 | 633 | // Set to what it previously was if it's not editable |
| 634 | 634 | if ( ! in_array( $field_id, $allowed_fields ) ) { |
| 635 | - $_POST[ $input_name ] = $entry[ $input['id'] ]; |
|
| 635 | + $_POST[ $input_name ] = $entry[ $input[ 'id' ] ]; |
|
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | 638 | |
| 639 | - GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
|
| 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 |
@@ -676,19 +676,19 @@ discard block |
||
| 676 | 676 | |
| 677 | 677 | $input_name = 'input_' . $field_id; |
| 678 | 678 | |
| 679 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 679 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 680 | 680 | |
| 681 | 681 | // We have a new image |
| 682 | 682 | |
| 683 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
| 683 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
| 684 | 684 | |
| 685 | 685 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 686 | 686 | $ary = stripslashes_deep( $ary ); |
| 687 | 687 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 688 | 688 | |
| 689 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
| 690 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
| 691 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
| 689 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
| 690 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
| 691 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
| 692 | 692 | |
| 693 | 693 | $image_meta = array( |
| 694 | 694 | 'post_excerpt' => $img_caption, |
@@ -697,7 +697,7 @@ discard block |
||
| 697 | 697 | |
| 698 | 698 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
| 699 | 699 | if ( ! empty( $img_title ) ) { |
| 700 | - $image_meta['post_title'] = $img_title; |
|
| 700 | + $image_meta[ 'post_title' ] = $img_title; |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | /** |
@@ -755,15 +755,15 @@ discard block |
||
| 755 | 755 | */ |
| 756 | 756 | private function maybe_update_post_fields( $form ) { |
| 757 | 757 | |
| 758 | - if( empty( $this->entry['post_id'] ) ) { |
|
| 758 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
| 759 | 759 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
| 760 | 760 | return; |
| 761 | 761 | } |
| 762 | 762 | |
| 763 | - $post_id = $this->entry['post_id']; |
|
| 763 | + $post_id = $this->entry[ 'post_id' ]; |
|
| 764 | 764 | |
| 765 | 765 | // Security check |
| 766 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 766 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 767 | 767 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
| 768 | 768 | return; |
| 769 | 769 | } |
@@ -776,25 +776,25 @@ discard block |
||
| 776 | 776 | |
| 777 | 777 | $field = RGFormsModel::get_field( $form, $field_id ); |
| 778 | 778 | |
| 779 | - if( ! $field ) { |
|
| 779 | + if ( ! $field ) { |
|
| 780 | 780 | continue; |
| 781 | 781 | } |
| 782 | 782 | |
| 783 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 783 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 784 | 784 | |
| 785 | 785 | // Get the value of the field, including $_POSTed value |
| 786 | 786 | $value = RGFormsModel::get_field_value( $field ); |
| 787 | 787 | |
| 788 | 788 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
| 789 | 789 | $entry_tmp = $this->entry; |
| 790 | - $entry_tmp["{$field_id}"] = $value; |
|
| 790 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
| 791 | 791 | |
| 792 | - switch( $field->type ) { |
|
| 792 | + switch ( $field->type ) { |
|
| 793 | 793 | |
| 794 | 794 | case 'post_title': |
| 795 | 795 | $post_title = $value; |
| 796 | 796 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
| 797 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 797 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
| 798 | 798 | } |
| 799 | 799 | $updated_post->post_title = $post_title; |
| 800 | 800 | $updated_post->post_name = $post_title; |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | case 'post_content': |
| 805 | 805 | $post_content = $value; |
| 806 | 806 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
| 807 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 807 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
| 808 | 808 | } |
| 809 | 809 | $updated_post->post_content = $post_content; |
| 810 | 810 | unset( $post_content ); |
@@ -822,11 +822,11 @@ discard block |
||
| 822 | 822 | $value = $value[ $field_id ]; |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 825 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 826 | 826 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
| 827 | 827 | } |
| 828 | 828 | |
| 829 | - $value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry ); |
|
| 829 | + $value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry ); |
|
| 830 | 830 | |
| 831 | 831 | update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
| 832 | 832 | break; |
@@ -838,7 +838,7 @@ discard block |
||
| 838 | 838 | } |
| 839 | 839 | |
| 840 | 840 | // update entry after |
| 841 | - $this->entry["{$field_id}"] = $value; |
|
| 841 | + $this->entry[ "{$field_id}" ] = $value; |
|
| 842 | 842 | |
| 843 | 843 | $update_entry = true; |
| 844 | 844 | |
@@ -847,11 +847,11 @@ discard block |
||
| 847 | 847 | |
| 848 | 848 | } |
| 849 | 849 | |
| 850 | - if( $update_entry ) { |
|
| 850 | + if ( $update_entry ) { |
|
| 851 | 851 | |
| 852 | 852 | $return_entry = GFAPI::update_entry( $this->entry ); |
| 853 | 853 | |
| 854 | - if( is_wp_error( $return_entry ) ) { |
|
| 854 | + if ( is_wp_error( $return_entry ) ) { |
|
| 855 | 855 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
| 856 | 856 | } else { |
| 857 | 857 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -861,7 +861,7 @@ discard block |
||
| 861 | 861 | |
| 862 | 862 | $return_post = wp_update_post( $updated_post, true ); |
| 863 | 863 | |
| 864 | - if( is_wp_error( $return_post ) ) { |
|
| 864 | + if ( is_wp_error( $return_post ) ) { |
|
| 865 | 865 | $return_post->add_data( $updated_post, '$updated_post' ); |
| 866 | 866 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
| 867 | 867 | } else { |
@@ -895,7 +895,7 @@ discard block |
||
| 895 | 895 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
| 896 | 896 | |
| 897 | 897 | // replace conditional shortcodes |
| 898 | - if( $do_shortcode ) { |
|
| 898 | + if ( $do_shortcode ) { |
|
| 899 | 899 | $output = do_shortcode( $output ); |
| 900 | 900 | } |
| 901 | 901 | |
@@ -914,19 +914,19 @@ discard block |
||
| 914 | 914 | */ |
| 915 | 915 | private function after_update() { |
| 916 | 916 | |
| 917 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
| 918 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
| 917 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 918 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 919 | 919 | |
| 920 | 920 | // Re-define the entry now that we've updated it. |
| 921 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
| 921 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
| 922 | 922 | |
| 923 | 923 | $entry = GFFormsModel::set_entry_meta( $entry, self::$original_form ); |
| 924 | 924 | |
| 925 | 925 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
| 926 | 926 | // We need to clear the cache because Gravity Forms caches the field values, which |
| 927 | 927 | // we have just updated. |
| 928 | - foreach ($this->form['fields'] as $key => $field) { |
|
| 929 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
| 928 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
| 929 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
| 930 | 930 | } |
| 931 | 931 | } |
| 932 | 932 | |
@@ -936,11 +936,11 @@ discard block |
||
| 936 | 936 | * @since develop |
| 937 | 937 | */ |
| 938 | 938 | if ( $allowed_feeds = $this->view->settings->get( 'edit_feeds', array() ) ) { |
| 939 | - $feeds = GFAPI::get_feeds( null, $entry['form_id'] ); |
|
| 939 | + $feeds = GFAPI::get_feeds( null, $entry[ 'form_id' ] ); |
|
| 940 | 940 | if ( ! is_wp_error( $feeds ) ) { |
| 941 | 941 | $registered_feeds = array(); |
| 942 | 942 | foreach ( GFAddOn::get_registered_addons() as $registered_feed ) { |
| 943 | - if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
| 943 | + if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) { |
|
| 944 | 944 | if ( method_exists( $registered_feed, 'get_instance' ) ) { |
| 945 | 945 | $registered_feed = call_user_func( array( $registered_feed, 'get_instance' ) ); |
| 946 | 946 | $registered_feeds[ $registered_feed->get_slug() ] = $registered_feed; |
@@ -948,8 +948,8 @@ discard block |
||
| 948 | 948 | } |
| 949 | 949 | } |
| 950 | 950 | foreach ( $feeds as $feed ) { |
| 951 | - if ( in_array( $feed['id'], $allowed_feeds ) ) { |
|
| 952 | - if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed['addon_slug'] ) ) { |
|
| 951 | + if ( in_array( $feed[ 'id' ], $allowed_feeds ) ) { |
|
| 952 | + if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed[ 'addon_slug' ] ) ) { |
|
| 953 | 953 | $returned_entry = $feed_object->process_feed( $feed, $entry, self::$original_form ); |
| 954 | 954 | if ( is_array( $returned_entry ) && rgar( $returned_entry, 'id' ) ) { |
| 955 | 955 | $entry = $returned_entry; |
@@ -979,7 +979,7 @@ discard block |
||
| 979 | 979 | |
| 980 | 980 | <div class="gv-edit-entry-wrapper"><?php |
| 981 | 981 | |
| 982 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
| 982 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
| 983 | 983 | |
| 984 | 984 | /** |
| 985 | 985 | * Fixes weird wpautop() issue |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | * @param string $edit_entry_title Modify the "Edit Entry" title |
| 996 | 996 | * @param GravityView_Edit_Entry_Render $this This object |
| 997 | 997 | */ |
| 998 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 998 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
| 999 | 999 | |
| 1000 | 1000 | echo esc_attr( $edit_entry_title ); |
| 1001 | 1001 | ?></span> |
@@ -1045,13 +1045,13 @@ discard block |
||
| 1045 | 1045 | |
| 1046 | 1046 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
| 1047 | 1047 | |
| 1048 | - if( ! $this->is_valid ){ |
|
| 1048 | + if ( ! $this->is_valid ) { |
|
| 1049 | 1049 | |
| 1050 | 1050 | // Keeping this compatible with Gravity Forms. |
| 1051 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
| 1052 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
| 1051 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
| 1052 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
| 1053 | 1053 | |
| 1054 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
| 1054 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
| 1055 | 1055 | |
| 1056 | 1056 | } else { |
| 1057 | 1057 | $view = \GV\View::by_id( $this->view_id ); |
@@ -1062,23 +1062,23 @@ discard block |
||
| 1062 | 1062 | |
| 1063 | 1063 | case '0': |
| 1064 | 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>' ); |
|
| 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 | 1066 | break; |
| 1067 | 1067 | |
| 1068 | 1068 | case '1': |
| 1069 | 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>' ); |
|
| 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 | 1071 | break; |
| 1072 | 1072 | |
| 1073 | 1073 | case '2': |
| 1074 | 1074 | $redirect_url = $edit_redirect_url; |
| 1075 | 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>' ); |
|
| 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 | 1077 | break; |
| 1078 | 1078 | |
| 1079 | 1079 | case '': |
| 1080 | 1080 | default: |
| 1081 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 1081 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
| 1082 | 1082 | break; |
| 1083 | 1083 | } |
| 1084 | 1084 | |
@@ -1094,7 +1094,7 @@ discard block |
||
| 1094 | 1094 | * @param array $entry Gravity Forms entry array |
| 1095 | 1095 | * @param string $back_link URL to return to the original entry. @since 1.6 |
| 1096 | 1096 | */ |
| 1097 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
| 1097 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
| 1098 | 1098 | |
| 1099 | 1099 | echo GVCommon::generate_notice( $message ); |
| 1100 | 1100 | } |
@@ -1118,8 +1118,8 @@ discard block |
||
| 1118 | 1118 | */ |
| 1119 | 1119 | do_action( 'gravityview/edit-entry/render/before', $this ); |
| 1120 | 1120 | |
| 1121 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
| 1122 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
| 1121 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
| 1122 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
| 1123 | 1123 | add_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) ); |
| 1124 | 1124 | add_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) ); |
| 1125 | 1125 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
@@ -1128,17 +1128,17 @@ discard block |
||
| 1128 | 1128 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
| 1129 | 1129 | |
| 1130 | 1130 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
| 1131 | - unset( $_GET['page'] ); |
|
| 1131 | + unset( $_GET[ 'page' ] ); |
|
| 1132 | 1132 | |
| 1133 | 1133 | $this->show_next_button = false; |
| 1134 | 1134 | $this->show_previous_button = false; |
| 1135 | 1135 | |
| 1136 | 1136 | // TODO: Verify multiple-page forms |
| 1137 | 1137 | if ( GFCommon::has_pages( $this->form ) && apply_filters( 'gravityview/features/paged-edit', false ) ) { |
| 1138 | - if ( intval( $page_number = \GV\Utils::_POST( 'gform_target_page_number_' . $this->form['id'], 1 ) ) > 1 ) { |
|
| 1139 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form; |
|
| 1140 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'is_valid' ] = true; |
|
| 1141 | - GFFormDisplay::$submission[ $this->form['id'] ][ 'page_number' ] = $page_number; |
|
| 1138 | + if ( intval( $page_number = \GV\Utils::_POST( 'gform_target_page_number_' . $this->form[ 'id' ], 1 ) ) > 1 ) { |
|
| 1139 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'form' ] = $this->form; |
|
| 1140 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'is_valid' ] = true; |
|
| 1141 | + GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'page_number' ] = $page_number; |
|
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | 1144 | if ( ( $page_number = intval( $page_number ) ) < 2 ) { |
@@ -1164,7 +1164,7 @@ discard block |
||
| 1164 | 1164 | |
| 1165 | 1165 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
| 1166 | 1166 | |
| 1167 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
| 1167 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
| 1168 | 1168 | |
| 1169 | 1169 | ob_get_clean(); |
| 1170 | 1170 | |
@@ -1192,7 +1192,7 @@ discard block |
||
| 1192 | 1192 | * @return string |
| 1193 | 1193 | */ |
| 1194 | 1194 | public function render_form_buttons() { |
| 1195 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
| 1195 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
| 1196 | 1196 | } |
| 1197 | 1197 | |
| 1198 | 1198 | |
@@ -1212,10 +1212,10 @@ discard block |
||
| 1212 | 1212 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
| 1213 | 1213 | |
| 1214 | 1214 | // In case we have validated the form, use it to inject the validation results into the form render |
| 1215 | - if( isset( $this->form_after_validation ) && $this->form_after_validation['id'] === $form['id'] ) { |
|
| 1215 | + if ( isset( $this->form_after_validation ) && $this->form_after_validation[ 'id' ] === $form[ 'id' ] ) { |
|
| 1216 | 1216 | $form = $this->form_after_validation; |
| 1217 | 1217 | } else { |
| 1218 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1218 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | 1221 | $form = $this->filter_conditional_logic( $form ); |
@@ -1223,8 +1223,8 @@ discard block |
||
| 1223 | 1223 | $form = $this->prefill_conditional_logic( $form ); |
| 1224 | 1224 | |
| 1225 | 1225 | // for now we don't support Save and Continue feature. |
| 1226 | - if( ! self::$supports_save_and_continue ) { |
|
| 1227 | - unset( $form['save'] ); |
|
| 1226 | + if ( ! self::$supports_save_and_continue ) { |
|
| 1227 | + unset( $form[ 'save' ] ); |
|
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | 1230 | $form = $this->unselect_default_values( $form ); |
@@ -1247,31 +1247,31 @@ discard block |
||
| 1247 | 1247 | */ |
| 1248 | 1248 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
| 1249 | 1249 | |
| 1250 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
| 1250 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
| 1251 | 1251 | return $field_content; |
| 1252 | 1252 | } |
| 1253 | 1253 | |
| 1254 | 1254 | $message = null; |
| 1255 | 1255 | |
| 1256 | 1256 | // First, make sure they have the capability to edit the post. |
| 1257 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1257 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
| 1258 | 1258 | |
| 1259 | 1259 | /** |
| 1260 | 1260 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
| 1261 | 1261 | * @param string $message The existing "You don't have permission..." text |
| 1262 | 1262 | */ |
| 1263 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1263 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
| 1264 | 1264 | |
| 1265 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1265 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
| 1266 | 1266 | /** |
| 1267 | 1267 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
| 1268 | 1268 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
| 1269 | 1269 | */ |
| 1270 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1270 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | - if( $message ) { |
|
| 1274 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1273 | + if ( $message ) { |
|
| 1274 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1275 | 1275 | } |
| 1276 | 1276 | |
| 1277 | 1277 | return $field_content; |
@@ -1295,8 +1295,8 @@ discard block |
||
| 1295 | 1295 | |
| 1296 | 1296 | // If the form has been submitted, then we don't need to pre-fill the values, |
| 1297 | 1297 | // Except for fileupload type and when a field input is overridden- run always!! |
| 1298 | - if( |
|
| 1299 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1298 | + if ( |
|
| 1299 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1300 | 1300 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
| 1301 | 1301 | && ! GFCommon::is_product_field( $field->type ) |
| 1302 | 1302 | || ! empty( $field_content ) |
@@ -1316,7 +1316,7 @@ discard block |
||
| 1316 | 1316 | $return = null; |
| 1317 | 1317 | |
| 1318 | 1318 | /** @var GravityView_Field $gv_field */ |
| 1319 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1319 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1320 | 1320 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1321 | 1321 | } else { |
| 1322 | 1322 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1325,7 +1325,7 @@ discard block |
||
| 1325 | 1325 | // If there was output, it's an error |
| 1326 | 1326 | $warnings = ob_get_clean(); |
| 1327 | 1327 | |
| 1328 | - if( !empty( $warnings ) ) { |
|
| 1328 | + if ( ! empty( $warnings ) ) { |
|
| 1329 | 1329 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
| 1330 | 1330 | } |
| 1331 | 1331 | |
@@ -1350,7 +1350,7 @@ discard block |
||
| 1350 | 1350 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
| 1351 | 1351 | |
| 1352 | 1352 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
| 1353 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1353 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1354 | 1354 | |
| 1355 | 1355 | $field_value = array(); |
| 1356 | 1356 | |
@@ -1359,10 +1359,10 @@ discard block |
||
| 1359 | 1359 | |
| 1360 | 1360 | foreach ( (array)$field->inputs as $input ) { |
| 1361 | 1361 | |
| 1362 | - $input_id = strval( $input['id'] ); |
|
| 1362 | + $input_id = strval( $input[ 'id' ] ); |
|
| 1363 | 1363 | |
| 1364 | 1364 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1365 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1365 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1366 | 1366 | $allow_pre_populated = false; |
| 1367 | 1367 | } |
| 1368 | 1368 | |
@@ -1370,7 +1370,7 @@ discard block |
||
| 1370 | 1370 | |
| 1371 | 1371 | $pre_value = $field->get_value_submission( array(), false ); |
| 1372 | 1372 | |
| 1373 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1373 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1374 | 1374 | |
| 1375 | 1375 | } else { |
| 1376 | 1376 | |
@@ -1381,13 +1381,13 @@ discard block |
||
| 1381 | 1381 | |
| 1382 | 1382 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
| 1383 | 1383 | // or pre-populated value if not empty and set to override saved value |
| 1384 | - $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
| 1384 | + $field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value; |
|
| 1385 | 1385 | |
| 1386 | 1386 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
| 1387 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
| 1387 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
| 1388 | 1388 | $categories = array(); |
| 1389 | 1389 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1390 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1390 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1391 | 1391 | } |
| 1392 | 1392 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1393 | 1393 | } |
@@ -1415,7 +1415,7 @@ discard block |
||
| 1415 | 1415 | * @param GF_Field $field Gravity Forms field object |
| 1416 | 1416 | * @param GravityView_Edit_Entry_Render $this Current object |
| 1417 | 1417 | */ |
| 1418 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1418 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
| 1419 | 1419 | |
| 1420 | 1420 | return $field_value; |
| 1421 | 1421 | } |
@@ -1432,12 +1432,12 @@ discard block |
||
| 1432 | 1432 | */ |
| 1433 | 1433 | public function gform_pre_validation( $form ) { |
| 1434 | 1434 | |
| 1435 | - if( ! $this->verify_nonce() ) { |
|
| 1435 | + if ( ! $this->verify_nonce() ) { |
|
| 1436 | 1436 | return $form; |
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | 1439 | // Fix PHP warning regarding undefined index. |
| 1440 | - foreach ( $form['fields'] as &$field) { |
|
| 1440 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1441 | 1441 | |
| 1442 | 1442 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1443 | 1443 | // expects certain field array items to be set. |
@@ -1445,7 +1445,7 @@ discard block |
||
| 1445 | 1445 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
| 1446 | 1446 | } |
| 1447 | 1447 | |
| 1448 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
| 1448 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
| 1449 | 1449 | |
| 1450 | 1450 | /** |
| 1451 | 1451 | * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend. |
@@ -1459,26 +1459,26 @@ discard block |
||
| 1459 | 1459 | // Set the previous value |
| 1460 | 1460 | $entry = $this->get_entry(); |
| 1461 | 1461 | |
| 1462 | - $input_name = 'input_'.$field->id; |
|
| 1463 | - $form_id = $form['id']; |
|
| 1462 | + $input_name = 'input_' . $field->id; |
|
| 1463 | + $form_id = $form[ 'id' ]; |
|
| 1464 | 1464 | |
| 1465 | 1465 | $value = NULL; |
| 1466 | 1466 | |
| 1467 | 1467 | // Use the previous entry value as the default. |
| 1468 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1468 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1469 | 1469 | $value = $entry[ $field->id ]; |
| 1470 | 1470 | } |
| 1471 | 1471 | |
| 1472 | 1472 | // If this is a single upload file |
| 1473 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1474 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1475 | - $value = $file_path['url']; |
|
| 1473 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 1474 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
| 1475 | + $value = $file_path[ 'url' ]; |
|
| 1476 | 1476 | |
| 1477 | 1477 | } else { |
| 1478 | 1478 | |
| 1479 | 1479 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
| 1480 | 1480 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
| 1481 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1481 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
| 1482 | 1482 | |
| 1483 | 1483 | } |
| 1484 | 1484 | |
@@ -1486,10 +1486,10 @@ discard block |
||
| 1486 | 1486 | |
| 1487 | 1487 | // If there are fresh uploads, process and merge them. |
| 1488 | 1488 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
| 1489 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1489 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
| 1490 | 1490 | $value = empty( $value ) ? '[]' : $value; |
| 1491 | 1491 | $value = stripslashes_deep( $value ); |
| 1492 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1492 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
| 1493 | 1493 | } |
| 1494 | 1494 | |
| 1495 | 1495 | } else { |
@@ -1507,8 +1507,8 @@ discard block |
||
| 1507 | 1507 | |
| 1508 | 1508 | case 'number': |
| 1509 | 1509 | // Fix "undefined index" issue at line 1286 in form_display.php |
| 1510 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1511 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1510 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
| 1511 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
| 1512 | 1512 | } |
| 1513 | 1513 | break; |
| 1514 | 1514 | } |
@@ -1545,7 +1545,7 @@ discard block |
||
| 1545 | 1545 | * You can enter whatever you want! |
| 1546 | 1546 | * We try validating, and customize the results using `self::custom_validation()` |
| 1547 | 1547 | */ |
| 1548 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
| 1548 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
| 1549 | 1549 | |
| 1550 | 1550 | // Needed by the validate funtion |
| 1551 | 1551 | $failed_validation_page = NULL; |
@@ -1553,14 +1553,14 @@ discard block |
||
| 1553 | 1553 | |
| 1554 | 1554 | // Prevent entry limit from running when editing an entry, also |
| 1555 | 1555 | // prevent form scheduling from preventing editing |
| 1556 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
| 1556 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
| 1557 | 1557 | |
| 1558 | 1558 | // Hide fields depending on Edit Entry settings |
| 1559 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1559 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1560 | 1560 | |
| 1561 | 1561 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
| 1562 | 1562 | |
| 1563 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1563 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1564 | 1564 | } |
| 1565 | 1565 | |
| 1566 | 1566 | |
@@ -1583,7 +1583,7 @@ discard block |
||
| 1583 | 1583 | |
| 1584 | 1584 | $gv_valid = true; |
| 1585 | 1585 | |
| 1586 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
| 1586 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
| 1587 | 1587 | |
| 1588 | 1588 | $value = RGFormsModel::get_field_value( $field ); |
| 1589 | 1589 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1596,22 +1596,22 @@ discard block |
||
| 1596 | 1596 | case 'post_image': |
| 1597 | 1597 | |
| 1598 | 1598 | // in case nothing is uploaded but there are already files saved |
| 1599 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1599 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
| 1600 | 1600 | $field->failed_validation = false; |
| 1601 | 1601 | unset( $field->validation_message ); |
| 1602 | 1602 | } |
| 1603 | 1603 | |
| 1604 | 1604 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
| 1605 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1605 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
| 1606 | 1606 | |
| 1607 | 1607 | $input_name = 'input_' . $field->id; |
| 1608 | 1608 | //uploaded |
| 1609 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1609 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
| 1610 | 1610 | |
| 1611 | 1611 | //existent |
| 1612 | 1612 | $entry = $this->get_entry(); |
| 1613 | 1613 | $value = NULL; |
| 1614 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1614 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1615 | 1615 | $value = json_decode( $entry[ $field->id ], true ); |
| 1616 | 1616 | } |
| 1617 | 1617 | |
@@ -1619,13 +1619,13 @@ discard block |
||
| 1619 | 1619 | $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) + |
| 1620 | 1620 | ( is_array( $value ) ? count( $value ) : 0 ); |
| 1621 | 1621 | |
| 1622 | - if( $count_files > $field->maxFiles ) { |
|
| 1622 | + if ( $count_files > $field->maxFiles ) { |
|
| 1623 | 1623 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
| 1624 | 1624 | $field->failed_validation = 1; |
| 1625 | 1625 | $gv_valid = false; |
| 1626 | 1626 | |
| 1627 | 1627 | // in case of error make sure the newest upload files are removed from the upload input |
| 1628 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1628 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
| 1629 | 1629 | } |
| 1630 | 1630 | |
| 1631 | 1631 | } |
@@ -1636,7 +1636,7 @@ discard block |
||
| 1636 | 1636 | } |
| 1637 | 1637 | |
| 1638 | 1638 | // This field has failed validation. |
| 1639 | - if( !empty( $field->failed_validation ) ) { |
|
| 1639 | + if ( ! empty( $field->failed_validation ) ) { |
|
| 1640 | 1640 | |
| 1641 | 1641 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
| 1642 | 1642 | |
@@ -1654,19 +1654,19 @@ discard block |
||
| 1654 | 1654 | } |
| 1655 | 1655 | |
| 1656 | 1656 | // You can't continue inside a switch, so we do it after. |
| 1657 | - if( empty( $field->failed_validation ) ) { |
|
| 1657 | + if ( empty( $field->failed_validation ) ) { |
|
| 1658 | 1658 | continue; |
| 1659 | 1659 | } |
| 1660 | 1660 | |
| 1661 | 1661 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1662 | 1662 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1663 | - if( !empty( $field->noDuplicates ) ) { |
|
| 1663 | + if ( ! empty( $field->noDuplicates ) ) { |
|
| 1664 | 1664 | |
| 1665 | 1665 | $entry = $this->get_entry(); |
| 1666 | 1666 | |
| 1667 | 1667 | // If the value of the entry is the same as the stored value |
| 1668 | 1668 | // Then we can assume it's not a duplicate, it's the same. |
| 1669 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1669 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1670 | 1670 | //if value submitted was not changed, then don't validate |
| 1671 | 1671 | $field->failed_validation = false; |
| 1672 | 1672 | |
@@ -1679,7 +1679,7 @@ discard block |
||
| 1679 | 1679 | } |
| 1680 | 1680 | |
| 1681 | 1681 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1682 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1682 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1683 | 1683 | unset( $field->validation_message ); |
| 1684 | 1684 | $field->validation_message = false; |
| 1685 | 1685 | continue; |
@@ -1691,12 +1691,12 @@ discard block |
||
| 1691 | 1691 | |
| 1692 | 1692 | } |
| 1693 | 1693 | |
| 1694 | - $validation_results['is_valid'] = $gv_valid; |
|
| 1694 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
| 1695 | 1695 | |
| 1696 | 1696 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
| 1697 | 1697 | |
| 1698 | 1698 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
| 1699 | - $this->form_after_validation = $validation_results['form']; |
|
| 1699 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
| 1700 | 1700 | |
| 1701 | 1701 | return $validation_results; |
| 1702 | 1702 | } |
@@ -1709,7 +1709,7 @@ discard block |
||
| 1709 | 1709 | */ |
| 1710 | 1710 | public function get_entry() { |
| 1711 | 1711 | |
| 1712 | - if( empty( $this->entry ) ) { |
|
| 1712 | + if ( empty( $this->entry ) ) { |
|
| 1713 | 1713 | // Get the database value of the entry that's being edited |
| 1714 | 1714 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
| 1715 | 1715 | } |
@@ -1741,10 +1741,10 @@ discard block |
||
| 1741 | 1741 | } |
| 1742 | 1742 | |
| 1743 | 1743 | // If edit tab not yet configured, show all fields |
| 1744 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
| 1744 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
| 1745 | 1745 | |
| 1746 | 1746 | // Hide fields depending on admin settings |
| 1747 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
| 1747 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
| 1748 | 1748 | |
| 1749 | 1749 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
| 1750 | 1750 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1777,7 +1777,7 @@ discard block |
||
| 1777 | 1777 | */ |
| 1778 | 1778 | private function filter_fields( $fields, $configured_fields ) { |
| 1779 | 1779 | |
| 1780 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
| 1780 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
| 1781 | 1781 | return $fields; |
| 1782 | 1782 | } |
| 1783 | 1783 | |
@@ -1794,12 +1794,12 @@ discard block |
||
| 1794 | 1794 | |
| 1795 | 1795 | // Remove the fields that have calculation properties and keep them to be used later |
| 1796 | 1796 | // @since 1.16.2 |
| 1797 | - if( $field->has_calculation() ) { |
|
| 1798 | - $this->fields_with_calculation[] = $field; |
|
| 1797 | + if ( $field->has_calculation() ) { |
|
| 1798 | + $this->fields_with_calculation[ ] = $field; |
|
| 1799 | 1799 | // don't remove the calculation fields on form render. |
| 1800 | 1800 | } |
| 1801 | 1801 | |
| 1802 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1802 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1803 | 1803 | unset( $fields[ $key ] ); |
| 1804 | 1804 | } |
| 1805 | 1805 | } |
@@ -1817,7 +1817,7 @@ discard block |
||
| 1817 | 1817 | continue; // Same |
| 1818 | 1818 | } |
| 1819 | 1819 | |
| 1820 | - $out_fields[] = $field; |
|
| 1820 | + $out_fields[ ] = $field; |
|
| 1821 | 1821 | } |
| 1822 | 1822 | |
| 1823 | 1823 | return array_values( $out_fields ); |
@@ -1828,8 +1828,8 @@ discard block |
||
| 1828 | 1828 | |
| 1829 | 1829 | /** @var GF_Field $field */ |
| 1830 | 1830 | foreach ( $fields as $field ) { |
| 1831 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1832 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1831 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1832 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1833 | 1833 | break; |
| 1834 | 1834 | } |
| 1835 | 1835 | |
@@ -1852,14 +1852,14 @@ discard block |
||
| 1852 | 1852 | |
| 1853 | 1853 | $return_field = $field; |
| 1854 | 1854 | |
| 1855 | - if( empty( $field_setting['show_label'] ) ) { |
|
| 1855 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
| 1856 | 1856 | $return_field->label = ''; |
| 1857 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
| 1858 | - $return_field->label = $field_setting['custom_label']; |
|
| 1857 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
| 1858 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
| 1859 | 1859 | } |
| 1860 | 1860 | |
| 1861 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
| 1862 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
| 1861 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
| 1862 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
| 1863 | 1863 | } |
| 1864 | 1864 | |
| 1865 | 1865 | /** |
@@ -1897,16 +1897,16 @@ discard block |
||
| 1897 | 1897 | */ |
| 1898 | 1898 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
| 1899 | 1899 | |
| 1900 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1901 | - foreach( $fields as $k => $field ) { |
|
| 1902 | - if( $field->adminOnly ) { |
|
| 1900 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
| 1901 | + foreach ( $fields as $k => $field ) { |
|
| 1902 | + if ( $field->adminOnly ) { |
|
| 1903 | 1903 | unset( $fields[ $k ] ); |
| 1904 | 1904 | } |
| 1905 | 1905 | } |
| 1906 | 1906 | return array_values( $fields ); |
| 1907 | 1907 | } |
| 1908 | 1908 | |
| 1909 | - foreach( $fields as &$field ) { |
|
| 1909 | + foreach ( $fields as &$field ) { |
|
| 1910 | 1910 | $field->adminOnly = false; |
| 1911 | 1911 | } |
| 1912 | 1912 | |
@@ -1927,7 +1927,7 @@ discard block |
||
| 1927 | 1927 | */ |
| 1928 | 1928 | private function unselect_default_values( $form ) { |
| 1929 | 1929 | |
| 1930 | - foreach ( $form['fields'] as &$field ) { |
|
| 1930 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1931 | 1931 | |
| 1932 | 1932 | if ( empty( $field->choices ) ) { |
| 1933 | 1933 | continue; |
@@ -1935,7 +1935,7 @@ discard block |
||
| 1935 | 1935 | |
| 1936 | 1936 | foreach ( $field->choices as &$choice ) { |
| 1937 | 1937 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 1938 | - $choice['isSelected'] = false; |
|
| 1938 | + $choice[ 'isSelected' ] = false; |
|
| 1939 | 1939 | } |
| 1940 | 1940 | } |
| 1941 | 1941 | } |
@@ -1960,22 +1960,22 @@ discard block |
||
| 1960 | 1960 | */ |
| 1961 | 1961 | function prefill_conditional_logic( $form ) { |
| 1962 | 1962 | |
| 1963 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1963 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1964 | 1964 | return $form; |
| 1965 | 1965 | } |
| 1966 | 1966 | |
| 1967 | 1967 | // Have Conditional Logic pre-fill fields as if the data were default values |
| 1968 | 1968 | /** @var GF_Field $field */ |
| 1969 | - foreach ( $form['fields'] as &$field ) { |
|
| 1969 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1970 | 1970 | |
| 1971 | - if( 'checkbox' === $field->type ) { |
|
| 1971 | + if ( 'checkbox' === $field->type ) { |
|
| 1972 | 1972 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1973 | - $input_id = $input['id']; |
|
| 1973 | + $input_id = $input[ 'id' ]; |
|
| 1974 | 1974 | $choice = $field->choices[ $key ]; |
| 1975 | 1975 | $value = \GV\Utils::get( $this->entry, $input_id ); |
| 1976 | 1976 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
| 1977 | - if( $match ) { |
|
| 1978 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 1977 | + if ( $match ) { |
|
| 1978 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
| 1979 | 1979 | } |
| 1980 | 1980 | } |
| 1981 | 1981 | } else { |
@@ -1983,15 +1983,15 @@ discard block |
||
| 1983 | 1983 | // We need to run through each field to set the default values |
| 1984 | 1984 | foreach ( $this->entry as $field_id => $field_value ) { |
| 1985 | 1985 | |
| 1986 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1986 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1987 | 1987 | |
| 1988 | - if( 'list' === $field->type ) { |
|
| 1988 | + if ( 'list' === $field->type ) { |
|
| 1989 | 1989 | $list_rows = maybe_unserialize( $field_value ); |
| 1990 | 1990 | |
| 1991 | 1991 | $list_field_value = array(); |
| 1992 | - foreach ( (array) $list_rows as $row ) { |
|
| 1993 | - foreach ( (array) $row as $column ) { |
|
| 1994 | - $list_field_value[] = $column; |
|
| 1992 | + foreach ( (array)$list_rows as $row ) { |
|
| 1993 | + foreach ( (array)$row as $column ) { |
|
| 1994 | + $list_field_value[ ] = $column; |
|
| 1995 | 1995 | } |
| 1996 | 1996 | } |
| 1997 | 1997 | |
@@ -2024,32 +2024,32 @@ discard block |
||
| 2024 | 2024 | * @see https://github.com/gravityview/GravityView/issues/840 |
| 2025 | 2025 | * @since develop |
| 2026 | 2026 | */ |
| 2027 | - $the_form = GFAPI::get_form( $form['id'] ); |
|
| 2027 | + $the_form = GFAPI::get_form( $form[ 'id' ] ); |
|
| 2028 | 2028 | $editable_ids = array(); |
| 2029 | - foreach ( $form['fields'] as $field ) { |
|
| 2030 | - $editable_ids[] = $field['id']; // wp_list_pluck is destructive in this context |
|
| 2029 | + foreach ( $form[ 'fields' ] as $field ) { |
|
| 2030 | + $editable_ids[ ] = $field[ 'id' ]; // wp_list_pluck is destructive in this context |
|
| 2031 | 2031 | } |
| 2032 | 2032 | $remove_conditions_rule = array(); |
| 2033 | - foreach ( $the_form['fields'] as $field ) { |
|
| 2034 | - if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic['rules'] ) ) { |
|
| 2035 | - foreach ( $field->conditionalLogic['rules'] as $i => $rule ) { |
|
| 2036 | - if ( ! in_array( $rule['fieldId'], $editable_ids ) ) { |
|
| 2033 | + foreach ( $the_form[ 'fields' ] as $field ) { |
|
| 2034 | + if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic[ 'rules' ] ) ) { |
|
| 2035 | + foreach ( $field->conditionalLogic[ 'rules' ] as $i => $rule ) { |
|
| 2036 | + if ( ! in_array( $rule[ 'fieldId' ], $editable_ids ) ) { |
|
| 2037 | 2037 | /** |
| 2038 | 2038 | * This conditional field is not editable in this View. |
| 2039 | 2039 | * We need to remove the rule, but only if it matches. |
| 2040 | 2040 | */ |
| 2041 | - if ( $_field = GFAPI::get_field( $the_form, $rule['fieldId'] ) ) { |
|
| 2041 | + if ( $_field = GFAPI::get_field( $the_form, $rule[ 'fieldId' ] ) ) { |
|
| 2042 | 2042 | $value = $_field->get_value_export( $this->entry ); |
| 2043 | - } elseif ( isset( $this->entry[ $rule['fieldId'] ] ) ) { |
|
| 2044 | - $value = $this->entry[ $rule['fieldId'] ]; |
|
| 2043 | + } elseif ( isset( $this->entry[ $rule[ 'fieldId' ] ] ) ) { |
|
| 2044 | + $value = $this->entry[ $rule[ 'fieldId' ] ]; |
|
| 2045 | 2045 | } else { |
| 2046 | - $value = gform_get_meta( $this->entry['id'], $rule['fieldId'] ); |
|
| 2046 | + $value = gform_get_meta( $this->entry[ 'id' ], $rule[ 'fieldId' ] ); |
|
| 2047 | 2047 | } |
| 2048 | 2048 | |
| 2049 | - $match = GFFormsModel::matches_operation( $value, $rule['value'], $rule['operator'] ); |
|
| 2049 | + $match = GFFormsModel::matches_operation( $value, $rule[ 'value' ], $rule[ 'operator' ] ); |
|
| 2050 | 2050 | |
| 2051 | 2051 | if ( $match ) { |
| 2052 | - $remove_conditions_rule[] = array( $field['id'], $i ); |
|
| 2052 | + $remove_conditions_rule[ ] = array( $field[ 'id' ], $i ); |
|
| 2053 | 2053 | } |
| 2054 | 2054 | } |
| 2055 | 2055 | } |
@@ -2057,21 +2057,21 @@ discard block |
||
| 2057 | 2057 | } |
| 2058 | 2058 | |
| 2059 | 2059 | if ( $remove_conditions_rule ) { |
| 2060 | - foreach ( $form['fields'] as &$field ) { |
|
| 2060 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 2061 | 2061 | foreach ( $remove_conditions_rule as $_remove_conditions_r ) { |
| 2062 | 2062 | |
| 2063 | 2063 | list( $rule_field_id, $rule_i ) = $_remove_conditions_r; |
| 2064 | 2064 | |
| 2065 | - if ( $field['id'] == $rule_field_id ) { |
|
| 2066 | - unset( $field->conditionalLogic['rules'][ $rule_i ] ); |
|
| 2067 | - gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field['id'] ) ); |
|
| 2065 | + if ( $field[ 'id' ] == $rule_field_id ) { |
|
| 2066 | + unset( $field->conditionalLogic[ 'rules' ][ $rule_i ] ); |
|
| 2067 | + gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field[ 'id' ] ) ); |
|
| 2068 | 2068 | } |
| 2069 | 2069 | } |
| 2070 | 2070 | } |
| 2071 | 2071 | } |
| 2072 | 2072 | |
| 2073 | 2073 | /** Normalize the indices... */ |
| 2074 | - $form['fields'] = array_values( $form['fields'] ); |
|
| 2074 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
| 2075 | 2075 | |
| 2076 | 2076 | /** |
| 2077 | 2077 | * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields? |
@@ -2081,16 +2081,16 @@ discard block |
||
| 2081 | 2081 | */ |
| 2082 | 2082 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
| 2083 | 2083 | |
| 2084 | - if( $use_conditional_logic ) { |
|
| 2084 | + if ( $use_conditional_logic ) { |
|
| 2085 | 2085 | return $form; |
| 2086 | 2086 | } |
| 2087 | 2087 | |
| 2088 | - foreach( $form['fields'] as &$field ) { |
|
| 2088 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 2089 | 2089 | /* @var GF_Field $field */ |
| 2090 | 2090 | $field->conditionalLogic = null; |
| 2091 | 2091 | } |
| 2092 | 2092 | |
| 2093 | - unset( $form['button']['conditionalLogic'] ); |
|
| 2093 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
| 2094 | 2094 | |
| 2095 | 2095 | return $form; |
| 2096 | 2096 | |
@@ -2107,7 +2107,7 @@ discard block |
||
| 2107 | 2107 | */ |
| 2108 | 2108 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
| 2109 | 2109 | |
| 2110 | - if( ! $this->is_edit_entry() ) { |
|
| 2110 | + if ( ! $this->is_edit_entry() ) { |
|
| 2111 | 2111 | return $has_conditional_logic; |
| 2112 | 2112 | } |
| 2113 | 2113 | |
@@ -2139,44 +2139,44 @@ discard block |
||
| 2139 | 2139 | * 2. There are two entries embedded using oEmbed |
| 2140 | 2140 | * 3. One of the entries has just been saved |
| 2141 | 2141 | */ |
| 2142 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
| 2142 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
| 2143 | 2143 | |
| 2144 | 2144 | $error = true; |
| 2145 | 2145 | |
| 2146 | 2146 | } |
| 2147 | 2147 | |
| 2148 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
| 2148 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
| 2149 | 2149 | |
| 2150 | 2150 | $error = true; |
| 2151 | 2151 | |
| 2152 | - } elseif( ! $this->verify_nonce() ) { |
|
| 2152 | + } elseif ( ! $this->verify_nonce() ) { |
|
| 2153 | 2153 | |
| 2154 | 2154 | /** |
| 2155 | 2155 | * If the Entry is embedded, there may be two entries on the same page. |
| 2156 | 2156 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
| 2157 | 2157 | */ |
| 2158 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 2158 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 2159 | 2159 | $error = true; |
| 2160 | 2160 | } else { |
| 2161 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
| 2161 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
| 2162 | 2162 | } |
| 2163 | 2163 | |
| 2164 | 2164 | } |
| 2165 | 2165 | |
| 2166 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 2167 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
| 2166 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 2167 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
| 2168 | 2168 | } |
| 2169 | 2169 | |
| 2170 | - if( $this->entry['status'] === 'trash' ) { |
|
| 2171 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 2170 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
| 2171 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 2172 | 2172 | } |
| 2173 | 2173 | |
| 2174 | 2174 | // No errors; everything's fine here! |
| 2175 | - if( empty( $error ) ) { |
|
| 2175 | + if ( empty( $error ) ) { |
|
| 2176 | 2176 | return true; |
| 2177 | 2177 | } |
| 2178 | 2178 | |
| 2179 | - if( $echo && $error !== true ) { |
|
| 2179 | + if ( $echo && $error !== true ) { |
|
| 2180 | 2180 | |
| 2181 | 2181 | $error = esc_html( $error ); |
| 2182 | 2182 | |
@@ -2184,10 +2184,10 @@ discard block |
||
| 2184 | 2184 | * @since 1.9 |
| 2185 | 2185 | */ |
| 2186 | 2186 | if ( ! empty( $this->entry ) ) { |
| 2187 | - $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;" ) ); |
|
| 2187 | + $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;" ) ); |
|
| 2188 | 2188 | } |
| 2189 | 2189 | |
| 2190 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
| 2190 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
| 2191 | 2191 | } |
| 2192 | 2192 | |
| 2193 | 2193 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2207,17 +2207,17 @@ discard block |
||
| 2207 | 2207 | |
| 2208 | 2208 | $error = NULL; |
| 2209 | 2209 | |
| 2210 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2211 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
| 2210 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 2211 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
| 2212 | 2212 | } |
| 2213 | 2213 | |
| 2214 | 2214 | // No errors; everything's fine here! |
| 2215 | - if( empty( $error ) ) { |
|
| 2215 | + if ( empty( $error ) ) { |
|
| 2216 | 2216 | return true; |
| 2217 | 2217 | } |
| 2218 | 2218 | |
| 2219 | - if( $echo ) { |
|
| 2220 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
| 2219 | + if ( $echo ) { |
|
| 2220 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
| 2221 | 2221 | } |
| 2222 | 2222 | |
| 2223 | 2223 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2238,14 +2238,14 @@ discard block |
||
| 2238 | 2238 | private function check_user_cap_edit_field( $field ) { |
| 2239 | 2239 | |
| 2240 | 2240 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
| 2241 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2241 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2242 | 2242 | return true; |
| 2243 | 2243 | } |
| 2244 | 2244 | |
| 2245 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
| 2245 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
| 2246 | 2246 | |
| 2247 | - if( $field_cap ) { |
|
| 2248 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
| 2247 | + if ( $field_cap ) { |
|
| 2248 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
| 2249 | 2249 | } |
| 2250 | 2250 | |
| 2251 | 2251 | return false; |
@@ -2259,17 +2259,17 @@ discard block |
||
| 2259 | 2259 | public function verify_nonce() { |
| 2260 | 2260 | |
| 2261 | 2261 | // Verify form submitted for editing single |
| 2262 | - if( $this->is_edit_entry_submission() ) { |
|
| 2262 | + if ( $this->is_edit_entry_submission() ) { |
|
| 2263 | 2263 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
| 2264 | 2264 | } |
| 2265 | 2265 | |
| 2266 | 2266 | // Verify |
| 2267 | - else if( ! $this->is_edit_entry() ) { |
|
| 2267 | + else if ( ! $this->is_edit_entry() ) { |
|
| 2268 | 2268 | $valid = false; |
| 2269 | 2269 | } |
| 2270 | 2270 | |
| 2271 | 2271 | else { |
| 2272 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
| 2272 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
| 2273 | 2273 | } |
| 2274 | 2274 | |
| 2275 | 2275 | /** |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $labels = array( |
| 44 | 44 | 'cancel' => __( 'Cancel', 'gravityview' ), |
| 45 | - 'submit' => __( 'Update', 'gravityview '), |
|
| 45 | + 'submit' => __( 'Update', 'gravityview ' ), |
|
| 46 | 46 | 'next' => __( 'Next', 'gravityview' ), |
| 47 | 47 | 'previous' => __( 'Previous', 'gravityview' ), |
| 48 | 48 | ); |
@@ -60,28 +60,28 @@ discard block |
||
| 60 | 60 | if ( $object->show_previous_button ) { |
| 61 | 61 | $previous_tabindex = GFCommon::get_tabindex(); |
| 62 | 62 | ?> |
| 63 | - <input id="gform_previous_button_<?php echo esc_attr( $object->form['id'] ); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-previous" type="submit" <?php echo $previous_tabindex; ?> value="<?php echo esc_attr( $labels['previous'] ); ?>" name="save" /> |
|
| 63 | + <input id="gform_previous_button_<?php echo esc_attr( $object->form[ 'id' ] ); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-previous" type="submit" <?php echo $previous_tabindex; ?> value="<?php echo esc_attr( $labels[ 'previous' ] ); ?>" name="save" /> |
|
| 64 | 64 | <?php |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | if ( $object->show_next_button ) { |
| 68 | - $next_tabindex = GFCommon::get_tabindex(); |
|
| 68 | + $next_tabindex = GFCommon::get_tabindex(); |
|
| 69 | 69 | ?> |
| 70 | - <input id="gform_next_button_<?php echo esc_attr( $object->form['id'] ); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-next" type="submit" <?php echo $next_tabindex; ?> value="<?php echo esc_attr( $labels['next'] ); ?>" name="save" /> |
|
| 70 | + <input id="gform_next_button_<?php echo esc_attr( $object->form[ 'id' ] ); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-next" type="submit" <?php echo $next_tabindex; ?> value="<?php echo esc_attr( $labels[ 'next' ] ); ?>" name="save" /> |
|
| 71 | 71 | <?php |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | if ( $object->show_update_button ) { |
| 75 | - $update_tabindex = GFCommon::get_tabindex(); |
|
| 75 | + $update_tabindex = GFCommon::get_tabindex(); |
|
| 76 | 76 | ?> |
| 77 | - <input id="gform_submit_button_<?php echo esc_attr( $object->form['id'] ); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-update" type="submit" <?php echo $update_tabindex; ?> value="<?php echo esc_attr( $labels['submit'] ); ?>" name="save" /> |
|
| 77 | + <input id="gform_submit_button_<?php echo esc_attr( $object->form[ 'id' ] ); ?>" class="btn btn-lg button button-large gform_button button-primary gv-button-update" type="submit" <?php echo $update_tabindex; ?> value="<?php echo esc_attr( $labels[ 'submit' ] ); ?>" name="save" /> |
|
| 78 | 78 | <?php |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - $cancel_tabindex = GFCommon::get_tabindex(); |
|
| 81 | + $cancel_tabindex = GFCommon::get_tabindex(); |
|
| 82 | 82 | |
| 83 | 83 | ?> |
| 84 | - <a class="btn btn-sm button button-small gv-button-cancel" <?php echo $cancel_tabindex; ?> href="<?php echo esc_url( $back_link ); ?>"><?php echo esc_attr( $labels['cancel'] ); ?></a> |
|
| 84 | + <a class="btn btn-sm button button-small gv-button-cancel" <?php echo $cancel_tabindex; ?> href="<?php echo esc_url( $back_link ); ?>"><?php echo esc_attr( $labels[ 'cancel' ] ); ?></a> |
|
| 85 | 85 | <?php |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -97,5 +97,5 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | ?> |
| 99 | 99 | <input type="hidden" name="action" value="update" /> |
| 100 | - <input type="hidden" name="lid" value="<?php echo esc_attr( $object->entry['id'] ); ?>" /> |
|
| 100 | + <input type="hidden" name="lid" value="<?php echo esc_attr( $object->entry[ 'id' ] ); ?>" /> |
|
| 101 | 101 | </div> |