Completed
Push — develop ( d04c10...8cb174 )
by Gennady
20:01
created
includes/extensions/edit-entry/class-edit-entry-render.php 2 patches
Indentation   +296 added lines, -296 removed lines patch added patch discarded remove patch
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
 
103 103
 	/**
104 104
 	 * ID of the current post. May also be ID of the current View.
105
-     *
106
-     * @since 2.0.13
107
-     * 
108
-     * @var int
105
+	 *
106
+	 * @since 2.0.13
107
+	 * 
108
+	 * @var int
109 109
 	 */
110 110
 	public $post_id;
111 111
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 */
188 188
 	public function prevent_maybe_process_form() {
189 189
 
190
-	    if( ! $this->is_edit_entry_submission() ) {
190
+		if( ! $this->is_edit_entry_submission() ) {
191 191
 			return;
192 192
 		}
193 193
 
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
 	 * When Edit entry view is requested setup the vars
222 222
 	 */
223 223
 	private function setup_vars() {
224
-        global $post;
224
+		global $post;
225 225
 
226 226
 		$gravityview_view = GravityView_View::getInstance();
227 227
 
228 228
 
229 229
 		$entries = $gravityview_view->getEntries();
230
-	    self::$original_entry = $entries[0];
231
-	    $this->entry = $entries[0];
230
+		self::$original_entry = $entries[0];
231
+		$this->entry = $entries[0];
232 232
 
233 233
 		self::$original_form = $gravityview_view->getForm();
234 234
 		$this->form = $gravityview_view->getForm();
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
 
371 371
 			GFFormsModel::save_lead( $form, $this->entry );
372 372
 
373
-	        // Delete the values for hidden inputs
374
-	        $this->unset_hidden_field_values();
373
+			// Delete the values for hidden inputs
374
+			$this->unset_hidden_field_values();
375 375
 			
376 376
 			$this->entry['date_created'] = $date_created;
377 377
 
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 			// Perform actions normally performed after updating a lead
382 382
 			$this->after_update();
383 383
 
384
-	        /**
384
+			/**
385 385
 			 * Must be AFTER after_update()!
386 386
 			 * @see https://github.com/gravityview/GravityView/issues/764
387 387
 			 */
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 
390 390
 			/**
391 391
 			 * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry
392
-             * @since 2.1 Added $gv_data parameter
392
+			 * @since 2.1 Added $gv_data parameter
393 393
 			 * @param array $form Gravity Forms form array
394 394
 			 * @param string $entry_id Numeric ID of the entry that was updated
395 395
 			 * @param GravityView_Edit_Entry_Render $this This object
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 	 * @return void
414 414
 	 */
415 415
 	private function unset_hidden_field_values() {
416
-	    global $wpdb;
416
+		global $wpdb;
417 417
 
418 418
 		/**
419 419
 		 * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic
@@ -437,17 +437,17 @@  discard block
 block discarded – undo
437 437
 			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );
438 438
 		}
439 439
 
440
-	    foreach ( $this->entry as $input_id => $field_value ) {
440
+		foreach ( $this->entry as $input_id => $field_value ) {
441 441
 
442 442
 			if ( ! is_numeric( $input_id ) ) {
443 443
 				continue;
444 444
 			}
445 445
 
446
-		    $field = RGFormsModel::get_field( $this->form, $input_id );
446
+			$field = RGFormsModel::get_field( $this->form, $input_id );
447 447
 
448
-		    // Reset fields that are hidden
449
-		    // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic
450
-		    if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) {
448
+			// Reset fields that are hidden
449
+			// Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic
450
+			if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) {
451 451
 
452 452
 				$empty_value = $field->get_value_save_entry(
453 453
 					is_array( $field->get_entry_inputs() ) ? array() : '',
@@ -459,16 +459,16 @@  discard block
 block discarded – undo
459 459
 					$empty_value = '';
460 460
 				}
461 461
 
462
-			    $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
462
+				$lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
463 463
 
464
-			    GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );
464
+				GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );
465 465
 
466
-			    // Prevent the $_POST values of hidden fields from being used as default values when rendering the form
466
+				// Prevent the $_POST values of hidden fields from being used as default values when rendering the form
467 467
 				// after submission
468
-			    $post_input_id = 'input_' . str_replace( '.', '_', $input_id );
469
-			    $_POST[ $post_input_id ] = '';
470
-		    }
471
-	    }
468
+				$post_input_id = 'input_' . str_replace( '.', '_', $input_id );
469
+				$_POST[ $post_input_id ] = '';
470
+			}
471
+		}
472 472
 	}
473 473
 
474 474
 	/**
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 
563 563
 		$form = $this->filter_conditional_logic( $this->form );
564 564
 
565
-	    /** @var GF_Field $field */
565
+		/** @var GF_Field $field */
566 566
 		foreach( $form['fields'] as $k => &$field ) {
567 567
 
568 568
 			/**
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 
579 579
 			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
580 580
 				foreach( $field->inputs as $key => $input ) {
581
-				    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
581
+					$field->inputs[ $key ][ 'id' ] = (string)$input['id'];
582 582
 				}
583 583
 			}
584 584
 		}
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
 
619 619
 				$inputs = $field->get_entry_inputs();
620 620
 				if ( is_array( $inputs ) ) {
621
-				    foreach ( $inputs as $input ) {
621
+					foreach ( $inputs as $input ) {
622 622
 						list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 );
623 623
 
624 624
 						if ( 'product' === $field->type ) {
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 						}
638 638
 
639 639
 						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] );
640
-				    }
640
+					}
641 641
 				} else {
642 642
 					// Set to what it previously was if it's not editable
643 643
 					if ( ! in_array( $field->id, $allowed_fields ) ) {
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
684 684
 
685 685
 			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
686
-	        $ary = stripslashes_deep( $ary );
686
+			$ary = stripslashes_deep( $ary );
687 687
 			$img_url = \GV\Utils::get( $ary, 0 );
688 688
 
689 689
 			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 	private function maybe_update_post_fields( $form ) {
757 757
 
758 758
 		if( empty( $this->entry['post_id'] ) ) {
759
-	        gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
759
+			gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
760 760
 			return;
761 761
 		}
762 762
 
@@ -791,49 +791,49 @@  discard block
 block discarded – undo
791 791
 
792 792
 				switch( $field->type ) {
793 793
 
794
-				    case 'post_title':
795
-				        $post_title = $value;
796
-				        if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
797
-				            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
798
-				        }
799
-				        $updated_post->post_title = $post_title;
800
-				        $updated_post->post_name  = $post_title;
801
-				        unset( $post_title );
802
-				        break;
803
-
804
-				    case 'post_content':
805
-				        $post_content = $value;
806
-				        if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
807
-				            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
808
-				        }
809
-				        $updated_post->post_content = $post_content;
810
-				        unset( $post_content );
811
-				        break;
812
-				    case 'post_excerpt':
813
-				        $updated_post->post_excerpt = $value;
814
-				        break;
815
-				    case 'post_tags':
816
-				        wp_set_post_tags( $post_id, $value, false );
817
-				        break;
818
-				    case 'post_category':
819
-				        break;
820
-				    case 'post_custom_field':
794
+					case 'post_title':
795
+						$post_title = $value;
796
+						if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
797
+							$post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
798
+						}
799
+						$updated_post->post_title = $post_title;
800
+						$updated_post->post_name  = $post_title;
801
+						unset( $post_title );
802
+						break;
803
+
804
+					case 'post_content':
805
+						$post_content = $value;
806
+						if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
807
+							$post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
808
+						}
809
+						$updated_post->post_content = $post_content;
810
+						unset( $post_content );
811
+						break;
812
+					case 'post_excerpt':
813
+						$updated_post->post_excerpt = $value;
814
+						break;
815
+					case 'post_tags':
816
+						wp_set_post_tags( $post_id, $value, false );
817
+						break;
818
+					case 'post_category':
819
+						break;
820
+					case 'post_custom_field':
821 821
 						if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) {
822 822
 							$value = $value[ $field_id ];
823 823
 						}
824 824
 
825
-				        if( ! empty( $field->customFieldTemplateEnabled ) ) {
826
-				            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
827
-				        }
825
+						if( ! empty( $field->customFieldTemplateEnabled ) ) {
826
+							$value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
827
+						}
828 828
 
829 829
 						$value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry );
830 830
 
831
-				        update_post_meta( $post_id, $field->postCustomFieldName, $value );
832
-				        break;
831
+						update_post_meta( $post_id, $field->postCustomFieldName, $value );
832
+						break;
833 833
 
834
-				    case 'post_image':
835
-				        $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
836
-				        break;
834
+					case 'post_image':
835
+						$value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
836
+						break;
837 837
 
838 838
 				}
839 839
 
@@ -990,14 +990,14 @@  discard block
 block discarded – undo
990 990
 			?><h2 class="gv-edit-entry-title">
991 991
 				<span><?php
992 992
 
993
-				    /**
994
-				     * @filter `gravityview_edit_entry_title` Modify the edit entry title
995
-				     * @param string $edit_entry_title Modify the "Edit Entry" title
996
-				     * @param GravityView_Edit_Entry_Render $this This object
997
-				     */
998
-				    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
993
+					/**
994
+					 * @filter `gravityview_edit_entry_title` Modify the edit entry title
995
+					 * @param string $edit_entry_title Modify the "Edit Entry" title
996
+					 * @param GravityView_Edit_Entry_Render $this This object
997
+					 */
998
+					$edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
999 999
 
1000
-				    echo esc_attr( $edit_entry_title );
1000
+					echo esc_attr( $edit_entry_title );
1001 1001
 			?></span>
1002 1002
 			</h2>
1003 1003
 
@@ -1060,26 +1060,26 @@  discard block
 block discarded – undo
1060 1060
 
1061 1061
 				switch ( $edit_redirect ) {
1062 1062
 
1063
-                    case '0':
1064
-	                    $redirect_url = $back_link;
1065
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
1066
-                        break;
1067
-
1068
-                    case '1':
1069
-	                    $redirect_url = $directory_link = GravityView_API::directory_link();
1070
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
1071
-	                    break;
1072
-
1073
-                    case '2':
1074
-	                    $redirect_url = $edit_redirect_url;
1075
-	                    $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
1076
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
1077
-                        break;
1078
-
1079
-                    case '':
1080
-                    default:
1081
-					    $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
1082
-                        break;
1063
+					case '0':
1064
+						$redirect_url = $back_link;
1065
+						$entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
1066
+						break;
1067
+
1068
+					case '1':
1069
+						$redirect_url = $directory_link = GravityView_API::directory_link();
1070
+						$entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
1071
+						break;
1072
+
1073
+					case '2':
1074
+						$redirect_url = $edit_redirect_url;
1075
+						$redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
1076
+						$entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
1077
+						break;
1078
+
1079
+					case '':
1080
+					default:
1081
+						$entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
1082
+						break;
1083 1083
 				}
1084 1084
 
1085 1085
 				if ( isset( $redirect_url ) ) {
@@ -1145,13 +1145,13 @@  discard block
 block discarded – undo
1145 1145
 				);
1146 1146
 
1147 1147
 				/**
1148
-				* @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels
1149
-				* @since 1.16.3
1150
-				* @param array $labels Default button labels associative array
1151
-				* @param array $form The Gravity Forms form
1152
-				* @param array $entry The Gravity Forms entry
1153
-				* @param int $view_id The current View ID
1154
-				*/
1148
+				 * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels
1149
+				 * @since 1.16.3
1150
+				 * @param array $labels Default button labels associative array
1151
+				 * @param array $form The Gravity Forms form
1152
+				 * @param array $entry The Gravity Forms entry
1153
+				 * @param int $view_id The current View ID
1154
+				 */
1155 1155
 				$labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id );
1156 1156
 
1157 1157
 				GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form;
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
 
1194 1194
 		ob_get_clean();
1195 1195
 
1196
-	    remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
1196
+		remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
1197 1197
 		remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
1198 1198
 		remove_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) );
1199 1199
 		remove_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) );
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 
1250 1250
 		// for now we don't support Save and Continue feature.
1251 1251
 		if( ! self::$supports_save_and_continue ) {
1252
-	        unset( $form['save'] );
1252
+			unset( $form['save'] );
1253 1253
 		}
1254 1254
 
1255 1255
 		$form = $this->unselect_default_values( $form );
@@ -1276,30 +1276,30 @@  discard block
 block discarded – undo
1276 1276
 			return $field_content;
1277 1277
 		}
1278 1278
 
1279
-        $message = null;
1279
+		$message = null;
1280 1280
 
1281
-        // First, make sure they have the capability to edit the post.
1282
-        if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1281
+		// First, make sure they have the capability to edit the post.
1282
+		if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1283 1283
 
1284
-            /**
1285
-             * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1286
-             * @param string $message The existing "You don't have permission..." text
1287
-             */
1288
-            $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1284
+			/**
1285
+			 * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1286
+			 * @param string $message The existing "You don't have permission..." text
1287
+			 */
1288
+			$message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1289 1289
 
1290
-        } elseif( null === get_post( $this->entry['post_id'] ) ) {
1291
-            /**
1292
-             * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1293
-             * @param string $message The existing "This field is not editable; the post no longer exists." text
1294
-             */
1295
-            $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1296
-        }
1290
+		} elseif( null === get_post( $this->entry['post_id'] ) ) {
1291
+			/**
1292
+			 * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1293
+			 * @param string $message The existing "This field is not editable; the post no longer exists." text
1294
+			 */
1295
+			$message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1296
+		}
1297 1297
 
1298
-        if( $message ) {
1299
-            $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1300
-        }
1298
+		if( $message ) {
1299
+			$field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1300
+		}
1301 1301
 
1302
-        return $field_content;
1302
+		return $field_content;
1303 1303
 	}
1304 1304
 
1305 1305
 	/**
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
 			|| ! empty( $field_content )
1328 1328
 			|| in_array( $field->type, array( 'honeypot' ) )
1329 1329
 		) {
1330
-	        return $field_content;
1330
+			return $field_content;
1331 1331
 		}
1332 1332
 
1333 1333
 		// SET SOME FIELD DEFAULTS TO PREVENT ISSUES
@@ -1335,24 +1335,24 @@  discard block
 block discarded – undo
1335 1335
 
1336 1336
 		$field_value = $this->get_field_value( $field );
1337 1337
 
1338
-	    // Prevent any PHP warnings, like undefined index
1339
-	    ob_start();
1338
+		// Prevent any PHP warnings, like undefined index
1339
+		ob_start();
1340 1340
 
1341
-	    $return = null;
1341
+		$return = null;
1342 1342
 
1343 1343
 		/** @var GravityView_Field $gv_field */
1344 1344
 		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1345 1345
 			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1346 1346
 		} else {
1347
-	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
1348
-	    }
1347
+			$return = $field->get_field_input( $this->form, $field_value, $this->entry );
1348
+		}
1349 1349
 
1350
-	    // If there was output, it's an error
1351
-	    $warnings = ob_get_clean();
1350
+		// If there was output, it's an error
1351
+		$warnings = ob_get_clean();
1352 1352
 
1353
-	    if( !empty( $warnings ) ) {
1354
-		    gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1355
-	    }
1353
+		if( !empty( $warnings ) ) {
1354
+			gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1355
+		}
1356 1356
 
1357 1357
 		return $return;
1358 1358
 	}
@@ -1387,8 +1387,8 @@  discard block
 block discarded – undo
1387 1387
 				$input_id = strval( $input['id'] );
1388 1388
 
1389 1389
 				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1390
-				    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1391
-				    $allow_pre_populated = false;
1390
+					$field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1391
+					$allow_pre_populated = false;
1392 1392
 				}
1393 1393
 
1394 1394
 			}
@@ -1412,7 +1412,7 @@  discard block
 block discarded – undo
1412 1412
 			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1413 1413
 				$categories = array();
1414 1414
 				foreach ( explode( ',', $field_value ) as $cat_string ) {
1415
-				    $categories[] = GFCommon::format_post_category( $cat_string, true );
1415
+					$categories[] = GFCommon::format_post_category( $cat_string, true );
1416 1416
 				}
1417 1417
 				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1418 1418
 			}
@@ -1422,25 +1422,25 @@  discard block
 block discarded – undo
1422 1422
 		// if value is empty get the default value if defined
1423 1423
 		$field_value = $field->get_value_default_if_empty( $field_value );
1424 1424
 
1425
-	    /**
1426
-	     * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1427
-	     * @since 1.11
1428
-	     * @since 1.20 Added third param
1429
-	     * @param mixed $field_value field value used to populate the input
1430
-	     * @param object $field Gravity Forms field object ( Class GF_Field )
1431
-	     * @param GravityView_Edit_Entry_Render $this Current object
1432
-	     */
1433
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this );
1434
-
1435
-	    /**
1436
-	     * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1437
-	     * @since 1.17
1438
-	     * @since 1.20 Added third param
1439
-	     * @param mixed $field_value field value used to populate the input
1440
-	     * @param GF_Field $field Gravity Forms field object
1441
-	     * @param GravityView_Edit_Entry_Render $this Current object
1442
-	     */
1443
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1425
+		/**
1426
+		 * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1427
+		 * @since 1.11
1428
+		 * @since 1.20 Added third param
1429
+		 * @param mixed $field_value field value used to populate the input
1430
+		 * @param object $field Gravity Forms field object ( Class GF_Field )
1431
+		 * @param GravityView_Edit_Entry_Render $this Current object
1432
+		 */
1433
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this );
1434
+
1435
+		/**
1436
+		 * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1437
+		 * @since 1.17
1438
+		 * @since 1.20 Added third param
1439
+		 * @param mixed $field_value field value used to populate the input
1440
+		 * @param GF_Field $field Gravity Forms field object
1441
+		 * @param GravityView_Edit_Entry_Render $this Current object
1442
+		 */
1443
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1444 1444
 
1445 1445
 		return $field_value;
1446 1446
 	}
@@ -1467,7 +1467,7 @@  discard block
 block discarded – undo
1467 1467
 			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1468 1468
 			// expects certain field array items to be set.
1469 1469
 			foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) {
1470
-	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1470
+				$field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1471 1471
 			}
1472 1472
 
1473 1473
 			switch( RGFormsModel::get_input_type( $field ) ) {
@@ -1481,61 +1481,61 @@  discard block
 block discarded – undo
1481 1481
 				 */
1482 1482
 				case 'fileupload':
1483 1483
 
1484
-				    // Set the previous value
1485
-				    $entry = $this->get_entry();
1484
+					// Set the previous value
1485
+					$entry = $this->get_entry();
1486 1486
 
1487
-				    $input_name = 'input_'.$field->id;
1488
-				    $form_id = $form['id'];
1487
+					$input_name = 'input_'.$field->id;
1488
+					$form_id = $form['id'];
1489 1489
 
1490
-				    $value = NULL;
1490
+					$value = NULL;
1491 1491
 
1492
-				    // Use the previous entry value as the default.
1493
-				    if( isset( $entry[ $field->id ] ) ) {
1494
-				        $value = $entry[ $field->id ];
1495
-				    }
1492
+					// Use the previous entry value as the default.
1493
+					if( isset( $entry[ $field->id ] ) ) {
1494
+						$value = $entry[ $field->id ];
1495
+					}
1496 1496
 
1497
-				    // If this is a single upload file
1498
-				    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1499
-				        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1500
-				        $value = $file_path['url'];
1497
+					// If this is a single upload file
1498
+					if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1499
+						$file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1500
+						$value = $file_path['url'];
1501 1501
 
1502
-				    } else {
1502
+					} else {
1503 1503
 
1504
-				        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1505
-				        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1506
-				        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1504
+						// Fix PHP warning on line 1498 of form_display.php for post_image fields
1505
+						// Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1506
+						$_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1507 1507
 
1508
-				    }
1508
+					}
1509 1509
 
1510
-				    if ( \GV\Utils::get( $field, "multipleFiles" ) ) {
1510
+					if ( \GV\Utils::get( $field, "multipleFiles" ) ) {
1511 1511
 
1512
-				        // If there are fresh uploads, process and merge them.
1513
-				        // Otherwise, use the passed values, which should be json-encoded array of URLs
1514
-				        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1515
-				            $value = empty( $value ) ? '[]' : $value;
1516
-				            $value = stripslashes_deep( $value );
1517
-				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1518
-				        }
1512
+						// If there are fresh uploads, process and merge them.
1513
+						// Otherwise, use the passed values, which should be json-encoded array of URLs
1514
+						if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1515
+							$value = empty( $value ) ? '[]' : $value;
1516
+							$value = stripslashes_deep( $value );
1517
+							$value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1518
+						}
1519 1519
 
1520
-				    } else {
1520
+					} else {
1521 1521
 
1522
-				        // A file already exists when editing an entry
1523
-				        // We set this to solve issue when file upload fields are required.
1524
-				        GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1522
+						// A file already exists when editing an entry
1523
+						// We set this to solve issue when file upload fields are required.
1524
+						GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1525 1525
 
1526
-				    }
1526
+					}
1527 1527
 
1528
-				    $this->entry[ $input_name ] = $value;
1529
-				    $_POST[ $input_name ] = $value;
1528
+					$this->entry[ $input_name ] = $value;
1529
+					$_POST[ $input_name ] = $value;
1530 1530
 
1531
-				    break;
1531
+					break;
1532 1532
 
1533 1533
 				case 'number':
1534
-				    // Fix "undefined index" issue at line 1286 in form_display.php
1535
-				    if( !isset( $_POST['input_'.$field->id ] ) ) {
1536
-				        $_POST['input_'.$field->id ] = NULL;
1537
-				    }
1538
-				    break;
1534
+					// Fix "undefined index" issue at line 1286 in form_display.php
1535
+					if( !isset( $_POST['input_'.$field->id ] ) ) {
1536
+						$_POST['input_'.$field->id ] = NULL;
1537
+					}
1538
+					break;
1539 1539
 			}
1540 1540
 
1541 1541
 		}
@@ -1620,43 +1620,43 @@  discard block
 block discarded – undo
1620 1620
 				case 'fileupload' :
1621 1621
 				case 'post_image':
1622 1622
 
1623
-				    // in case nothing is uploaded but there are already files saved
1624
-				    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1625
-				        $field->failed_validation = false;
1626
-				        unset( $field->validation_message );
1627
-				    }
1623
+					// in case nothing is uploaded but there are already files saved
1624
+					if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1625
+						$field->failed_validation = false;
1626
+						unset( $field->validation_message );
1627
+					}
1628 1628
 
1629
-				    // validate if multi file upload reached max number of files [maxFiles] => 2
1630
-				    if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1629
+					// validate if multi file upload reached max number of files [maxFiles] => 2
1630
+					if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1631 1631
 
1632
-				        $input_name = 'input_' . $field->id;
1633
-				        //uploaded
1634
-				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1632
+						$input_name = 'input_' . $field->id;
1633
+						//uploaded
1634
+						$file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1635 1635
 
1636
-				        //existent
1637
-				        $entry = $this->get_entry();
1638
-				        $value = NULL;
1639
-				        if( isset( $entry[ $field->id ] ) ) {
1640
-				            $value = json_decode( $entry[ $field->id ], true );
1641
-				        }
1636
+						//existent
1637
+						$entry = $this->get_entry();
1638
+						$value = NULL;
1639
+						if( isset( $entry[ $field->id ] ) ) {
1640
+							$value = json_decode( $entry[ $field->id ], true );
1641
+						}
1642 1642
 
1643
-				        // count uploaded files and existent entry files
1644
-				        $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) +
1645
-						               ( is_array( $value ) ? count( $value ) : 0 );
1643
+						// count uploaded files and existent entry files
1644
+						$count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) +
1645
+									   ( is_array( $value ) ? count( $value ) : 0 );
1646 1646
 
1647
-				        if( $count_files > $field->maxFiles ) {
1648
-				            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1649
-				            $field->failed_validation = 1;
1650
-				            $gv_valid = false;
1647
+						if( $count_files > $field->maxFiles ) {
1648
+							$field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1649
+							$field->failed_validation = 1;
1650
+							$gv_valid = false;
1651 1651
 
1652
-				            // in case of error make sure the newest upload files are removed from the upload input
1653
-				            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1654
-				        }
1652
+							// in case of error make sure the newest upload files are removed from the upload input
1653
+							GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1654
+						}
1655 1655
 
1656
-				    }
1656
+					}
1657 1657
 
1658 1658
 
1659
-				    break;
1659
+					break;
1660 1660
 
1661 1661
 			}
1662 1662
 
@@ -1667,47 +1667,47 @@  discard block
 block discarded – undo
1667 1667
 
1668 1668
 				switch ( $field_type ) {
1669 1669
 
1670
-				    // Captchas don't need to be re-entered.
1671
-				    case 'captcha':
1670
+					// Captchas don't need to be re-entered.
1671
+					case 'captcha':
1672 1672
 
1673
-				        // Post Image fields aren't editable, so we un-fail them.
1674
-				    case 'post_image':
1675
-				        $field->failed_validation = false;
1676
-				        unset( $field->validation_message );
1677
-				        break;
1673
+						// Post Image fields aren't editable, so we un-fail them.
1674
+					case 'post_image':
1675
+						$field->failed_validation = false;
1676
+						unset( $field->validation_message );
1677
+						break;
1678 1678
 
1679 1679
 				}
1680 1680
 
1681 1681
 				// You can't continue inside a switch, so we do it after.
1682 1682
 				if( empty( $field->failed_validation ) ) {
1683
-				    continue;
1683
+					continue;
1684 1684
 				}
1685 1685
 
1686 1686
 				// checks if the No Duplicates option is not validating entry against itself, since
1687 1687
 				// we're editing a stored entry, it would also assume it's a duplicate.
1688 1688
 				if( !empty( $field->noDuplicates ) ) {
1689 1689
 
1690
-				    $entry = $this->get_entry();
1690
+					$entry = $this->get_entry();
1691 1691
 
1692
-				    // If the value of the entry is the same as the stored value
1693
-				    // Then we can assume it's not a duplicate, it's the same.
1694
-				    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1695
-				        //if value submitted was not changed, then don't validate
1696
-				        $field->failed_validation = false;
1692
+					// If the value of the entry is the same as the stored value
1693
+					// Then we can assume it's not a duplicate, it's the same.
1694
+					if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1695
+						//if value submitted was not changed, then don't validate
1696
+						$field->failed_validation = false;
1697 1697
 
1698
-				        unset( $field->validation_message );
1698
+						unset( $field->validation_message );
1699 1699
 
1700
-				        gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) );
1700
+						gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) );
1701 1701
 
1702
-				        continue;
1703
-				    }
1702
+						continue;
1703
+					}
1704 1704
 				}
1705 1705
 
1706 1706
 				// if here then probably we are facing the validation 'At least one field must be filled out'
1707 1707
 				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1708
-				    unset( $field->validation_message );
1709
-	                $field->validation_message = false;
1710
-				    continue;
1708
+					unset( $field->validation_message );
1709
+					$field->validation_message = false;
1710
+					continue;
1711 1711
 				}
1712 1712
 
1713 1713
 				$gv_valid = false;
@@ -1771,8 +1771,8 @@  discard block
 block discarded – undo
1771 1771
 		// Hide fields depending on admin settings
1772 1772
 		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1773 1773
 
1774
-	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1775
-	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1774
+		// If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1775
+		$fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1776 1776
 
1777 1777
 		/**
1778 1778
 		 * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form
@@ -1851,11 +1851,11 @@  discard block
 block discarded – undo
1851 1851
 		// The edit tab has been configured, so we loop through to configured settings
1852 1852
 		foreach ( $configured_fields as $configured_field ) {
1853 1853
 
1854
-	        /** @var GF_Field $field */
1855
-	        foreach ( $fields as $field ) {
1854
+			/** @var GF_Field $field */
1855
+			foreach ( $fields as $field ) {
1856 1856
 				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1857
-				    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1858
-				    break;
1857
+					$edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1858
+					break;
1859 1859
 				}
1860 1860
 
1861 1861
 			}
@@ -1911,28 +1911,28 @@  discard block
 block discarded – undo
1911 1911
 	 */
1912 1912
 	private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) {
1913 1913
 
1914
-	    /**
1914
+		/**
1915 1915
 		 * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true
1916
-	     * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1917
-	     * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1918
-	     * @since 1.9.1
1919
-	     * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions.
1920
-	     * @param array $form GF Form array
1921
-	     * @param int $view_id View ID
1922
-	     */
1923
-	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1924
-
1925
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1916
+		 * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1917
+		 * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1918
+		 * @since 1.9.1
1919
+		 * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions.
1920
+		 * @param array $form GF Form array
1921
+		 * @param int $view_id View ID
1922
+		 */
1923
+		$use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1924
+
1925
+		if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1926 1926
 			foreach( $fields as $k => $field ) {
1927 1927
 				if( $field->adminOnly ) {
1928
-				    unset( $fields[ $k ] );
1928
+					unset( $fields[ $k ] );
1929 1929
 				}
1930 1930
 			}
1931 1931
 			return array_values( $fields );
1932 1932
 		}
1933 1933
 
1934
-	    foreach( $fields as &$field ) {
1935
-		    $field->adminOnly = false;
1934
+		foreach( $fields as &$field ) {
1935
+			$field->adminOnly = false;
1936 1936
 		}
1937 1937
 
1938 1938
 		return $fields;
@@ -1952,13 +1952,13 @@  discard block
 block discarded – undo
1952 1952
 	 */
1953 1953
 	private function unselect_default_values( $form ) {
1954 1954
 
1955
-	    foreach ( $form['fields'] as &$field ) {
1955
+		foreach ( $form['fields'] as &$field ) {
1956 1956
 
1957 1957
 			if ( empty( $field->choices ) ) {
1958
-                continue;
1958
+				continue;
1959 1959
 			}
1960 1960
 
1961
-            foreach ( $field->choices as &$choice ) {
1961
+			foreach ( $field->choices as &$choice ) {
1962 1962
 				if ( \GV\Utils::get( $choice, 'isSelected' ) ) {
1963 1963
 					$choice['isSelected'] = false;
1964 1964
 				}
@@ -1995,36 +1995,36 @@  discard block
 block discarded – undo
1995 1995
 
1996 1996
 			if( 'checkbox' === $field->type ) {
1997 1997
 				foreach ( $field->get_entry_inputs() as $key => $input ) {
1998
-				    $input_id = $input['id'];
1999
-				    $choice = $field->choices[ $key ];
2000
-				    $value = \GV\Utils::get( $this->entry, $input_id );
2001
-				    $match = RGFormsModel::choice_value_match( $field, $choice, $value );
2002
-				    if( $match ) {
2003
-				        $field->choices[ $key ]['isSelected'] = true;
2004
-				    }
1998
+					$input_id = $input['id'];
1999
+					$choice = $field->choices[ $key ];
2000
+					$value = \GV\Utils::get( $this->entry, $input_id );
2001
+					$match = RGFormsModel::choice_value_match( $field, $choice, $value );
2002
+					if( $match ) {
2003
+						$field->choices[ $key ]['isSelected'] = true;
2004
+					}
2005 2005
 				}
2006 2006
 			} else {
2007 2007
 
2008 2008
 				// We need to run through each field to set the default values
2009 2009
 				foreach ( $this->entry as $field_id => $field_value ) {
2010 2010
 
2011
-				    if( floatval( $field_id ) === floatval( $field->id ) ) {
2011
+					if( floatval( $field_id ) === floatval( $field->id ) ) {
2012 2012
 
2013
-				        if( 'list' === $field->type ) {
2014
-				            $list_rows = maybe_unserialize( $field_value );
2013
+						if( 'list' === $field->type ) {
2014
+							$list_rows = maybe_unserialize( $field_value );
2015 2015
 
2016
-				            $list_field_value = array();
2017
-				            foreach ( (array) $list_rows as $row ) {
2018
-				                foreach ( (array) $row as $column ) {
2019
-				                    $list_field_value[] = $column;
2020
-				                }
2021
-				            }
2016
+							$list_field_value = array();
2017
+							foreach ( (array) $list_rows as $row ) {
2018
+								foreach ( (array) $row as $column ) {
2019
+									$list_field_value[] = $column;
2020
+								}
2021
+							}
2022 2022
 
2023
-				            $field->defaultValue = serialize( $list_field_value );
2024
-				        } else {
2025
-				            $field->defaultValue = $field_value;
2026
-				        }
2027
-				    }
2023
+							$field->defaultValue = serialize( $list_field_value );
2024
+						} else {
2025
+							$field->defaultValue = $field_value;
2026
+						}
2027
+					}
2028 2028
 				}
2029 2029
 			}
2030 2030
 		}
@@ -2085,7 +2085,7 @@  discard block
 block discarded – undo
2085 2085
 			foreach ( $form['fields'] as &$field ) {
2086 2086
 				foreach ( $remove_conditions_rule as $_remove_conditions_r ) {
2087 2087
 
2088
-				    list( $rule_field_id, $rule_i ) = $_remove_conditions_r;
2088
+					list( $rule_field_id, $rule_i ) = $_remove_conditions_r;
2089 2089
 
2090 2090
 					if ( $field['id'] == $rule_field_id ) {
2091 2091
 						unset( $field->conditionalLogic['rules'][ $rule_i ] );
@@ -2136,7 +2136,7 @@  discard block
 block discarded – undo
2136 2136
 			return $has_conditional_logic;
2137 2137
 		}
2138 2138
 
2139
-	    /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */
2139
+		/** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */
2140 2140
 		return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form );
2141 2141
 	}
2142 2142
 
@@ -2203,14 +2203,14 @@  discard block
 block discarded – undo
2203 2203
 
2204 2204
 		if( $echo && $error !== true ) {
2205 2205
 
2206
-	        $error = esc_html( $error );
2206
+			$error = esc_html( $error );
2207 2207
 
2208
-	        /**
2209
-	         * @since 1.9
2210
-	         */
2211
-	        if ( ! empty( $this->entry ) ) {
2212
-		        $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) );
2213
-	        }
2208
+			/**
2209
+			 * @since 1.9
2210
+			 */
2211
+			if ( ! empty( $this->entry ) ) {
2212
+				$error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) );
2213
+			}
2214 2214
 
2215 2215
 			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
2216 2216
 		}
Please login to merge, or discard this patch.
Spacing   +237 added lines, -237 removed lines patch added patch discarded remove patch
@@ -134,16 +134,16 @@  discard block
 block discarded – undo
134 134
 	function load() {
135 135
 
136 136
 		/** @define "GRAVITYVIEW_DIR" "../../../" */
137
-		include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' );
137
+		include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' );
138 138
 
139 139
 		// Don't display an embedded form when editing an entry
140 140
 		add_action( 'wp_head', array( $this, 'prevent_render_form' ) );
141 141
 		add_action( 'wp_footer', array( $this, 'prevent_render_form' ) );
142 142
 
143 143
 		// Stop Gravity Forms processing what is ours!
144
-		add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 );
144
+		add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 );
145 145
 
146
-		add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') );
146
+		add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) );
147 147
 
148 148
 		add_action( 'gravityview_edit_entry', array( $this, 'init' ), 10, 4 );
149 149
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 		add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 );
155 155
 
156 156
 		// Add fields expected by GFFormDisplay::validate()
157
-		add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') );
157
+		add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) );
158 158
 
159 159
 		// Fix multiselect value for GF 2.2
160 160
 		add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 );
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 * @return void
172 172
 	 */
173 173
 	public function prevent_render_form() {
174
-		if( $this->is_edit_entry() ) {
175
-			if( 'wp_head' === current_filter() ) {
174
+		if ( $this->is_edit_entry() ) {
175
+			if ( 'wp_head' === current_filter() ) {
176 176
 				add_filter( 'gform_shortcode_form', '__return_empty_string' );
177 177
 			} else {
178 178
 				remove_filter( 'gform_shortcode_form', '__return_empty_string' );
@@ -187,14 +187,14 @@  discard block
 block discarded – undo
187 187
 	 */
188 188
 	public function prevent_maybe_process_form() {
189 189
 
190
-	    if( ! $this->is_edit_entry_submission() ) {
190
+	    if ( ! $this->is_edit_entry_submission() ) {
191 191
 			return;
192 192
 		}
193 193
 
194 194
 		gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] Removing GFForms::maybe_process_form() action.' );
195 195
 
196
-		remove_action( 'wp',  array( 'RGForms', 'maybe_process_form'), 9 );
197
-		remove_action( 'wp',  array( 'GFForms', 'maybe_process_form'), 9 );
196
+		remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 );
197
+		remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 );
198 198
 	}
199 199
 
200 200
 	/**
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 */
204 204
 	public function is_edit_entry() {
205 205
 
206
-		$is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] );
206
+		$is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] );
207 207
 
208 208
 		return ( $is_edit_entry || $this->is_edit_entry_submission() );
209 209
 	}
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 * @return boolean
215 215
 	 */
216 216
 	public function is_edit_entry_submission() {
217
-		return !empty( $_POST[ self::$nonce_field ] );
217
+		return ! empty( $_POST[ self::$nonce_field ] );
218 218
 	}
219 219
 
220 220
 	/**
@@ -227,16 +227,16 @@  discard block
 block discarded – undo
227 227
 
228 228
 
229 229
 		$entries = $gravityview_view->getEntries();
230
-	    self::$original_entry = $entries[0];
231
-	    $this->entry = $entries[0];
230
+	    self::$original_entry = $entries[ 0 ];
231
+	    $this->entry = $entries[ 0 ];
232 232
 
233 233
 		self::$original_form = $gravityview_view->getForm();
234 234
 		$this->form = $gravityview_view->getForm();
235
-		$this->form_id = $this->entry['form_id'];
235
+		$this->form_id = $this->entry[ 'form_id' ];
236 236
 		$this->view_id = $gravityview_view->getViewId();
237 237
 		$this->post_id = \GV\Utils::get( $post, 'ID', null );
238 238
 
239
-		self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] );
239
+		self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] );
240 240
 	}
241 241
 
242 242
 
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
 	private function print_scripts() {
296 296
 		$gravityview_view = GravityView_View::getInstance();
297 297
 
298
-		wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
298
+		wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
299 299
 
300
-		GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false);
300
+		GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false );
301 301
 
302 302
 		wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) );
303 303
 
@@ -313,19 +313,19 @@  discard block
 block discarded – undo
313 313
 	 */
314 314
 	private function process_save( $gv_data ) {
315 315
 
316
-		if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) {
316
+		if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) {
317 317
 			return;
318 318
 		}
319 319
 
320 320
 		// Make sure the entry, view, and form IDs are all correct
321 321
 		$valid = $this->verify_nonce();
322 322
 
323
-		if ( !$valid ) {
323
+		if ( ! $valid ) {
324 324
 			gravityview()->log->error( 'Nonce validation failed.' );
325 325
 			return;
326 326
 		}
327 327
 
328
-		if ( $this->entry['id'] !== $_POST['lid'] ) {
328
+		if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) {
329 329
 			gravityview()->log->error( 'Entry ID did not match posted entry ID.' );
330 330
 			return;
331 331
 		}
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
 		$this->validate();
338 338
 
339
-		if( $this->is_valid ) {
339
+		if ( $this->is_valid ) {
340 340
 
341 341
 			gravityview()->log->debug( 'Submission is valid.' );
342 342
 
@@ -348,15 +348,15 @@  discard block
 block discarded – undo
348 348
 			/**
349 349
 			 * @hack to avoid the capability validation of the method save_lead for GF 1.9+
350 350
 			 */
351
-			unset( $_GET['page'] );
351
+			unset( $_GET[ 'page' ] );
352 352
 
353
-			$date_created = $this->entry['date_created'];
353
+			$date_created = $this->entry[ 'date_created' ];
354 354
 
355 355
 			/**
356 356
 			 * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead()
357 357
 			 * @since 1.17.2
358 358
 			 */
359
-			unset( $this->entry['date_created'] );
359
+			unset( $this->entry[ 'date_created' ] );
360 360
 
361 361
 			/**
362 362
 			 * @action `gravityview/edit_entry/before_update` Perform an action after the entry has been updated using Edit Entry
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
 			 * @param GravityView_Edit_Entry_Render $this This object
367 367
 			 * @param GravityView_View_Data $gv_data The View data
368 368
 			 */
369
-			do_action( 'gravityview/edit_entry/before_update', $form, $this->entry['id'], $this, $gv_data );
369
+			do_action( 'gravityview/edit_entry/before_update', $form, $this->entry[ 'id' ], $this, $gv_data );
370 370
 
371 371
 			GFFormsModel::save_lead( $form, $this->entry );
372 372
 
373 373
 	        // Delete the values for hidden inputs
374 374
 	        $this->unset_hidden_field_values();
375 375
 			
376
-			$this->entry['date_created'] = $date_created;
376
+			$this->entry[ 'date_created' ] = $date_created;
377 377
 
378 378
 			// Process calculation fields
379 379
 			$this->update_calculation_fields();
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 			 * @param GravityView_Edit_Entry_Render $this This object
396 396
 			 * @param GravityView_View_Data $gv_data The View data
397 397
 			 */
398
-			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data );
398
+			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data );
399 399
 
400 400
 		} else {
401 401
 			gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) );
@@ -425,16 +425,16 @@  discard block
 block discarded – undo
425 425
 
426 426
 		$this->unset_hidden_calculations = array();
427 427
 
428
-		if( ! $unset_hidden_field_values ) {
428
+		if ( ! $unset_hidden_field_values ) {
429 429
 			return;
430 430
 		}
431 431
 
432 432
 		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
433 433
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
434
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) );
434
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) );
435 435
 		} else {
436 436
 			$lead_detail_table = GFFormsModel::get_lead_details_table_name();
437
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );
437
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) );
438 438
 		}
439 439
 
440 440
 	    foreach ( $this->entry as $input_id => $field_value ) {
@@ -451,11 +451,11 @@  discard block
 block discarded – undo
451 451
 
452 452
 				$empty_value = $field->get_value_save_entry(
453 453
 					is_array( $field->get_entry_inputs() ) ? array() : '',
454
-					$this->form, '', $this->entry['id'], $this->entry
454
+					$this->form, '', $this->entry[ 'id' ], $this->entry
455 455
 				);
456 456
 
457 457
 				if ( $field->has_calculation() ) {
458
-					$this->unset_hidden_calculations[] = $field->id; // Unset
458
+					$this->unset_hidden_calculations[ ] = $field->id; // Unset
459 459
 					$empty_value = '';
460 460
 				}
461 461
 
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 		}
527 527
 
528 528
 		/** No file is being uploaded. */
529
-		if ( empty( $_FILES[ $input_name ]['name'] ) ) {
529
+		if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) {
530 530
 			/** So return the original upload */
531 531
 			return $entry[ $input_id ];
532 532
 		}
@@ -544,11 +544,11 @@  discard block
 block discarded – undo
544 544
 	 * @return mixed
545 545
 	 */
546 546
 	public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) {
547
-		if( ! $this->is_edit_entry() ) {
547
+		if ( ! $this->is_edit_entry() ) {
548 548
 			return $plupload_init;
549 549
 		}
550 550
 
551
-		$plupload_init['gf_vars']['max_files'] = 0;
551
+		$plupload_init[ 'gf_vars' ][ 'max_files' ] = 0;
552 552
 
553 553
 		return $plupload_init;
554 554
 	}
@@ -563,27 +563,27 @@  discard block
 block discarded – undo
563 563
 		$form = $this->filter_conditional_logic( $this->form );
564 564
 
565 565
 	    /** @var GF_Field $field */
566
-		foreach( $form['fields'] as $k => &$field ) {
566
+		foreach ( $form[ 'fields' ] as $k => &$field ) {
567 567
 
568 568
 			/**
569 569
 			 * Remove the fields with calculation formulas before save to avoid conflicts with GF logic
570 570
 			 * @since 1.16.3
571 571
 			 * @var GF_Field $field
572 572
 			 */
573
-			if( $field->has_calculation() ) {
574
-				unset( $form['fields'][ $k ] );
573
+			if ( $field->has_calculation() ) {
574
+				unset( $form[ 'fields' ][ $k ] );
575 575
 			}
576 576
 
577 577
 			$field->adminOnly = false;
578 578
 
579
-			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
580
-				foreach( $field->inputs as $key => $input ) {
581
-				    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
579
+			if ( isset( $field->inputs ) && is_array( $field->inputs ) ) {
580
+				foreach ( $field->inputs as $key => $input ) {
581
+				    $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ];
582 582
 				}
583 583
 			}
584 584
 		}
585 585
 
586
-		$form['fields'] = array_values( $form['fields'] );
586
+		$form[ 'fields' ] = array_values( $form[ 'fields' ] );
587 587
 
588 588
 		return $form;
589 589
 	}
@@ -595,14 +595,14 @@  discard block
 block discarded – undo
595 595
 		$update = false;
596 596
 
597 597
 		// get the most up to date entry values
598
-		$entry = GFAPI::get_entry( $this->entry['id'] );
598
+		$entry = GFAPI::get_entry( $this->entry[ 'id' ] );
599 599
 
600 600
 		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
601 601
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
602
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) );
602
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) );
603 603
 		} else {
604 604
 			$lead_detail_table = GFFormsModel::get_lead_details_table_name();
605
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) );
605
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) );
606 606
 		}
607 607
 
608 608
 
@@ -619,24 +619,24 @@  discard block
 block discarded – undo
619 619
 				$inputs = $field->get_entry_inputs();
620 620
 				if ( is_array( $inputs ) ) {
621 621
 				    foreach ( $inputs as $input ) {
622
-						list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 );
622
+						list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 );
623 623
 
624 624
 						if ( 'product' === $field->type ) {
625
-							$input_name = 'input_' . str_replace( '.', '_', $input['id'] );
625
+							$input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] );
626 626
 
627 627
 							// Only allow quantity to be set if it's allowed to be edited
628 628
 							if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) {
629 629
 							} else { // otherwise set to what it previously was
630
-								$_POST[ $input_name ] = $entry[ $input['id'] ];
630
+								$_POST[ $input_name ] = $entry[ $input[ 'id' ] ];
631 631
 							}
632 632
 						} else {
633 633
 							// Set to what it previously was if it's not editable
634 634
 							if ( ! in_array( $field_id, $allowed_fields ) ) {
635
-								$_POST[ $input_name ] = $entry[ $input['id'] ];
635
+								$_POST[ $input_name ] = $entry[ $input[ 'id' ] ];
636 636
 							}
637 637
 						}
638 638
 
639
-						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] );
639
+						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] );
640 640
 				    }
641 641
 				} else {
642 642
 					// Set to what it previously was if it's not editable
@@ -676,19 +676,19 @@  discard block
 block discarded – undo
676 676
 
677 677
 		$input_name = 'input_' . $field_id;
678 678
 
679
-		if ( !empty( $_FILES[ $input_name ]['name'] ) ) {
679
+		if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
680 680
 
681 681
 			// We have a new image
682 682
 
683
-			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
683
+			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] );
684 684
 
685 685
 			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
686 686
 	        $ary = stripslashes_deep( $ary );
687 687
 			$img_url = \GV\Utils::get( $ary, 0 );
688 688
 
689
-			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
690
-			$img_caption     = count( $ary ) > 2 ? $ary[2] : '';
691
-			$img_description = count( $ary ) > 3 ? $ary[3] : '';
689
+			$img_title       = count( $ary ) > 1 ? $ary[ 1 ] : '';
690
+			$img_caption     = count( $ary ) > 2 ? $ary[ 2 ] : '';
691
+			$img_description = count( $ary ) > 3 ? $ary[ 3 ] : '';
692 692
 
693 693
 			$image_meta = array(
694 694
 				'post_excerpt' => $img_caption,
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 
698 698
 			//adding title only if it is not empty. It will default to the file name if it is not in the array
699 699
 			if ( ! empty( $img_title ) ) {
700
-				$image_meta['post_title'] = $img_title;
700
+				$image_meta[ 'post_title' ] = $img_title;
701 701
 			}
702 702
 
703 703
 			/**
@@ -755,15 +755,15 @@  discard block
 block discarded – undo
755 755
 	 */
756 756
 	private function maybe_update_post_fields( $form ) {
757 757
 
758
-		if( empty( $this->entry['post_id'] ) ) {
758
+		if ( empty( $this->entry[ 'post_id' ] ) ) {
759 759
 	        gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
760 760
 			return;
761 761
 		}
762 762
 
763
-		$post_id = $this->entry['post_id'];
763
+		$post_id = $this->entry[ 'post_id' ];
764 764
 
765 765
 		// Security check
766
-		if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
766
+		if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
767 767
 			gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) );
768 768
 			return;
769 769
 		}
@@ -776,25 +776,25 @@  discard block
 block discarded – undo
776 776
 
777 777
 			$field = RGFormsModel::get_field( $form, $field_id );
778 778
 
779
-			if( ! $field ) {
779
+			if ( ! $field ) {
780 780
 				continue;
781 781
 			}
782 782
 
783
-			if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
783
+			if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
784 784
 
785 785
 				// Get the value of the field, including $_POSTed value
786 786
 				$value = RGFormsModel::get_field_value( $field );
787 787
 
788 788
 				// Use temporary entry variable, to make values available to fill_post_template() and update_post_image()
789 789
 				$entry_tmp = $this->entry;
790
-				$entry_tmp["{$field_id}"] = $value;
790
+				$entry_tmp[ "{$field_id}" ] = $value;
791 791
 
792
-				switch( $field->type ) {
792
+				switch ( $field->type ) {
793 793
 
794 794
 				    case 'post_title':
795 795
 				        $post_title = $value;
796 796
 				        if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
797
-				            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
797
+				            $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp );
798 798
 				        }
799 799
 				        $updated_post->post_title = $post_title;
800 800
 				        $updated_post->post_name  = $post_title;
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 				    case 'post_content':
805 805
 				        $post_content = $value;
806 806
 				        if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
807
-				            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
807
+				            $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true );
808 808
 				        }
809 809
 				        $updated_post->post_content = $post_content;
810 810
 				        unset( $post_content );
@@ -822,11 +822,11 @@  discard block
 block discarded – undo
822 822
 							$value = $value[ $field_id ];
823 823
 						}
824 824
 
825
-				        if( ! empty( $field->customFieldTemplateEnabled ) ) {
825
+				        if ( ! empty( $field->customFieldTemplateEnabled ) ) {
826 826
 				            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
827 827
 				        }
828 828
 
829
-						$value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry );
829
+						$value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry );
830 830
 
831 831
 				        update_post_meta( $post_id, $field->postCustomFieldName, $value );
832 832
 				        break;
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 				}
839 839
 
840 840
 				// update entry after
841
-				$this->entry["{$field_id}"] = $value;
841
+				$this->entry[ "{$field_id}" ] = $value;
842 842
 
843 843
 				$update_entry = true;
844 844
 
@@ -847,11 +847,11 @@  discard block
 block discarded – undo
847 847
 
848 848
 		}
849 849
 
850
-		if( $update_entry ) {
850
+		if ( $update_entry ) {
851 851
 
852 852
 			$return_entry = GFAPI::update_entry( $this->entry );
853 853
 
854
-			if( is_wp_error( $return_entry ) ) {
854
+			if ( is_wp_error( $return_entry ) ) {
855 855
 				gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) );
856 856
 			} else {
857 857
 				gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) );
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 
862 862
 		$return_post = wp_update_post( $updated_post, true );
863 863
 
864
-		if( is_wp_error( $return_post ) ) {
864
+		if ( is_wp_error( $return_post ) ) {
865 865
 			$return_post->add_data( $updated_post, '$updated_post' );
866 866
 			gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) );
867 867
 		} else {
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 		$output = GFCommon::replace_variables( $output, $form, $entry, false, false, false );
896 896
 
897 897
 		// replace conditional shortcodes
898
-		if( $do_shortcode ) {
898
+		if ( $do_shortcode ) {
899 899
 			$output = do_shortcode( $output );
900 900
 		}
901 901
 
@@ -914,19 +914,19 @@  discard block
 block discarded – undo
914 914
 	 */
915 915
 	private function after_update() {
916 916
 
917
-		do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry );
918
-		do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry );
917
+		do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry );
918
+		do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry );
919 919
 
920 920
 		// Re-define the entry now that we've updated it.
921
-		$entry = RGFormsModel::get_lead( $this->entry['id'] );
921
+		$entry = RGFormsModel::get_lead( $this->entry[ 'id' ] );
922 922
 
923 923
 		$entry = GFFormsModel::set_entry_meta( $entry, self::$original_form );
924 924
 
925 925
 		if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) {
926 926
 			// We need to clear the cache because Gravity Forms caches the field values, which
927 927
 			// we have just updated.
928
-			foreach ($this->form['fields'] as $key => $field) {
929
-				GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );
928
+			foreach ( $this->form[ 'fields' ] as $key => $field ) {
929
+				GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id );
930 930
 			}
931 931
 		}
932 932
 
@@ -936,11 +936,11 @@  discard block
 block discarded – undo
936 936
 		 * @since develop
937 937
 		 */
938 938
 		if ( $allowed_feeds = $this->view->settings->get( 'edit_feeds', array() ) ) {
939
-			$feeds = GFAPI::get_feeds( null, $entry['form_id'] );
939
+			$feeds = GFAPI::get_feeds( null, $entry[ 'form_id' ] );
940 940
 			if ( ! is_wp_error( $feeds ) ) {
941 941
 				$registered_feeds = array();
942 942
 				foreach ( GFAddOn::get_registered_addons() as $registered_feed ) {
943
-					if ( is_subclass_of( $registered_feed,  'GFFeedAddOn' ) ) {
943
+					if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) {
944 944
 						if ( method_exists( $registered_feed, 'get_instance' ) ) {
945 945
 							$registered_feed = call_user_func( array( $registered_feed, 'get_instance' ) );
946 946
 							$registered_feeds[ $registered_feed->get_slug() ] = $registered_feed;
@@ -948,8 +948,8 @@  discard block
 block discarded – undo
948 948
 					}
949 949
 				}
950 950
 				foreach ( $feeds as $feed ) {
951
-					if ( in_array( $feed['id'], $allowed_feeds ) ) {
952
-						if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed['addon_slug'] ) ) {
951
+					if ( in_array( $feed[ 'id' ], $allowed_feeds ) ) {
952
+						if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed[ 'addon_slug' ] ) ) {
953 953
 							$returned_entry = $feed_object->process_feed( $feed, $entry, self::$original_form );
954 954
 							if ( is_array( $returned_entry ) && rgar( $returned_entry, 'id' ) ) {
955 955
 								$entry = $returned_entry;
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 
980 980
 		<div class="gv-edit-entry-wrapper"><?php
981 981
 
982
-			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );
982
+			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this );
983 983
 
984 984
 			/**
985 985
 			 * Fixes weird wpautop() issue
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 				     * @param string $edit_entry_title Modify the "Edit Entry" title
996 996
 				     * @param GravityView_Edit_Entry_Render $this This object
997 997
 				     */
998
-				    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
998
+				    $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this );
999 999
 
1000 1000
 				    echo esc_attr( $edit_entry_title );
1001 1001
 			?></span>
@@ -1045,13 +1045,13 @@  discard block
 block discarded – undo
1045 1045
 
1046 1046
 			$back_link = remove_query_arg( array( 'page', 'view', 'edit' ) );
1047 1047
 
1048
-			if( ! $this->is_valid ){
1048
+			if ( ! $this->is_valid ) {
1049 1049
 
1050 1050
 				// Keeping this compatible with Gravity Forms.
1051
-				$validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
1052
-				$message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form);
1051
+				$validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>";
1052
+				$message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form );
1053 1053
 
1054
-				echo GVCommon::generate_notice( $message , 'gv-error' );
1054
+				echo GVCommon::generate_notice( $message, 'gv-error' );
1055 1055
 
1056 1056
 			} else {
1057 1057
 				$view = \GV\View::by_id( $this->view_id );
@@ -1062,23 +1062,23 @@  discard block
 block discarded – undo
1062 1062
 
1063 1063
                     case '0':
1064 1064
 	                    $redirect_url = $back_link;
1065
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
1065
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' );
1066 1066
                         break;
1067 1067
 
1068 1068
                     case '1':
1069 1069
 	                    $redirect_url = $directory_link = GravityView_API::directory_link();
1070
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
1070
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
1071 1071
 	                    break;
1072 1072
 
1073 1073
                     case '2':
1074 1074
 	                    $redirect_url = $edit_redirect_url;
1075 1075
 	                    $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
1076
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
1076
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
1077 1077
                         break;
1078 1078
 
1079 1079
                     case '':
1080 1080
                     default:
1081
-					    $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
1081
+					    $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' );
1082 1082
                         break;
1083 1083
 				}
1084 1084
 
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
 				 * @param array $entry Gravity Forms entry array
1095 1095
 				 * @param string $back_link URL to return to the original entry. @since 1.6
1096 1096
 				 */
1097
-				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );
1097
+				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link );
1098 1098
 
1099 1099
 				echo GVCommon::generate_notice( $message );
1100 1100
 			}
@@ -1118,8 +1118,8 @@  discard block
 block discarded – undo
1118 1118
 		 */
1119 1119
 		do_action( 'gravityview/edit-entry/render/before', $this );
1120 1120
 
1121
-		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );
1122
-		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );
1121
+		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 );
1122
+		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
1123 1123
 		add_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) );
1124 1124
 		add_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) );
1125 1125
 		add_filter( 'gform_disable_view_counter', '__return_true' );
@@ -1128,14 +1128,14 @@  discard block
 block discarded – undo
1128 1128
 		add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );
1129 1129
 
1130 1130
 		// We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.
1131
-		unset( $_GET['page'] );
1131
+		unset( $_GET[ 'page' ] );
1132 1132
 
1133 1133
 		$this->show_next_button = false;
1134 1134
 		$this->show_previous_button = false;
1135 1135
 
1136 1136
 		// TODO: Verify multiple-page forms
1137 1137
 		if ( GFCommon::has_pages( $this->form ) && apply_filters( 'gravityview/features/paged-edit', false ) ) {
1138
-			if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form['id'], 0 ) ) ) {
1138
+			if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form[ 'id' ], 0 ) ) ) {
1139 1139
 
1140 1140
 				$labels = array(
1141 1141
 					'cancel'   => __( 'Cancel', 'gravityview' ),
@@ -1154,16 +1154,16 @@  discard block
 block discarded – undo
1154 1154
 				*/
1155 1155
 				$labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id );
1156 1156
 
1157
-				GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form;
1158
-				GFFormDisplay::$submission[ $this->form['id'] ][ 'is_valid' ] = true;
1157
+				GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'form' ] = $this->form;
1158
+				GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'is_valid' ] = true;
1159 1159
 
1160
-				if ( \GV\Utils::_POST( 'save' ) === $labels['next'] ) {
1160
+				if ( \GV\Utils::_POST( 'save' ) === $labels[ 'next' ] ) {
1161 1161
 					$page_number++;
1162
-				} elseif ( \GV\Utils::_POST( 'save' ) === $labels['previous'] ) {
1162
+				} elseif ( \GV\Utils::_POST( 'save' ) === $labels[ 'previous' ] ) {
1163 1163
 					$page_number--;
1164 1164
 				}
1165 1165
 
1166
-				GFFormDisplay::$submission[ $this->form['id'] ][ 'page_number' ] = $page_number;
1166
+				GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'page_number' ] = $page_number;
1167 1167
 			}
1168 1168
 
1169 1169
 			if ( ( $page_number = intval( $page_number ) ) < 2 ) {
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
 
1190 1190
 		ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic
1191 1191
 
1192
-		$html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );
1192
+		$html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry );
1193 1193
 
1194 1194
 		ob_get_clean();
1195 1195
 
@@ -1217,7 +1217,7 @@  discard block
 block discarded – undo
1217 1217
 	 * @return string
1218 1218
 	 */
1219 1219
 	public function render_form_buttons() {
1220
-		return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );
1220
+		return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this );
1221 1221
 	}
1222 1222
 
1223 1223
 
@@ -1237,10 +1237,10 @@  discard block
 block discarded – undo
1237 1237
 	public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) {
1238 1238
 
1239 1239
 		// In case we have validated the form, use it to inject the validation results into the form render
1240
-		if( isset( $this->form_after_validation ) && $this->form_after_validation['id'] === $form['id'] ) {
1240
+		if ( isset( $this->form_after_validation ) && $this->form_after_validation[ 'id' ] === $form[ 'id' ] ) {
1241 1241
 			$form = $this->form_after_validation;
1242 1242
 		} else {
1243
-			$form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );
1243
+			$form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id );
1244 1244
 		}
1245 1245
 
1246 1246
 		$form = $this->filter_conditional_logic( $form );
@@ -1248,8 +1248,8 @@  discard block
 block discarded – undo
1248 1248
 		$form = $this->prefill_conditional_logic( $form );
1249 1249
 
1250 1250
 		// for now we don't support Save and Continue feature.
1251
-		if( ! self::$supports_save_and_continue ) {
1252
-	        unset( $form['save'] );
1251
+		if ( ! self::$supports_save_and_continue ) {
1252
+	        unset( $form[ 'save' ] );
1253 1253
 		}
1254 1254
 
1255 1255
 		$form = $this->unselect_default_values( $form );
@@ -1272,31 +1272,31 @@  discard block
 block discarded – undo
1272 1272
 	 */
1273 1273
 	public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) {
1274 1274
 
1275
-		if( ! GFCommon::is_post_field( $field ) ) {
1275
+		if ( ! GFCommon::is_post_field( $field ) ) {
1276 1276
 			return $field_content;
1277 1277
 		}
1278 1278
 
1279 1279
         $message = null;
1280 1280
 
1281 1281
         // First, make sure they have the capability to edit the post.
1282
-        if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1282
+        if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) {
1283 1283
 
1284 1284
             /**
1285 1285
              * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1286 1286
              * @param string $message The existing "You don't have permission..." text
1287 1287
              */
1288
-            $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1288
+            $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don&rsquo;t have permission to edit this post.', 'gravityview' ) );
1289 1289
 
1290
-        } elseif( null === get_post( $this->entry['post_id'] ) ) {
1290
+        } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) {
1291 1291
             /**
1292 1292
              * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1293 1293
              * @param string $message The existing "This field is not editable; the post no longer exists." text
1294 1294
              */
1295
-            $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1295
+            $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) );
1296 1296
         }
1297 1297
 
1298
-        if( $message ) {
1299
-            $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1298
+        if ( $message ) {
1299
+            $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1300 1300
         }
1301 1301
 
1302 1302
         return $field_content;
@@ -1320,8 +1320,8 @@  discard block
 block discarded – undo
1320 1320
 
1321 1321
 		// If the form has been submitted, then we don't need to pre-fill the values,
1322 1322
 		// Except for fileupload type and when a field input is overridden- run always!!
1323
-		if(
1324
-			( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1323
+		if (
1324
+			( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1325 1325
 			&& false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) )
1326 1326
 			&& ! GFCommon::is_product_field( $field->type )
1327 1327
 			|| ! empty( $field_content )
@@ -1341,7 +1341,7 @@  discard block
 block discarded – undo
1341 1341
 	    $return = null;
1342 1342
 
1343 1343
 		/** @var GravityView_Field $gv_field */
1344
-		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1344
+		if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1345 1345
 			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1346 1346
 		} else {
1347 1347
 	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
@@ -1350,7 +1350,7 @@  discard block
 block discarded – undo
1350 1350
 	    // If there was output, it's an error
1351 1351
 	    $warnings = ob_get_clean();
1352 1352
 
1353
-	    if( !empty( $warnings ) ) {
1353
+	    if ( ! empty( $warnings ) ) {
1354 1354
 		    gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1355 1355
 	    }
1356 1356
 
@@ -1375,7 +1375,7 @@  discard block
 block discarded – undo
1375 1375
 		$override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );
1376 1376
 
1377 1377
 		// We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)
1378
-		if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) {
1378
+		if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) {
1379 1379
 
1380 1380
 			$field_value = array();
1381 1381
 
@@ -1384,10 +1384,10 @@  discard block
 block discarded – undo
1384 1384
 
1385 1385
 			foreach ( (array)$field->inputs as $input ) {
1386 1386
 
1387
-				$input_id = strval( $input['id'] );
1387
+				$input_id = strval( $input[ 'id' ] );
1388 1388
 
1389 1389
 				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1390
-				    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1390
+				    $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1391 1391
 				    $allow_pre_populated = false;
1392 1392
 				}
1393 1393
 
@@ -1395,7 +1395,7 @@  discard block
 block discarded – undo
1395 1395
 
1396 1396
 			$pre_value = $field->get_value_submission( array(), false );
1397 1397
 
1398
-			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1398
+			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1399 1399
 
1400 1400
 		} else {
1401 1401
 
@@ -1406,13 +1406,13 @@  discard block
 block discarded – undo
1406 1406
 
1407 1407
 			// saved field entry value (if empty, fallback to the pre-populated value, if exists)
1408 1408
 			// or pre-populated value if not empty and set to override saved value
1409
-			$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;
1409
+			$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;
1410 1410
 
1411 1411
 			// in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.
1412
-			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1412
+			if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) {
1413 1413
 				$categories = array();
1414 1414
 				foreach ( explode( ',', $field_value ) as $cat_string ) {
1415
-				    $categories[] = GFCommon::format_post_category( $cat_string, true );
1415
+				    $categories[ ] = GFCommon::format_post_category( $cat_string, true );
1416 1416
 				}
1417 1417
 				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1418 1418
 			}
@@ -1440,7 +1440,7 @@  discard block
 block discarded – undo
1440 1440
 	     * @param GF_Field $field Gravity Forms field object
1441 1441
 	     * @param GravityView_Edit_Entry_Render $this Current object
1442 1442
 	     */
1443
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1443
+	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this );
1444 1444
 
1445 1445
 		return $field_value;
1446 1446
 	}
@@ -1457,12 +1457,12 @@  discard block
 block discarded – undo
1457 1457
 	 */
1458 1458
 	public function gform_pre_validation( $form ) {
1459 1459
 
1460
-		if( ! $this->verify_nonce() ) {
1460
+		if ( ! $this->verify_nonce() ) {
1461 1461
 			return $form;
1462 1462
 		}
1463 1463
 
1464 1464
 		// Fix PHP warning regarding undefined index.
1465
-		foreach ( $form['fields'] as &$field) {
1465
+		foreach ( $form[ 'fields' ] as &$field ) {
1466 1466
 
1467 1467
 			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1468 1468
 			// expects certain field array items to be set.
@@ -1470,7 +1470,7 @@  discard block
 block discarded – undo
1470 1470
 	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1471 1471
 			}
1472 1472
 
1473
-			switch( RGFormsModel::get_input_type( $field ) ) {
1473
+			switch ( RGFormsModel::get_input_type( $field ) ) {
1474 1474
 
1475 1475
 				/**
1476 1476
 				 * 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.
@@ -1484,26 +1484,26 @@  discard block
 block discarded – undo
1484 1484
 				    // Set the previous value
1485 1485
 				    $entry = $this->get_entry();
1486 1486
 
1487
-				    $input_name = 'input_'.$field->id;
1488
-				    $form_id = $form['id'];
1487
+				    $input_name = 'input_' . $field->id;
1488
+				    $form_id = $form[ 'id' ];
1489 1489
 
1490 1490
 				    $value = NULL;
1491 1491
 
1492 1492
 				    // Use the previous entry value as the default.
1493
-				    if( isset( $entry[ $field->id ] ) ) {
1493
+				    if ( isset( $entry[ $field->id ] ) ) {
1494 1494
 				        $value = $entry[ $field->id ];
1495 1495
 				    }
1496 1496
 
1497 1497
 				    // If this is a single upload file
1498
-				    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1499
-				        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1500
-				        $value = $file_path['url'];
1498
+				    if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
1499
+				        $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] );
1500
+				        $value = $file_path[ 'url' ];
1501 1501
 
1502 1502
 				    } else {
1503 1503
 
1504 1504
 				        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1505 1505
 				        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1506
-				        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1506
+				        $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' );
1507 1507
 
1508 1508
 				    }
1509 1509
 
@@ -1511,10 +1511,10 @@  discard block
 block discarded – undo
1511 1511
 
1512 1512
 				        // If there are fresh uploads, process and merge them.
1513 1513
 				        // Otherwise, use the passed values, which should be json-encoded array of URLs
1514
-				        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1514
+				        if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) {
1515 1515
 				            $value = empty( $value ) ? '[]' : $value;
1516 1516
 				            $value = stripslashes_deep( $value );
1517
-				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1517
+				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() );
1518 1518
 				        }
1519 1519
 
1520 1520
 				    } else {
@@ -1532,8 +1532,8 @@  discard block
 block discarded – undo
1532 1532
 
1533 1533
 				case 'number':
1534 1534
 				    // Fix "undefined index" issue at line 1286 in form_display.php
1535
-				    if( !isset( $_POST['input_'.$field->id ] ) ) {
1536
-				        $_POST['input_'.$field->id ] = NULL;
1535
+				    if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) {
1536
+				        $_POST[ 'input_' . $field->id ] = NULL;
1537 1537
 				    }
1538 1538
 				    break;
1539 1539
 			}
@@ -1570,7 +1570,7 @@  discard block
 block discarded – undo
1570 1570
 		 * You can enter whatever you want!
1571 1571
 		 * We try validating, and customize the results using `self::custom_validation()`
1572 1572
 		 */
1573
-		add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);
1573
+		add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 );
1574 1574
 
1575 1575
 		// Needed by the validate funtion
1576 1576
 		$failed_validation_page = NULL;
@@ -1578,14 +1578,14 @@  discard block
 block discarded – undo
1578 1578
 
1579 1579
 		// Prevent entry limit from running when editing an entry, also
1580 1580
 		// prevent form scheduling from preventing editing
1581
-		unset( $this->form['limitEntries'], $this->form['scheduleForm'] );
1581
+		unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] );
1582 1582
 
1583 1583
 		// Hide fields depending on Edit Entry settings
1584
-		$this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1584
+		$this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1585 1585
 
1586 1586
 		$this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );
1587 1587
 
1588
-		remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 );
1588
+		remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 );
1589 1589
 	}
1590 1590
 
1591 1591
 
@@ -1608,7 +1608,7 @@  discard block
 block discarded – undo
1608 1608
 
1609 1609
 		$gv_valid = true;
1610 1610
 
1611
-		foreach ( $validation_results['form']['fields'] as $key => &$field ) {
1611
+		foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) {
1612 1612
 
1613 1613
 			$value = RGFormsModel::get_field_value( $field );
1614 1614
 			$field_type = RGFormsModel::get_input_type( $field );
@@ -1621,22 +1621,22 @@  discard block
 block discarded – undo
1621 1621
 				case 'post_image':
1622 1622
 
1623 1623
 				    // in case nothing is uploaded but there are already files saved
1624
-				    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1624
+				    if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) {
1625 1625
 				        $field->failed_validation = false;
1626 1626
 				        unset( $field->validation_message );
1627 1627
 				    }
1628 1628
 
1629 1629
 				    // validate if multi file upload reached max number of files [maxFiles] => 2
1630
-				    if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1630
+				    if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) {
1631 1631
 
1632 1632
 				        $input_name = 'input_' . $field->id;
1633 1633
 				        //uploaded
1634
-				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1634
+				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array();
1635 1635
 
1636 1636
 				        //existent
1637 1637
 				        $entry = $this->get_entry();
1638 1638
 				        $value = NULL;
1639
-				        if( isset( $entry[ $field->id ] ) ) {
1639
+				        if ( isset( $entry[ $field->id ] ) ) {
1640 1640
 				            $value = json_decode( $entry[ $field->id ], true );
1641 1641
 				        }
1642 1642
 
@@ -1644,13 +1644,13 @@  discard block
 block discarded – undo
1644 1644
 				        $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) +
1645 1645
 						               ( is_array( $value ) ? count( $value ) : 0 );
1646 1646
 
1647
-				        if( $count_files > $field->maxFiles ) {
1647
+				        if ( $count_files > $field->maxFiles ) {
1648 1648
 				            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1649 1649
 				            $field->failed_validation = 1;
1650 1650
 				            $gv_valid = false;
1651 1651
 
1652 1652
 				            // in case of error make sure the newest upload files are removed from the upload input
1653
-				            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1653
+				            GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null;
1654 1654
 				        }
1655 1655
 
1656 1656
 				    }
@@ -1661,7 +1661,7 @@  discard block
 block discarded – undo
1661 1661
 			}
1662 1662
 
1663 1663
 			// This field has failed validation.
1664
-			if( !empty( $field->failed_validation ) ) {
1664
+			if ( ! empty( $field->failed_validation ) ) {
1665 1665
 
1666 1666
 				gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) );
1667 1667
 
@@ -1679,19 +1679,19 @@  discard block
 block discarded – undo
1679 1679
 				}
1680 1680
 
1681 1681
 				// You can't continue inside a switch, so we do it after.
1682
-				if( empty( $field->failed_validation ) ) {
1682
+				if ( empty( $field->failed_validation ) ) {
1683 1683
 				    continue;
1684 1684
 				}
1685 1685
 
1686 1686
 				// checks if the No Duplicates option is not validating entry against itself, since
1687 1687
 				// we're editing a stored entry, it would also assume it's a duplicate.
1688
-				if( !empty( $field->noDuplicates ) ) {
1688
+				if ( ! empty( $field->noDuplicates ) ) {
1689 1689
 
1690 1690
 				    $entry = $this->get_entry();
1691 1691
 
1692 1692
 				    // If the value of the entry is the same as the stored value
1693 1693
 				    // Then we can assume it's not a duplicate, it's the same.
1694
-				    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1694
+				    if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) {
1695 1695
 				        //if value submitted was not changed, then don't validate
1696 1696
 				        $field->failed_validation = false;
1697 1697
 
@@ -1704,7 +1704,7 @@  discard block
 block discarded – undo
1704 1704
 				}
1705 1705
 
1706 1706
 				// if here then probably we are facing the validation 'At least one field must be filled out'
1707
-				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1707
+				if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) {
1708 1708
 				    unset( $field->validation_message );
1709 1709
 	                $field->validation_message = false;
1710 1710
 				    continue;
@@ -1716,12 +1716,12 @@  discard block
 block discarded – undo
1716 1716
 
1717 1717
 		}
1718 1718
 
1719
-		$validation_results['is_valid'] = $gv_valid;
1719
+		$validation_results[ 'is_valid' ] = $gv_valid;
1720 1720
 
1721 1721
 		gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) );
1722 1722
 
1723 1723
 		// We'll need this result when rendering the form ( on GFFormDisplay::get_form )
1724
-		$this->form_after_validation = $validation_results['form'];
1724
+		$this->form_after_validation = $validation_results[ 'form' ];
1725 1725
 
1726 1726
 		return $validation_results;
1727 1727
 	}
@@ -1734,7 +1734,7 @@  discard block
 block discarded – undo
1734 1734
 	 */
1735 1735
 	public function get_entry() {
1736 1736
 
1737
-		if( empty( $this->entry ) ) {
1737
+		if ( empty( $this->entry ) ) {
1738 1738
 			// Get the database value of the entry that's being edited
1739 1739
 			$this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );
1740 1740
 		}
@@ -1766,10 +1766,10 @@  discard block
 block discarded – undo
1766 1766
 		}
1767 1767
 
1768 1768
 		// If edit tab not yet configured, show all fields
1769
-		$edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;
1769
+		$edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL;
1770 1770
 
1771 1771
 		// Hide fields depending on admin settings
1772
-		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1772
+		$fields = $this->filter_fields( $form[ 'fields' ], $edit_fields );
1773 1773
 
1774 1774
 	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1775 1775
 	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
@@ -1802,7 +1802,7 @@  discard block
 block discarded – undo
1802 1802
 	 */
1803 1803
 	private function filter_fields( $fields, $configured_fields ) {
1804 1804
 
1805
-		if( empty( $fields ) || !is_array( $fields ) ) {
1805
+		if ( empty( $fields ) || ! is_array( $fields ) ) {
1806 1806
 			return $fields;
1807 1807
 		}
1808 1808
 
@@ -1819,12 +1819,12 @@  discard block
 block discarded – undo
1819 1819
 
1820 1820
 			// Remove the fields that have calculation properties and keep them to be used later
1821 1821
 			// @since 1.16.2
1822
-			if( $field->has_calculation() ) {
1823
-				$this->fields_with_calculation[] = $field;
1822
+			if ( $field->has_calculation() ) {
1823
+				$this->fields_with_calculation[ ] = $field;
1824 1824
 				// don't remove the calculation fields on form render.
1825 1825
 			}
1826 1826
 
1827
-			if( in_array( $field->type, $field_type_blacklist ) ) {
1827
+			if ( in_array( $field->type, $field_type_blacklist ) ) {
1828 1828
 				unset( $fields[ $key ] );
1829 1829
 			}
1830 1830
 		}
@@ -1842,7 +1842,7 @@  discard block
 block discarded – undo
1842 1842
 					continue; // Same
1843 1843
 				}
1844 1844
 
1845
-				$out_fields[] = $field;
1845
+				$out_fields[ ] = $field;
1846 1846
 			}
1847 1847
 
1848 1848
 			return array_values( $out_fields );
@@ -1853,8 +1853,8 @@  discard block
 block discarded – undo
1853 1853
 
1854 1854
 	        /** @var GF_Field $field */
1855 1855
 	        foreach ( $fields as $field ) {
1856
-				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1857
-				    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1856
+				if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1857
+				    $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field );
1858 1858
 				    break;
1859 1859
 				}
1860 1860
 
@@ -1877,14 +1877,14 @@  discard block
 block discarded – undo
1877 1877
 
1878 1878
 		$return_field = $field;
1879 1879
 
1880
-		if( empty( $field_setting['show_label'] ) ) {
1880
+		if ( empty( $field_setting[ 'show_label' ] ) ) {
1881 1881
 			$return_field->label = '';
1882
-		} elseif ( !empty( $field_setting['custom_label'] ) ) {
1883
-			$return_field->label = $field_setting['custom_label'];
1882
+		} elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) {
1883
+			$return_field->label = $field_setting[ 'custom_label' ];
1884 1884
 		}
1885 1885
 
1886
-		if( !empty( $field_setting['custom_class'] ) ) {
1887
-			$return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );
1886
+		if ( ! empty( $field_setting[ 'custom_class' ] ) ) {
1887
+			$return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] );
1888 1888
 		}
1889 1889
 
1890 1890
 		/**
@@ -1922,16 +1922,16 @@  discard block
 block discarded – undo
1922 1922
 	     */
1923 1923
 	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1924 1924
 
1925
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1926
-			foreach( $fields as $k => $field ) {
1927
-				if( $field->adminOnly ) {
1925
+	    if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) {
1926
+			foreach ( $fields as $k => $field ) {
1927
+				if ( $field->adminOnly ) {
1928 1928
 				    unset( $fields[ $k ] );
1929 1929
 				}
1930 1930
 			}
1931 1931
 			return array_values( $fields );
1932 1932
 		}
1933 1933
 
1934
-	    foreach( $fields as &$field ) {
1934
+	    foreach ( $fields as &$field ) {
1935 1935
 		    $field->adminOnly = false;
1936 1936
 		}
1937 1937
 
@@ -1952,7 +1952,7 @@  discard block
 block discarded – undo
1952 1952
 	 */
1953 1953
 	private function unselect_default_values( $form ) {
1954 1954
 
1955
-	    foreach ( $form['fields'] as &$field ) {
1955
+	    foreach ( $form[ 'fields' ] as &$field ) {
1956 1956
 
1957 1957
 			if ( empty( $field->choices ) ) {
1958 1958
                 continue;
@@ -1960,7 +1960,7 @@  discard block
 block discarded – undo
1960 1960
 
1961 1961
             foreach ( $field->choices as &$choice ) {
1962 1962
 				if ( \GV\Utils::get( $choice, 'isSelected' ) ) {
1963
-					$choice['isSelected'] = false;
1963
+					$choice[ 'isSelected' ] = false;
1964 1964
 				}
1965 1965
 			}
1966 1966
 		}
@@ -1985,22 +1985,22 @@  discard block
 block discarded – undo
1985 1985
 	 */
1986 1986
 	function prefill_conditional_logic( $form ) {
1987 1987
 
1988
-		if( ! GFFormDisplay::has_conditional_logic( $form ) ) {
1988
+		if ( ! GFFormDisplay::has_conditional_logic( $form ) ) {
1989 1989
 			return $form;
1990 1990
 		}
1991 1991
 
1992 1992
 		// Have Conditional Logic pre-fill fields as if the data were default values
1993 1993
 		/** @var GF_Field $field */
1994
-		foreach ( $form['fields'] as &$field ) {
1994
+		foreach ( $form[ 'fields' ] as &$field ) {
1995 1995
 
1996
-			if( 'checkbox' === $field->type ) {
1996
+			if ( 'checkbox' === $field->type ) {
1997 1997
 				foreach ( $field->get_entry_inputs() as $key => $input ) {
1998
-				    $input_id = $input['id'];
1998
+				    $input_id = $input[ 'id' ];
1999 1999
 				    $choice = $field->choices[ $key ];
2000 2000
 				    $value = \GV\Utils::get( $this->entry, $input_id );
2001 2001
 				    $match = RGFormsModel::choice_value_match( $field, $choice, $value );
2002
-				    if( $match ) {
2003
-				        $field->choices[ $key ]['isSelected'] = true;
2002
+				    if ( $match ) {
2003
+				        $field->choices[ $key ][ 'isSelected' ] = true;
2004 2004
 				    }
2005 2005
 				}
2006 2006
 			} else {
@@ -2008,15 +2008,15 @@  discard block
 block discarded – undo
2008 2008
 				// We need to run through each field to set the default values
2009 2009
 				foreach ( $this->entry as $field_id => $field_value ) {
2010 2010
 
2011
-				    if( floatval( $field_id ) === floatval( $field->id ) ) {
2011
+				    if ( floatval( $field_id ) === floatval( $field->id ) ) {
2012 2012
 
2013
-				        if( 'list' === $field->type ) {
2013
+				        if ( 'list' === $field->type ) {
2014 2014
 				            $list_rows = maybe_unserialize( $field_value );
2015 2015
 
2016 2016
 				            $list_field_value = array();
2017
-				            foreach ( (array) $list_rows as $row ) {
2018
-				                foreach ( (array) $row as $column ) {
2019
-				                    $list_field_value[] = $column;
2017
+				            foreach ( (array)$list_rows as $row ) {
2018
+				                foreach ( (array)$row as $column ) {
2019
+				                    $list_field_value[ ] = $column;
2020 2020
 				                }
2021 2021
 				            }
2022 2022
 
@@ -2049,32 +2049,32 @@  discard block
 block discarded – undo
2049 2049
 		 * @see https://github.com/gravityview/GravityView/issues/840
2050 2050
 		 * @since develop
2051 2051
 		 */
2052
-		$the_form = GFAPI::get_form( $form['id'] );
2052
+		$the_form = GFAPI::get_form( $form[ 'id' ] );
2053 2053
 		$editable_ids = array();
2054
-		foreach ( $form['fields'] as $field ) {
2055
-			$editable_ids[] = $field['id']; // wp_list_pluck is destructive in this context
2054
+		foreach ( $form[ 'fields' ] as $field ) {
2055
+			$editable_ids[ ] = $field[ 'id' ]; // wp_list_pluck is destructive in this context
2056 2056
 		}
2057 2057
 		$remove_conditions_rule = array();
2058
-		foreach ( $the_form['fields'] as $field ) {
2059
-			if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic['rules'] ) ) {
2060
-				foreach ( $field->conditionalLogic['rules'] as $i => $rule ) {
2061
-					if ( ! in_array( $rule['fieldId'], $editable_ids ) ) {
2058
+		foreach ( $the_form[ 'fields' ] as $field ) {
2059
+			if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic[ 'rules' ] ) ) {
2060
+				foreach ( $field->conditionalLogic[ 'rules' ] as $i => $rule ) {
2061
+					if ( ! in_array( $rule[ 'fieldId' ], $editable_ids ) ) {
2062 2062
 						/**
2063 2063
 						 * This conditional field is not editable in this View.
2064 2064
 						 * We need to remove the rule, but only if it matches.
2065 2065
 						 */
2066
-						if ( $_field = GFAPI::get_field( $the_form, $rule['fieldId'] ) ) {
2066
+						if ( $_field = GFAPI::get_field( $the_form, $rule[ 'fieldId' ] ) ) {
2067 2067
 							$value = $_field->get_value_export( $this->entry );
2068
-						} elseif ( isset( $this->entry[ $rule['fieldId'] ] ) ) {
2069
-							$value = $this->entry[ $rule['fieldId'] ];
2068
+						} elseif ( isset( $this->entry[ $rule[ 'fieldId' ] ] ) ) {
2069
+							$value = $this->entry[ $rule[ 'fieldId' ] ];
2070 2070
 						} else {
2071
-							$value = gform_get_meta( $this->entry['id'], $rule['fieldId'] );
2071
+							$value = gform_get_meta( $this->entry[ 'id' ], $rule[ 'fieldId' ] );
2072 2072
 						}
2073 2073
 
2074
-						$match = GFFormsModel::matches_operation( $value, $rule['value'], $rule['operator'] );
2074
+						$match = GFFormsModel::matches_operation( $value, $rule[ 'value' ], $rule[ 'operator' ] );
2075 2075
 						
2076 2076
 						if ( $match ) {
2077
-							$remove_conditions_rule[] = array( $field['id'], $i );
2077
+							$remove_conditions_rule[ ] = array( $field[ 'id' ], $i );
2078 2078
 						}
2079 2079
 					}
2080 2080
 				}
@@ -2082,21 +2082,21 @@  discard block
 block discarded – undo
2082 2082
 		}
2083 2083
 
2084 2084
 		if ( $remove_conditions_rule ) {
2085
-			foreach ( $form['fields'] as &$field ) {
2085
+			foreach ( $form[ 'fields' ] as &$field ) {
2086 2086
 				foreach ( $remove_conditions_rule as $_remove_conditions_r ) {
2087 2087
 
2088 2088
 				    list( $rule_field_id, $rule_i ) = $_remove_conditions_r;
2089 2089
 
2090
-					if ( $field['id'] == $rule_field_id ) {
2091
-						unset( $field->conditionalLogic['rules'][ $rule_i ] );
2092
-						gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field['id'] ) );
2090
+					if ( $field[ 'id' ] == $rule_field_id ) {
2091
+						unset( $field->conditionalLogic[ 'rules' ][ $rule_i ] );
2092
+						gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field[ 'id' ] ) );
2093 2093
 					}
2094 2094
 				}
2095 2095
 			}
2096 2096
 		}
2097 2097
 
2098 2098
 		/** Normalize the indices... */
2099
-		$form['fields'] = array_values( $form['fields'] );
2099
+		$form[ 'fields' ] = array_values( $form[ 'fields' ] );
2100 2100
 
2101 2101
 		/**
2102 2102
 		 * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields?
@@ -2106,16 +2106,16 @@  discard block
 block discarded – undo
2106 2106
 		 */
2107 2107
 		$use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );
2108 2108
 
2109
-		if( $use_conditional_logic ) {
2109
+		if ( $use_conditional_logic ) {
2110 2110
 			return $form;
2111 2111
 		}
2112 2112
 
2113
-		foreach( $form['fields'] as &$field ) {
2113
+		foreach ( $form[ 'fields' ] as &$field ) {
2114 2114
 			/* @var GF_Field $field */
2115 2115
 			$field->conditionalLogic = null;
2116 2116
 		}
2117 2117
 
2118
-		unset( $form['button']['conditionalLogic'] );
2118
+		unset( $form[ 'button' ][ 'conditionalLogic' ] );
2119 2119
 
2120 2120
 		return $form;
2121 2121
 
@@ -2132,7 +2132,7 @@  discard block
 block discarded – undo
2132 2132
 	 */
2133 2133
 	public function manage_conditional_logic( $has_conditional_logic, $form ) {
2134 2134
 
2135
-		if( ! $this->is_edit_entry() ) {
2135
+		if ( ! $this->is_edit_entry() ) {
2136 2136
 			return $has_conditional_logic;
2137 2137
 		}
2138 2138
 
@@ -2164,44 +2164,44 @@  discard block
 block discarded – undo
2164 2164
 		 *  2. There are two entries embedded using oEmbed
2165 2165
 		 *  3. One of the entries has just been saved
2166 2166
 		 */
2167
-		if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) {
2167
+		if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) {
2168 2168
 
2169 2169
 			$error = true;
2170 2170
 
2171 2171
 		}
2172 2172
 
2173
-		if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) {
2173
+		if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) {
2174 2174
 
2175 2175
 			$error = true;
2176 2176
 
2177
-		} elseif( ! $this->verify_nonce() ) {
2177
+		} elseif ( ! $this->verify_nonce() ) {
2178 2178
 
2179 2179
 			/**
2180 2180
 			 * If the Entry is embedded, there may be two entries on the same page.
2181 2181
 			 * If that's the case, and one is being edited, the other should fail gracefully and not display an error.
2182 2182
 			 */
2183
-			if( GravityView_oEmbed::getInstance()->get_entry_id() ) {
2183
+			if ( GravityView_oEmbed::getInstance()->get_entry_id() ) {
2184 2184
 				$error = true;
2185 2185
 			} else {
2186
-				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');
2186
+				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' );
2187 2187
 			}
2188 2188
 
2189 2189
 		}
2190 2190
 
2191
-		if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
2192
-			$error = __( 'You do not have permission to edit this entry.', 'gravityview');
2191
+		if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
2192
+			$error = __( 'You do not have permission to edit this entry.', 'gravityview' );
2193 2193
 		}
2194 2194
 
2195
-		if( $this->entry['status'] === 'trash' ) {
2196
-			$error = __('You cannot edit the entry; it is in the trash.', 'gravityview' );
2195
+		if ( $this->entry[ 'status' ] === 'trash' ) {
2196
+			$error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' );
2197 2197
 		}
2198 2198
 
2199 2199
 		// No errors; everything's fine here!
2200
-		if( empty( $error ) ) {
2200
+		if ( empty( $error ) ) {
2201 2201
 			return true;
2202 2202
 		}
2203 2203
 
2204
-		if( $echo && $error !== true ) {
2204
+		if ( $echo && $error !== true ) {
2205 2205
 
2206 2206
 	        $error = esc_html( $error );
2207 2207
 
@@ -2209,10 +2209,10 @@  discard block
 block discarded – undo
2209 2209
 	         * @since 1.9
2210 2210
 	         */
2211 2211
 	        if ( ! empty( $this->entry ) ) {
2212
-		        $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) );
2212
+		        $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) );
2213 2213
 	        }
2214 2214
 
2215
-			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
2215
+			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' );
2216 2216
 		}
2217 2217
 
2218 2218
 		gravityview()->log->error( '{error}', array( 'error' => $error ) );
@@ -2232,17 +2232,17 @@  discard block
 block discarded – undo
2232 2232
 
2233 2233
 		$error = NULL;
2234 2234
 
2235
-		if( ! $this->check_user_cap_edit_field( $field ) ) {
2236
-			$error = __( 'You do not have permission to edit this field.', 'gravityview');
2235
+		if ( ! $this->check_user_cap_edit_field( $field ) ) {
2236
+			$error = __( 'You do not have permission to edit this field.', 'gravityview' );
2237 2237
 		}
2238 2238
 
2239 2239
 		// No errors; everything's fine here!
2240
-		if( empty( $error ) ) {
2240
+		if ( empty( $error ) ) {
2241 2241
 			return true;
2242 2242
 		}
2243 2243
 
2244
-		if( $echo ) {
2245
-			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');
2244
+		if ( $echo ) {
2245
+			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' );
2246 2246
 		}
2247 2247
 
2248 2248
 		gravityview()->log->error( '{error}', array( 'error' => $error ) );
@@ -2263,14 +2263,14 @@  discard block
 block discarded – undo
2263 2263
 	private function check_user_cap_edit_field( $field ) {
2264 2264
 
2265 2265
 		// If they can edit any entries (as defined in Gravity Forms), we're good.
2266
-		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
2266
+		if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
2267 2267
 			return true;
2268 2268
 		}
2269 2269
 
2270
-		$field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;
2270
+		$field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false;
2271 2271
 
2272
-		if( $field_cap ) {
2273
-			return GVCommon::has_cap( $field['allow_edit_cap'] );
2272
+		if ( $field_cap ) {
2273
+			return GVCommon::has_cap( $field[ 'allow_edit_cap' ] );
2274 2274
 		}
2275 2275
 
2276 2276
 		return false;
@@ -2284,17 +2284,17 @@  discard block
 block discarded – undo
2284 2284
 	public function verify_nonce() {
2285 2285
 
2286 2286
 		// Verify form submitted for editing single
2287
-		if( $this->is_edit_entry_submission() ) {
2287
+		if ( $this->is_edit_entry_submission() ) {
2288 2288
 			$valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );
2289 2289
 		}
2290 2290
 
2291 2291
 		// Verify
2292
-		else if( ! $this->is_edit_entry() ) {
2292
+		else if ( ! $this->is_edit_entry() ) {
2293 2293
 			$valid = false;
2294 2294
 		}
2295 2295
 
2296 2296
 		else {
2297
-			$valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
2297
+			$valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key );
2298 2298
 		}
2299 2299
 
2300 2300
 		/**
Please login to merge, or discard this patch.