Completed
Push — develop ( 5626c8...63f992 )
by Gennady
15:59
created
includes/extensions/edit-entry/class-edit-entry-render.php 3 patches
Indentation   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
333 333
 
334 334
 			GFFormsModel::save_lead( $form, $this->entry );
335 335
 
336
-	        // Delete the values for hidden inputs
337
-	        $this->unset_hidden_field_values();
336
+			// Delete the values for hidden inputs
337
+			$this->unset_hidden_field_values();
338 338
 			
339 339
 			$this->entry['date_created'] = $date_created;
340 340
 
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 			// Perform actions normally performed after updating a lead
345 345
 			$this->after_update();
346 346
 
347
-	        /**
347
+			/**
348 348
 			 * Must be AFTER after_update()!
349 349
 			 * @see https://github.com/gravityview/GravityView/issues/764
350 350
 			 */
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 
353 353
 			/**
354 354
 			 * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry
355
-             * @since 2.1 Added $gv_data parameter
355
+			 * @since 2.1 Added $gv_data parameter
356 356
 			 * @param array $form Gravity Forms form array
357 357
 			 * @param string $entry_id Numeric ID of the entry that was updated
358 358
 			 * @param GravityView_Edit_Entry_Render $this This object
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	 * @return void
377 377
 	 */
378 378
 	private function unset_hidden_field_values() {
379
-	    global $wpdb;
379
+		global $wpdb;
380 380
 
381 381
 		/**
382 382
 		 * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic
@@ -398,29 +398,29 @@  discard block
 block discarded – undo
398 398
 			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );
399 399
 		}
400 400
 
401
-	    foreach ( $this->entry as $input_id => $field_value ) {
401
+		foreach ( $this->entry as $input_id => $field_value ) {
402 402
 
403
-		    $field = RGFormsModel::get_field( $this->form, $input_id );
403
+			$field = RGFormsModel::get_field( $this->form, $input_id );
404 404
 
405
-		    // Reset fields that are hidden
406
-		    // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic
407
-		    if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) {
405
+			// Reset fields that are hidden
406
+			// Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic
407
+			if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) {
408 408
 
409 409
 				$empty_value = $field->get_value_save_entry(
410 410
 					is_array( $field->get_entry_inputs() ) ? array() : '',
411 411
 					$this->form, '', $this->entry['id'], $this->entry
412 412
 				);
413 413
 
414
-			    $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
414
+				$lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
415 415
 
416
-			    GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );
416
+				GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );
417 417
 
418
-			    // Prevent the $_POST values of hidden fields from being used as default values when rendering the form
418
+				// Prevent the $_POST values of hidden fields from being used as default values when rendering the form
419 419
 				// after submission
420
-			    $post_input_id = 'input_' . str_replace( '.', '_', $input_id );
421
-			    $_POST[ $post_input_id ] = '';
422
-		    }
423
-	    }
420
+				$post_input_id = 'input_' . str_replace( '.', '_', $input_id );
421
+				$_POST[ $post_input_id ] = '';
422
+			}
423
+		}
424 424
 	}
425 425
 
426 426
 	/**
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 
515 515
 		$form = $this->form;
516 516
 
517
-	    /** @var GF_Field $field */
517
+		/** @var GF_Field $field */
518 518
 		foreach( $form['fields'] as $k => &$field ) {
519 519
 
520 520
 			/**
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 
531 531
 			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
532 532
 				foreach( $field->inputs as $key => $input ) {
533
-				    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
533
+					$field->inputs[ $key ][ 'id' ] = (string)$input['id'];
534 534
 				}
535 535
 			}
536 536
 		}
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 			foreach ( $this->fields_with_calculation as $field ) {
566 566
 				$inputs = $field->get_entry_inputs();
567 567
 				if ( is_array( $inputs ) ) {
568
-				    foreach ( $inputs as $input ) {
568
+					foreach ( $inputs as $input ) {
569 569
 						list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 );
570 570
 
571 571
 						if ( 'product' === $field->type ) {
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 						}
585 585
 
586 586
 						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] );
587
-				    }
587
+					}
588 588
 				} else {
589 589
 					// Set to what it previously was if it's not editable
590 590
 					if ( ! in_array( $field->id, $allowed_fields ) ) {
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
631 631
 
632 632
 			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
633
-	        $ary = stripslashes_deep( $ary );
633
+			$ary = stripslashes_deep( $ary );
634 634
 			$img_url = \GV\Utils::get( $ary, 0 );
635 635
 
636 636
 			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 	private function maybe_update_post_fields( $form ) {
704 704
 
705 705
 		if( empty( $this->entry['post_id'] ) ) {
706
-	        gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
706
+			gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
707 707
 			return;
708 708
 		}
709 709
 
@@ -738,49 +738,49 @@  discard block
 block discarded – undo
738 738
 
739 739
 				switch( $field->type ) {
740 740
 
741
-				    case 'post_title':
742
-				        $post_title = $value;
743
-				        if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
744
-				            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
745
-				        }
746
-				        $updated_post->post_title = $post_title;
747
-				        $updated_post->post_name  = $post_title;
748
-				        unset( $post_title );
749
-				        break;
750
-
751
-				    case 'post_content':
752
-				        $post_content = $value;
753
-				        if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
754
-				            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
755
-				        }
756
-				        $updated_post->post_content = $post_content;
757
-				        unset( $post_content );
758
-				        break;
759
-				    case 'post_excerpt':
760
-				        $updated_post->post_excerpt = $value;
761
-				        break;
762
-				    case 'post_tags':
763
-				        wp_set_post_tags( $post_id, $value, false );
764
-				        break;
765
-				    case 'post_category':
766
-				        break;
767
-				    case 'post_custom_field':
741
+					case 'post_title':
742
+						$post_title = $value;
743
+						if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
744
+							$post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
745
+						}
746
+						$updated_post->post_title = $post_title;
747
+						$updated_post->post_name  = $post_title;
748
+						unset( $post_title );
749
+						break;
750
+
751
+					case 'post_content':
752
+						$post_content = $value;
753
+						if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
754
+							$post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
755
+						}
756
+						$updated_post->post_content = $post_content;
757
+						unset( $post_content );
758
+						break;
759
+					case 'post_excerpt':
760
+						$updated_post->post_excerpt = $value;
761
+						break;
762
+					case 'post_tags':
763
+						wp_set_post_tags( $post_id, $value, false );
764
+						break;
765
+					case 'post_category':
766
+						break;
767
+					case 'post_custom_field':
768 768
 						if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) {
769 769
 							$value = $value[ $field_id ];
770 770
 						}
771 771
 
772
-				        if( ! empty( $field->customFieldTemplateEnabled ) ) {
773
-				            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
774
-				        }
772
+						if( ! empty( $field->customFieldTemplateEnabled ) ) {
773
+							$value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
774
+						}
775 775
 
776 776
 						$value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry );
777 777
 
778
-				        update_post_meta( $post_id, $field->postCustomFieldName, $value );
779
-				        break;
778
+						update_post_meta( $post_id, $field->postCustomFieldName, $value );
779
+						break;
780 780
 
781
-				    case 'post_image':
782
-				        $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
783
-				        break;
781
+					case 'post_image':
782
+						$value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
783
+						break;
784 784
 
785 785
 				}
786 786
 
@@ -903,14 +903,14 @@  discard block
 block discarded – undo
903 903
 			?><h2 class="gv-edit-entry-title">
904 904
 				<span><?php
905 905
 
906
-				    /**
907
-				     * @filter `gravityview_edit_entry_title` Modify the edit entry title
908
-				     * @param string $edit_entry_title Modify the "Edit Entry" title
909
-				     * @param GravityView_Edit_Entry_Render $this This object
910
-				     */
911
-				    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
906
+					/**
907
+					 * @filter `gravityview_edit_entry_title` Modify the edit entry title
908
+					 * @param string $edit_entry_title Modify the "Edit Entry" title
909
+					 * @param GravityView_Edit_Entry_Render $this This object
910
+					 */
911
+					$edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
912 912
 
913
-				    echo esc_attr( $edit_entry_title );
913
+					echo esc_attr( $edit_entry_title );
914 914
 			?></span>
915 915
 			</h2>
916 916
 
@@ -973,26 +973,26 @@  discard block
 block discarded – undo
973 973
 
974 974
 				switch ( $edit_redirect ) {
975 975
 
976
-                    case '0':
977
-	                    $redirect_url = $back_link;
978
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
979
-                        break;
980
-
981
-                    case '1':
982
-	                    $redirect_url = $directory_link = GravityView_API::directory_link();
983
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
984
-	                    break;
985
-
986
-                    case '2':
987
-	                    $redirect_url = $edit_redirect_url;
988
-	                    $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
989
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
990
-                        break;
991
-
992
-                    case '':
993
-                    default:
994
-					    $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
995
-                        break;
976
+					case '0':
977
+						$redirect_url = $back_link;
978
+						$entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
979
+						break;
980
+
981
+					case '1':
982
+						$redirect_url = $directory_link = GravityView_API::directory_link();
983
+						$entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
984
+						break;
985
+
986
+					case '2':
987
+						$redirect_url = $edit_redirect_url;
988
+						$redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
989
+						$entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
990
+						break;
991
+
992
+					case '':
993
+					default:
994
+						$entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
995
+						break;
996 996
 				}
997 997
 
998 998
 				if ( isset( $redirect_url ) ) {
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 
1050 1050
 		ob_get_clean();
1051 1051
 
1052
-	    remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
1052
+		remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
1053 1053
 		remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
1054 1054
 		remove_filter( 'gform_disable_view_counter', '__return_true' );
1055 1055
 		remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 );
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
 
1104 1104
 		// for now we don't support Save and Continue feature.
1105 1105
 		if( ! self::$supports_save_and_continue ) {
1106
-	        unset( $form['save'] );
1106
+			unset( $form['save'] );
1107 1107
 		}
1108 1108
 
1109 1109
 		$form = $this->unselect_default_values( $form );
@@ -1130,30 +1130,30 @@  discard block
 block discarded – undo
1130 1130
 			return $field_content;
1131 1131
 		}
1132 1132
 
1133
-        $message = null;
1133
+		$message = null;
1134 1134
 
1135
-        // First, make sure they have the capability to edit the post.
1136
-        if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1135
+		// First, make sure they have the capability to edit the post.
1136
+		if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1137 1137
 
1138
-            /**
1139
-             * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1140
-             * @param string $message The existing "You don't have permission..." text
1141
-             */
1142
-            $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1138
+			/**
1139
+			 * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1140
+			 * @param string $message The existing "You don't have permission..." text
1141
+			 */
1142
+			$message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1143 1143
 
1144
-        } elseif( null === get_post( $this->entry['post_id'] ) ) {
1145
-            /**
1146
-             * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1147
-             * @param string $message The existing "This field is not editable; the post no longer exists." text
1148
-             */
1149
-            $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1150
-        }
1144
+		} elseif( null === get_post( $this->entry['post_id'] ) ) {
1145
+			/**
1146
+			 * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1147
+			 * @param string $message The existing "This field is not editable; the post no longer exists." text
1148
+			 */
1149
+			$message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1150
+		}
1151 1151
 
1152
-        if( $message ) {
1153
-            $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1154
-        }
1152
+		if( $message ) {
1153
+			$field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1154
+		}
1155 1155
 
1156
-        return $field_content;
1156
+		return $field_content;
1157 1157
 	}
1158 1158
 
1159 1159
 	/**
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 			|| ! empty( $field_content )
1182 1182
 			|| in_array( $field->type, array( 'honeypot' ) )
1183 1183
 		) {
1184
-	        return $field_content;
1184
+			return $field_content;
1185 1185
 		}
1186 1186
 
1187 1187
 		// SET SOME FIELD DEFAULTS TO PREVENT ISSUES
@@ -1189,24 +1189,24 @@  discard block
 block discarded – undo
1189 1189
 
1190 1190
 		$field_value = $this->get_field_value( $field );
1191 1191
 
1192
-	    // Prevent any PHP warnings, like undefined index
1193
-	    ob_start();
1192
+		// Prevent any PHP warnings, like undefined index
1193
+		ob_start();
1194 1194
 
1195
-	    $return = null;
1195
+		$return = null;
1196 1196
 
1197 1197
 		/** @var GravityView_Field $gv_field */
1198 1198
 		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1199 1199
 			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1200 1200
 		} else {
1201
-	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
1202
-	    }
1201
+			$return = $field->get_field_input( $this->form, $field_value, $this->entry );
1202
+		}
1203 1203
 
1204
-	    // If there was output, it's an error
1205
-	    $warnings = ob_get_clean();
1204
+		// If there was output, it's an error
1205
+		$warnings = ob_get_clean();
1206 1206
 
1207
-	    if( !empty( $warnings ) ) {
1208
-		    gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1209
-	    }
1207
+		if( !empty( $warnings ) ) {
1208
+			gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1209
+		}
1210 1210
 
1211 1211
 		return $return;
1212 1212
 	}
@@ -1241,8 +1241,8 @@  discard block
 block discarded – undo
1241 1241
 				$input_id = strval( $input['id'] );
1242 1242
 
1243 1243
 				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1244
-				    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1245
-				    $allow_pre_populated = false;
1244
+					$field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1245
+					$allow_pre_populated = false;
1246 1246
 				}
1247 1247
 
1248 1248
 			}
@@ -1266,7 +1266,7 @@  discard block
 block discarded – undo
1266 1266
 			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1267 1267
 				$categories = array();
1268 1268
 				foreach ( explode( ',', $field_value ) as $cat_string ) {
1269
-				    $categories[] = GFCommon::format_post_category( $cat_string, true );
1269
+					$categories[] = GFCommon::format_post_category( $cat_string, true );
1270 1270
 				}
1271 1271
 				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1272 1272
 			}
@@ -1276,25 +1276,25 @@  discard block
 block discarded – undo
1276 1276
 		// if value is empty get the default value if defined
1277 1277
 		$field_value = $field->get_value_default_if_empty( $field_value );
1278 1278
 
1279
-	    /**
1280
-	     * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1281
-	     * @since 1.11
1282
-	     * @since 1.20 Added third param
1283
-	     * @param mixed $field_value field value used to populate the input
1284
-	     * @param object $field Gravity Forms field object ( Class GF_Field )
1285
-	     * @param GravityView_Edit_Entry_Render $this Current object
1286
-	     */
1287
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this );
1288
-
1289
-	    /**
1290
-	     * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1291
-	     * @since 1.17
1292
-	     * @since 1.20 Added third param
1293
-	     * @param mixed $field_value field value used to populate the input
1294
-	     * @param GF_Field $field Gravity Forms field object
1295
-	     * @param GravityView_Edit_Entry_Render $this Current object
1296
-	     */
1297
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1279
+		/**
1280
+		 * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1281
+		 * @since 1.11
1282
+		 * @since 1.20 Added third param
1283
+		 * @param mixed $field_value field value used to populate the input
1284
+		 * @param object $field Gravity Forms field object ( Class GF_Field )
1285
+		 * @param GravityView_Edit_Entry_Render $this Current object
1286
+		 */
1287
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this );
1288
+
1289
+		/**
1290
+		 * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1291
+		 * @since 1.17
1292
+		 * @since 1.20 Added third param
1293
+		 * @param mixed $field_value field value used to populate the input
1294
+		 * @param GF_Field $field Gravity Forms field object
1295
+		 * @param GravityView_Edit_Entry_Render $this Current object
1296
+		 */
1297
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1298 1298
 
1299 1299
 		return $field_value;
1300 1300
 	}
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
 			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1322 1322
 			// expects certain field array items to be set.
1323 1323
 			foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) {
1324
-	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1324
+				$field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1325 1325
 			}
1326 1326
 
1327 1327
 			switch( RGFormsModel::get_input_type( $field ) ) {
@@ -1335,61 +1335,61 @@  discard block
 block discarded – undo
1335 1335
 				 */
1336 1336
 				case 'fileupload':
1337 1337
 
1338
-				    // Set the previous value
1339
-				    $entry = $this->get_entry();
1338
+					// Set the previous value
1339
+					$entry = $this->get_entry();
1340 1340
 
1341
-				    $input_name = 'input_'.$field->id;
1342
-				    $form_id = $form['id'];
1341
+					$input_name = 'input_'.$field->id;
1342
+					$form_id = $form['id'];
1343 1343
 
1344
-				    $value = NULL;
1344
+					$value = NULL;
1345 1345
 
1346
-				    // Use the previous entry value as the default.
1347
-				    if( isset( $entry[ $field->id ] ) ) {
1348
-				        $value = $entry[ $field->id ];
1349
-				    }
1346
+					// Use the previous entry value as the default.
1347
+					if( isset( $entry[ $field->id ] ) ) {
1348
+						$value = $entry[ $field->id ];
1349
+					}
1350 1350
 
1351
-				    // If this is a single upload file
1352
-				    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1353
-				        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1354
-				        $value = $file_path['url'];
1351
+					// If this is a single upload file
1352
+					if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1353
+						$file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1354
+						$value = $file_path['url'];
1355 1355
 
1356
-				    } else {
1356
+					} else {
1357 1357
 
1358
-				        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1359
-				        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1360
-				        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1358
+						// Fix PHP warning on line 1498 of form_display.php for post_image fields
1359
+						// Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1360
+						$_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1361 1361
 
1362
-				    }
1362
+					}
1363 1363
 
1364
-				    if ( \GV\Utils::get( $field, "multipleFiles" ) ) {
1364
+					if ( \GV\Utils::get( $field, "multipleFiles" ) ) {
1365 1365
 
1366
-				        // If there are fresh uploads, process and merge them.
1367
-				        // Otherwise, use the passed values, which should be json-encoded array of URLs
1368
-				        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1369
-				            $value = empty( $value ) ? '[]' : $value;
1370
-				            $value = stripslashes_deep( $value );
1371
-				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1372
-				        }
1366
+						// If there are fresh uploads, process and merge them.
1367
+						// Otherwise, use the passed values, which should be json-encoded array of URLs
1368
+						if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1369
+							$value = empty( $value ) ? '[]' : $value;
1370
+							$value = stripslashes_deep( $value );
1371
+							$value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1372
+						}
1373 1373
 
1374
-				    } else {
1374
+					} else {
1375 1375
 
1376
-				        // A file already exists when editing an entry
1377
-				        // We set this to solve issue when file upload fields are required.
1378
-				        GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1376
+						// A file already exists when editing an entry
1377
+						// We set this to solve issue when file upload fields are required.
1378
+						GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1379 1379
 
1380
-				    }
1380
+					}
1381 1381
 
1382
-				    $this->entry[ $input_name ] = $value;
1383
-				    $_POST[ $input_name ] = $value;
1382
+					$this->entry[ $input_name ] = $value;
1383
+					$_POST[ $input_name ] = $value;
1384 1384
 
1385
-				    break;
1385
+					break;
1386 1386
 
1387 1387
 				case 'number':
1388
-				    // Fix "undefined index" issue at line 1286 in form_display.php
1389
-				    if( !isset( $_POST['input_'.$field->id ] ) ) {
1390
-				        $_POST['input_'.$field->id ] = NULL;
1391
-				    }
1392
-				    break;
1388
+					// Fix "undefined index" issue at line 1286 in form_display.php
1389
+					if( !isset( $_POST['input_'.$field->id ] ) ) {
1390
+						$_POST['input_'.$field->id ] = NULL;
1391
+					}
1392
+					break;
1393 1393
 			}
1394 1394
 
1395 1395
 		}
@@ -1474,42 +1474,42 @@  discard block
 block discarded – undo
1474 1474
 				case 'fileupload' :
1475 1475
 				case 'post_image':
1476 1476
 
1477
-				    // in case nothing is uploaded but there are already files saved
1478
-				    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1479
-				        $field->failed_validation = false;
1480
-				        unset( $field->validation_message );
1481
-				    }
1477
+					// in case nothing is uploaded but there are already files saved
1478
+					if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1479
+						$field->failed_validation = false;
1480
+						unset( $field->validation_message );
1481
+					}
1482 1482
 
1483
-				    // validate if multi file upload reached max number of files [maxFiles] => 2
1484
-				    if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1483
+					// validate if multi file upload reached max number of files [maxFiles] => 2
1484
+					if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1485 1485
 
1486
-				        $input_name = 'input_' . $field->id;
1487
-				        //uploaded
1488
-				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1486
+						$input_name = 'input_' . $field->id;
1487
+						//uploaded
1488
+						$file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1489 1489
 
1490
-				        //existent
1491
-				        $entry = $this->get_entry();
1492
-				        $value = NULL;
1493
-				        if( isset( $entry[ $field->id ] ) ) {
1494
-				            $value = json_decode( $entry[ $field->id ], true );
1495
-				        }
1490
+						//existent
1491
+						$entry = $this->get_entry();
1492
+						$value = NULL;
1493
+						if( isset( $entry[ $field->id ] ) ) {
1494
+							$value = json_decode( $entry[ $field->id ], true );
1495
+						}
1496 1496
 
1497
-				        // count uploaded files and existent entry files
1498
-				        $count_files = count( $file_names ) + count( $value );
1497
+						// count uploaded files and existent entry files
1498
+						$count_files = count( $file_names ) + count( $value );
1499 1499
 
1500
-				        if( $count_files > $field->maxFiles ) {
1501
-				            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1502
-				            $field->failed_validation = 1;
1503
-				            $gv_valid = false;
1500
+						if( $count_files > $field->maxFiles ) {
1501
+							$field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1502
+							$field->failed_validation = 1;
1503
+							$gv_valid = false;
1504 1504
 
1505
-				            // in case of error make sure the newest upload files are removed from the upload input
1506
-				            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1507
-				        }
1505
+							// in case of error make sure the newest upload files are removed from the upload input
1506
+							GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1507
+						}
1508 1508
 
1509
-				    }
1509
+					}
1510 1510
 
1511 1511
 
1512
-				    break;
1512
+					break;
1513 1513
 
1514 1514
 			}
1515 1515
 
@@ -1520,47 +1520,47 @@  discard block
 block discarded – undo
1520 1520
 
1521 1521
 				switch ( $field_type ) {
1522 1522
 
1523
-				    // Captchas don't need to be re-entered.
1524
-				    case 'captcha':
1523
+					// Captchas don't need to be re-entered.
1524
+					case 'captcha':
1525 1525
 
1526
-				        // Post Image fields aren't editable, so we un-fail them.
1527
-				    case 'post_image':
1528
-				        $field->failed_validation = false;
1529
-				        unset( $field->validation_message );
1530
-				        break;
1526
+						// Post Image fields aren't editable, so we un-fail them.
1527
+					case 'post_image':
1528
+						$field->failed_validation = false;
1529
+						unset( $field->validation_message );
1530
+						break;
1531 1531
 
1532 1532
 				}
1533 1533
 
1534 1534
 				// You can't continue inside a switch, so we do it after.
1535 1535
 				if( empty( $field->failed_validation ) ) {
1536
-				    continue;
1536
+					continue;
1537 1537
 				}
1538 1538
 
1539 1539
 				// checks if the No Duplicates option is not validating entry against itself, since
1540 1540
 				// we're editing a stored entry, it would also assume it's a duplicate.
1541 1541
 				if( !empty( $field->noDuplicates ) ) {
1542 1542
 
1543
-				    $entry = $this->get_entry();
1543
+					$entry = $this->get_entry();
1544 1544
 
1545
-				    // If the value of the entry is the same as the stored value
1546
-				    // Then we can assume it's not a duplicate, it's the same.
1547
-				    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1548
-				        //if value submitted was not changed, then don't validate
1549
-				        $field->failed_validation = false;
1545
+					// If the value of the entry is the same as the stored value
1546
+					// Then we can assume it's not a duplicate, it's the same.
1547
+					if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1548
+						//if value submitted was not changed, then don't validate
1549
+						$field->failed_validation = false;
1550 1550
 
1551
-				        unset( $field->validation_message );
1551
+						unset( $field->validation_message );
1552 1552
 
1553
-				        gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) );
1553
+						gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) );
1554 1554
 
1555
-				        continue;
1556
-				    }
1555
+						continue;
1556
+					}
1557 1557
 				}
1558 1558
 
1559 1559
 				// if here then probably we are facing the validation 'At least one field must be filled out'
1560 1560
 				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1561
-				    unset( $field->validation_message );
1562
-	                $field->validation_message = false;
1563
-				    continue;
1561
+					unset( $field->validation_message );
1562
+					$field->validation_message = false;
1563
+					continue;
1564 1564
 				}
1565 1565
 
1566 1566
 				$gv_valid = false;
@@ -1624,8 +1624,8 @@  discard block
 block discarded – undo
1624 1624
 		// Hide fields depending on admin settings
1625 1625
 		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1626 1626
 
1627
-	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1628
-	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1627
+		// If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1628
+		$fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1629 1629
 
1630 1630
 		/**
1631 1631
 		 * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form
@@ -1685,11 +1685,11 @@  discard block
 block discarded – undo
1685 1685
 		// The edit tab has been configured, so we loop through to configured settings
1686 1686
 		foreach ( $configured_fields as $configured_field ) {
1687 1687
 
1688
-	        /** @var GF_Field $field */
1689
-	        foreach ( $fields as $field ) {
1688
+			/** @var GF_Field $field */
1689
+			foreach ( $fields as $field ) {
1690 1690
 				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1691
-				    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1692
-				    break;
1691
+					$edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1692
+					break;
1693 1693
 				}
1694 1694
 
1695 1695
 			}
@@ -1745,28 +1745,28 @@  discard block
 block discarded – undo
1745 1745
 	 */
1746 1746
 	private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) {
1747 1747
 
1748
-	    /**
1748
+		/**
1749 1749
 		 * @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
1750
-	     * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1751
-	     * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1752
-	     * @since 1.9.1
1753
-	     * @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.
1754
-	     * @param array $form GF Form array
1755
-	     * @param int $view_id View ID
1756
-	     */
1757
-	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1758
-
1759
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1750
+		 * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1751
+		 * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1752
+		 * @since 1.9.1
1753
+		 * @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.
1754
+		 * @param array $form GF Form array
1755
+		 * @param int $view_id View ID
1756
+		 */
1757
+		$use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1758
+
1759
+		if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1760 1760
 			foreach( $fields as $k => $field ) {
1761 1761
 				if( $field->adminOnly ) {
1762
-				    unset( $fields[ $k ] );
1762
+					unset( $fields[ $k ] );
1763 1763
 				}
1764 1764
 			}
1765 1765
 			return array_values( $fields );
1766 1766
 		}
1767 1767
 
1768
-	    foreach( $fields as &$field ) {
1769
-		    $field->adminOnly = false;
1768
+		foreach( $fields as &$field ) {
1769
+			$field->adminOnly = false;
1770 1770
 		}
1771 1771
 
1772 1772
 		return $fields;
@@ -1786,13 +1786,13 @@  discard block
 block discarded – undo
1786 1786
 	 */
1787 1787
 	private function unselect_default_values( $form ) {
1788 1788
 
1789
-	    foreach ( $form['fields'] as &$field ) {
1789
+		foreach ( $form['fields'] as &$field ) {
1790 1790
 
1791 1791
 			if ( empty( $field->choices ) ) {
1792
-                continue;
1792
+				continue;
1793 1793
 			}
1794 1794
 
1795
-            foreach ( $field->choices as &$choice ) {
1795
+			foreach ( $field->choices as &$choice ) {
1796 1796
 				if ( \GV\Utils::get( $choice, 'isSelected' ) ) {
1797 1797
 					$choice['isSelected'] = false;
1798 1798
 				}
@@ -1829,36 +1829,36 @@  discard block
 block discarded – undo
1829 1829
 
1830 1830
 			if( 'checkbox' === $field->type ) {
1831 1831
 				foreach ( $field->get_entry_inputs() as $key => $input ) {
1832
-				    $input_id = $input['id'];
1833
-				    $choice = $field->choices[ $key ];
1834
-				    $value = \GV\Utils::get( $this->entry, $input_id );
1835
-				    $match = RGFormsModel::choice_value_match( $field, $choice, $value );
1836
-				    if( $match ) {
1837
-				        $field->choices[ $key ]['isSelected'] = true;
1838
-				    }
1832
+					$input_id = $input['id'];
1833
+					$choice = $field->choices[ $key ];
1834
+					$value = \GV\Utils::get( $this->entry, $input_id );
1835
+					$match = RGFormsModel::choice_value_match( $field, $choice, $value );
1836
+					if( $match ) {
1837
+						$field->choices[ $key ]['isSelected'] = true;
1838
+					}
1839 1839
 				}
1840 1840
 			} else {
1841 1841
 
1842 1842
 				// We need to run through each field to set the default values
1843 1843
 				foreach ( $this->entry as $field_id => $field_value ) {
1844 1844
 
1845
-				    if( floatval( $field_id ) === floatval( $field->id ) ) {
1845
+					if( floatval( $field_id ) === floatval( $field->id ) ) {
1846 1846
 
1847
-				        if( 'list' === $field->type ) {
1848
-				            $list_rows = maybe_unserialize( $field_value );
1847
+						if( 'list' === $field->type ) {
1848
+							$list_rows = maybe_unserialize( $field_value );
1849 1849
 
1850
-				            $list_field_value = array();
1851
-				            foreach ( (array) $list_rows as $row ) {
1852
-				                foreach ( (array) $row as $column ) {
1853
-				                    $list_field_value[] = $column;
1854
-				                }
1855
-				            }
1850
+							$list_field_value = array();
1851
+							foreach ( (array) $list_rows as $row ) {
1852
+								foreach ( (array) $row as $column ) {
1853
+									$list_field_value[] = $column;
1854
+								}
1855
+							}
1856 1856
 
1857
-				            $field->defaultValue = serialize( $list_field_value );
1858
-				        } else {
1859
-				            $field->defaultValue = $field_value;
1860
-				        }
1861
-				    }
1857
+							$field->defaultValue = serialize( $list_field_value );
1858
+						} else {
1859
+							$field->defaultValue = $field_value;
1860
+						}
1861
+					}
1862 1862
 				}
1863 1863
 			}
1864 1864
 		}
@@ -1915,7 +1915,7 @@  discard block
 block discarded – undo
1915 1915
 			return $has_conditional_logic;
1916 1916
 		}
1917 1917
 
1918
-	    /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */
1918
+		/** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */
1919 1919
 		return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form );
1920 1920
 	}
1921 1921
 
@@ -1982,14 +1982,14 @@  discard block
 block discarded – undo
1982 1982
 
1983 1983
 		if( $echo && $error !== true ) {
1984 1984
 
1985
-	        $error = esc_html( $error );
1985
+			$error = esc_html( $error );
1986 1986
 
1987
-	        /**
1988
-	         * @since 1.9
1989
-	         */
1990
-	        if ( ! empty( $this->entry ) ) {
1991
-		        $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;" ) );
1992
-	        }
1987
+			/**
1988
+			 * @since 1.9
1989
+			 */
1990
+			if ( ! empty( $this->entry ) ) {
1991
+				$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;" ) );
1992
+			}
1993 1993
 
1994 1994
 			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
1995 1995
 		}
Please login to merge, or discard this patch.
Spacing   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -115,16 +115,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,16 +208,16 @@  discard block
 block discarded – undo
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();
216
-		$this->form_id = $this->entry['form_id'];
216
+		$this->form_id = $this->entry[ 'form_id' ];
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 			 * @param GravityView_Edit_Entry_Render $this This object
359 359
 			 * @param GravityView_View_Data $gv_data The View data
360 360
 			 */
361
-			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data );
361
+			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data );
362 362
 
363 363
 		} else {
364 364
 			gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) );
@@ -386,16 +386,16 @@  discard block
 block discarded – undo
386 386
 		 */
387 387
 		$unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this );
388 388
 
389
-		if( ! $unset_hidden_field_values ) {
389
+		if ( ! $unset_hidden_field_values ) {
390 390
 			return;
391 391
 		}
392 392
 
393 393
 		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
394 394
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
395
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) );
395
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) );
396 396
 		} else {
397 397
 			$lead_detail_table = GFFormsModel::get_lead_details_table_name();
398
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );
398
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) );
399 399
 		}
400 400
 
401 401
 	    foreach ( $this->entry as $input_id => $field_value ) {
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 
409 409
 				$empty_value = $field->get_value_save_entry(
410 410
 					is_array( $field->get_entry_inputs() ) ? array() : '',
411
-					$this->form, '', $this->entry['id'], $this->entry
411
+					$this->form, '', $this->entry[ 'id' ], $this->entry
412 412
 				);
413 413
 
414 414
 			    $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 		}
479 479
 
480 480
 		/** No file is being uploaded. */
481
-		if ( empty( $_FILES[ $input_name ]['name'] ) ) {
481
+		if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) {
482 482
 			/** So return the original upload */
483 483
 			return $entry[ $input_id ];
484 484
 		}
@@ -496,11 +496,11 @@  discard block
 block discarded – undo
496 496
 	 * @return mixed
497 497
 	 */
498 498
 	public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) {
499
-		if( ! $this->is_edit_entry() ) {
499
+		if ( ! $this->is_edit_entry() ) {
500 500
 			return $plupload_init;
501 501
 		}
502 502
 
503
-		$plupload_init['gf_vars']['max_files'] = 0;
503
+		$plupload_init[ 'gf_vars' ][ 'max_files' ] = 0;
504 504
 
505 505
 		return $plupload_init;
506 506
 	}
@@ -515,27 +515,27 @@  discard block
 block discarded – undo
515 515
 		$form = $this->form;
516 516
 
517 517
 	    /** @var GF_Field $field */
518
-		foreach( $form['fields'] as $k => &$field ) {
518
+		foreach ( $form[ 'fields' ] as $k => &$field ) {
519 519
 
520 520
 			/**
521 521
 			 * Remove the fields with calculation formulas before save to avoid conflicts with GF logic
522 522
 			 * @since 1.16.3
523 523
 			 * @var GF_Field $field
524 524
 			 */
525
-			if( $field->has_calculation() ) {
526
-				unset( $form['fields'][ $k ] );
525
+			if ( $field->has_calculation() ) {
526
+				unset( $form[ 'fields' ][ $k ] );
527 527
 			}
528 528
 
529 529
 			$field->adminOnly = false;
530 530
 
531
-			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
532
-				foreach( $field->inputs as $key => $input ) {
533
-				    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
531
+			if ( isset( $field->inputs ) && is_array( $field->inputs ) ) {
532
+				foreach ( $field->inputs as $key => $input ) {
533
+				    $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ];
534 534
 				}
535 535
 			}
536 536
 		}
537 537
 
538
-		$form['fields'] = array_values( $form['fields'] );
538
+		$form[ 'fields' ] = array_values( $form[ 'fields' ] );
539 539
 
540 540
 		return $form;
541 541
 	}
@@ -547,14 +547,14 @@  discard block
 block discarded – undo
547 547
 		$update = false;
548 548
 
549 549
 		// get the most up to date entry values
550
-		$entry = GFAPI::get_entry( $this->entry['id'] );
550
+		$entry = GFAPI::get_entry( $this->entry[ 'id' ] );
551 551
 
552 552
 		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
553 553
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
554
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) );
554
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) );
555 555
 		} else {
556 556
 			$lead_detail_table = GFFormsModel::get_lead_details_table_name();
557
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) );
557
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) );
558 558
 		}
559 559
 
560 560
 
@@ -566,24 +566,24 @@  discard block
 block discarded – undo
566 566
 				$inputs = $field->get_entry_inputs();
567 567
 				if ( is_array( $inputs ) ) {
568 568
 				    foreach ( $inputs as $input ) {
569
-						list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 );
569
+						list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 );
570 570
 
571 571
 						if ( 'product' === $field->type ) {
572
-							$input_name = 'input_' . str_replace( '.', '_', $input['id'] );
572
+							$input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] );
573 573
 
574 574
 							// Only allow quantity to be set if it's allowed to be edited
575 575
 							if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) {
576 576
 							} else { // otherwise set to what it previously was
577
-								$_POST[ $input_name ] = $entry[ $input['id'] ];
577
+								$_POST[ $input_name ] = $entry[ $input[ 'id' ] ];
578 578
 							}
579 579
 						} else {
580 580
 							// Set to what it previously was if it's not editable
581 581
 							if ( ! in_array( $field_id, $allowed_fields ) ) {
582
-								$_POST[ $input_name ] = $entry[ $input['id'] ];
582
+								$_POST[ $input_name ] = $entry[ $input[ 'id' ] ];
583 583
 							}
584 584
 						}
585 585
 
586
-						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] );
586
+						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] );
587 587
 				    }
588 588
 				} else {
589 589
 					// Set to what it previously was if it's not editable
@@ -623,19 +623,19 @@  discard block
 block discarded – undo
623 623
 
624 624
 		$input_name = 'input_' . $field_id;
625 625
 
626
-		if ( !empty( $_FILES[ $input_name ]['name'] ) ) {
626
+		if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
627 627
 
628 628
 			// We have a new image
629 629
 
630
-			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
630
+			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] );
631 631
 
632 632
 			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
633 633
 	        $ary = stripslashes_deep( $ary );
634 634
 			$img_url = \GV\Utils::get( $ary, 0 );
635 635
 
636
-			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
637
-			$img_caption     = count( $ary ) > 2 ? $ary[2] : '';
638
-			$img_description = count( $ary ) > 3 ? $ary[3] : '';
636
+			$img_title       = count( $ary ) > 1 ? $ary[ 1 ] : '';
637
+			$img_caption     = count( $ary ) > 2 ? $ary[ 2 ] : '';
638
+			$img_description = count( $ary ) > 3 ? $ary[ 3 ] : '';
639 639
 
640 640
 			$image_meta = array(
641 641
 				'post_excerpt' => $img_caption,
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 
645 645
 			//adding title only if it is not empty. It will default to the file name if it is not in the array
646 646
 			if ( ! empty( $img_title ) ) {
647
-				$image_meta['post_title'] = $img_title;
647
+				$image_meta[ 'post_title' ] = $img_title;
648 648
 			}
649 649
 
650 650
 			/**
@@ -702,15 +702,15 @@  discard block
 block discarded – undo
702 702
 	 */
703 703
 	private function maybe_update_post_fields( $form ) {
704 704
 
705
-		if( empty( $this->entry['post_id'] ) ) {
705
+		if ( empty( $this->entry[ 'post_id' ] ) ) {
706 706
 	        gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
707 707
 			return;
708 708
 		}
709 709
 
710
-		$post_id = $this->entry['post_id'];
710
+		$post_id = $this->entry[ 'post_id' ];
711 711
 
712 712
 		// Security check
713
-		if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
713
+		if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
714 714
 			gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) );
715 715
 			return;
716 716
 		}
@@ -723,25 +723,25 @@  discard block
 block discarded – undo
723 723
 
724 724
 			$field = RGFormsModel::get_field( $form, $field_id );
725 725
 
726
-			if( ! $field ) {
726
+			if ( ! $field ) {
727 727
 				continue;
728 728
 			}
729 729
 
730
-			if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
730
+			if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
731 731
 
732 732
 				// Get the value of the field, including $_POSTed value
733 733
 				$value = RGFormsModel::get_field_value( $field );
734 734
 
735 735
 				// Use temporary entry variable, to make values available to fill_post_template() and update_post_image()
736 736
 				$entry_tmp = $this->entry;
737
-				$entry_tmp["{$field_id}"] = $value;
737
+				$entry_tmp[ "{$field_id}" ] = $value;
738 738
 
739
-				switch( $field->type ) {
739
+				switch ( $field->type ) {
740 740
 
741 741
 				    case 'post_title':
742 742
 				        $post_title = $value;
743 743
 				        if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
744
-				            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
744
+				            $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp );
745 745
 				        }
746 746
 				        $updated_post->post_title = $post_title;
747 747
 				        $updated_post->post_name  = $post_title;
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
 				    case 'post_content':
752 752
 				        $post_content = $value;
753 753
 				        if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
754
-				            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
754
+				            $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true );
755 755
 				        }
756 756
 				        $updated_post->post_content = $post_content;
757 757
 				        unset( $post_content );
@@ -769,11 +769,11 @@  discard block
 block discarded – undo
769 769
 							$value = $value[ $field_id ];
770 770
 						}
771 771
 
772
-				        if( ! empty( $field->customFieldTemplateEnabled ) ) {
772
+				        if ( ! empty( $field->customFieldTemplateEnabled ) ) {
773 773
 				            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
774 774
 				        }
775 775
 
776
-						$value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry );
776
+						$value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry );
777 777
 
778 778
 				        update_post_meta( $post_id, $field->postCustomFieldName, $value );
779 779
 				        break;
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 				}
786 786
 
787 787
 				// update entry after
788
-				$this->entry["{$field_id}"] = $value;
788
+				$this->entry[ "{$field_id}" ] = $value;
789 789
 
790 790
 				$update_entry = true;
791 791
 
@@ -794,11 +794,11 @@  discard block
 block discarded – undo
794 794
 
795 795
 		}
796 796
 
797
-		if( $update_entry ) {
797
+		if ( $update_entry ) {
798 798
 
799 799
 			$return_entry = GFAPI::update_entry( $this->entry );
800 800
 
801
-			if( is_wp_error( $return_entry ) ) {
801
+			if ( is_wp_error( $return_entry ) ) {
802 802
 				gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) );
803 803
 			} else {
804 804
 				gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) );
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 
809 809
 		$return_post = wp_update_post( $updated_post, true );
810 810
 
811
-		if( is_wp_error( $return_post ) ) {
811
+		if ( is_wp_error( $return_post ) ) {
812 812
 			$return_post->add_data( $updated_post, '$updated_post' );
813 813
 			gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) );
814 814
 		} else {
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 		$output = GFCommon::replace_variables( $output, $form, $entry, false, false, false );
843 843
 
844 844
 		// replace conditional shortcodes
845
-		if( $do_shortcode ) {
845
+		if ( $do_shortcode ) {
846 846
 			$output = do_shortcode( $output );
847 847
 		}
848 848
 
@@ -861,19 +861,19 @@  discard block
 block discarded – undo
861 861
 	 */
862 862
 	private function after_update() {
863 863
 
864
-		do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry );
865
-		do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry );
864
+		do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry );
865
+		do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry );
866 866
 
867 867
 		// Re-define the entry now that we've updated it.
868
-		$entry = RGFormsModel::get_lead( $this->entry['id'] );
868
+		$entry = RGFormsModel::get_lead( $this->entry[ 'id' ] );
869 869
 
870 870
 		$entry = GFFormsModel::set_entry_meta( $entry, self::$original_form );
871 871
 
872 872
 		if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) {
873 873
 			// We need to clear the cache because Gravity Forms caches the field values, which
874 874
 			// we have just updated.
875
-			foreach ($this->form['fields'] as $key => $field) {
876
-				GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );
875
+			foreach ( $this->form[ 'fields' ] as $key => $field ) {
876
+				GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id );
877 877
 			}
878 878
 		}
879 879
 
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 
893 893
 		<div class="gv-edit-entry-wrapper"><?php
894 894
 
895
-			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );
895
+			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this );
896 896
 
897 897
 			/**
898 898
 			 * Fixes weird wpautop() issue
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 				     * @param string $edit_entry_title Modify the "Edit Entry" title
909 909
 				     * @param GravityView_Edit_Entry_Render $this This object
910 910
 				     */
911
-				    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
911
+				    $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this );
912 912
 
913 913
 				    echo esc_attr( $edit_entry_title );
914 914
 			?></span>
@@ -958,13 +958,13 @@  discard block
 block discarded – undo
958 958
 
959 959
 			$back_link = remove_query_arg( array( 'page', 'view', 'edit' ) );
960 960
 
961
-			if( ! $this->is_valid ){
961
+			if ( ! $this->is_valid ) {
962 962
 
963 963
 				// Keeping this compatible with Gravity Forms.
964
-				$validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
965
-				$message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form);
964
+				$validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>";
965
+				$message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form );
966 966
 
967
-				echo GVCommon::generate_notice( $message , 'gv-error' );
967
+				echo GVCommon::generate_notice( $message, 'gv-error' );
968 968
 
969 969
 			} else {
970 970
 				$view = \GV\View::by_id( $this->view_id );
@@ -975,23 +975,23 @@  discard block
 block discarded – undo
975 975
 
976 976
                     case '0':
977 977
 	                    $redirect_url = $back_link;
978
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
978
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' );
979 979
                         break;
980 980
 
981 981
                     case '1':
982 982
 	                    $redirect_url = $directory_link = GravityView_API::directory_link();
983
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
983
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
984 984
 	                    break;
985 985
 
986 986
                     case '2':
987 987
 	                    $redirect_url = $edit_redirect_url;
988 988
 	                    $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
989
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
989
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
990 990
                         break;
991 991
 
992 992
                     case '':
993 993
                     default:
994
-					    $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
994
+					    $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' );
995 995
                         break;
996 996
 				}
997 997
 
@@ -1007,7 +1007,7 @@  discard block
 block discarded – undo
1007 1007
 				 * @param array $entry Gravity Forms entry array
1008 1008
 				 * @param string $back_link URL to return to the original entry. @since 1.6
1009 1009
 				 */
1010
-				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );
1010
+				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link );
1011 1011
 
1012 1012
 				echo GVCommon::generate_notice( $message );
1013 1013
 			}
@@ -1031,21 +1031,21 @@  discard block
 block discarded – undo
1031 1031
 		 */
1032 1032
 		do_action( 'gravityview/edit-entry/render/before', $this );
1033 1033
 
1034
-		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );
1035
-		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );
1034
+		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 );
1035
+		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
1036 1036
 		add_filter( 'gform_disable_view_counter', '__return_true' );
1037 1037
 
1038 1038
 		add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 );
1039 1039
 		add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );
1040 1040
 
1041 1041
 		// We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.
1042
-		unset( $_GET['page'] );
1042
+		unset( $_GET[ 'page' ] );
1043 1043
 
1044 1044
 		// TODO: Verify multiple-page forms
1045 1045
 
1046 1046
 		ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic
1047 1047
 
1048
-		$html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );
1048
+		$html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry );
1049 1049
 
1050 1050
 		ob_get_clean();
1051 1051
 
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 	 * @return string
1072 1072
 	 */
1073 1073
 	public function render_form_buttons() {
1074
-		return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );
1074
+		return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this );
1075 1075
 	}
1076 1076
 
1077 1077
 
@@ -1091,10 +1091,10 @@  discard block
 block discarded – undo
1091 1091
 	public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) {
1092 1092
 
1093 1093
 		// In case we have validated the form, use it to inject the validation results into the form render
1094
-		if( isset( $this->form_after_validation ) ) {
1094
+		if ( isset( $this->form_after_validation ) ) {
1095 1095
 			$form = $this->form_after_validation;
1096 1096
 		} else {
1097
-			$form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );
1097
+			$form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id );
1098 1098
 		}
1099 1099
 
1100 1100
 		$form = $this->filter_conditional_logic( $form );
@@ -1102,8 +1102,8 @@  discard block
 block discarded – undo
1102 1102
 		$form = $this->prefill_conditional_logic( $form );
1103 1103
 
1104 1104
 		// for now we don't support Save and Continue feature.
1105
-		if( ! self::$supports_save_and_continue ) {
1106
-	        unset( $form['save'] );
1105
+		if ( ! self::$supports_save_and_continue ) {
1106
+	        unset( $form[ 'save' ] );
1107 1107
 		}
1108 1108
 
1109 1109
 		$form = $this->unselect_default_values( $form );
@@ -1126,31 +1126,31 @@  discard block
 block discarded – undo
1126 1126
 	 */
1127 1127
 	public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) {
1128 1128
 
1129
-		if( ! GFCommon::is_post_field( $field ) ) {
1129
+		if ( ! GFCommon::is_post_field( $field ) ) {
1130 1130
 			return $field_content;
1131 1131
 		}
1132 1132
 
1133 1133
         $message = null;
1134 1134
 
1135 1135
         // First, make sure they have the capability to edit the post.
1136
-        if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1136
+        if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) {
1137 1137
 
1138 1138
             /**
1139 1139
              * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1140 1140
              * @param string $message The existing "You don't have permission..." text
1141 1141
              */
1142
-            $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1142
+            $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don&rsquo;t have permission to edit this post.', 'gravityview' ) );
1143 1143
 
1144
-        } elseif( null === get_post( $this->entry['post_id'] ) ) {
1144
+        } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) {
1145 1145
             /**
1146 1146
              * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1147 1147
              * @param string $message The existing "This field is not editable; the post no longer exists." text
1148 1148
              */
1149
-            $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1149
+            $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) );
1150 1150
         }
1151 1151
 
1152
-        if( $message ) {
1153
-            $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1152
+        if ( $message ) {
1153
+            $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1154 1154
         }
1155 1155
 
1156 1156
         return $field_content;
@@ -1174,8 +1174,8 @@  discard block
 block discarded – undo
1174 1174
 
1175 1175
 		// If the form has been submitted, then we don't need to pre-fill the values,
1176 1176
 		// Except for fileupload type and when a field input is overridden- run always!!
1177
-		if(
1178
-			( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1177
+		if (
1178
+			( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1179 1179
 			&& false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) )
1180 1180
 			&& ! GFCommon::is_product_field( $field->type )
1181 1181
 			|| ! empty( $field_content )
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
 	    $return = null;
1196 1196
 
1197 1197
 		/** @var GravityView_Field $gv_field */
1198
-		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1198
+		if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1199 1199
 			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1200 1200
 		} else {
1201 1201
 	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
 	    // If there was output, it's an error
1205 1205
 	    $warnings = ob_get_clean();
1206 1206
 
1207
-	    if( !empty( $warnings ) ) {
1207
+	    if ( ! empty( $warnings ) ) {
1208 1208
 		    gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1209 1209
 	    }
1210 1210
 
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
 		$override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );
1230 1230
 
1231 1231
 		// We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)
1232
-		if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) {
1232
+		if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) {
1233 1233
 
1234 1234
 			$field_value = array();
1235 1235
 
@@ -1238,10 +1238,10 @@  discard block
 block discarded – undo
1238 1238
 
1239 1239
 			foreach ( (array)$field->inputs as $input ) {
1240 1240
 
1241
-				$input_id = strval( $input['id'] );
1241
+				$input_id = strval( $input[ 'id' ] );
1242 1242
 
1243 1243
 				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1244
-				    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1244
+				    $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1245 1245
 				    $allow_pre_populated = false;
1246 1246
 				}
1247 1247
 
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 
1250 1250
 			$pre_value = $field->get_value_submission( array(), false );
1251 1251
 
1252
-			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1252
+			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1253 1253
 
1254 1254
 		} else {
1255 1255
 
@@ -1260,13 +1260,13 @@  discard block
 block discarded – undo
1260 1260
 
1261 1261
 			// saved field entry value (if empty, fallback to the pre-populated value, if exists)
1262 1262
 			// or pre-populated value if not empty and set to override saved value
1263
-			$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;
1263
+			$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;
1264 1264
 
1265 1265
 			// in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.
1266
-			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1266
+			if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) {
1267 1267
 				$categories = array();
1268 1268
 				foreach ( explode( ',', $field_value ) as $cat_string ) {
1269
-				    $categories[] = GFCommon::format_post_category( $cat_string, true );
1269
+				    $categories[ ] = GFCommon::format_post_category( $cat_string, true );
1270 1270
 				}
1271 1271
 				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1272 1272
 			}
@@ -1294,7 +1294,7 @@  discard block
 block discarded – undo
1294 1294
 	     * @param GF_Field $field Gravity Forms field object
1295 1295
 	     * @param GravityView_Edit_Entry_Render $this Current object
1296 1296
 	     */
1297
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1297
+	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this );
1298 1298
 
1299 1299
 		return $field_value;
1300 1300
 	}
@@ -1311,12 +1311,12 @@  discard block
 block discarded – undo
1311 1311
 	 */
1312 1312
 	public function gform_pre_validation( $form ) {
1313 1313
 
1314
-		if( ! $this->verify_nonce() ) {
1314
+		if ( ! $this->verify_nonce() ) {
1315 1315
 			return $form;
1316 1316
 		}
1317 1317
 
1318 1318
 		// Fix PHP warning regarding undefined index.
1319
-		foreach ( $form['fields'] as &$field) {
1319
+		foreach ( $form[ 'fields' ] as &$field ) {
1320 1320
 
1321 1321
 			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1322 1322
 			// expects certain field array items to be set.
@@ -1324,7 +1324,7 @@  discard block
 block discarded – undo
1324 1324
 	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1325 1325
 			}
1326 1326
 
1327
-			switch( RGFormsModel::get_input_type( $field ) ) {
1327
+			switch ( RGFormsModel::get_input_type( $field ) ) {
1328 1328
 
1329 1329
 				/**
1330 1330
 				 * 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.
@@ -1338,26 +1338,26 @@  discard block
 block discarded – undo
1338 1338
 				    // Set the previous value
1339 1339
 				    $entry = $this->get_entry();
1340 1340
 
1341
-				    $input_name = 'input_'.$field->id;
1342
-				    $form_id = $form['id'];
1341
+				    $input_name = 'input_' . $field->id;
1342
+				    $form_id = $form[ 'id' ];
1343 1343
 
1344 1344
 				    $value = NULL;
1345 1345
 
1346 1346
 				    // Use the previous entry value as the default.
1347
-				    if( isset( $entry[ $field->id ] ) ) {
1347
+				    if ( isset( $entry[ $field->id ] ) ) {
1348 1348
 				        $value = $entry[ $field->id ];
1349 1349
 				    }
1350 1350
 
1351 1351
 				    // If this is a single upload file
1352
-				    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1353
-				        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1354
-				        $value = $file_path['url'];
1352
+				    if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
1353
+				        $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] );
1354
+				        $value = $file_path[ 'url' ];
1355 1355
 
1356 1356
 				    } else {
1357 1357
 
1358 1358
 				        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1359 1359
 				        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1360
-				        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1360
+				        $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' );
1361 1361
 
1362 1362
 				    }
1363 1363
 
@@ -1365,10 +1365,10 @@  discard block
 block discarded – undo
1365 1365
 
1366 1366
 				        // If there are fresh uploads, process and merge them.
1367 1367
 				        // Otherwise, use the passed values, which should be json-encoded array of URLs
1368
-				        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1368
+				        if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) {
1369 1369
 				            $value = empty( $value ) ? '[]' : $value;
1370 1370
 				            $value = stripslashes_deep( $value );
1371
-				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1371
+				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() );
1372 1372
 				        }
1373 1373
 
1374 1374
 				    } else {
@@ -1386,8 +1386,8 @@  discard block
 block discarded – undo
1386 1386
 
1387 1387
 				case 'number':
1388 1388
 				    // Fix "undefined index" issue at line 1286 in form_display.php
1389
-				    if( !isset( $_POST['input_'.$field->id ] ) ) {
1390
-				        $_POST['input_'.$field->id ] = NULL;
1389
+				    if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) {
1390
+				        $_POST[ 'input_' . $field->id ] = NULL;
1391 1391
 				    }
1392 1392
 				    break;
1393 1393
 			}
@@ -1424,7 +1424,7 @@  discard block
 block discarded – undo
1424 1424
 		 * You can enter whatever you want!
1425 1425
 		 * We try validating, and customize the results using `self::custom_validation()`
1426 1426
 		 */
1427
-		add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);
1427
+		add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 );
1428 1428
 
1429 1429
 		// Needed by the validate funtion
1430 1430
 		$failed_validation_page = NULL;
@@ -1432,14 +1432,14 @@  discard block
 block discarded – undo
1432 1432
 
1433 1433
 		// Prevent entry limit from running when editing an entry, also
1434 1434
 		// prevent form scheduling from preventing editing
1435
-		unset( $this->form['limitEntries'], $this->form['scheduleForm'] );
1435
+		unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] );
1436 1436
 
1437 1437
 		// Hide fields depending on Edit Entry settings
1438
-		$this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1438
+		$this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1439 1439
 
1440 1440
 		$this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );
1441 1441
 
1442
-		remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 );
1442
+		remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 );
1443 1443
 	}
1444 1444
 
1445 1445
 
@@ -1462,7 +1462,7 @@  discard block
 block discarded – undo
1462 1462
 
1463 1463
 		$gv_valid = true;
1464 1464
 
1465
-		foreach ( $validation_results['form']['fields'] as $key => &$field ) {
1465
+		foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) {
1466 1466
 
1467 1467
 			$value = RGFormsModel::get_field_value( $field );
1468 1468
 			$field_type = RGFormsModel::get_input_type( $field );
@@ -1475,35 +1475,35 @@  discard block
 block discarded – undo
1475 1475
 				case 'post_image':
1476 1476
 
1477 1477
 				    // in case nothing is uploaded but there are already files saved
1478
-				    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1478
+				    if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) {
1479 1479
 				        $field->failed_validation = false;
1480 1480
 				        unset( $field->validation_message );
1481 1481
 				    }
1482 1482
 
1483 1483
 				    // validate if multi file upload reached max number of files [maxFiles] => 2
1484
-				    if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1484
+				    if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) {
1485 1485
 
1486 1486
 				        $input_name = 'input_' . $field->id;
1487 1487
 				        //uploaded
1488
-				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1488
+				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array();
1489 1489
 
1490 1490
 				        //existent
1491 1491
 				        $entry = $this->get_entry();
1492 1492
 				        $value = NULL;
1493
-				        if( isset( $entry[ $field->id ] ) ) {
1493
+				        if ( isset( $entry[ $field->id ] ) ) {
1494 1494
 				            $value = json_decode( $entry[ $field->id ], true );
1495 1495
 				        }
1496 1496
 
1497 1497
 				        // count uploaded files and existent entry files
1498 1498
 				        $count_files = count( $file_names ) + count( $value );
1499 1499
 
1500
-				        if( $count_files > $field->maxFiles ) {
1500
+				        if ( $count_files > $field->maxFiles ) {
1501 1501
 				            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1502 1502
 				            $field->failed_validation = 1;
1503 1503
 				            $gv_valid = false;
1504 1504
 
1505 1505
 				            // in case of error make sure the newest upload files are removed from the upload input
1506
-				            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1506
+				            GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null;
1507 1507
 				        }
1508 1508
 
1509 1509
 				    }
@@ -1514,7 +1514,7 @@  discard block
 block discarded – undo
1514 1514
 			}
1515 1515
 
1516 1516
 			// This field has failed validation.
1517
-			if( !empty( $field->failed_validation ) ) {
1517
+			if ( ! empty( $field->failed_validation ) ) {
1518 1518
 
1519 1519
 				gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) );
1520 1520
 
@@ -1532,19 +1532,19 @@  discard block
 block discarded – undo
1532 1532
 				}
1533 1533
 
1534 1534
 				// You can't continue inside a switch, so we do it after.
1535
-				if( empty( $field->failed_validation ) ) {
1535
+				if ( empty( $field->failed_validation ) ) {
1536 1536
 				    continue;
1537 1537
 				}
1538 1538
 
1539 1539
 				// checks if the No Duplicates option is not validating entry against itself, since
1540 1540
 				// we're editing a stored entry, it would also assume it's a duplicate.
1541
-				if( !empty( $field->noDuplicates ) ) {
1541
+				if ( ! empty( $field->noDuplicates ) ) {
1542 1542
 
1543 1543
 				    $entry = $this->get_entry();
1544 1544
 
1545 1545
 				    // If the value of the entry is the same as the stored value
1546 1546
 				    // Then we can assume it's not a duplicate, it's the same.
1547
-				    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1547
+				    if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) {
1548 1548
 				        //if value submitted was not changed, then don't validate
1549 1549
 				        $field->failed_validation = false;
1550 1550
 
@@ -1557,7 +1557,7 @@  discard block
 block discarded – undo
1557 1557
 				}
1558 1558
 
1559 1559
 				// if here then probably we are facing the validation 'At least one field must be filled out'
1560
-				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1560
+				if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) {
1561 1561
 				    unset( $field->validation_message );
1562 1562
 	                $field->validation_message = false;
1563 1563
 				    continue;
@@ -1569,12 +1569,12 @@  discard block
 block discarded – undo
1569 1569
 
1570 1570
 		}
1571 1571
 
1572
-		$validation_results['is_valid'] = $gv_valid;
1572
+		$validation_results[ 'is_valid' ] = $gv_valid;
1573 1573
 
1574 1574
 		gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) );
1575 1575
 
1576 1576
 		// We'll need this result when rendering the form ( on GFFormDisplay::get_form )
1577
-		$this->form_after_validation = $validation_results['form'];
1577
+		$this->form_after_validation = $validation_results[ 'form' ];
1578 1578
 
1579 1579
 		return $validation_results;
1580 1580
 	}
@@ -1587,7 +1587,7 @@  discard block
 block discarded – undo
1587 1587
 	 */
1588 1588
 	public function get_entry() {
1589 1589
 
1590
-		if( empty( $this->entry ) ) {
1590
+		if ( empty( $this->entry ) ) {
1591 1591
 			// Get the database value of the entry that's being edited
1592 1592
 			$this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );
1593 1593
 		}
@@ -1619,10 +1619,10 @@  discard block
 block discarded – undo
1619 1619
 		}
1620 1620
 
1621 1621
 		// If edit tab not yet configured, show all fields
1622
-		$edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;
1622
+		$edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL;
1623 1623
 
1624 1624
 		// Hide fields depending on admin settings
1625
-		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1625
+		$fields = $this->filter_fields( $form[ 'fields' ], $edit_fields );
1626 1626
 
1627 1627
 	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1628 1628
 	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
@@ -1654,7 +1654,7 @@  discard block
 block discarded – undo
1654 1654
 	 */
1655 1655
 	private function filter_fields( $fields, $configured_fields ) {
1656 1656
 
1657
-		if( empty( $fields ) || !is_array( $fields ) ) {
1657
+		if ( empty( $fields ) || ! is_array( $fields ) ) {
1658 1658
 			return $fields;
1659 1659
 		}
1660 1660
 
@@ -1667,18 +1667,18 @@  discard block
 block discarded – undo
1667 1667
 
1668 1668
 			// Remove the fields that have calculation properties and keep them to be used later
1669 1669
 			// @since 1.16.2
1670
-			if( $field->has_calculation() ) {
1671
-				$this->fields_with_calculation[] = $field;
1670
+			if ( $field->has_calculation() ) {
1671
+				$this->fields_with_calculation[ ] = $field;
1672 1672
 				// don't remove the calculation fields on form render.
1673 1673
 			}
1674 1674
 
1675
-			if( in_array( $field->type, $field_type_blacklist ) ) {
1675
+			if ( in_array( $field->type, $field_type_blacklist ) ) {
1676 1676
 				unset( $fields[ $key ] );
1677 1677
 			}
1678 1678
 		}
1679 1679
 
1680 1680
 		// The Edit tab has not been configured, so we return all fields by default.
1681
-		if( empty( $configured_fields ) ) {
1681
+		if ( empty( $configured_fields ) ) {
1682 1682
 			return array_values( $fields );
1683 1683
 		}
1684 1684
 
@@ -1687,8 +1687,8 @@  discard block
 block discarded – undo
1687 1687
 
1688 1688
 	        /** @var GF_Field $field */
1689 1689
 	        foreach ( $fields as $field ) {
1690
-				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1691
-				    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1690
+				if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1691
+				    $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field );
1692 1692
 				    break;
1693 1693
 				}
1694 1694
 
@@ -1711,14 +1711,14 @@  discard block
 block discarded – undo
1711 1711
 
1712 1712
 		$return_field = $field;
1713 1713
 
1714
-		if( empty( $field_setting['show_label'] ) ) {
1714
+		if ( empty( $field_setting[ 'show_label' ] ) ) {
1715 1715
 			$return_field->label = '';
1716
-		} elseif ( !empty( $field_setting['custom_label'] ) ) {
1717
-			$return_field->label = $field_setting['custom_label'];
1716
+		} elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) {
1717
+			$return_field->label = $field_setting[ 'custom_label' ];
1718 1718
 		}
1719 1719
 
1720
-		if( !empty( $field_setting['custom_class'] ) ) {
1721
-			$return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );
1720
+		if ( ! empty( $field_setting[ 'custom_class' ] ) ) {
1721
+			$return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] );
1722 1722
 		}
1723 1723
 
1724 1724
 		/**
@@ -1756,16 +1756,16 @@  discard block
 block discarded – undo
1756 1756
 	     */
1757 1757
 	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1758 1758
 
1759
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1760
-			foreach( $fields as $k => $field ) {
1761
-				if( $field->adminOnly ) {
1759
+	    if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) {
1760
+			foreach ( $fields as $k => $field ) {
1761
+				if ( $field->adminOnly ) {
1762 1762
 				    unset( $fields[ $k ] );
1763 1763
 				}
1764 1764
 			}
1765 1765
 			return array_values( $fields );
1766 1766
 		}
1767 1767
 
1768
-	    foreach( $fields as &$field ) {
1768
+	    foreach ( $fields as &$field ) {
1769 1769
 		    $field->adminOnly = false;
1770 1770
 		}
1771 1771
 
@@ -1786,7 +1786,7 @@  discard block
 block discarded – undo
1786 1786
 	 */
1787 1787
 	private function unselect_default_values( $form ) {
1788 1788
 
1789
-	    foreach ( $form['fields'] as &$field ) {
1789
+	    foreach ( $form[ 'fields' ] as &$field ) {
1790 1790
 
1791 1791
 			if ( empty( $field->choices ) ) {
1792 1792
                 continue;
@@ -1794,7 +1794,7 @@  discard block
 block discarded – undo
1794 1794
 
1795 1795
             foreach ( $field->choices as &$choice ) {
1796 1796
 				if ( \GV\Utils::get( $choice, 'isSelected' ) ) {
1797
-					$choice['isSelected'] = false;
1797
+					$choice[ 'isSelected' ] = false;
1798 1798
 				}
1799 1799
 			}
1800 1800
 		}
@@ -1819,22 +1819,22 @@  discard block
 block discarded – undo
1819 1819
 	 */
1820 1820
 	function prefill_conditional_logic( $form ) {
1821 1821
 
1822
-		if( ! GFFormDisplay::has_conditional_logic( $form ) ) {
1822
+		if ( ! GFFormDisplay::has_conditional_logic( $form ) ) {
1823 1823
 			return $form;
1824 1824
 		}
1825 1825
 
1826 1826
 		// Have Conditional Logic pre-fill fields as if the data were default values
1827 1827
 		/** @var GF_Field $field */
1828
-		foreach ( $form['fields'] as &$field ) {
1828
+		foreach ( $form[ 'fields' ] as &$field ) {
1829 1829
 
1830
-			if( 'checkbox' === $field->type ) {
1830
+			if ( 'checkbox' === $field->type ) {
1831 1831
 				foreach ( $field->get_entry_inputs() as $key => $input ) {
1832
-				    $input_id = $input['id'];
1832
+				    $input_id = $input[ 'id' ];
1833 1833
 				    $choice = $field->choices[ $key ];
1834 1834
 				    $value = \GV\Utils::get( $this->entry, $input_id );
1835 1835
 				    $match = RGFormsModel::choice_value_match( $field, $choice, $value );
1836
-				    if( $match ) {
1837
-				        $field->choices[ $key ]['isSelected'] = true;
1836
+				    if ( $match ) {
1837
+				        $field->choices[ $key ][ 'isSelected' ] = true;
1838 1838
 				    }
1839 1839
 				}
1840 1840
 			} else {
@@ -1842,15 +1842,15 @@  discard block
 block discarded – undo
1842 1842
 				// We need to run through each field to set the default values
1843 1843
 				foreach ( $this->entry as $field_id => $field_value ) {
1844 1844
 
1845
-				    if( floatval( $field_id ) === floatval( $field->id ) ) {
1845
+				    if ( floatval( $field_id ) === floatval( $field->id ) ) {
1846 1846
 
1847
-				        if( 'list' === $field->type ) {
1847
+				        if ( 'list' === $field->type ) {
1848 1848
 				            $list_rows = maybe_unserialize( $field_value );
1849 1849
 
1850 1850
 				            $list_field_value = array();
1851
-				            foreach ( (array) $list_rows as $row ) {
1852
-				                foreach ( (array) $row as $column ) {
1853
-				                    $list_field_value[] = $column;
1851
+				            foreach ( (array)$list_rows as $row ) {
1852
+				                foreach ( (array)$row as $column ) {
1853
+				                    $list_field_value[ ] = $column;
1854 1854
 				                }
1855 1855
 				            }
1856 1856
 
@@ -1885,16 +1885,16 @@  discard block
 block discarded – undo
1885 1885
 		 */
1886 1886
 		$use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );
1887 1887
 
1888
-		if( $use_conditional_logic ) {
1888
+		if ( $use_conditional_logic ) {
1889 1889
 			return $form;
1890 1890
 		}
1891 1891
 
1892
-		foreach( $form['fields'] as &$field ) {
1892
+		foreach ( $form[ 'fields' ] as &$field ) {
1893 1893
 			/* @var GF_Field $field */
1894 1894
 			$field->conditionalLogic = null;
1895 1895
 		}
1896 1896
 
1897
-		unset( $form['button']['conditionalLogic'] );
1897
+		unset( $form[ 'button' ][ 'conditionalLogic' ] );
1898 1898
 
1899 1899
 		return $form;
1900 1900
 
@@ -1911,7 +1911,7 @@  discard block
 block discarded – undo
1911 1911
 	 */
1912 1912
 	public function manage_conditional_logic( $has_conditional_logic, $form ) {
1913 1913
 
1914
-		if( ! $this->is_edit_entry() ) {
1914
+		if ( ! $this->is_edit_entry() ) {
1915 1915
 			return $has_conditional_logic;
1916 1916
 		}
1917 1917
 
@@ -1943,44 +1943,44 @@  discard block
 block discarded – undo
1943 1943
 		 *  2. There are two entries embedded using oEmbed
1944 1944
 		 *  3. One of the entries has just been saved
1945 1945
 		 */
1946
-		if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) {
1946
+		if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) {
1947 1947
 
1948 1948
 			$error = true;
1949 1949
 
1950 1950
 		}
1951 1951
 
1952
-		if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) {
1952
+		if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) {
1953 1953
 
1954 1954
 			$error = true;
1955 1955
 
1956
-		} elseif( ! $this->verify_nonce() ) {
1956
+		} elseif ( ! $this->verify_nonce() ) {
1957 1957
 
1958 1958
 			/**
1959 1959
 			 * If the Entry is embedded, there may be two entries on the same page.
1960 1960
 			 * If that's the case, and one is being edited, the other should fail gracefully and not display an error.
1961 1961
 			 */
1962
-			if( GravityView_oEmbed::getInstance()->get_entry_id() ) {
1962
+			if ( GravityView_oEmbed::getInstance()->get_entry_id() ) {
1963 1963
 				$error = true;
1964 1964
 			} else {
1965
-				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');
1965
+				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' );
1966 1966
 			}
1967 1967
 
1968 1968
 		}
1969 1969
 
1970
-		if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
1971
-			$error = __( 'You do not have permission to edit this entry.', 'gravityview');
1970
+		if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
1971
+			$error = __( 'You do not have permission to edit this entry.', 'gravityview' );
1972 1972
 		}
1973 1973
 
1974
-		if( $this->entry['status'] === 'trash' ) {
1975
-			$error = __('You cannot edit the entry; it is in the trash.', 'gravityview' );
1974
+		if ( $this->entry[ 'status' ] === 'trash' ) {
1975
+			$error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' );
1976 1976
 		}
1977 1977
 
1978 1978
 		// No errors; everything's fine here!
1979
-		if( empty( $error ) ) {
1979
+		if ( empty( $error ) ) {
1980 1980
 			return true;
1981 1981
 		}
1982 1982
 
1983
-		if( $echo && $error !== true ) {
1983
+		if ( $echo && $error !== true ) {
1984 1984
 
1985 1985
 	        $error = esc_html( $error );
1986 1986
 
@@ -1988,10 +1988,10 @@  discard block
 block discarded – undo
1988 1988
 	         * @since 1.9
1989 1989
 	         */
1990 1990
 	        if ( ! empty( $this->entry ) ) {
1991
-		        $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;" ) );
1991
+		        $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;" ) );
1992 1992
 	        }
1993 1993
 
1994
-			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
1994
+			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' );
1995 1995
 		}
1996 1996
 
1997 1997
 		gravityview()->log->error( '{error}', array( 'error' => $error ) );
@@ -2011,17 +2011,17 @@  discard block
 block discarded – undo
2011 2011
 
2012 2012
 		$error = NULL;
2013 2013
 
2014
-		if( ! $this->check_user_cap_edit_field( $field ) ) {
2015
-			$error = __( 'You do not have permission to edit this field.', 'gravityview');
2014
+		if ( ! $this->check_user_cap_edit_field( $field ) ) {
2015
+			$error = __( 'You do not have permission to edit this field.', 'gravityview' );
2016 2016
 		}
2017 2017
 
2018 2018
 		// No errors; everything's fine here!
2019
-		if( empty( $error ) ) {
2019
+		if ( empty( $error ) ) {
2020 2020
 			return true;
2021 2021
 		}
2022 2022
 
2023
-		if( $echo ) {
2024
-			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');
2023
+		if ( $echo ) {
2024
+			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' );
2025 2025
 		}
2026 2026
 
2027 2027
 		gravityview()->log->error( '{error}', array( 'error' => $error ) );
@@ -2042,14 +2042,14 @@  discard block
 block discarded – undo
2042 2042
 	private function check_user_cap_edit_field( $field ) {
2043 2043
 
2044 2044
 		// If they can edit any entries (as defined in Gravity Forms), we're good.
2045
-		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
2045
+		if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
2046 2046
 			return true;
2047 2047
 		}
2048 2048
 
2049
-		$field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;
2049
+		$field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false;
2050 2050
 
2051
-		if( $field_cap ) {
2052
-			return GVCommon::has_cap( $field['allow_edit_cap'] );
2051
+		if ( $field_cap ) {
2052
+			return GVCommon::has_cap( $field[ 'allow_edit_cap' ] );
2053 2053
 		}
2054 2054
 
2055 2055
 		return false;
@@ -2063,17 +2063,17 @@  discard block
 block discarded – undo
2063 2063
 	public function verify_nonce() {
2064 2064
 
2065 2065
 		// Verify form submitted for editing single
2066
-		if( $this->is_edit_entry_submission() ) {
2066
+		if ( $this->is_edit_entry_submission() ) {
2067 2067
 			$valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );
2068 2068
 		}
2069 2069
 
2070 2070
 		// Verify
2071
-		else if( ! $this->is_edit_entry() ) {
2071
+		else if ( ! $this->is_edit_entry() ) {
2072 2072
 			$valid = false;
2073 2073
 		}
2074 2074
 
2075 2075
 		else {
2076
-			$valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
2076
+			$valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key );
2077 2077
 		}
2078 2078
 
2079 2079
 		/**
Please login to merge, or discard this patch.
Braces   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -573,7 +573,8 @@  discard block
 block discarded – undo
573 573
 
574 574
 							// Only allow quantity to be set if it's allowed to be edited
575 575
 							if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) {
576
-							} else { // otherwise set to what it previously was
576
+							} else {
577
+// otherwise set to what it previously was
577 578
 								$_POST[ $input_name ] = $entry[ $input['id'] ];
578 579
 							}
579 580
 						} else {
@@ -958,7 +959,7 @@  discard block
 block discarded – undo
958 959
 
959 960
 			$back_link = remove_query_arg( array( 'page', 'view', 'edit' ) );
960 961
 
961
-			if( ! $this->is_valid ){
962
+			if( ! $this->is_valid ) {
962 963
 
963 964
 				// Keeping this compatible with Gravity Forms.
964 965
 				$validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
@@ -2070,9 +2071,7 @@  discard block
 block discarded – undo
2070 2071
 		// Verify
2071 2072
 		else if( ! $this->is_edit_entry() ) {
2072 2073
 			$valid = false;
2073
-		}
2074
-
2075
-		else {
2074
+		} else {
2076 2075
 			$valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
2077 2076
 		}
2078 2077
 
Please login to merge, or discard this patch.