@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | 96 | * ID of the current post. May also be ID of the current View. |
| 97 | - * |
|
| 98 | - * @since 2.0.13 |
|
| 99 | - * |
|
| 100 | - * @var int |
|
| 97 | + * |
|
| 98 | + * @since 2.0.13 |
|
| 99 | + * |
|
| 100 | + * @var int |
|
| 101 | 101 | */ |
| 102 | 102 | public $post_id; |
| 103 | 103 | |
@@ -169,12 +169,12 @@ discard block |
||
| 169 | 169 | public function prevent_maybe_process_form() { |
| 170 | 170 | |
| 171 | 171 | if( ! empty( $_POST ) ) { |
| 172 | - gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
| 172 | + gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | if( $this->is_edit_entry_submission() ) { |
| 176 | 176 | remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
| 177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
@@ -202,14 +202,14 @@ discard block |
||
| 202 | 202 | * When Edit entry view is requested setup the vars |
| 203 | 203 | */ |
| 204 | 204 | private function setup_vars() { |
| 205 | - global $post; |
|
| 205 | + global $post; |
|
| 206 | 206 | |
| 207 | 207 | $gravityview_view = GravityView_View::getInstance(); |
| 208 | 208 | |
| 209 | 209 | |
| 210 | 210 | $entries = $gravityview_view->getEntries(); |
| 211 | - self::$original_entry = $entries[0]; |
|
| 212 | - $this->entry = $entries[0]; |
|
| 211 | + self::$original_entry = $entries[0]; |
|
| 212 | + $this->entry = $entries[0]; |
|
| 213 | 213 | |
| 214 | 214 | self::$original_form = $gravityview_view->getForm(); |
| 215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -333,8 +333,8 @@ discard block |
||
| 333 | 333 | |
| 334 | 334 | GFFormsModel::save_lead( $form, $this->entry ); |
| 335 | 335 | |
| 336 | - // Delete the values for hidden inputs |
|
| 337 | - $this->unset_hidden_field_values(); |
|
| 336 | + // Delete the values for hidden inputs |
|
| 337 | + $this->unset_hidden_field_values(); |
|
| 338 | 338 | |
| 339 | 339 | $this->entry['date_created'] = $date_created; |
| 340 | 340 | |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | // Perform actions normally performed after updating a lead |
| 348 | 348 | $this->after_update(); |
| 349 | 349 | |
| 350 | - /** |
|
| 350 | + /** |
|
| 351 | 351 | * Must be AFTER after_update()! |
| 352 | 352 | * @see https://github.com/gravityview/GravityView/issues/764 |
| 353 | 353 | */ |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | |
| 356 | 356 | /** |
| 357 | 357 | * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry |
| 358 | - * @since 2.1 Added $gv_data parameter |
|
| 358 | + * @since 2.1 Added $gv_data parameter |
|
| 359 | 359 | * @param array $form Gravity Forms form array |
| 360 | 360 | * @param string $entry_id Numeric ID of the entry that was updated |
| 361 | 361 | * @param GravityView_Edit_Entry_Render $this This object |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | * @return void |
| 380 | 380 | */ |
| 381 | 381 | private function unset_hidden_field_values() { |
| 382 | - global $wpdb; |
|
| 382 | + global $wpdb; |
|
| 383 | 383 | |
| 384 | 384 | /** |
| 385 | 385 | * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic |
@@ -401,27 +401,27 @@ discard block |
||
| 401 | 401 | $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - foreach ( $this->entry as $input_id => $field_value ) { |
|
| 404 | + foreach ( $this->entry as $input_id => $field_value ) { |
|
| 405 | 405 | |
| 406 | - $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
| 406 | + $field = RGFormsModel::get_field( $this->form, $input_id ); |
|
| 407 | 407 | |
| 408 | - // Reset fields that are hidden |
|
| 409 | - // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
| 410 | - if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
| 408 | + // Reset fields that are hidden |
|
| 409 | + // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic |
|
| 410 | + if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) { |
|
| 411 | 411 | |
| 412 | - // List fields are stored as empty arrays when empty |
|
| 413 | - $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : ''; |
|
| 412 | + // List fields are stored as empty arrays when empty |
|
| 413 | + $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : ''; |
|
| 414 | 414 | |
| 415 | - $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 415 | + $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id ); |
|
| 416 | 416 | |
| 417 | - GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 417 | + GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value ); |
|
| 418 | 418 | |
| 419 | - // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 419 | + // Prevent the $_POST values of hidden fields from being used as default values when rendering the form |
|
| 420 | 420 | // after submission |
| 421 | - $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 422 | - $_POST[ $post_input_id ] = ''; |
|
| 423 | - } |
|
| 424 | - } |
|
| 421 | + $post_input_id = 'input_' . str_replace( '.', '_', $input_id ); |
|
| 422 | + $_POST[ $post_input_id ] = ''; |
|
| 423 | + } |
|
| 424 | + } |
|
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | /** |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | |
| 516 | 516 | $form = $this->form; |
| 517 | 517 | |
| 518 | - /** @var GF_Field $field */ |
|
| 518 | + /** @var GF_Field $field */ |
|
| 519 | 519 | foreach( $form['fields'] as $k => &$field ) { |
| 520 | 520 | |
| 521 | 521 | /** |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | |
| 532 | 532 | if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
| 533 | 533 | foreach( $field->inputs as $key => $input ) { |
| 534 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 534 | + $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 535 | 535 | } |
| 536 | 536 | } |
| 537 | 537 | } |
@@ -558,9 +558,9 @@ discard block |
||
| 558 | 558 | foreach ( $this->fields_with_calculation as $field ) { |
| 559 | 559 | $inputs = $field->get_entry_inputs(); |
| 560 | 560 | if ( is_array( $inputs ) ) { |
| 561 | - foreach ( $inputs as $input ) { |
|
| 561 | + foreach ( $inputs as $input ) { |
|
| 562 | 562 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
| 563 | - } |
|
| 563 | + } |
|
| 564 | 564 | } else { |
| 565 | 565 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $field->id ); |
| 566 | 566 | } |
@@ -616,7 +616,7 @@ discard block |
||
| 616 | 616 | $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
| 617 | 617 | |
| 618 | 618 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 619 | - $ary = stripslashes_deep( $ary ); |
|
| 619 | + $ary = stripslashes_deep( $ary ); |
|
| 620 | 620 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 621 | 621 | |
| 622 | 622 | $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | private function maybe_update_post_fields( $form ) { |
| 690 | 690 | |
| 691 | 691 | if( empty( $this->entry['post_id'] ) ) { |
| 692 | - gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 692 | + gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
|
| 693 | 693 | return; |
| 694 | 694 | } |
| 695 | 695 | |
@@ -724,51 +724,51 @@ discard block |
||
| 724 | 724 | |
| 725 | 725 | switch( $field->type ) { |
| 726 | 726 | |
| 727 | - case 'post_title': |
|
| 728 | - $post_title = $value; |
|
| 729 | - if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 730 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 731 | - } |
|
| 732 | - $updated_post->post_title = $post_title; |
|
| 733 | - $updated_post->post_name = $post_title; |
|
| 734 | - unset( $post_title ); |
|
| 735 | - break; |
|
| 736 | - |
|
| 737 | - case 'post_content': |
|
| 738 | - $post_content = $value; |
|
| 739 | - if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 740 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 741 | - } |
|
| 742 | - $updated_post->post_content = $post_content; |
|
| 743 | - unset( $post_content ); |
|
| 744 | - break; |
|
| 745 | - case 'post_excerpt': |
|
| 746 | - $updated_post->post_excerpt = $value; |
|
| 747 | - break; |
|
| 748 | - case 'post_tags': |
|
| 749 | - wp_set_post_tags( $post_id, $value, false ); |
|
| 750 | - break; |
|
| 751 | - case 'post_category': |
|
| 752 | - break; |
|
| 753 | - case 'post_custom_field': |
|
| 727 | + case 'post_title': |
|
| 728 | + $post_title = $value; |
|
| 729 | + if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
|
| 730 | + $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 731 | + } |
|
| 732 | + $updated_post->post_title = $post_title; |
|
| 733 | + $updated_post->post_name = $post_title; |
|
| 734 | + unset( $post_title ); |
|
| 735 | + break; |
|
| 736 | + |
|
| 737 | + case 'post_content': |
|
| 738 | + $post_content = $value; |
|
| 739 | + if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
|
| 740 | + $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 741 | + } |
|
| 742 | + $updated_post->post_content = $post_content; |
|
| 743 | + unset( $post_content ); |
|
| 744 | + break; |
|
| 745 | + case 'post_excerpt': |
|
| 746 | + $updated_post->post_excerpt = $value; |
|
| 747 | + break; |
|
| 748 | + case 'post_tags': |
|
| 749 | + wp_set_post_tags( $post_id, $value, false ); |
|
| 750 | + break; |
|
| 751 | + case 'post_category': |
|
| 752 | + break; |
|
| 753 | + case 'post_custom_field': |
|
| 754 | 754 | if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) { |
| 755 | 755 | $value = $value[ $field_id ]; |
| 756 | 756 | } |
| 757 | 757 | |
| 758 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 759 | - $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 760 | - } |
|
| 758 | + if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 759 | + $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
|
| 760 | + } |
|
| 761 | 761 | |
| 762 | - if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
|
| 763 | - $value = wp_json_encode( $value ); |
|
| 764 | - } |
|
| 762 | + if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) { |
|
| 763 | + $value = wp_json_encode( $value ); |
|
| 764 | + } |
|
| 765 | 765 | |
| 766 | - update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 767 | - break; |
|
| 766 | + update_post_meta( $post_id, $field->postCustomFieldName, $value ); |
|
| 767 | + break; |
|
| 768 | 768 | |
| 769 | - case 'post_image': |
|
| 770 | - $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 771 | - break; |
|
| 769 | + case 'post_image': |
|
| 770 | + $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id ); |
|
| 771 | + break; |
|
| 772 | 772 | |
| 773 | 773 | } |
| 774 | 774 | |
@@ -813,20 +813,20 @@ discard block |
||
| 813 | 813 | */ |
| 814 | 814 | private function is_field_json_encoded( $field ) { |
| 815 | 815 | |
| 816 | - $json_encoded = false; |
|
| 816 | + $json_encoded = false; |
|
| 817 | 817 | |
| 818 | 818 | $input_type = RGFormsModel::get_input_type( $field ); |
| 819 | 819 | |
| 820 | - // Only certain custom field types are supported |
|
| 821 | - switch( $input_type ) { |
|
| 822 | - case 'fileupload': |
|
| 823 | - case 'list': |
|
| 824 | - case 'multiselect': |
|
| 825 | - $json_encoded = true; |
|
| 826 | - break; |
|
| 827 | - } |
|
| 820 | + // Only certain custom field types are supported |
|
| 821 | + switch( $input_type ) { |
|
| 822 | + case 'fileupload': |
|
| 823 | + case 'list': |
|
| 824 | + case 'multiselect': |
|
| 825 | + $json_encoded = true; |
|
| 826 | + break; |
|
| 827 | + } |
|
| 828 | 828 | |
| 829 | - return $json_encoded; |
|
| 829 | + return $json_encoded; |
|
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | /** |
@@ -916,14 +916,14 @@ discard block |
||
| 916 | 916 | ?><h2 class="gv-edit-entry-title"> |
| 917 | 917 | <span><?php |
| 918 | 918 | |
| 919 | - /** |
|
| 920 | - * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 921 | - * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 922 | - * @param GravityView_Edit_Entry_Render $this This object |
|
| 923 | - */ |
|
| 924 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 919 | + /** |
|
| 920 | + * @filter `gravityview_edit_entry_title` Modify the edit entry title |
|
| 921 | + * @param string $edit_entry_title Modify the "Edit Entry" title |
|
| 922 | + * @param GravityView_Edit_Entry_Render $this This object |
|
| 923 | + */ |
|
| 924 | + $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 925 | 925 | |
| 926 | - echo esc_attr( $edit_entry_title ); |
|
| 926 | + echo esc_attr( $edit_entry_title ); |
|
| 927 | 927 | ?></span> |
| 928 | 928 | </h2> |
| 929 | 929 | |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | |
| 1033 | 1033 | ob_get_clean(); |
| 1034 | 1034 | |
| 1035 | - remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1035 | + remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 ); |
|
| 1036 | 1036 | remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
| 1037 | 1037 | remove_filter( 'gform_disable_view_counter', '__return_true' ); |
| 1038 | 1038 | remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 ); |
@@ -1086,7 +1086,7 @@ discard block |
||
| 1086 | 1086 | |
| 1087 | 1087 | // for now we don't support Save and Continue feature. |
| 1088 | 1088 | if( ! self::$supports_save_and_continue ) { |
| 1089 | - unset( $form['save'] ); |
|
| 1089 | + unset( $form['save'] ); |
|
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | 1092 | $form = $this->unselect_default_values( $form ); |
@@ -1113,30 +1113,30 @@ discard block |
||
| 1113 | 1113 | return $field_content; |
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | - $message = null; |
|
| 1116 | + $message = null; |
|
| 1117 | 1117 | |
| 1118 | - // First, make sure they have the capability to edit the post. |
|
| 1119 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1118 | + // First, make sure they have the capability to edit the post. |
|
| 1119 | + if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1120 | 1120 | |
| 1121 | - /** |
|
| 1122 | - * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1123 | - * @param string $message The existing "You don't have permission..." text |
|
| 1124 | - */ |
|
| 1125 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1121 | + /** |
|
| 1122 | + * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
|
| 1123 | + * @param string $message The existing "You don't have permission..." text |
|
| 1124 | + */ |
|
| 1125 | + $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1126 | 1126 | |
| 1127 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1128 | - /** |
|
| 1129 | - * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1130 | - * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1131 | - */ |
|
| 1132 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1133 | - } |
|
| 1127 | + } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1128 | + /** |
|
| 1129 | + * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
|
| 1130 | + * @param string $message The existing "This field is not editable; the post no longer exists." text |
|
| 1131 | + */ |
|
| 1132 | + $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1133 | + } |
|
| 1134 | 1134 | |
| 1135 | - if( $message ) { |
|
| 1136 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1137 | - } |
|
| 1135 | + if( $message ) { |
|
| 1136 | + $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1137 | + } |
|
| 1138 | 1138 | |
| 1139 | - return $field_content; |
|
| 1139 | + return $field_content; |
|
| 1140 | 1140 | } |
| 1141 | 1141 | |
| 1142 | 1142 | /** |
@@ -1164,7 +1164,7 @@ discard block |
||
| 1164 | 1164 | || ! empty( $field_content ) |
| 1165 | 1165 | || in_array( $field->type, array( 'honeypot' ) ) |
| 1166 | 1166 | ) { |
| 1167 | - return $field_content; |
|
| 1167 | + return $field_content; |
|
| 1168 | 1168 | } |
| 1169 | 1169 | |
| 1170 | 1170 | // SET SOME FIELD DEFAULTS TO PREVENT ISSUES |
@@ -1172,24 +1172,24 @@ discard block |
||
| 1172 | 1172 | |
| 1173 | 1173 | $field_value = $this->get_field_value( $field ); |
| 1174 | 1174 | |
| 1175 | - // Prevent any PHP warnings, like undefined index |
|
| 1176 | - ob_start(); |
|
| 1175 | + // Prevent any PHP warnings, like undefined index |
|
| 1176 | + ob_start(); |
|
| 1177 | 1177 | |
| 1178 | - $return = null; |
|
| 1178 | + $return = null; |
|
| 1179 | 1179 | |
| 1180 | 1180 | /** @var GravityView_Field $gv_field */ |
| 1181 | 1181 | if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
| 1182 | 1182 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1183 | 1183 | } else { |
| 1184 | - $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1185 | - } |
|
| 1184 | + $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
|
| 1185 | + } |
|
| 1186 | 1186 | |
| 1187 | - // If there was output, it's an error |
|
| 1188 | - $warnings = ob_get_clean(); |
|
| 1187 | + // If there was output, it's an error |
|
| 1188 | + $warnings = ob_get_clean(); |
|
| 1189 | 1189 | |
| 1190 | - if( !empty( $warnings ) ) { |
|
| 1191 | - gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1192 | - } |
|
| 1190 | + if( !empty( $warnings ) ) { |
|
| 1191 | + gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
|
| 1192 | + } |
|
| 1193 | 1193 | |
| 1194 | 1194 | return $return; |
| 1195 | 1195 | } |
@@ -1224,8 +1224,8 @@ discard block |
||
| 1224 | 1224 | $input_id = strval( $input['id'] ); |
| 1225 | 1225 | |
| 1226 | 1226 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1227 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1228 | - $allow_pre_populated = false; |
|
| 1227 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1228 | + $allow_pre_populated = false; |
|
| 1229 | 1229 | } |
| 1230 | 1230 | |
| 1231 | 1231 | } |
@@ -1249,7 +1249,7 @@ discard block |
||
| 1249 | 1249 | if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
| 1250 | 1250 | $categories = array(); |
| 1251 | 1251 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1252 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1252 | + $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1253 | 1253 | } |
| 1254 | 1254 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1255 | 1255 | } |
@@ -1259,25 +1259,25 @@ discard block |
||
| 1259 | 1259 | // if value is empty get the default value if defined |
| 1260 | 1260 | $field_value = $field->get_value_default_if_empty( $field_value ); |
| 1261 | 1261 | |
| 1262 | - /** |
|
| 1263 | - * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1264 | - * @since 1.11 |
|
| 1265 | - * @since 1.20 Added third param |
|
| 1266 | - * @param mixed $field_value field value used to populate the input |
|
| 1267 | - * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1268 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1269 | - */ |
|
| 1270 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1271 | - |
|
| 1272 | - /** |
|
| 1273 | - * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1274 | - * @since 1.17 |
|
| 1275 | - * @since 1.20 Added third param |
|
| 1276 | - * @param mixed $field_value field value used to populate the input |
|
| 1277 | - * @param GF_Field $field Gravity Forms field object |
|
| 1278 | - * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1279 | - */ |
|
| 1280 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1262 | + /** |
|
| 1263 | + * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed |
|
| 1264 | + * @since 1.11 |
|
| 1265 | + * @since 1.20 Added third param |
|
| 1266 | + * @param mixed $field_value field value used to populate the input |
|
| 1267 | + * @param object $field Gravity Forms field object ( Class GF_Field ) |
|
| 1268 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1269 | + */ |
|
| 1270 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this ); |
|
| 1271 | + |
|
| 1272 | + /** |
|
| 1273 | + * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type |
|
| 1274 | + * @since 1.17 |
|
| 1275 | + * @since 1.20 Added third param |
|
| 1276 | + * @param mixed $field_value field value used to populate the input |
|
| 1277 | + * @param GF_Field $field Gravity Forms field object |
|
| 1278 | + * @param GravityView_Edit_Entry_Render $this Current object |
|
| 1279 | + */ |
|
| 1280 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1281 | 1281 | |
| 1282 | 1282 | return $field_value; |
| 1283 | 1283 | } |
@@ -1304,7 +1304,7 @@ discard block |
||
| 1304 | 1304 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1305 | 1305 | // expects certain field array items to be set. |
| 1306 | 1306 | foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) { |
| 1307 | - $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1307 | + $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
|
| 1308 | 1308 | } |
| 1309 | 1309 | |
| 1310 | 1310 | switch( RGFormsModel::get_input_type( $field ) ) { |
@@ -1318,61 +1318,61 @@ discard block |
||
| 1318 | 1318 | */ |
| 1319 | 1319 | case 'fileupload': |
| 1320 | 1320 | |
| 1321 | - // Set the previous value |
|
| 1322 | - $entry = $this->get_entry(); |
|
| 1321 | + // Set the previous value |
|
| 1322 | + $entry = $this->get_entry(); |
|
| 1323 | 1323 | |
| 1324 | - $input_name = 'input_'.$field->id; |
|
| 1325 | - $form_id = $form['id']; |
|
| 1324 | + $input_name = 'input_'.$field->id; |
|
| 1325 | + $form_id = $form['id']; |
|
| 1326 | 1326 | |
| 1327 | - $value = NULL; |
|
| 1327 | + $value = NULL; |
|
| 1328 | 1328 | |
| 1329 | - // Use the previous entry value as the default. |
|
| 1330 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1331 | - $value = $entry[ $field->id ]; |
|
| 1332 | - } |
|
| 1329 | + // Use the previous entry value as the default. |
|
| 1330 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1331 | + $value = $entry[ $field->id ]; |
|
| 1332 | + } |
|
| 1333 | 1333 | |
| 1334 | - // If this is a single upload file |
|
| 1335 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1336 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1337 | - $value = $file_path['url']; |
|
| 1334 | + // If this is a single upload file |
|
| 1335 | + if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1336 | + $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1337 | + $value = $file_path['url']; |
|
| 1338 | 1338 | |
| 1339 | - } else { |
|
| 1339 | + } else { |
|
| 1340 | 1340 | |
| 1341 | - // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1342 | - // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1343 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1341 | + // Fix PHP warning on line 1498 of form_display.php for post_image fields |
|
| 1342 | + // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
|
| 1343 | + $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1344 | 1344 | |
| 1345 | - } |
|
| 1345 | + } |
|
| 1346 | 1346 | |
| 1347 | - if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1347 | + if ( \GV\Utils::get( $field, "multipleFiles" ) ) { |
|
| 1348 | 1348 | |
| 1349 | - // If there are fresh uploads, process and merge them. |
|
| 1350 | - // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1351 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1352 | - $value = empty( $value ) ? '[]' : $value; |
|
| 1353 | - $value = stripslashes_deep( $value ); |
|
| 1354 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1355 | - } |
|
| 1349 | + // If there are fresh uploads, process and merge them. |
|
| 1350 | + // Otherwise, use the passed values, which should be json-encoded array of URLs |
|
| 1351 | + if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1352 | + $value = empty( $value ) ? '[]' : $value; |
|
| 1353 | + $value = stripslashes_deep( $value ); |
|
| 1354 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1355 | + } |
|
| 1356 | 1356 | |
| 1357 | - } else { |
|
| 1357 | + } else { |
|
| 1358 | 1358 | |
| 1359 | - // A file already exists when editing an entry |
|
| 1360 | - // We set this to solve issue when file upload fields are required. |
|
| 1361 | - GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1359 | + // A file already exists when editing an entry |
|
| 1360 | + // We set this to solve issue when file upload fields are required. |
|
| 1361 | + GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value; |
|
| 1362 | 1362 | |
| 1363 | - } |
|
| 1363 | + } |
|
| 1364 | 1364 | |
| 1365 | - $this->entry[ $input_name ] = $value; |
|
| 1366 | - $_POST[ $input_name ] = $value; |
|
| 1365 | + $this->entry[ $input_name ] = $value; |
|
| 1366 | + $_POST[ $input_name ] = $value; |
|
| 1367 | 1367 | |
| 1368 | - break; |
|
| 1368 | + break; |
|
| 1369 | 1369 | |
| 1370 | 1370 | case 'number': |
| 1371 | - // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1372 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1373 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1374 | - } |
|
| 1375 | - break; |
|
| 1371 | + // Fix "undefined index" issue at line 1286 in form_display.php |
|
| 1372 | + if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1373 | + $_POST['input_'.$field->id ] = NULL; |
|
| 1374 | + } |
|
| 1375 | + break; |
|
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | 1378 | } |
@@ -1457,42 +1457,42 @@ discard block |
||
| 1457 | 1457 | case 'fileupload' : |
| 1458 | 1458 | case 'post_image': |
| 1459 | 1459 | |
| 1460 | - // in case nothing is uploaded but there are already files saved |
|
| 1461 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1462 | - $field->failed_validation = false; |
|
| 1463 | - unset( $field->validation_message ); |
|
| 1464 | - } |
|
| 1460 | + // in case nothing is uploaded but there are already files saved |
|
| 1461 | + if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1462 | + $field->failed_validation = false; |
|
| 1463 | + unset( $field->validation_message ); |
|
| 1464 | + } |
|
| 1465 | 1465 | |
| 1466 | - // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1467 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1466 | + // validate if multi file upload reached max number of files [maxFiles] => 2 |
|
| 1467 | + if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1468 | 1468 | |
| 1469 | - $input_name = 'input_' . $field->id; |
|
| 1470 | - //uploaded |
|
| 1471 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1469 | + $input_name = 'input_' . $field->id; |
|
| 1470 | + //uploaded |
|
| 1471 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1472 | 1472 | |
| 1473 | - //existent |
|
| 1474 | - $entry = $this->get_entry(); |
|
| 1475 | - $value = NULL; |
|
| 1476 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1477 | - $value = json_decode( $entry[ $field->id ], true ); |
|
| 1478 | - } |
|
| 1473 | + //existent |
|
| 1474 | + $entry = $this->get_entry(); |
|
| 1475 | + $value = NULL; |
|
| 1476 | + if( isset( $entry[ $field->id ] ) ) { |
|
| 1477 | + $value = json_decode( $entry[ $field->id ], true ); |
|
| 1478 | + } |
|
| 1479 | 1479 | |
| 1480 | - // count uploaded files and existent entry files |
|
| 1481 | - $count_files = count( $file_names ) + count( $value ); |
|
| 1480 | + // count uploaded files and existent entry files |
|
| 1481 | + $count_files = count( $file_names ) + count( $value ); |
|
| 1482 | 1482 | |
| 1483 | - if( $count_files > $field->maxFiles ) { |
|
| 1484 | - $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1485 | - $field->failed_validation = 1; |
|
| 1486 | - $gv_valid = false; |
|
| 1483 | + if( $count_files > $field->maxFiles ) { |
|
| 1484 | + $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
|
| 1485 | + $field->failed_validation = 1; |
|
| 1486 | + $gv_valid = false; |
|
| 1487 | 1487 | |
| 1488 | - // in case of error make sure the newest upload files are removed from the upload input |
|
| 1489 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1490 | - } |
|
| 1488 | + // in case of error make sure the newest upload files are removed from the upload input |
|
| 1489 | + GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1490 | + } |
|
| 1491 | 1491 | |
| 1492 | - } |
|
| 1492 | + } |
|
| 1493 | 1493 | |
| 1494 | 1494 | |
| 1495 | - break; |
|
| 1495 | + break; |
|
| 1496 | 1496 | |
| 1497 | 1497 | } |
| 1498 | 1498 | |
@@ -1503,47 +1503,47 @@ discard block |
||
| 1503 | 1503 | |
| 1504 | 1504 | switch ( $field_type ) { |
| 1505 | 1505 | |
| 1506 | - // Captchas don't need to be re-entered. |
|
| 1507 | - case 'captcha': |
|
| 1506 | + // Captchas don't need to be re-entered. |
|
| 1507 | + case 'captcha': |
|
| 1508 | 1508 | |
| 1509 | - // Post Image fields aren't editable, so we un-fail them. |
|
| 1510 | - case 'post_image': |
|
| 1511 | - $field->failed_validation = false; |
|
| 1512 | - unset( $field->validation_message ); |
|
| 1513 | - break; |
|
| 1509 | + // Post Image fields aren't editable, so we un-fail them. |
|
| 1510 | + case 'post_image': |
|
| 1511 | + $field->failed_validation = false; |
|
| 1512 | + unset( $field->validation_message ); |
|
| 1513 | + break; |
|
| 1514 | 1514 | |
| 1515 | 1515 | } |
| 1516 | 1516 | |
| 1517 | 1517 | // You can't continue inside a switch, so we do it after. |
| 1518 | 1518 | if( empty( $field->failed_validation ) ) { |
| 1519 | - continue; |
|
| 1519 | + continue; |
|
| 1520 | 1520 | } |
| 1521 | 1521 | |
| 1522 | 1522 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1523 | 1523 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1524 | 1524 | if( !empty( $field->noDuplicates ) ) { |
| 1525 | 1525 | |
| 1526 | - $entry = $this->get_entry(); |
|
| 1526 | + $entry = $this->get_entry(); |
|
| 1527 | 1527 | |
| 1528 | - // If the value of the entry is the same as the stored value |
|
| 1529 | - // Then we can assume it's not a duplicate, it's the same. |
|
| 1530 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1531 | - //if value submitted was not changed, then don't validate |
|
| 1532 | - $field->failed_validation = false; |
|
| 1528 | + // If the value of the entry is the same as the stored value |
|
| 1529 | + // Then we can assume it's not a duplicate, it's the same. |
|
| 1530 | + if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1531 | + //if value submitted was not changed, then don't validate |
|
| 1532 | + $field->failed_validation = false; |
|
| 1533 | 1533 | |
| 1534 | - unset( $field->validation_message ); |
|
| 1534 | + unset( $field->validation_message ); |
|
| 1535 | 1535 | |
| 1536 | - gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1536 | + gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) ); |
|
| 1537 | 1537 | |
| 1538 | - continue; |
|
| 1539 | - } |
|
| 1538 | + continue; |
|
| 1539 | + } |
|
| 1540 | 1540 | } |
| 1541 | 1541 | |
| 1542 | 1542 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1543 | 1543 | if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
| 1544 | - unset( $field->validation_message ); |
|
| 1545 | - $field->validation_message = false; |
|
| 1546 | - continue; |
|
| 1544 | + unset( $field->validation_message ); |
|
| 1545 | + $field->validation_message = false; |
|
| 1546 | + continue; |
|
| 1547 | 1547 | } |
| 1548 | 1548 | |
| 1549 | 1549 | $gv_valid = false; |
@@ -1607,8 +1607,8 @@ discard block |
||
| 1607 | 1607 | // Hide fields depending on admin settings |
| 1608 | 1608 | $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
| 1609 | 1609 | |
| 1610 | - // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1611 | - $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1610 | + // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
|
| 1611 | + $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
|
| 1612 | 1612 | |
| 1613 | 1613 | /** |
| 1614 | 1614 | * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form |
@@ -1668,11 +1668,11 @@ discard block |
||
| 1668 | 1668 | // The edit tab has been configured, so we loop through to configured settings |
| 1669 | 1669 | foreach ( $configured_fields as $configured_field ) { |
| 1670 | 1670 | |
| 1671 | - /** @var GF_Field $field */ |
|
| 1672 | - foreach ( $fields as $field ) { |
|
| 1671 | + /** @var GF_Field $field */ |
|
| 1672 | + foreach ( $fields as $field ) { |
|
| 1673 | 1673 | if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
| 1674 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1675 | - break; |
|
| 1674 | + $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1675 | + break; |
|
| 1676 | 1676 | } |
| 1677 | 1677 | |
| 1678 | 1678 | } |
@@ -1728,28 +1728,28 @@ discard block |
||
| 1728 | 1728 | */ |
| 1729 | 1729 | private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) { |
| 1730 | 1730 | |
| 1731 | - /** |
|
| 1731 | + /** |
|
| 1732 | 1732 | * @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 |
| 1733 | - * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1734 | - * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1735 | - * @since 1.9.1 |
|
| 1736 | - * @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. |
|
| 1737 | - * @param array $form GF Form array |
|
| 1738 | - * @param int $view_id View ID |
|
| 1739 | - */ |
|
| 1740 | - $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1741 | - |
|
| 1742 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1733 | + * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators. |
|
| 1734 | + * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions |
|
| 1735 | + * @since 1.9.1 |
|
| 1736 | + * @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. |
|
| 1737 | + * @param array $form GF Form array |
|
| 1738 | + * @param int $view_id View ID |
|
| 1739 | + */ |
|
| 1740 | + $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
|
| 1741 | + |
|
| 1742 | + if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1743 | 1743 | foreach( $fields as $k => $field ) { |
| 1744 | 1744 | if( $field->adminOnly ) { |
| 1745 | - unset( $fields[ $k ] ); |
|
| 1745 | + unset( $fields[ $k ] ); |
|
| 1746 | 1746 | } |
| 1747 | 1747 | } |
| 1748 | 1748 | return array_values( $fields ); |
| 1749 | 1749 | } |
| 1750 | 1750 | |
| 1751 | - foreach( $fields as &$field ) { |
|
| 1752 | - $field->adminOnly = false; |
|
| 1751 | + foreach( $fields as &$field ) { |
|
| 1752 | + $field->adminOnly = false; |
|
| 1753 | 1753 | } |
| 1754 | 1754 | |
| 1755 | 1755 | return $fields; |
@@ -1769,13 +1769,13 @@ discard block |
||
| 1769 | 1769 | */ |
| 1770 | 1770 | private function unselect_default_values( $form ) { |
| 1771 | 1771 | |
| 1772 | - foreach ( $form['fields'] as &$field ) { |
|
| 1772 | + foreach ( $form['fields'] as &$field ) { |
|
| 1773 | 1773 | |
| 1774 | 1774 | if ( empty( $field->choices ) ) { |
| 1775 | - continue; |
|
| 1775 | + continue; |
|
| 1776 | 1776 | } |
| 1777 | 1777 | |
| 1778 | - foreach ( $field->choices as &$choice ) { |
|
| 1778 | + foreach ( $field->choices as &$choice ) { |
|
| 1779 | 1779 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 1780 | 1780 | $choice['isSelected'] = false; |
| 1781 | 1781 | } |
@@ -1812,36 +1812,36 @@ discard block |
||
| 1812 | 1812 | |
| 1813 | 1813 | if( 'checkbox' === $field->type ) { |
| 1814 | 1814 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1815 | - $input_id = $input['id']; |
|
| 1816 | - $choice = $field->choices[ $key ]; |
|
| 1817 | - $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 1818 | - $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 1819 | - if( $match ) { |
|
| 1820 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 1821 | - } |
|
| 1815 | + $input_id = $input['id']; |
|
| 1816 | + $choice = $field->choices[ $key ]; |
|
| 1817 | + $value = \GV\Utils::get( $this->entry, $input_id ); |
|
| 1818 | + $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
|
| 1819 | + if( $match ) { |
|
| 1820 | + $field->choices[ $key ]['isSelected'] = true; |
|
| 1821 | + } |
|
| 1822 | 1822 | } |
| 1823 | 1823 | } else { |
| 1824 | 1824 | |
| 1825 | 1825 | // We need to run through each field to set the default values |
| 1826 | 1826 | foreach ( $this->entry as $field_id => $field_value ) { |
| 1827 | 1827 | |
| 1828 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1828 | + if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1829 | 1829 | |
| 1830 | - if( 'list' === $field->type ) { |
|
| 1831 | - $list_rows = maybe_unserialize( $field_value ); |
|
| 1830 | + if( 'list' === $field->type ) { |
|
| 1831 | + $list_rows = maybe_unserialize( $field_value ); |
|
| 1832 | 1832 | |
| 1833 | - $list_field_value = array(); |
|
| 1834 | - foreach ( (array) $list_rows as $row ) { |
|
| 1835 | - foreach ( (array) $row as $column ) { |
|
| 1836 | - $list_field_value[] = $column; |
|
| 1837 | - } |
|
| 1838 | - } |
|
| 1833 | + $list_field_value = array(); |
|
| 1834 | + foreach ( (array) $list_rows as $row ) { |
|
| 1835 | + foreach ( (array) $row as $column ) { |
|
| 1836 | + $list_field_value[] = $column; |
|
| 1837 | + } |
|
| 1838 | + } |
|
| 1839 | 1839 | |
| 1840 | - $field->defaultValue = serialize( $list_field_value ); |
|
| 1841 | - } else { |
|
| 1842 | - $field->defaultValue = $field_value; |
|
| 1843 | - } |
|
| 1844 | - } |
|
| 1840 | + $field->defaultValue = serialize( $list_field_value ); |
|
| 1841 | + } else { |
|
| 1842 | + $field->defaultValue = $field_value; |
|
| 1843 | + } |
|
| 1844 | + } |
|
| 1845 | 1845 | } |
| 1846 | 1846 | } |
| 1847 | 1847 | } |
@@ -1898,7 +1898,7 @@ discard block |
||
| 1898 | 1898 | return $has_conditional_logic; |
| 1899 | 1899 | } |
| 1900 | 1900 | |
| 1901 | - /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 1901 | + /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */ |
|
| 1902 | 1902 | return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form ); |
| 1903 | 1903 | } |
| 1904 | 1904 | |
@@ -1965,14 +1965,14 @@ discard block |
||
| 1965 | 1965 | |
| 1966 | 1966 | if( $echo && $error !== true ) { |
| 1967 | 1967 | |
| 1968 | - $error = esc_html( $error ); |
|
| 1968 | + $error = esc_html( $error ); |
|
| 1969 | 1969 | |
| 1970 | - /** |
|
| 1971 | - * @since 1.9 |
|
| 1972 | - */ |
|
| 1973 | - if ( ! empty( $this->entry ) ) { |
|
| 1974 | - $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;" ) ); |
|
| 1975 | - } |
|
| 1970 | + /** |
|
| 1971 | + * @since 1.9 |
|
| 1972 | + */ |
|
| 1973 | + if ( ! empty( $this->entry ) ) { |
|
| 1974 | + $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;" ) ); |
|
| 1975 | + } |
|
| 1976 | 1976 | |
| 1977 | 1977 | echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
| 1978 | 1978 | } |
@@ -115,16 +115,16 @@ discard block |
||
| 115 | 115 | function load() { |
| 116 | 116 | |
| 117 | 117 | /** @define "GRAVITYVIEW_DIR" "../../../" */ |
| 118 | - include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' ); |
|
| 118 | + include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' ); |
|
| 119 | 119 | |
| 120 | 120 | // Don't display an embedded form when editing an entry |
| 121 | 121 | add_action( 'wp_head', array( $this, 'prevent_render_form' ) ); |
| 122 | 122 | add_action( 'wp_footer', array( $this, 'prevent_render_form' ) ); |
| 123 | 123 | |
| 124 | 124 | // Stop Gravity Forms processing what is ours! |
| 125 | - add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 ); |
|
| 125 | + add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 ); |
|
| 126 | 126 | |
| 127 | - add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') ); |
|
| 127 | + add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) ); |
|
| 128 | 128 | |
| 129 | 129 | add_action( 'gravityview_edit_entry', array( $this, 'init' ) ); |
| 130 | 130 | |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 ); |
| 136 | 136 | |
| 137 | 137 | // Add fields expected by GFFormDisplay::validate() |
| 138 | - add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') ); |
|
| 138 | + add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) ); |
|
| 139 | 139 | |
| 140 | 140 | // Fix multiselect value for GF 2.2 |
| 141 | 141 | add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 ); |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | * @return void |
| 153 | 153 | */ |
| 154 | 154 | public function prevent_render_form() { |
| 155 | - if( $this->is_edit_entry() ) { |
|
| 156 | - if( 'wp_head' === current_filter() ) { |
|
| 155 | + if ( $this->is_edit_entry() ) { |
|
| 156 | + if ( 'wp_head' === current_filter() ) { |
|
| 157 | 157 | add_filter( 'gform_shortcode_form', '__return_empty_string' ); |
| 158 | 158 | } else { |
| 159 | 159 | remove_filter( 'gform_shortcode_form', '__return_empty_string' ); |
@@ -168,13 +168,13 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function prevent_maybe_process_form() { |
| 170 | 170 | |
| 171 | - if( ! empty( $_POST ) ) { |
|
| 171 | + if ( ! empty( $_POST ) ) { |
|
| 172 | 172 | gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) ); |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if( $this->is_edit_entry_submission() ) { |
|
| 176 | - remove_action( 'wp', array( 'RGForms', 'maybe_process_form'), 9 ); |
|
| 177 | - remove_action( 'wp', array( 'GFForms', 'maybe_process_form'), 9 ); |
|
| 175 | + if ( $this->is_edit_entry_submission() ) { |
|
| 176 | + remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 ); |
|
| 177 | + remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 ); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function is_edit_entry() { |
| 186 | 186 | |
| 187 | - $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] ); |
|
| 187 | + $is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] ); |
|
| 188 | 188 | |
| 189 | 189 | return ( $is_edit_entry || $this->is_edit_entry_submission() ); |
| 190 | 190 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @return boolean |
| 196 | 196 | */ |
| 197 | 197 | public function is_edit_entry_submission() { |
| 198 | - return !empty( $_POST[ self::$nonce_field ] ); |
|
| 198 | + return ! empty( $_POST[ self::$nonce_field ] ); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | |
| 210 | 210 | $entries = $gravityview_view->getEntries(); |
| 211 | - self::$original_entry = $entries[0]; |
|
| 212 | - $this->entry = $entries[0]; |
|
| 211 | + self::$original_entry = $entries[ 0 ]; |
|
| 212 | + $this->entry = $entries[ 0 ]; |
|
| 213 | 213 | |
| 214 | 214 | self::$original_form = $gravityview_view->getForm(); |
| 215 | 215 | $this->form = $gravityview_view->getForm(); |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $this->view_id = $gravityview_view->getViewId(); |
| 218 | 218 | $this->post_id = \GV\Utils::get( $post, 'ID', null ); |
| 219 | 219 | |
| 220 | - self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] ); |
|
| 220 | + self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] ); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | |
@@ -268,9 +268,9 @@ discard block |
||
| 268 | 268 | private function print_scripts() { |
| 269 | 269 | $gravityview_view = GravityView_View::getInstance(); |
| 270 | 270 | |
| 271 | - wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 271 | + wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) ); |
|
| 272 | 272 | |
| 273 | - GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false); |
|
| 273 | + GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false ); |
|
| 274 | 274 | |
| 275 | 275 | wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) ); |
| 276 | 276 | |
@@ -286,19 +286,19 @@ discard block |
||
| 286 | 286 | */ |
| 287 | 287 | private function process_save( $gv_data ) { |
| 288 | 288 | |
| 289 | - if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) { |
|
| 289 | + if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) { |
|
| 290 | 290 | return; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | // Make sure the entry, view, and form IDs are all correct |
| 294 | 294 | $valid = $this->verify_nonce(); |
| 295 | 295 | |
| 296 | - if ( !$valid ) { |
|
| 296 | + if ( ! $valid ) { |
|
| 297 | 297 | gravityview()->log->error( 'Nonce validation failed.' ); |
| 298 | 298 | return; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - if ( $this->entry['id'] !== $_POST['lid'] ) { |
|
| 301 | + if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) { |
|
| 302 | 302 | gravityview()->log->error( 'Entry ID did not match posted entry ID.' ); |
| 303 | 303 | return; |
| 304 | 304 | } |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | $this->validate(); |
| 311 | 311 | |
| 312 | - if( $this->is_valid ) { |
|
| 312 | + if ( $this->is_valid ) { |
|
| 313 | 313 | |
| 314 | 314 | gravityview()->log->debug( 'Submission is valid.' ); |
| 315 | 315 | |
@@ -321,22 +321,22 @@ discard block |
||
| 321 | 321 | /** |
| 322 | 322 | * @hack to avoid the capability validation of the method save_lead for GF 1.9+ |
| 323 | 323 | */ |
| 324 | - unset( $_GET['page'] ); |
|
| 324 | + unset( $_GET[ 'page' ] ); |
|
| 325 | 325 | |
| 326 | - $date_created = $this->entry['date_created']; |
|
| 326 | + $date_created = $this->entry[ 'date_created' ]; |
|
| 327 | 327 | |
| 328 | 328 | /** |
| 329 | 329 | * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead() |
| 330 | 330 | * @since 1.17.2 |
| 331 | 331 | */ |
| 332 | - unset( $this->entry['date_created'] ); |
|
| 332 | + unset( $this->entry[ 'date_created' ] ); |
|
| 333 | 333 | |
| 334 | 334 | GFFormsModel::save_lead( $form, $this->entry ); |
| 335 | 335 | |
| 336 | 336 | // Delete the values for hidden inputs |
| 337 | 337 | $this->unset_hidden_field_values(); |
| 338 | 338 | |
| 339 | - $this->entry['date_created'] = $date_created; |
|
| 339 | + $this->entry[ 'date_created' ] = $date_created; |
|
| 340 | 340 | |
| 341 | 341 | // Process calculation fields |
| 342 | 342 | $this->update_calculation_fields(); |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | * @param GravityView_Edit_Entry_Render $this This object |
| 362 | 362 | * @param GravityView_View_Data $gv_data The View data |
| 363 | 363 | */ |
| 364 | - do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data ); |
|
| 364 | + do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data ); |
|
| 365 | 365 | |
| 366 | 366 | } else { |
| 367 | 367 | gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) ); |
@@ -389,16 +389,16 @@ discard block |
||
| 389 | 389 | */ |
| 390 | 390 | $unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this ); |
| 391 | 391 | |
| 392 | - if( ! $unset_hidden_field_values ) { |
|
| 392 | + if ( ! $unset_hidden_field_values ) { |
|
| 393 | 393 | return; |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) { |
| 397 | 397 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 398 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) ); |
|
| 398 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) ); |
|
| 399 | 399 | } else { |
| 400 | 400 | $lead_detail_table = GFFormsModel::get_lead_details_table_name(); |
| 401 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) ); |
|
| 401 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) ); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | foreach ( $this->entry as $input_id => $field_value ) { |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | /** No file is being uploaded. */ |
| 482 | - if ( empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 482 | + if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 483 | 483 | /** So return the original upload */ |
| 484 | 484 | return $entry[ $input_id ]; |
| 485 | 485 | } |
@@ -497,11 +497,11 @@ discard block |
||
| 497 | 497 | * @return mixed |
| 498 | 498 | */ |
| 499 | 499 | public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) { |
| 500 | - if( ! $this->is_edit_entry() ) { |
|
| 500 | + if ( ! $this->is_edit_entry() ) { |
|
| 501 | 501 | return $plupload_init; |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | - $plupload_init['gf_vars']['max_files'] = 0; |
|
| 504 | + $plupload_init[ 'gf_vars' ][ 'max_files' ] = 0; |
|
| 505 | 505 | |
| 506 | 506 | return $plupload_init; |
| 507 | 507 | } |
@@ -516,27 +516,27 @@ discard block |
||
| 516 | 516 | $form = $this->form; |
| 517 | 517 | |
| 518 | 518 | /** @var GF_Field $field */ |
| 519 | - foreach( $form['fields'] as $k => &$field ) { |
|
| 519 | + foreach ( $form[ 'fields' ] as $k => &$field ) { |
|
| 520 | 520 | |
| 521 | 521 | /** |
| 522 | 522 | * Remove the fields with calculation formulas before save to avoid conflicts with GF logic |
| 523 | 523 | * @since 1.16.3 |
| 524 | 524 | * @var GF_Field $field |
| 525 | 525 | */ |
| 526 | - if( $field->has_calculation() ) { |
|
| 527 | - unset( $form['fields'][ $k ] ); |
|
| 526 | + if ( $field->has_calculation() ) { |
|
| 527 | + unset( $form[ 'fields' ][ $k ] ); |
|
| 528 | 528 | } |
| 529 | 529 | |
| 530 | 530 | $field->adminOnly = false; |
| 531 | 531 | |
| 532 | - if( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 533 | - foreach( $field->inputs as $key => $input ) { |
|
| 534 | - $field->inputs[ $key ][ 'id' ] = (string)$input['id']; |
|
| 532 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) ) { |
|
| 533 | + foreach ( $field->inputs as $key => $input ) { |
|
| 534 | + $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ]; |
|
| 535 | 535 | } |
| 536 | 536 | } |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - $form['fields'] = array_values( $form['fields'] ); |
|
| 539 | + $form[ 'fields' ] = array_values( $form[ 'fields' ] ); |
|
| 540 | 540 | |
| 541 | 541 | return $form; |
| 542 | 542 | } |
@@ -548,10 +548,10 @@ discard block |
||
| 548 | 548 | $update = false; |
| 549 | 549 | |
| 550 | 550 | // get the most up to date entry values |
| 551 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 551 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 552 | 552 | |
| 553 | 553 | $entry_meta_table = GFFormsModel::get_entry_meta_table_name(); |
| 554 | - $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, meta_key FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) ); |
|
| 554 | + $current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, meta_key FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) ); |
|
| 555 | 555 | |
| 556 | 556 | if ( ! empty( $this->fields_with_calculation ) ) { |
| 557 | 557 | $update = true; |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | $inputs = $field->get_entry_inputs(); |
| 560 | 560 | if ( is_array( $inputs ) ) { |
| 561 | 561 | foreach ( $inputs as $input ) { |
| 562 | - GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] ); |
|
| 562 | + GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] ); |
|
| 563 | 563 | } |
| 564 | 564 | } else { |
| 565 | 565 | GFFormsModel::save_input( $form, $field, $entry, $current_fields, $field->id ); |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | return; |
| 580 | 580 | } |
| 581 | 581 | |
| 582 | - $entry = GFAPI::get_entry( $this->entry['id'] ); |
|
| 582 | + $entry = GFAPI::get_entry( $this->entry[ 'id' ] ); |
|
| 583 | 583 | |
| 584 | 584 | foreach ( array( 'score', 'percent', 'grade', 'is_pass' ) as $meta ) { |
| 585 | 585 | GFQuiz::get_instance()->update_entry_meta( "gfquiz_$meta", $entry, self::$original_form ); |
@@ -609,19 +609,19 @@ discard block |
||
| 609 | 609 | |
| 610 | 610 | $input_name = 'input_' . $field_id; |
| 611 | 611 | |
| 612 | - if ( !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 612 | + if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 613 | 613 | |
| 614 | 614 | // We have a new image |
| 615 | 615 | |
| 616 | - $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] ); |
|
| 616 | + $value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] ); |
|
| 617 | 617 | |
| 618 | 618 | $ary = ! empty( $value ) ? explode( '|:|', $value ) : array(); |
| 619 | 619 | $ary = stripslashes_deep( $ary ); |
| 620 | 620 | $img_url = \GV\Utils::get( $ary, 0 ); |
| 621 | 621 | |
| 622 | - $img_title = count( $ary ) > 1 ? $ary[1] : ''; |
|
| 623 | - $img_caption = count( $ary ) > 2 ? $ary[2] : ''; |
|
| 624 | - $img_description = count( $ary ) > 3 ? $ary[3] : ''; |
|
| 622 | + $img_title = count( $ary ) > 1 ? $ary[ 1 ] : ''; |
|
| 623 | + $img_caption = count( $ary ) > 2 ? $ary[ 2 ] : ''; |
|
| 624 | + $img_description = count( $ary ) > 3 ? $ary[ 3 ] : ''; |
|
| 625 | 625 | |
| 626 | 626 | $image_meta = array( |
| 627 | 627 | 'post_excerpt' => $img_caption, |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | |
| 631 | 631 | //adding title only if it is not empty. It will default to the file name if it is not in the array |
| 632 | 632 | if ( ! empty( $img_title ) ) { |
| 633 | - $image_meta['post_title'] = $img_title; |
|
| 633 | + $image_meta[ 'post_title' ] = $img_title; |
|
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | /** |
@@ -688,15 +688,15 @@ discard block |
||
| 688 | 688 | */ |
| 689 | 689 | private function maybe_update_post_fields( $form ) { |
| 690 | 690 | |
| 691 | - if( empty( $this->entry['post_id'] ) ) { |
|
| 691 | + if ( empty( $this->entry[ 'post_id' ] ) ) { |
|
| 692 | 692 | gravityview()->log->debug( 'This entry has no post fields. Continuing...' ); |
| 693 | 693 | return; |
| 694 | 694 | } |
| 695 | 695 | |
| 696 | - $post_id = $this->entry['post_id']; |
|
| 696 | + $post_id = $this->entry[ 'post_id' ]; |
|
| 697 | 697 | |
| 698 | 698 | // Security check |
| 699 | - if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 699 | + if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) { |
|
| 700 | 700 | gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) ); |
| 701 | 701 | return; |
| 702 | 702 | } |
@@ -709,25 +709,25 @@ discard block |
||
| 709 | 709 | |
| 710 | 710 | $field = RGFormsModel::get_field( $form, $field_id ); |
| 711 | 711 | |
| 712 | - if( ! $field ) { |
|
| 712 | + if ( ! $field ) { |
|
| 713 | 713 | continue; |
| 714 | 714 | } |
| 715 | 715 | |
| 716 | - if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 716 | + if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) { |
|
| 717 | 717 | |
| 718 | 718 | // Get the value of the field, including $_POSTed value |
| 719 | 719 | $value = RGFormsModel::get_field_value( $field ); |
| 720 | 720 | |
| 721 | 721 | // Use temporary entry variable, to make values available to fill_post_template() and update_post_image() |
| 722 | 722 | $entry_tmp = $this->entry; |
| 723 | - $entry_tmp["{$field_id}"] = $value; |
|
| 723 | + $entry_tmp[ "{$field_id}" ] = $value; |
|
| 724 | 724 | |
| 725 | - switch( $field->type ) { |
|
| 725 | + switch ( $field->type ) { |
|
| 726 | 726 | |
| 727 | 727 | case 'post_title': |
| 728 | 728 | $post_title = $value; |
| 729 | 729 | if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) { |
| 730 | - $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp ); |
|
| 730 | + $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp ); |
|
| 731 | 731 | } |
| 732 | 732 | $updated_post->post_title = $post_title; |
| 733 | 733 | $updated_post->post_name = $post_title; |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | case 'post_content': |
| 738 | 738 | $post_content = $value; |
| 739 | 739 | if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) { |
| 740 | - $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true ); |
|
| 740 | + $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true ); |
|
| 741 | 741 | } |
| 742 | 742 | $updated_post->post_content = $post_content; |
| 743 | 743 | unset( $post_content ); |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | $value = $value[ $field_id ]; |
| 756 | 756 | } |
| 757 | 757 | |
| 758 | - if( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 758 | + if ( ! empty( $field->customFieldTemplateEnabled ) ) { |
|
| 759 | 759 | $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true ); |
| 760 | 760 | } |
| 761 | 761 | |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | // update entry after |
| 776 | - $this->entry["{$field_id}"] = $value; |
|
| 776 | + $this->entry[ "{$field_id}" ] = $value; |
|
| 777 | 777 | |
| 778 | 778 | $update_entry = true; |
| 779 | 779 | |
@@ -782,11 +782,11 @@ discard block |
||
| 782 | 782 | |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | - if( $update_entry ) { |
|
| 785 | + if ( $update_entry ) { |
|
| 786 | 786 | |
| 787 | 787 | $return_entry = GFAPI::update_entry( $this->entry ); |
| 788 | 788 | |
| 789 | - if( is_wp_error( $return_entry ) ) { |
|
| 789 | + if ( is_wp_error( $return_entry ) ) { |
|
| 790 | 790 | gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) ); |
| 791 | 791 | } else { |
| 792 | 792 | gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) ); |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | |
| 797 | 797 | $return_post = wp_update_post( $updated_post, true ); |
| 798 | 798 | |
| 799 | - if( is_wp_error( $return_post ) ) { |
|
| 799 | + if ( is_wp_error( $return_post ) ) { |
|
| 800 | 800 | $return_post->add_data( $updated_post, '$updated_post' ); |
| 801 | 801 | gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) ); |
| 802 | 802 | } else { |
@@ -818,7 +818,7 @@ discard block |
||
| 818 | 818 | $input_type = RGFormsModel::get_input_type( $field ); |
| 819 | 819 | |
| 820 | 820 | // Only certain custom field types are supported |
| 821 | - switch( $input_type ) { |
|
| 821 | + switch ( $input_type ) { |
|
| 822 | 822 | case 'fileupload': |
| 823 | 823 | case 'list': |
| 824 | 824 | case 'multiselect': |
@@ -855,7 +855,7 @@ discard block |
||
| 855 | 855 | $output = GFCommon::replace_variables( $output, $form, $entry, false, false, false ); |
| 856 | 856 | |
| 857 | 857 | // replace conditional shortcodes |
| 858 | - if( $do_shortcode ) { |
|
| 858 | + if ( $do_shortcode ) { |
|
| 859 | 859 | $output = do_shortcode( $output ); |
| 860 | 860 | } |
| 861 | 861 | |
@@ -874,19 +874,19 @@ discard block |
||
| 874 | 874 | */ |
| 875 | 875 | private function after_update() { |
| 876 | 876 | |
| 877 | - do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry ); |
|
| 878 | - do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry ); |
|
| 877 | + do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 878 | + do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry ); |
|
| 879 | 879 | |
| 880 | 880 | // Re-define the entry now that we've updated it. |
| 881 | - $entry = RGFormsModel::get_lead( $this->entry['id'] ); |
|
| 881 | + $entry = RGFormsModel::get_lead( $this->entry[ 'id' ] ); |
|
| 882 | 882 | |
| 883 | 883 | $entry = GFFormsModel::set_entry_meta( $entry, $this->form ); |
| 884 | 884 | |
| 885 | 885 | if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) { |
| 886 | 886 | // We need to clear the cache because Gravity Forms caches the field values, which |
| 887 | 887 | // we have just updated. |
| 888 | - foreach ($this->form['fields'] as $key => $field) { |
|
| 889 | - GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id ); |
|
| 888 | + foreach ( $this->form[ 'fields' ] as $key => $field ) { |
|
| 889 | + GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id ); |
|
| 890 | 890 | } |
| 891 | 891 | } |
| 892 | 892 | |
@@ -905,7 +905,7 @@ discard block |
||
| 905 | 905 | |
| 906 | 906 | <div class="gv-edit-entry-wrapper"><?php |
| 907 | 907 | |
| 908 | - $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this ); |
|
| 908 | + $javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this ); |
|
| 909 | 909 | |
| 910 | 910 | /** |
| 911 | 911 | * Fixes weird wpautop() issue |
@@ -921,7 +921,7 @@ discard block |
||
| 921 | 921 | * @param string $edit_entry_title Modify the "Edit Entry" title |
| 922 | 922 | * @param GravityView_Edit_Entry_Render $this This object |
| 923 | 923 | */ |
| 924 | - $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this ); |
|
| 924 | + $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this ); |
|
| 925 | 925 | |
| 926 | 926 | echo esc_attr( $edit_entry_title ); |
| 927 | 927 | ?></span> |
@@ -971,16 +971,16 @@ discard block |
||
| 971 | 971 | |
| 972 | 972 | $back_link = remove_query_arg( array( 'page', 'view', 'edit' ) ); |
| 973 | 973 | |
| 974 | - if( ! $this->is_valid ){ |
|
| 974 | + if ( ! $this->is_valid ) { |
|
| 975 | 975 | |
| 976 | 976 | // Keeping this compatible with Gravity Forms. |
| 977 | - $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; |
|
| 978 | - $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); |
|
| 977 | + $validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>"; |
|
| 978 | + $message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form ); |
|
| 979 | 979 | |
| 980 | - echo GVCommon::generate_notice( $message , 'gv-error' ); |
|
| 980 | + echo GVCommon::generate_notice( $message, 'gv-error' ); |
|
| 981 | 981 | |
| 982 | 982 | } else { |
| 983 | - $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' ); |
|
| 983 | + $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' ); |
|
| 984 | 984 | |
| 985 | 985 | /** |
| 986 | 986 | * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) |
@@ -990,7 +990,7 @@ discard block |
||
| 990 | 990 | * @param array $entry Gravity Forms entry array |
| 991 | 991 | * @param string $back_link URL to return to the original entry. @since 1.6 |
| 992 | 992 | */ |
| 993 | - $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link ); |
|
| 993 | + $message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link ); |
|
| 994 | 994 | |
| 995 | 995 | echo GVCommon::generate_notice( $message ); |
| 996 | 996 | } |
@@ -1014,21 +1014,21 @@ discard block |
||
| 1014 | 1014 | */ |
| 1015 | 1015 | do_action( 'gravityview/edit-entry/render/before', $this ); |
| 1016 | 1016 | |
| 1017 | - add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 ); |
|
| 1018 | - add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') ); |
|
| 1017 | + add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 ); |
|
| 1018 | + add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) ); |
|
| 1019 | 1019 | add_filter( 'gform_disable_view_counter', '__return_true' ); |
| 1020 | 1020 | |
| 1021 | 1021 | add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 ); |
| 1022 | 1022 | add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 ); |
| 1023 | 1023 | |
| 1024 | 1024 | // We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin. |
| 1025 | - unset( $_GET['page'] ); |
|
| 1025 | + unset( $_GET[ 'page' ] ); |
|
| 1026 | 1026 | |
| 1027 | 1027 | // TODO: Verify multiple-page forms |
| 1028 | 1028 | |
| 1029 | 1029 | ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic |
| 1030 | 1030 | |
| 1031 | - $html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry ); |
|
| 1031 | + $html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry ); |
|
| 1032 | 1032 | |
| 1033 | 1033 | ob_get_clean(); |
| 1034 | 1034 | |
@@ -1054,7 +1054,7 @@ discard block |
||
| 1054 | 1054 | * @return string |
| 1055 | 1055 | */ |
| 1056 | 1056 | public function render_form_buttons() { |
| 1057 | - return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this ); |
|
| 1057 | + return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this ); |
|
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | |
@@ -1074,10 +1074,10 @@ discard block |
||
| 1074 | 1074 | public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) { |
| 1075 | 1075 | |
| 1076 | 1076 | // In case we have validated the form, use it to inject the validation results into the form render |
| 1077 | - if( isset( $this->form_after_validation ) ) { |
|
| 1077 | + if ( isset( $this->form_after_validation ) ) { |
|
| 1078 | 1078 | $form = $this->form_after_validation; |
| 1079 | 1079 | } else { |
| 1080 | - $form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1080 | + $form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id ); |
|
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | 1083 | $form = $this->filter_conditional_logic( $form ); |
@@ -1085,8 +1085,8 @@ discard block |
||
| 1085 | 1085 | $form = $this->prefill_conditional_logic( $form ); |
| 1086 | 1086 | |
| 1087 | 1087 | // for now we don't support Save and Continue feature. |
| 1088 | - if( ! self::$supports_save_and_continue ) { |
|
| 1089 | - unset( $form['save'] ); |
|
| 1088 | + if ( ! self::$supports_save_and_continue ) { |
|
| 1089 | + unset( $form[ 'save' ] ); |
|
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | 1092 | $form = $this->unselect_default_values( $form ); |
@@ -1109,31 +1109,31 @@ discard block |
||
| 1109 | 1109 | */ |
| 1110 | 1110 | public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) { |
| 1111 | 1111 | |
| 1112 | - if( ! GFCommon::is_post_field( $field ) ) { |
|
| 1112 | + if ( ! GFCommon::is_post_field( $field ) ) { |
|
| 1113 | 1113 | return $field_content; |
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | 1116 | $message = null; |
| 1117 | 1117 | |
| 1118 | 1118 | // First, make sure they have the capability to edit the post. |
| 1119 | - if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) { |
|
| 1119 | + if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) { |
|
| 1120 | 1120 | |
| 1121 | 1121 | /** |
| 1122 | 1122 | * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post |
| 1123 | 1123 | * @param string $message The existing "You don't have permission..." text |
| 1124 | 1124 | */ |
| 1125 | - $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don’t have permission to edit this post.', 'gravityview') ); |
|
| 1125 | + $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don’t have permission to edit this post.', 'gravityview' ) ); |
|
| 1126 | 1126 | |
| 1127 | - } elseif( null === get_post( $this->entry['post_id'] ) ) { |
|
| 1127 | + } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) { |
|
| 1128 | 1128 | /** |
| 1129 | 1129 | * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists |
| 1130 | 1130 | * @param string $message The existing "This field is not editable; the post no longer exists." text |
| 1131 | 1131 | */ |
| 1132 | - $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1132 | + $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) ); |
|
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | - if( $message ) { |
|
| 1136 | - $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1135 | + if ( $message ) { |
|
| 1136 | + $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) ); |
|
| 1137 | 1137 | } |
| 1138 | 1138 | |
| 1139 | 1139 | return $field_content; |
@@ -1157,8 +1157,8 @@ discard block |
||
| 1157 | 1157 | |
| 1158 | 1158 | // If the form has been submitted, then we don't need to pre-fill the values, |
| 1159 | 1159 | // Except for fileupload type and when a field input is overridden- run always!! |
| 1160 | - if( |
|
| 1161 | - ( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1160 | + if ( |
|
| 1161 | + ( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) ) |
|
| 1162 | 1162 | && false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) |
| 1163 | 1163 | && ! GFCommon::is_product_field( $field->type ) |
| 1164 | 1164 | || ! empty( $field_content ) |
@@ -1178,7 +1178,7 @@ discard block |
||
| 1178 | 1178 | $return = null; |
| 1179 | 1179 | |
| 1180 | 1180 | /** @var GravityView_Field $gv_field */ |
| 1181 | - if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1181 | + if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) { |
|
| 1182 | 1182 | $return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field ); |
| 1183 | 1183 | } else { |
| 1184 | 1184 | $return = $field->get_field_input( $this->form, $field_value, $this->entry ); |
@@ -1187,7 +1187,7 @@ discard block |
||
| 1187 | 1187 | // If there was output, it's an error |
| 1188 | 1188 | $warnings = ob_get_clean(); |
| 1189 | 1189 | |
| 1190 | - if( !empty( $warnings ) ) { |
|
| 1190 | + if ( ! empty( $warnings ) ) { |
|
| 1191 | 1191 | gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) ); |
| 1192 | 1192 | } |
| 1193 | 1193 | |
@@ -1212,7 +1212,7 @@ discard block |
||
| 1212 | 1212 | $override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field ); |
| 1213 | 1213 | |
| 1214 | 1214 | // We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs) |
| 1215 | - if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1215 | + if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) { |
|
| 1216 | 1216 | |
| 1217 | 1217 | $field_value = array(); |
| 1218 | 1218 | |
@@ -1221,10 +1221,10 @@ discard block |
||
| 1221 | 1221 | |
| 1222 | 1222 | foreach ( (array)$field->inputs as $input ) { |
| 1223 | 1223 | |
| 1224 | - $input_id = strval( $input['id'] ); |
|
| 1224 | + $input_id = strval( $input[ 'id' ] ); |
|
| 1225 | 1225 | |
| 1226 | 1226 | if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) { |
| 1227 | - $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1227 | + $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ]; |
|
| 1228 | 1228 | $allow_pre_populated = false; |
| 1229 | 1229 | } |
| 1230 | 1230 | |
@@ -1232,7 +1232,7 @@ discard block |
||
| 1232 | 1232 | |
| 1233 | 1233 | $pre_value = $field->get_value_submission( array(), false ); |
| 1234 | 1234 | |
| 1235 | - $field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1235 | + $field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value; |
|
| 1236 | 1236 | |
| 1237 | 1237 | } else { |
| 1238 | 1238 | |
@@ -1243,13 +1243,13 @@ discard block |
||
| 1243 | 1243 | |
| 1244 | 1244 | // saved field entry value (if empty, fallback to the pre-populated value, if exists) |
| 1245 | 1245 | // or pre-populated value if not empty and set to override saved value |
| 1246 | - $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; |
|
| 1246 | + $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; |
|
| 1247 | 1247 | |
| 1248 | 1248 | // in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs. |
| 1249 | - if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) { |
|
| 1249 | + if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) { |
|
| 1250 | 1250 | $categories = array(); |
| 1251 | 1251 | foreach ( explode( ',', $field_value ) as $cat_string ) { |
| 1252 | - $categories[] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1252 | + $categories[ ] = GFCommon::format_post_category( $cat_string, true ); |
|
| 1253 | 1253 | } |
| 1254 | 1254 | $field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories ); |
| 1255 | 1255 | } |
@@ -1277,7 +1277,7 @@ discard block |
||
| 1277 | 1277 | * @param GF_Field $field Gravity Forms field object |
| 1278 | 1278 | * @param GravityView_Edit_Entry_Render $this Current object |
| 1279 | 1279 | */ |
| 1280 | - $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this ); |
|
| 1280 | + $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this ); |
|
| 1281 | 1281 | |
| 1282 | 1282 | return $field_value; |
| 1283 | 1283 | } |
@@ -1294,12 +1294,12 @@ discard block |
||
| 1294 | 1294 | */ |
| 1295 | 1295 | public function gform_pre_validation( $form ) { |
| 1296 | 1296 | |
| 1297 | - if( ! $this->verify_nonce() ) { |
|
| 1297 | + if ( ! $this->verify_nonce() ) { |
|
| 1298 | 1298 | return $form; |
| 1299 | 1299 | } |
| 1300 | 1300 | |
| 1301 | 1301 | // Fix PHP warning regarding undefined index. |
| 1302 | - foreach ( $form['fields'] as &$field) { |
|
| 1302 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1303 | 1303 | |
| 1304 | 1304 | // This is because we're doing admin form pretending to be front-end, so Gravity Forms |
| 1305 | 1305 | // expects certain field array items to be set. |
@@ -1307,7 +1307,7 @@ discard block |
||
| 1307 | 1307 | $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL; |
| 1308 | 1308 | } |
| 1309 | 1309 | |
| 1310 | - switch( RGFormsModel::get_input_type( $field ) ) { |
|
| 1310 | + switch ( RGFormsModel::get_input_type( $field ) ) { |
|
| 1311 | 1311 | |
| 1312 | 1312 | /** |
| 1313 | 1313 | * 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. |
@@ -1321,26 +1321,26 @@ discard block |
||
| 1321 | 1321 | // Set the previous value |
| 1322 | 1322 | $entry = $this->get_entry(); |
| 1323 | 1323 | |
| 1324 | - $input_name = 'input_'.$field->id; |
|
| 1325 | - $form_id = $form['id']; |
|
| 1324 | + $input_name = 'input_' . $field->id; |
|
| 1325 | + $form_id = $form[ 'id' ]; |
|
| 1326 | 1326 | |
| 1327 | 1327 | $value = NULL; |
| 1328 | 1328 | |
| 1329 | 1329 | // Use the previous entry value as the default. |
| 1330 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1330 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1331 | 1331 | $value = $entry[ $field->id ]; |
| 1332 | 1332 | } |
| 1333 | 1333 | |
| 1334 | 1334 | // If this is a single upload file |
| 1335 | - if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) { |
|
| 1336 | - $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] ); |
|
| 1337 | - $value = $file_path['url']; |
|
| 1335 | + if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) { |
|
| 1336 | + $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] ); |
|
| 1337 | + $value = $file_path[ 'url' ]; |
|
| 1338 | 1338 | |
| 1339 | 1339 | } else { |
| 1340 | 1340 | |
| 1341 | 1341 | // Fix PHP warning on line 1498 of form_display.php for post_image fields |
| 1342 | 1342 | // Fix PHP Notice: Undefined index: size in form_display.php on line 1511 |
| 1343 | - $_FILES[ $input_name ] = array('name' => '', 'size' => '' ); |
|
| 1343 | + $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' ); |
|
| 1344 | 1344 | |
| 1345 | 1345 | } |
| 1346 | 1346 | |
@@ -1348,10 +1348,10 @@ discard block |
||
| 1348 | 1348 | |
| 1349 | 1349 | // If there are fresh uploads, process and merge them. |
| 1350 | 1350 | // Otherwise, use the passed values, which should be json-encoded array of URLs |
| 1351 | - if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) { |
|
| 1351 | + if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) { |
|
| 1352 | 1352 | $value = empty( $value ) ? '[]' : $value; |
| 1353 | 1353 | $value = stripslashes_deep( $value ); |
| 1354 | - $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array()); |
|
| 1354 | + $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() ); |
|
| 1355 | 1355 | } |
| 1356 | 1356 | |
| 1357 | 1357 | } else { |
@@ -1369,8 +1369,8 @@ discard block |
||
| 1369 | 1369 | |
| 1370 | 1370 | case 'number': |
| 1371 | 1371 | // Fix "undefined index" issue at line 1286 in form_display.php |
| 1372 | - if( !isset( $_POST['input_'.$field->id ] ) ) { |
|
| 1373 | - $_POST['input_'.$field->id ] = NULL; |
|
| 1372 | + if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) { |
|
| 1373 | + $_POST[ 'input_' . $field->id ] = NULL; |
|
| 1374 | 1374 | } |
| 1375 | 1375 | break; |
| 1376 | 1376 | } |
@@ -1407,7 +1407,7 @@ discard block |
||
| 1407 | 1407 | * You can enter whatever you want! |
| 1408 | 1408 | * We try validating, and customize the results using `self::custom_validation()` |
| 1409 | 1409 | */ |
| 1410 | - add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4); |
|
| 1410 | + add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 ); |
|
| 1411 | 1411 | |
| 1412 | 1412 | // Needed by the validate funtion |
| 1413 | 1413 | $failed_validation_page = NULL; |
@@ -1415,14 +1415,14 @@ discard block |
||
| 1415 | 1415 | |
| 1416 | 1416 | // Prevent entry limit from running when editing an entry, also |
| 1417 | 1417 | // prevent form scheduling from preventing editing |
| 1418 | - unset( $this->form['limitEntries'], $this->form['scheduleForm'] ); |
|
| 1418 | + unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] ); |
|
| 1419 | 1419 | |
| 1420 | 1420 | // Hide fields depending on Edit Entry settings |
| 1421 | - $this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1421 | + $this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id ); |
|
| 1422 | 1422 | |
| 1423 | 1423 | $this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page ); |
| 1424 | 1424 | |
| 1425 | - remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1425 | + remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 ); |
|
| 1426 | 1426 | } |
| 1427 | 1427 | |
| 1428 | 1428 | |
@@ -1445,7 +1445,7 @@ discard block |
||
| 1445 | 1445 | |
| 1446 | 1446 | $gv_valid = true; |
| 1447 | 1447 | |
| 1448 | - foreach ( $validation_results['form']['fields'] as $key => &$field ) { |
|
| 1448 | + foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) { |
|
| 1449 | 1449 | |
| 1450 | 1450 | $value = RGFormsModel::get_field_value( $field ); |
| 1451 | 1451 | $field_type = RGFormsModel::get_input_type( $field ); |
@@ -1458,35 +1458,35 @@ discard block |
||
| 1458 | 1458 | case 'post_image': |
| 1459 | 1459 | |
| 1460 | 1460 | // in case nothing is uploaded but there are already files saved |
| 1461 | - if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) { |
|
| 1461 | + if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) { |
|
| 1462 | 1462 | $field->failed_validation = false; |
| 1463 | 1463 | unset( $field->validation_message ); |
| 1464 | 1464 | } |
| 1465 | 1465 | |
| 1466 | 1466 | // validate if multi file upload reached max number of files [maxFiles] => 2 |
| 1467 | - if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) { |
|
| 1467 | + if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) { |
|
| 1468 | 1468 | |
| 1469 | 1469 | $input_name = 'input_' . $field->id; |
| 1470 | 1470 | //uploaded |
| 1471 | - $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array(); |
|
| 1471 | + $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array(); |
|
| 1472 | 1472 | |
| 1473 | 1473 | //existent |
| 1474 | 1474 | $entry = $this->get_entry(); |
| 1475 | 1475 | $value = NULL; |
| 1476 | - if( isset( $entry[ $field->id ] ) ) { |
|
| 1476 | + if ( isset( $entry[ $field->id ] ) ) { |
|
| 1477 | 1477 | $value = json_decode( $entry[ $field->id ], true ); |
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | 1480 | // count uploaded files and existent entry files |
| 1481 | 1481 | $count_files = count( $file_names ) + count( $value ); |
| 1482 | 1482 | |
| 1483 | - if( $count_files > $field->maxFiles ) { |
|
| 1483 | + if ( $count_files > $field->maxFiles ) { |
|
| 1484 | 1484 | $field->validation_message = __( 'Maximum number of files reached', 'gravityview' ); |
| 1485 | 1485 | $field->failed_validation = 1; |
| 1486 | 1486 | $gv_valid = false; |
| 1487 | 1487 | |
| 1488 | 1488 | // in case of error make sure the newest upload files are removed from the upload input |
| 1489 | - GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null; |
|
| 1489 | + GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null; |
|
| 1490 | 1490 | } |
| 1491 | 1491 | |
| 1492 | 1492 | } |
@@ -1497,7 +1497,7 @@ discard block |
||
| 1497 | 1497 | } |
| 1498 | 1498 | |
| 1499 | 1499 | // This field has failed validation. |
| 1500 | - if( !empty( $field->failed_validation ) ) { |
|
| 1500 | + if ( ! empty( $field->failed_validation ) ) { |
|
| 1501 | 1501 | |
| 1502 | 1502 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) ); |
| 1503 | 1503 | |
@@ -1515,19 +1515,19 @@ discard block |
||
| 1515 | 1515 | } |
| 1516 | 1516 | |
| 1517 | 1517 | // You can't continue inside a switch, so we do it after. |
| 1518 | - if( empty( $field->failed_validation ) ) { |
|
| 1518 | + if ( empty( $field->failed_validation ) ) { |
|
| 1519 | 1519 | continue; |
| 1520 | 1520 | } |
| 1521 | 1521 | |
| 1522 | 1522 | // checks if the No Duplicates option is not validating entry against itself, since |
| 1523 | 1523 | // we're editing a stored entry, it would also assume it's a duplicate. |
| 1524 | - if( !empty( $field->noDuplicates ) ) { |
|
| 1524 | + if ( ! empty( $field->noDuplicates ) ) { |
|
| 1525 | 1525 | |
| 1526 | 1526 | $entry = $this->get_entry(); |
| 1527 | 1527 | |
| 1528 | 1528 | // If the value of the entry is the same as the stored value |
| 1529 | 1529 | // Then we can assume it's not a duplicate, it's the same. |
| 1530 | - if( !empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1530 | + if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) { |
|
| 1531 | 1531 | //if value submitted was not changed, then don't validate |
| 1532 | 1532 | $field->failed_validation = false; |
| 1533 | 1533 | |
@@ -1540,7 +1540,7 @@ discard block |
||
| 1540 | 1540 | } |
| 1541 | 1541 | |
| 1542 | 1542 | // if here then probably we are facing the validation 'At least one field must be filled out' |
| 1543 | - if( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1543 | + if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) { |
|
| 1544 | 1544 | unset( $field->validation_message ); |
| 1545 | 1545 | $field->validation_message = false; |
| 1546 | 1546 | continue; |
@@ -1552,12 +1552,12 @@ discard block |
||
| 1552 | 1552 | |
| 1553 | 1553 | } |
| 1554 | 1554 | |
| 1555 | - $validation_results['is_valid'] = $gv_valid; |
|
| 1555 | + $validation_results[ 'is_valid' ] = $gv_valid; |
|
| 1556 | 1556 | |
| 1557 | 1557 | gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) ); |
| 1558 | 1558 | |
| 1559 | 1559 | // We'll need this result when rendering the form ( on GFFormDisplay::get_form ) |
| 1560 | - $this->form_after_validation = $validation_results['form']; |
|
| 1560 | + $this->form_after_validation = $validation_results[ 'form' ]; |
|
| 1561 | 1561 | |
| 1562 | 1562 | return $validation_results; |
| 1563 | 1563 | } |
@@ -1570,7 +1570,7 @@ discard block |
||
| 1570 | 1570 | */ |
| 1571 | 1571 | public function get_entry() { |
| 1572 | 1572 | |
| 1573 | - if( empty( $this->entry ) ) { |
|
| 1573 | + if ( empty( $this->entry ) ) { |
|
| 1574 | 1574 | // Get the database value of the entry that's being edited |
| 1575 | 1575 | $this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() ); |
| 1576 | 1576 | } |
@@ -1602,10 +1602,10 @@ discard block |
||
| 1602 | 1602 | } |
| 1603 | 1603 | |
| 1604 | 1604 | // If edit tab not yet configured, show all fields |
| 1605 | - $edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL; |
|
| 1605 | + $edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL; |
|
| 1606 | 1606 | |
| 1607 | 1607 | // Hide fields depending on admin settings |
| 1608 | - $fields = $this->filter_fields( $form['fields'], $edit_fields ); |
|
| 1608 | + $fields = $this->filter_fields( $form[ 'fields' ], $edit_fields ); |
|
| 1609 | 1609 | |
| 1610 | 1610 | // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't. |
| 1611 | 1611 | $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id ); |
@@ -1637,7 +1637,7 @@ discard block |
||
| 1637 | 1637 | */ |
| 1638 | 1638 | private function filter_fields( $fields, $configured_fields ) { |
| 1639 | 1639 | |
| 1640 | - if( empty( $fields ) || !is_array( $fields ) ) { |
|
| 1640 | + if ( empty( $fields ) || ! is_array( $fields ) ) { |
|
| 1641 | 1641 | return $fields; |
| 1642 | 1642 | } |
| 1643 | 1643 | |
@@ -1650,18 +1650,18 @@ discard block |
||
| 1650 | 1650 | |
| 1651 | 1651 | // Remove the fields that have calculation properties and keep them to be used later |
| 1652 | 1652 | // @since 1.16.2 |
| 1653 | - if( $field->has_calculation() ) { |
|
| 1654 | - $this->fields_with_calculation[] = $field; |
|
| 1653 | + if ( $field->has_calculation() ) { |
|
| 1654 | + $this->fields_with_calculation[ ] = $field; |
|
| 1655 | 1655 | // don't remove the calculation fields on form render. |
| 1656 | 1656 | } |
| 1657 | 1657 | |
| 1658 | - if( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1658 | + if ( in_array( $field->type, $field_type_blacklist ) ) { |
|
| 1659 | 1659 | unset( $fields[ $key ] ); |
| 1660 | 1660 | } |
| 1661 | 1661 | } |
| 1662 | 1662 | |
| 1663 | 1663 | // The Edit tab has not been configured, so we return all fields by default. |
| 1664 | - if( empty( $configured_fields ) ) { |
|
| 1664 | + if ( empty( $configured_fields ) ) { |
|
| 1665 | 1665 | return array_values( $fields ); |
| 1666 | 1666 | } |
| 1667 | 1667 | |
@@ -1670,8 +1670,8 @@ discard block |
||
| 1670 | 1670 | |
| 1671 | 1671 | /** @var GF_Field $field */ |
| 1672 | 1672 | foreach ( $fields as $field ) { |
| 1673 | - if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1674 | - $edit_fields[] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1673 | + if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) { |
|
| 1674 | + $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field ); |
|
| 1675 | 1675 | break; |
| 1676 | 1676 | } |
| 1677 | 1677 | |
@@ -1694,14 +1694,14 @@ discard block |
||
| 1694 | 1694 | |
| 1695 | 1695 | $return_field = $field; |
| 1696 | 1696 | |
| 1697 | - if( empty( $field_setting['show_label'] ) ) { |
|
| 1697 | + if ( empty( $field_setting[ 'show_label' ] ) ) { |
|
| 1698 | 1698 | $return_field->label = ''; |
| 1699 | - } elseif ( !empty( $field_setting['custom_label'] ) ) { |
|
| 1700 | - $return_field->label = $field_setting['custom_label']; |
|
| 1699 | + } elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) { |
|
| 1700 | + $return_field->label = $field_setting[ 'custom_label' ]; |
|
| 1701 | 1701 | } |
| 1702 | 1702 | |
| 1703 | - if( !empty( $field_setting['custom_class'] ) ) { |
|
| 1704 | - $return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] ); |
|
| 1703 | + if ( ! empty( $field_setting[ 'custom_class' ] ) ) { |
|
| 1704 | + $return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] ); |
|
| 1705 | 1705 | } |
| 1706 | 1706 | |
| 1707 | 1707 | /** |
@@ -1739,16 +1739,16 @@ discard block |
||
| 1739 | 1739 | */ |
| 1740 | 1740 | $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id ); |
| 1741 | 1741 | |
| 1742 | - if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) { |
|
| 1743 | - foreach( $fields as $k => $field ) { |
|
| 1744 | - if( $field->adminOnly ) { |
|
| 1742 | + if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) { |
|
| 1743 | + foreach ( $fields as $k => $field ) { |
|
| 1744 | + if ( $field->adminOnly ) { |
|
| 1745 | 1745 | unset( $fields[ $k ] ); |
| 1746 | 1746 | } |
| 1747 | 1747 | } |
| 1748 | 1748 | return array_values( $fields ); |
| 1749 | 1749 | } |
| 1750 | 1750 | |
| 1751 | - foreach( $fields as &$field ) { |
|
| 1751 | + foreach ( $fields as &$field ) { |
|
| 1752 | 1752 | $field->adminOnly = false; |
| 1753 | 1753 | } |
| 1754 | 1754 | |
@@ -1769,7 +1769,7 @@ discard block |
||
| 1769 | 1769 | */ |
| 1770 | 1770 | private function unselect_default_values( $form ) { |
| 1771 | 1771 | |
| 1772 | - foreach ( $form['fields'] as &$field ) { |
|
| 1772 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1773 | 1773 | |
| 1774 | 1774 | if ( empty( $field->choices ) ) { |
| 1775 | 1775 | continue; |
@@ -1777,7 +1777,7 @@ discard block |
||
| 1777 | 1777 | |
| 1778 | 1778 | foreach ( $field->choices as &$choice ) { |
| 1779 | 1779 | if ( \GV\Utils::get( $choice, 'isSelected' ) ) { |
| 1780 | - $choice['isSelected'] = false; |
|
| 1780 | + $choice[ 'isSelected' ] = false; |
|
| 1781 | 1781 | } |
| 1782 | 1782 | } |
| 1783 | 1783 | } |
@@ -1802,22 +1802,22 @@ discard block |
||
| 1802 | 1802 | */ |
| 1803 | 1803 | function prefill_conditional_logic( $form ) { |
| 1804 | 1804 | |
| 1805 | - if( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1805 | + if ( ! GFFormDisplay::has_conditional_logic( $form ) ) { |
|
| 1806 | 1806 | return $form; |
| 1807 | 1807 | } |
| 1808 | 1808 | |
| 1809 | 1809 | // Have Conditional Logic pre-fill fields as if the data were default values |
| 1810 | 1810 | /** @var GF_Field $field */ |
| 1811 | - foreach ( $form['fields'] as &$field ) { |
|
| 1811 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1812 | 1812 | |
| 1813 | - if( 'checkbox' === $field->type ) { |
|
| 1813 | + if ( 'checkbox' === $field->type ) { |
|
| 1814 | 1814 | foreach ( $field->get_entry_inputs() as $key => $input ) { |
| 1815 | - $input_id = $input['id']; |
|
| 1815 | + $input_id = $input[ 'id' ]; |
|
| 1816 | 1816 | $choice = $field->choices[ $key ]; |
| 1817 | 1817 | $value = \GV\Utils::get( $this->entry, $input_id ); |
| 1818 | 1818 | $match = RGFormsModel::choice_value_match( $field, $choice, $value ); |
| 1819 | - if( $match ) { |
|
| 1820 | - $field->choices[ $key ]['isSelected'] = true; |
|
| 1819 | + if ( $match ) { |
|
| 1820 | + $field->choices[ $key ][ 'isSelected' ] = true; |
|
| 1821 | 1821 | } |
| 1822 | 1822 | } |
| 1823 | 1823 | } else { |
@@ -1825,15 +1825,15 @@ discard block |
||
| 1825 | 1825 | // We need to run through each field to set the default values |
| 1826 | 1826 | foreach ( $this->entry as $field_id => $field_value ) { |
| 1827 | 1827 | |
| 1828 | - if( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1828 | + if ( floatval( $field_id ) === floatval( $field->id ) ) { |
|
| 1829 | 1829 | |
| 1830 | - if( 'list' === $field->type ) { |
|
| 1830 | + if ( 'list' === $field->type ) { |
|
| 1831 | 1831 | $list_rows = maybe_unserialize( $field_value ); |
| 1832 | 1832 | |
| 1833 | 1833 | $list_field_value = array(); |
| 1834 | - foreach ( (array) $list_rows as $row ) { |
|
| 1835 | - foreach ( (array) $row as $column ) { |
|
| 1836 | - $list_field_value[] = $column; |
|
| 1834 | + foreach ( (array)$list_rows as $row ) { |
|
| 1835 | + foreach ( (array)$row as $column ) { |
|
| 1836 | + $list_field_value[ ] = $column; |
|
| 1837 | 1837 | } |
| 1838 | 1838 | } |
| 1839 | 1839 | |
@@ -1868,16 +1868,16 @@ discard block |
||
| 1868 | 1868 | */ |
| 1869 | 1869 | $use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form ); |
| 1870 | 1870 | |
| 1871 | - if( $use_conditional_logic ) { |
|
| 1871 | + if ( $use_conditional_logic ) { |
|
| 1872 | 1872 | return $form; |
| 1873 | 1873 | } |
| 1874 | 1874 | |
| 1875 | - foreach( $form['fields'] as &$field ) { |
|
| 1875 | + foreach ( $form[ 'fields' ] as &$field ) { |
|
| 1876 | 1876 | /* @var GF_Field $field */ |
| 1877 | 1877 | $field->conditionalLogic = null; |
| 1878 | 1878 | } |
| 1879 | 1879 | |
| 1880 | - unset( $form['button']['conditionalLogic'] ); |
|
| 1880 | + unset( $form[ 'button' ][ 'conditionalLogic' ] ); |
|
| 1881 | 1881 | |
| 1882 | 1882 | return $form; |
| 1883 | 1883 | |
@@ -1894,7 +1894,7 @@ discard block |
||
| 1894 | 1894 | */ |
| 1895 | 1895 | public function manage_conditional_logic( $has_conditional_logic, $form ) { |
| 1896 | 1896 | |
| 1897 | - if( ! $this->is_edit_entry() ) { |
|
| 1897 | + if ( ! $this->is_edit_entry() ) { |
|
| 1898 | 1898 | return $has_conditional_logic; |
| 1899 | 1899 | } |
| 1900 | 1900 | |
@@ -1926,44 +1926,44 @@ discard block |
||
| 1926 | 1926 | * 2. There are two entries embedded using oEmbed |
| 1927 | 1927 | * 3. One of the entries has just been saved |
| 1928 | 1928 | */ |
| 1929 | - if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) { |
|
| 1929 | + if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) { |
|
| 1930 | 1930 | |
| 1931 | 1931 | $error = true; |
| 1932 | 1932 | |
| 1933 | 1933 | } |
| 1934 | 1934 | |
| 1935 | - if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) { |
|
| 1935 | + if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) { |
|
| 1936 | 1936 | |
| 1937 | 1937 | $error = true; |
| 1938 | 1938 | |
| 1939 | - } elseif( ! $this->verify_nonce() ) { |
|
| 1939 | + } elseif ( ! $this->verify_nonce() ) { |
|
| 1940 | 1940 | |
| 1941 | 1941 | /** |
| 1942 | 1942 | * If the Entry is embedded, there may be two entries on the same page. |
| 1943 | 1943 | * If that's the case, and one is being edited, the other should fail gracefully and not display an error. |
| 1944 | 1944 | */ |
| 1945 | - if( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1945 | + if ( GravityView_oEmbed::getInstance()->get_entry_id() ) { |
|
| 1946 | 1946 | $error = true; |
| 1947 | 1947 | } else { |
| 1948 | - $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview'); |
|
| 1948 | + $error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' ); |
|
| 1949 | 1949 | } |
| 1950 | 1950 | |
| 1951 | 1951 | } |
| 1952 | 1952 | |
| 1953 | - if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1954 | - $error = __( 'You do not have permission to edit this entry.', 'gravityview'); |
|
| 1953 | + if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) { |
|
| 1954 | + $error = __( 'You do not have permission to edit this entry.', 'gravityview' ); |
|
| 1955 | 1955 | } |
| 1956 | 1956 | |
| 1957 | - if( $this->entry['status'] === 'trash' ) { |
|
| 1958 | - $error = __('You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1957 | + if ( $this->entry[ 'status' ] === 'trash' ) { |
|
| 1958 | + $error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' ); |
|
| 1959 | 1959 | } |
| 1960 | 1960 | |
| 1961 | 1961 | // No errors; everything's fine here! |
| 1962 | - if( empty( $error ) ) { |
|
| 1962 | + if ( empty( $error ) ) { |
|
| 1963 | 1963 | return true; |
| 1964 | 1964 | } |
| 1965 | 1965 | |
| 1966 | - if( $echo && $error !== true ) { |
|
| 1966 | + if ( $echo && $error !== true ) { |
|
| 1967 | 1967 | |
| 1968 | 1968 | $error = esc_html( $error ); |
| 1969 | 1969 | |
@@ -1971,10 +1971,10 @@ discard block |
||
| 1971 | 1971 | * @since 1.9 |
| 1972 | 1972 | */ |
| 1973 | 1973 | if ( ! empty( $this->entry ) ) { |
| 1974 | - $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;" ) ); |
|
| 1974 | + $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;" ) ); |
|
| 1975 | 1975 | } |
| 1976 | 1976 | |
| 1977 | - echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error'); |
|
| 1977 | + echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' ); |
|
| 1978 | 1978 | } |
| 1979 | 1979 | |
| 1980 | 1980 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -1994,17 +1994,17 @@ discard block |
||
| 1994 | 1994 | |
| 1995 | 1995 | $error = NULL; |
| 1996 | 1996 | |
| 1997 | - if( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 1998 | - $error = __( 'You do not have permission to edit this field.', 'gravityview'); |
|
| 1997 | + if ( ! $this->check_user_cap_edit_field( $field ) ) { |
|
| 1998 | + $error = __( 'You do not have permission to edit this field.', 'gravityview' ); |
|
| 1999 | 1999 | } |
| 2000 | 2000 | |
| 2001 | 2001 | // No errors; everything's fine here! |
| 2002 | - if( empty( $error ) ) { |
|
| 2002 | + if ( empty( $error ) ) { |
|
| 2003 | 2003 | return true; |
| 2004 | 2004 | } |
| 2005 | 2005 | |
| 2006 | - if( $echo ) { |
|
| 2007 | - echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error'); |
|
| 2006 | + if ( $echo ) { |
|
| 2007 | + echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' ); |
|
| 2008 | 2008 | } |
| 2009 | 2009 | |
| 2010 | 2010 | gravityview()->log->error( '{error}', array( 'error' => $error ) ); |
@@ -2025,14 +2025,14 @@ discard block |
||
| 2025 | 2025 | private function check_user_cap_edit_field( $field ) { |
| 2026 | 2026 | |
| 2027 | 2027 | // If they can edit any entries (as defined in Gravity Forms), we're good. |
| 2028 | - if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2028 | + if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) { |
|
| 2029 | 2029 | return true; |
| 2030 | 2030 | } |
| 2031 | 2031 | |
| 2032 | - $field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false; |
|
| 2032 | + $field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false; |
|
| 2033 | 2033 | |
| 2034 | - if( $field_cap ) { |
|
| 2035 | - return GVCommon::has_cap( $field['allow_edit_cap'] ); |
|
| 2034 | + if ( $field_cap ) { |
|
| 2035 | + return GVCommon::has_cap( $field[ 'allow_edit_cap' ] ); |
|
| 2036 | 2036 | } |
| 2037 | 2037 | |
| 2038 | 2038 | return false; |
@@ -2046,17 +2046,17 @@ discard block |
||
| 2046 | 2046 | public function verify_nonce() { |
| 2047 | 2047 | |
| 2048 | 2048 | // Verify form submitted for editing single |
| 2049 | - if( $this->is_edit_entry_submission() ) { |
|
| 2049 | + if ( $this->is_edit_entry_submission() ) { |
|
| 2050 | 2050 | $valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field ); |
| 2051 | 2051 | } |
| 2052 | 2052 | |
| 2053 | 2053 | // Verify |
| 2054 | - else if( ! $this->is_edit_entry() ) { |
|
| 2054 | + else if ( ! $this->is_edit_entry() ) { |
|
| 2055 | 2055 | $valid = false; |
| 2056 | 2056 | } |
| 2057 | 2057 | |
| 2058 | 2058 | else { |
| 2059 | - $valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key ); |
|
| 2059 | + $valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key ); |
|
| 2060 | 2060 | } |
| 2061 | 2061 | |
| 2062 | 2062 | /** |