Completed
Push — develop ( 8cb174...3d2dcc )
by Gennady
18:21
created
includes/extensions/edit-entry/class-edit-entry-render.php 2 patches
Indentation   +303 added lines, -303 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
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 */
189 189
 	public function prevent_maybe_process_form() {
190 190
 
191
-	    if( ! $this->is_edit_entry_submission() ) {
191
+		if( ! $this->is_edit_entry_submission() ) {
192 192
 			return;
193 193
 		}
194 194
 
@@ -222,14 +222,14 @@  discard block
 block discarded – undo
222 222
 	 * When Edit entry view is requested setup the vars
223 223
 	 */
224 224
 	private function setup_vars() {
225
-        global $post;
225
+		global $post;
226 226
 
227 227
 		$gravityview_view = GravityView_View::getInstance();
228 228
 
229 229
 
230 230
 		$entries = $gravityview_view->getEntries();
231
-	    self::$original_entry = $entries[0];
232
-	    $this->entry = $entries[0];
231
+		self::$original_entry = $entries[0];
232
+		$this->entry = $entries[0];
233 233
 
234 234
 		self::$original_form = $gravityview_view->getForm();
235 235
 		$this->form = $gravityview_view->getForm();
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 
372 372
 			GFFormsModel::save_lead( $form, $this->entry );
373 373
 
374
-	        // Delete the values for hidden inputs
375
-	        $this->unset_hidden_field_values();
374
+			// Delete the values for hidden inputs
375
+			$this->unset_hidden_field_values();
376 376
 			
377 377
 			$this->entry['date_created'] = $date_created;
378 378
 
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 			// Perform actions normally performed after updating a lead
383 383
 			$this->after_update();
384 384
 
385
-	        /**
385
+			/**
386 386
 			 * Must be AFTER after_update()!
387 387
 			 * @see https://github.com/gravityview/GravityView/issues/764
388 388
 			 */
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 
391 391
 			/**
392 392
 			 * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry
393
-             * @since 2.1 Added $gv_data parameter
393
+			 * @since 2.1 Added $gv_data parameter
394 394
 			 * @param array $form Gravity Forms form array
395 395
 			 * @param string $entry_id Numeric ID of the entry that was updated
396 396
 			 * @param GravityView_Edit_Entry_Render $this This object
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 	 * @return void
415 415
 	 */
416 416
 	private function unset_hidden_field_values() {
417
-	    global $wpdb;
417
+		global $wpdb;
418 418
 
419 419
 		/**
420 420
 		 * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic
@@ -438,17 +438,17 @@  discard block
 block discarded – undo
438 438
 			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );
439 439
 		}
440 440
 
441
-	    foreach ( $this->entry as $input_id => $field_value ) {
441
+		foreach ( $this->entry as $input_id => $field_value ) {
442 442
 
443 443
 			if ( ! is_numeric( $input_id ) ) {
444 444
 				continue;
445 445
 			}
446 446
 
447
-		    $field = RGFormsModel::get_field( $this->form, $input_id );
447
+			$field = RGFormsModel::get_field( $this->form, $input_id );
448 448
 
449
-		    // Reset fields that are hidden
450
-		    // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic
451
-		    if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) {
449
+			// Reset fields that are hidden
450
+			// Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic
451
+			if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) {
452 452
 
453 453
 				$empty_value = $field->get_value_save_entry(
454 454
 					is_array( $field->get_entry_inputs() ) ? array() : '',
@@ -460,16 +460,16 @@  discard block
 block discarded – undo
460 460
 					$empty_value = '';
461 461
 				}
462 462
 
463
-			    $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
463
+				$lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
464 464
 
465
-			    GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );
465
+				GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );
466 466
 
467
-			    // Prevent the $_POST values of hidden fields from being used as default values when rendering the form
467
+				// Prevent the $_POST values of hidden fields from being used as default values when rendering the form
468 468
 				// after submission
469
-			    $post_input_id = 'input_' . str_replace( '.', '_', $input_id );
470
-			    $_POST[ $post_input_id ] = '';
471
-		    }
472
-	    }
469
+				$post_input_id = 'input_' . str_replace( '.', '_', $input_id );
470
+				$_POST[ $post_input_id ] = '';
471
+			}
472
+		}
473 473
 	}
474 474
 
475 475
 	/**
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 
564 564
 		$form = $this->filter_conditional_logic( $this->form );
565 565
 
566
-	    /** @var GF_Field $field */
566
+		/** @var GF_Field $field */
567 567
 		foreach( $form['fields'] as $k => &$field ) {
568 568
 
569 569
 			/**
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 
580 580
 			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
581 581
 				foreach( $field->inputs as $key => $input ) {
582
-				    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
582
+					$field->inputs[ $key ][ 'id' ] = (string)$input['id'];
583 583
 				}
584 584
 			}
585 585
 		}
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 
620 620
 				$inputs = $field->get_entry_inputs();
621 621
 				if ( is_array( $inputs ) ) {
622
-				    foreach ( $inputs as $input ) {
622
+					foreach ( $inputs as $input ) {
623 623
 						list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 );
624 624
 
625 625
 						if ( 'product' === $field->type ) {
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 						}
639 639
 
640 640
 						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] );
641
-				    }
641
+					}
642 642
 				} else {
643 643
 					// Set to what it previously was if it's not editable
644 644
 					if ( ! in_array( $field->id, $allowed_fields ) ) {
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
 			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
685 685
 
686 686
 			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
687
-	        $ary = stripslashes_deep( $ary );
687
+			$ary = stripslashes_deep( $ary );
688 688
 			$img_url = \GV\Utils::get( $ary, 0 );
689 689
 
690 690
 			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 	private function maybe_update_post_fields( $form ) {
758 758
 
759 759
 		if( empty( $this->entry['post_id'] ) ) {
760
-	        gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
760
+			gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
761 761
 			return;
762 762
 		}
763 763
 
@@ -792,49 +792,49 @@  discard block
 block discarded – undo
792 792
 
793 793
 				switch( $field->type ) {
794 794
 
795
-				    case 'post_title':
796
-				        $post_title = $value;
797
-				        if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
798
-				            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
799
-				        }
800
-				        $updated_post->post_title = $post_title;
801
-				        $updated_post->post_name  = $post_title;
802
-				        unset( $post_title );
803
-				        break;
804
-
805
-				    case 'post_content':
806
-				        $post_content = $value;
807
-				        if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
808
-				            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
809
-				        }
810
-				        $updated_post->post_content = $post_content;
811
-				        unset( $post_content );
812
-				        break;
813
-				    case 'post_excerpt':
814
-				        $updated_post->post_excerpt = $value;
815
-				        break;
816
-				    case 'post_tags':
817
-				        wp_set_post_tags( $post_id, $value, false );
818
-				        break;
819
-				    case 'post_category':
820
-				        break;
821
-				    case 'post_custom_field':
795
+					case 'post_title':
796
+						$post_title = $value;
797
+						if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
798
+							$post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
799
+						}
800
+						$updated_post->post_title = $post_title;
801
+						$updated_post->post_name  = $post_title;
802
+						unset( $post_title );
803
+						break;
804
+
805
+					case 'post_content':
806
+						$post_content = $value;
807
+						if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
808
+							$post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
809
+						}
810
+						$updated_post->post_content = $post_content;
811
+						unset( $post_content );
812
+						break;
813
+					case 'post_excerpt':
814
+						$updated_post->post_excerpt = $value;
815
+						break;
816
+					case 'post_tags':
817
+						wp_set_post_tags( $post_id, $value, false );
818
+						break;
819
+					case 'post_category':
820
+						break;
821
+					case 'post_custom_field':
822 822
 						if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) {
823 823
 							$value = $value[ $field_id ];
824 824
 						}
825 825
 
826
-				        if( ! empty( $field->customFieldTemplateEnabled ) ) {
827
-				            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
828
-				        }
826
+						if( ! empty( $field->customFieldTemplateEnabled ) ) {
827
+							$value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
828
+						}
829 829
 
830 830
 						$value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry );
831 831
 
832
-				        update_post_meta( $post_id, $field->postCustomFieldName, $value );
833
-				        break;
832
+						update_post_meta( $post_id, $field->postCustomFieldName, $value );
833
+						break;
834 834
 
835
-				    case 'post_image':
836
-				        $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
837
-				        break;
835
+					case 'post_image':
836
+						$value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
837
+						break;
838 838
 
839 839
 				}
840 840
 
@@ -991,14 +991,14 @@  discard block
 block discarded – undo
991 991
 			?><h2 class="gv-edit-entry-title">
992 992
 				<span><?php
993 993
 
994
-				    /**
995
-				     * @filter `gravityview_edit_entry_title` Modify the edit entry title
996
-				     * @param string $edit_entry_title Modify the "Edit Entry" title
997
-				     * @param GravityView_Edit_Entry_Render $this This object
998
-				     */
999
-				    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
994
+					/**
995
+					 * @filter `gravityview_edit_entry_title` Modify the edit entry title
996
+					 * @param string $edit_entry_title Modify the "Edit Entry" title
997
+					 * @param GravityView_Edit_Entry_Render $this This object
998
+					 */
999
+					$edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
1000 1000
 
1001
-				    echo esc_attr( $edit_entry_title );
1001
+					echo esc_attr( $edit_entry_title );
1002 1002
 			?></span>
1003 1003
 			</h2>
1004 1004
 
@@ -1053,13 +1053,13 @@  discard block
 block discarded – undo
1053 1053
 				);
1054 1054
 
1055 1055
 				/**
1056
-				* @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels
1057
-				* @since 1.16.3
1058
-				* @param array $labels Default button labels associative array
1059
-				* @param array $form The Gravity Forms form
1060
-				* @param array $entry The Gravity Forms entry
1061
-				* @param int $view_id The current View ID
1062
-				*/
1056
+				 * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels
1057
+				 * @since 1.16.3
1058
+				 * @param array $labels Default button labels associative array
1059
+				 * @param array $form The Gravity Forms form
1060
+				 * @param array $entry The Gravity Forms entry
1061
+				 * @param int $view_id The current View ID
1062
+				 */
1063 1063
 				$labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id );
1064 1064
 
1065 1065
 				$this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit'];
@@ -1096,26 +1096,26 @@  discard block
 block discarded – undo
1096 1096
 
1097 1097
 				switch ( $edit_redirect ) {
1098 1098
 
1099
-                    case '0':
1100
-	                    $redirect_url = $back_link;
1101
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
1102
-                        break;
1103
-
1104
-                    case '1':
1105
-	                    $redirect_url = $directory_link = GravityView_API::directory_link();
1106
-	                    $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>' );
1107
-	                    break;
1108
-
1109
-                    case '2':
1110
-	                    $redirect_url = $edit_redirect_url;
1111
-	                    $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
1112
-	                    $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>' );
1113
-                        break;
1114
-
1115
-                    case '':
1116
-                    default:
1117
-					    $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
1118
-                        break;
1099
+					case '0':
1100
+						$redirect_url = $back_link;
1101
+						$entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
1102
+						break;
1103
+
1104
+					case '1':
1105
+						$redirect_url = $directory_link = GravityView_API::directory_link();
1106
+						$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>' );
1107
+						break;
1108
+
1109
+					case '2':
1110
+						$redirect_url = $edit_redirect_url;
1111
+						$redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
1112
+						$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>' );
1113
+						break;
1114
+
1115
+					case '':
1116
+					default:
1117
+						$entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
1118
+						break;
1119 1119
 				}
1120 1120
 
1121 1121
 				if ( isset( $redirect_url ) ) {
@@ -1181,13 +1181,13 @@  discard block
 block discarded – undo
1181 1181
 				);
1182 1182
 
1183 1183
 				/**
1184
-				* @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels
1185
-				* @since 1.16.3
1186
-				* @param array $labels Default button labels associative array
1187
-				* @param array $form The Gravity Forms form
1188
-				* @param array $entry The Gravity Forms entry
1189
-				* @param int $view_id The current View ID
1190
-				*/
1184
+				 * @filter `gravityview/edit_entry/button_labels` Modify the cancel/submit buttons' labels
1185
+				 * @since 1.16.3
1186
+				 * @param array $labels Default button labels associative array
1187
+				 * @param array $form The Gravity Forms form
1188
+				 * @param array $entry The Gravity Forms entry
1189
+				 * @param int $view_id The current View ID
1190
+				 */
1191 1191
 				$labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id );
1192 1192
 
1193 1193
 				GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form;
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
 
1230 1230
 		ob_get_clean();
1231 1231
 
1232
-	    remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
1232
+		remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
1233 1233
 		remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
1234 1234
 		remove_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) );
1235 1235
 		remove_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) );
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
 
1286 1286
 		// for now we don't support Save and Continue feature.
1287 1287
 		if( ! self::$supports_save_and_continue ) {
1288
-	        unset( $form['save'] );
1288
+			unset( $form['save'] );
1289 1289
 		}
1290 1290
 
1291 1291
 		$form = $this->unselect_default_values( $form );
@@ -1312,30 +1312,30 @@  discard block
 block discarded – undo
1312 1312
 			return $field_content;
1313 1313
 		}
1314 1314
 
1315
-        $message = null;
1315
+		$message = null;
1316 1316
 
1317
-        // First, make sure they have the capability to edit the post.
1318
-        if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1317
+		// First, make sure they have the capability to edit the post.
1318
+		if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1319 1319
 
1320
-            /**
1321
-             * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1322
-             * @param string $message The existing "You don't have permission..." text
1323
-             */
1324
-            $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1320
+			/**
1321
+			 * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1322
+			 * @param string $message The existing "You don't have permission..." text
1323
+			 */
1324
+			$message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1325 1325
 
1326
-        } elseif( null === get_post( $this->entry['post_id'] ) ) {
1327
-            /**
1328
-             * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1329
-             * @param string $message The existing "This field is not editable; the post no longer exists." text
1330
-             */
1331
-            $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1332
-        }
1326
+		} elseif( null === get_post( $this->entry['post_id'] ) ) {
1327
+			/**
1328
+			 * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1329
+			 * @param string $message The existing "This field is not editable; the post no longer exists." text
1330
+			 */
1331
+			$message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1332
+		}
1333 1333
 
1334
-        if( $message ) {
1335
-            $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1336
-        }
1334
+		if( $message ) {
1335
+			$field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1336
+		}
1337 1337
 
1338
-        return $field_content;
1338
+		return $field_content;
1339 1339
 	}
1340 1340
 
1341 1341
 	/**
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
 			|| ! empty( $field_content )
1364 1364
 			|| in_array( $field->type, array( 'honeypot' ) )
1365 1365
 		) {
1366
-	        return $field_content;
1366
+			return $field_content;
1367 1367
 		}
1368 1368
 
1369 1369
 		// SET SOME FIELD DEFAULTS TO PREVENT ISSUES
@@ -1371,24 +1371,24 @@  discard block
 block discarded – undo
1371 1371
 
1372 1372
 		$field_value = $this->get_field_value( $field );
1373 1373
 
1374
-	    // Prevent any PHP warnings, like undefined index
1375
-	    ob_start();
1374
+		// Prevent any PHP warnings, like undefined index
1375
+		ob_start();
1376 1376
 
1377
-	    $return = null;
1377
+		$return = null;
1378 1378
 
1379 1379
 		/** @var GravityView_Field $gv_field */
1380 1380
 		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1381 1381
 			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1382 1382
 		} else {
1383
-	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
1384
-	    }
1383
+			$return = $field->get_field_input( $this->form, $field_value, $this->entry );
1384
+		}
1385 1385
 
1386
-	    // If there was output, it's an error
1387
-	    $warnings = ob_get_clean();
1386
+		// If there was output, it's an error
1387
+		$warnings = ob_get_clean();
1388 1388
 
1389
-	    if( !empty( $warnings ) ) {
1390
-		    gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1391
-	    }
1389
+		if( !empty( $warnings ) ) {
1390
+			gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1391
+		}
1392 1392
 
1393 1393
 		return $return;
1394 1394
 	}
@@ -1423,8 +1423,8 @@  discard block
 block discarded – undo
1423 1423
 				$input_id = strval( $input['id'] );
1424 1424
 
1425 1425
 				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1426
-				    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1427
-				    $allow_pre_populated = false;
1426
+					$field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1427
+					$allow_pre_populated = false;
1428 1428
 				}
1429 1429
 
1430 1430
 			}
@@ -1448,7 +1448,7 @@  discard block
 block discarded – undo
1448 1448
 			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1449 1449
 				$categories = array();
1450 1450
 				foreach ( explode( ',', $field_value ) as $cat_string ) {
1451
-				    $categories[] = GFCommon::format_post_category( $cat_string, true );
1451
+					$categories[] = GFCommon::format_post_category( $cat_string, true );
1452 1452
 				}
1453 1453
 				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1454 1454
 			}
@@ -1458,25 +1458,25 @@  discard block
 block discarded – undo
1458 1458
 		// if value is empty get the default value if defined
1459 1459
 		$field_value = $field->get_value_default_if_empty( $field_value );
1460 1460
 
1461
-	    /**
1462
-	     * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1463
-	     * @since 1.11
1464
-	     * @since 1.20 Added third param
1465
-	     * @param mixed $field_value field value used to populate the input
1466
-	     * @param object $field Gravity Forms field object ( Class GF_Field )
1467
-	     * @param GravityView_Edit_Entry_Render $this Current object
1468
-	     */
1469
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this );
1470
-
1471
-	    /**
1472
-	     * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1473
-	     * @since 1.17
1474
-	     * @since 1.20 Added third param
1475
-	     * @param mixed $field_value field value used to populate the input
1476
-	     * @param GF_Field $field Gravity Forms field object
1477
-	     * @param GravityView_Edit_Entry_Render $this Current object
1478
-	     */
1479
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1461
+		/**
1462
+		 * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1463
+		 * @since 1.11
1464
+		 * @since 1.20 Added third param
1465
+		 * @param mixed $field_value field value used to populate the input
1466
+		 * @param object $field Gravity Forms field object ( Class GF_Field )
1467
+		 * @param GravityView_Edit_Entry_Render $this Current object
1468
+		 */
1469
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this );
1470
+
1471
+		/**
1472
+		 * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1473
+		 * @since 1.17
1474
+		 * @since 1.20 Added third param
1475
+		 * @param mixed $field_value field value used to populate the input
1476
+		 * @param GF_Field $field Gravity Forms field object
1477
+		 * @param GravityView_Edit_Entry_Render $this Current object
1478
+		 */
1479
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1480 1480
 
1481 1481
 		return $field_value;
1482 1482
 	}
@@ -1503,7 +1503,7 @@  discard block
 block discarded – undo
1503 1503
 			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1504 1504
 			// expects certain field array items to be set.
1505 1505
 			foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) {
1506
-	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1506
+				$field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1507 1507
 			}
1508 1508
 
1509 1509
 			switch( RGFormsModel::get_input_type( $field ) ) {
@@ -1517,61 +1517,61 @@  discard block
 block discarded – undo
1517 1517
 				 */
1518 1518
 				case 'fileupload':
1519 1519
 
1520
-				    // Set the previous value
1521
-				    $entry = $this->get_entry();
1520
+					// Set the previous value
1521
+					$entry = $this->get_entry();
1522 1522
 
1523
-				    $input_name = 'input_'.$field->id;
1524
-				    $form_id = $form['id'];
1523
+					$input_name = 'input_'.$field->id;
1524
+					$form_id = $form['id'];
1525 1525
 
1526
-				    $value = NULL;
1526
+					$value = NULL;
1527 1527
 
1528
-				    // Use the previous entry value as the default.
1529
-				    if( isset( $entry[ $field->id ] ) ) {
1530
-				        $value = $entry[ $field->id ];
1531
-				    }
1528
+					// Use the previous entry value as the default.
1529
+					if( isset( $entry[ $field->id ] ) ) {
1530
+						$value = $entry[ $field->id ];
1531
+					}
1532 1532
 
1533
-				    // If this is a single upload file
1534
-				    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1535
-				        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1536
-				        $value = $file_path['url'];
1533
+					// If this is a single upload file
1534
+					if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1535
+						$file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1536
+						$value = $file_path['url'];
1537 1537
 
1538
-				    } else {
1538
+					} else {
1539 1539
 
1540
-				        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1541
-				        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1542
-				        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1540
+						// Fix PHP warning on line 1498 of form_display.php for post_image fields
1541
+						// Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1542
+						$_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1543 1543
 
1544
-				    }
1544
+					}
1545 1545
 
1546
-				    if ( \GV\Utils::get( $field, "multipleFiles" ) ) {
1546
+					if ( \GV\Utils::get( $field, "multipleFiles" ) ) {
1547 1547
 
1548
-				        // If there are fresh uploads, process and merge them.
1549
-				        // Otherwise, use the passed values, which should be json-encoded array of URLs
1550
-				        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1551
-				            $value = empty( $value ) ? '[]' : $value;
1552
-				            $value = stripslashes_deep( $value );
1553
-				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1554
-				        }
1548
+						// If there are fresh uploads, process and merge them.
1549
+						// Otherwise, use the passed values, which should be json-encoded array of URLs
1550
+						if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1551
+							$value = empty( $value ) ? '[]' : $value;
1552
+							$value = stripslashes_deep( $value );
1553
+							$value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1554
+						}
1555 1555
 
1556
-				    } else {
1556
+					} else {
1557 1557
 
1558
-				        // A file already exists when editing an entry
1559
-				        // We set this to solve issue when file upload fields are required.
1560
-				        GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1558
+						// A file already exists when editing an entry
1559
+						// We set this to solve issue when file upload fields are required.
1560
+						GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1561 1561
 
1562
-				    }
1562
+					}
1563 1563
 
1564
-				    $this->entry[ $input_name ] = $value;
1565
-				    $_POST[ $input_name ] = $value;
1564
+					$this->entry[ $input_name ] = $value;
1565
+					$_POST[ $input_name ] = $value;
1566 1566
 
1567
-				    break;
1567
+					break;
1568 1568
 
1569 1569
 				case 'number':
1570
-				    // Fix "undefined index" issue at line 1286 in form_display.php
1571
-				    if( !isset( $_POST['input_'.$field->id ] ) ) {
1572
-				        $_POST['input_'.$field->id ] = NULL;
1573
-				    }
1574
-				    break;
1570
+					// Fix "undefined index" issue at line 1286 in form_display.php
1571
+					if( !isset( $_POST['input_'.$field->id ] ) ) {
1572
+						$_POST['input_'.$field->id ] = NULL;
1573
+					}
1574
+					break;
1575 1575
 			}
1576 1576
 
1577 1577
 		}
@@ -1656,43 +1656,43 @@  discard block
 block discarded – undo
1656 1656
 				case 'fileupload' :
1657 1657
 				case 'post_image':
1658 1658
 
1659
-				    // in case nothing is uploaded but there are already files saved
1660
-				    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1661
-				        $field->failed_validation = false;
1662
-				        unset( $field->validation_message );
1663
-				    }
1659
+					// in case nothing is uploaded but there are already files saved
1660
+					if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1661
+						$field->failed_validation = false;
1662
+						unset( $field->validation_message );
1663
+					}
1664 1664
 
1665
-				    // validate if multi file upload reached max number of files [maxFiles] => 2
1666
-				    if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1665
+					// validate if multi file upload reached max number of files [maxFiles] => 2
1666
+					if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1667 1667
 
1668
-				        $input_name = 'input_' . $field->id;
1669
-				        //uploaded
1670
-				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1668
+						$input_name = 'input_' . $field->id;
1669
+						//uploaded
1670
+						$file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1671 1671
 
1672
-				        //existent
1673
-				        $entry = $this->get_entry();
1674
-				        $value = NULL;
1675
-				        if( isset( $entry[ $field->id ] ) ) {
1676
-				            $value = json_decode( $entry[ $field->id ], true );
1677
-				        }
1672
+						//existent
1673
+						$entry = $this->get_entry();
1674
+						$value = NULL;
1675
+						if( isset( $entry[ $field->id ] ) ) {
1676
+							$value = json_decode( $entry[ $field->id ], true );
1677
+						}
1678 1678
 
1679
-				        // count uploaded files and existent entry files
1680
-				        $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) +
1681
-						               ( is_array( $value ) ? count( $value ) : 0 );
1679
+						// count uploaded files and existent entry files
1680
+						$count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) +
1681
+									   ( is_array( $value ) ? count( $value ) : 0 );
1682 1682
 
1683
-				        if( $count_files > $field->maxFiles ) {
1684
-				            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1685
-				            $field->failed_validation = 1;
1686
-				            $gv_valid = false;
1683
+						if( $count_files > $field->maxFiles ) {
1684
+							$field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1685
+							$field->failed_validation = 1;
1686
+							$gv_valid = false;
1687 1687
 
1688
-				            // in case of error make sure the newest upload files are removed from the upload input
1689
-				            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1690
-				        }
1688
+							// in case of error make sure the newest upload files are removed from the upload input
1689
+							GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1690
+						}
1691 1691
 
1692
-				    }
1692
+					}
1693 1693
 
1694 1694
 
1695
-				    break;
1695
+					break;
1696 1696
 
1697 1697
 			}
1698 1698
 
@@ -1703,47 +1703,47 @@  discard block
 block discarded – undo
1703 1703
 
1704 1704
 				switch ( $field_type ) {
1705 1705
 
1706
-				    // Captchas don't need to be re-entered.
1707
-				    case 'captcha':
1706
+					// Captchas don't need to be re-entered.
1707
+					case 'captcha':
1708 1708
 
1709
-				        // Post Image fields aren't editable, so we un-fail them.
1710
-				    case 'post_image':
1711
-				        $field->failed_validation = false;
1712
-				        unset( $field->validation_message );
1713
-				        break;
1709
+						// Post Image fields aren't editable, so we un-fail them.
1710
+					case 'post_image':
1711
+						$field->failed_validation = false;
1712
+						unset( $field->validation_message );
1713
+						break;
1714 1714
 
1715 1715
 				}
1716 1716
 
1717 1717
 				// You can't continue inside a switch, so we do it after.
1718 1718
 				if( empty( $field->failed_validation ) ) {
1719
-				    continue;
1719
+					continue;
1720 1720
 				}
1721 1721
 
1722 1722
 				// checks if the No Duplicates option is not validating entry against itself, since
1723 1723
 				// we're editing a stored entry, it would also assume it's a duplicate.
1724 1724
 				if( !empty( $field->noDuplicates ) ) {
1725 1725
 
1726
-				    $entry = $this->get_entry();
1726
+					$entry = $this->get_entry();
1727 1727
 
1728
-				    // If the value of the entry is the same as the stored value
1729
-				    // Then we can assume it's not a duplicate, it's the same.
1730
-				    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1731
-				        //if value submitted was not changed, then don't validate
1732
-				        $field->failed_validation = false;
1728
+					// If the value of the entry is the same as the stored value
1729
+					// Then we can assume it's not a duplicate, it's the same.
1730
+					if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1731
+						//if value submitted was not changed, then don't validate
1732
+						$field->failed_validation = false;
1733 1733
 
1734
-				        unset( $field->validation_message );
1734
+						unset( $field->validation_message );
1735 1735
 
1736
-				        gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) );
1736
+						gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) );
1737 1737
 
1738
-				        continue;
1739
-				    }
1738
+						continue;
1739
+					}
1740 1740
 				}
1741 1741
 
1742 1742
 				// if here then probably we are facing the validation 'At least one field must be filled out'
1743 1743
 				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1744
-				    unset( $field->validation_message );
1745
-	                $field->validation_message = false;
1746
-				    continue;
1744
+					unset( $field->validation_message );
1745
+					$field->validation_message = false;
1746
+					continue;
1747 1747
 				}
1748 1748
 
1749 1749
 				$gv_valid = false;
@@ -1807,8 +1807,8 @@  discard block
 block discarded – undo
1807 1807
 		// Hide fields depending on admin settings
1808 1808
 		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1809 1809
 
1810
-	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1811
-	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1810
+		// If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1811
+		$fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1812 1812
 
1813 1813
 		/**
1814 1814
 		 * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form
@@ -1887,11 +1887,11 @@  discard block
 block discarded – undo
1887 1887
 		// The edit tab has been configured, so we loop through to configured settings
1888 1888
 		foreach ( $configured_fields as $configured_field ) {
1889 1889
 
1890
-	        /** @var GF_Field $field */
1891
-	        foreach ( $fields as $field ) {
1890
+			/** @var GF_Field $field */
1891
+			foreach ( $fields as $field ) {
1892 1892
 				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1893
-				    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1894
-				    break;
1893
+					$edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1894
+					break;
1895 1895
 				}
1896 1896
 
1897 1897
 			}
@@ -1947,28 +1947,28 @@  discard block
 block discarded – undo
1947 1947
 	 */
1948 1948
 	private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) {
1949 1949
 
1950
-	    /**
1950
+		/**
1951 1951
 		 * @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
1952
-	     * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1953
-	     * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1954
-	     * @since 1.9.1
1955
-	     * @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.
1956
-	     * @param array $form GF Form array
1957
-	     * @param int $view_id View ID
1958
-	     */
1959
-	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1960
-
1961
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1952
+		 * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1953
+		 * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1954
+		 * @since 1.9.1
1955
+		 * @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.
1956
+		 * @param array $form GF Form array
1957
+		 * @param int $view_id View ID
1958
+		 */
1959
+		$use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1960
+
1961
+		if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1962 1962
 			foreach( $fields as $k => $field ) {
1963 1963
 				if( $field->adminOnly ) {
1964
-				    unset( $fields[ $k ] );
1964
+					unset( $fields[ $k ] );
1965 1965
 				}
1966 1966
 			}
1967 1967
 			return array_values( $fields );
1968 1968
 		}
1969 1969
 
1970
-	    foreach( $fields as &$field ) {
1971
-		    $field->adminOnly = false;
1970
+		foreach( $fields as &$field ) {
1971
+			$field->adminOnly = false;
1972 1972
 		}
1973 1973
 
1974 1974
 		return $fields;
@@ -1988,13 +1988,13 @@  discard block
 block discarded – undo
1988 1988
 	 */
1989 1989
 	private function unselect_default_values( $form ) {
1990 1990
 
1991
-	    foreach ( $form['fields'] as &$field ) {
1991
+		foreach ( $form['fields'] as &$field ) {
1992 1992
 
1993 1993
 			if ( empty( $field->choices ) ) {
1994
-                continue;
1994
+				continue;
1995 1995
 			}
1996 1996
 
1997
-            foreach ( $field->choices as &$choice ) {
1997
+			foreach ( $field->choices as &$choice ) {
1998 1998
 				if ( \GV\Utils::get( $choice, 'isSelected' ) ) {
1999 1999
 					$choice['isSelected'] = false;
2000 2000
 				}
@@ -2031,36 +2031,36 @@  discard block
 block discarded – undo
2031 2031
 
2032 2032
 			if( 'checkbox' === $field->type ) {
2033 2033
 				foreach ( $field->get_entry_inputs() as $key => $input ) {
2034
-				    $input_id = $input['id'];
2035
-				    $choice = $field->choices[ $key ];
2036
-				    $value = \GV\Utils::get( $this->entry, $input_id );
2037
-				    $match = RGFormsModel::choice_value_match( $field, $choice, $value );
2038
-				    if( $match ) {
2039
-				        $field->choices[ $key ]['isSelected'] = true;
2040
-				    }
2034
+					$input_id = $input['id'];
2035
+					$choice = $field->choices[ $key ];
2036
+					$value = \GV\Utils::get( $this->entry, $input_id );
2037
+					$match = RGFormsModel::choice_value_match( $field, $choice, $value );
2038
+					if( $match ) {
2039
+						$field->choices[ $key ]['isSelected'] = true;
2040
+					}
2041 2041
 				}
2042 2042
 			} else {
2043 2043
 
2044 2044
 				// We need to run through each field to set the default values
2045 2045
 				foreach ( $this->entry as $field_id => $field_value ) {
2046 2046
 
2047
-				    if( floatval( $field_id ) === floatval( $field->id ) ) {
2047
+					if( floatval( $field_id ) === floatval( $field->id ) ) {
2048 2048
 
2049
-				        if( 'list' === $field->type ) {
2050
-				            $list_rows = maybe_unserialize( $field_value );
2049
+						if( 'list' === $field->type ) {
2050
+							$list_rows = maybe_unserialize( $field_value );
2051 2051
 
2052
-				            $list_field_value = array();
2053
-				            foreach ( (array) $list_rows as $row ) {
2054
-				                foreach ( (array) $row as $column ) {
2055
-				                    $list_field_value[] = $column;
2056
-				                }
2057
-				            }
2052
+							$list_field_value = array();
2053
+							foreach ( (array) $list_rows as $row ) {
2054
+								foreach ( (array) $row as $column ) {
2055
+									$list_field_value[] = $column;
2056
+								}
2057
+							}
2058 2058
 
2059
-				            $field->defaultValue = serialize( $list_field_value );
2060
-				        } else {
2061
-				            $field->defaultValue = $field_value;
2062
-				        }
2063
-				    }
2059
+							$field->defaultValue = serialize( $list_field_value );
2060
+						} else {
2061
+							$field->defaultValue = $field_value;
2062
+						}
2063
+					}
2064 2064
 				}
2065 2065
 			}
2066 2066
 		}
@@ -2121,7 +2121,7 @@  discard block
 block discarded – undo
2121 2121
 			foreach ( $form['fields'] as &$field ) {
2122 2122
 				foreach ( $remove_conditions_rule as $_remove_conditions_r ) {
2123 2123
 
2124
-				    list( $rule_field_id, $rule_i ) = $_remove_conditions_r;
2124
+					list( $rule_field_id, $rule_i ) = $_remove_conditions_r;
2125 2125
 
2126 2126
 					if ( $field['id'] == $rule_field_id ) {
2127 2127
 						unset( $field->conditionalLogic['rules'][ $rule_i ] );
@@ -2172,7 +2172,7 @@  discard block
 block discarded – undo
2172 2172
 			return $has_conditional_logic;
2173 2173
 		}
2174 2174
 
2175
-	    /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */
2175
+		/** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */
2176 2176
 		return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form );
2177 2177
 	}
2178 2178
 
@@ -2239,14 +2239,14 @@  discard block
 block discarded – undo
2239 2239
 
2240 2240
 		if( $echo && $error !== true ) {
2241 2241
 
2242
-	        $error = esc_html( $error );
2242
+			$error = esc_html( $error );
2243 2243
 
2244
-	        /**
2245
-	         * @since 1.9
2246
-	         */
2247
-	        if ( ! empty( $this->entry ) ) {
2248
-		        $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;" ) );
2249
-	        }
2244
+			/**
2245
+			 * @since 1.9
2246
+			 */
2247
+			if ( ! empty( $this->entry ) ) {
2248
+				$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;" ) );
2249
+			}
2250 2250
 
2251 2251
 			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
2252 2252
 		}
Please login to merge, or discard this patch.
Spacing   +239 added lines, -239 removed lines patch added patch discarded remove patch
@@ -135,16 +135,16 @@  discard block
 block discarded – undo
135 135
 	function load() {
136 136
 
137 137
 		/** @define "GRAVITYVIEW_DIR" "../../../" */
138
-		include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' );
138
+		include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' );
139 139
 
140 140
 		// Don't display an embedded form when editing an entry
141 141
 		add_action( 'wp_head', array( $this, 'prevent_render_form' ) );
142 142
 		add_action( 'wp_footer', array( $this, 'prevent_render_form' ) );
143 143
 
144 144
 		// Stop Gravity Forms processing what is ours!
145
-		add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 );
145
+		add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 );
146 146
 
147
-		add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') );
147
+		add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) );
148 148
 
149 149
 		add_action( 'gravityview_edit_entry', array( $this, 'init' ), 10, 4 );
150 150
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 		add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 );
156 156
 
157 157
 		// Add fields expected by GFFormDisplay::validate()
158
-		add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') );
158
+		add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) );
159 159
 
160 160
 		// Fix multiselect value for GF 2.2
161 161
 		add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 );
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	 * @return void
173 173
 	 */
174 174
 	public function prevent_render_form() {
175
-		if( $this->is_edit_entry() ) {
176
-			if( 'wp_head' === current_filter() ) {
175
+		if ( $this->is_edit_entry() ) {
176
+			if ( 'wp_head' === current_filter() ) {
177 177
 				add_filter( 'gform_shortcode_form', '__return_empty_string' );
178 178
 			} else {
179 179
 				remove_filter( 'gform_shortcode_form', '__return_empty_string' );
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
 	 */
189 189
 	public function prevent_maybe_process_form() {
190 190
 
191
-	    if( ! $this->is_edit_entry_submission() ) {
191
+	    if ( ! $this->is_edit_entry_submission() ) {
192 192
 			return;
193 193
 		}
194 194
 
195 195
 		gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] Removing GFForms::maybe_process_form() action.' );
196 196
 
197
-		remove_action( 'wp',  array( 'RGForms', 'maybe_process_form'), 9 );
198
-		remove_action( 'wp',  array( 'GFForms', 'maybe_process_form'), 9 );
197
+		remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 );
198
+		remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 );
199 199
 	}
200 200
 
201 201
 	/**
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 */
205 205
 	public function is_edit_entry() {
206 206
 
207
-		$is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] );
207
+		$is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] );
208 208
 
209 209
 		return ( $is_edit_entry || $this->is_edit_entry_submission() );
210 210
 	}
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 * @return boolean
216 216
 	 */
217 217
 	public function is_edit_entry_submission() {
218
-		return !empty( $_POST[ self::$nonce_field ] );
218
+		return ! empty( $_POST[ self::$nonce_field ] );
219 219
 	}
220 220
 
221 221
 	/**
@@ -228,16 +228,16 @@  discard block
 block discarded – undo
228 228
 
229 229
 
230 230
 		$entries = $gravityview_view->getEntries();
231
-	    self::$original_entry = $entries[0];
232
-	    $this->entry = $entries[0];
231
+	    self::$original_entry = $entries[ 0 ];
232
+	    $this->entry = $entries[ 0 ];
233 233
 
234 234
 		self::$original_form = $gravityview_view->getForm();
235 235
 		$this->form = $gravityview_view->getForm();
236
-		$this->form_id = $this->entry['form_id'];
236
+		$this->form_id = $this->entry[ 'form_id' ];
237 237
 		$this->view_id = $gravityview_view->getViewId();
238 238
 		$this->post_id = \GV\Utils::get( $post, 'ID', null );
239 239
 
240
-		self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] );
240
+		self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] );
241 241
 	}
242 242
 
243 243
 
@@ -296,9 +296,9 @@  discard block
 block discarded – undo
296 296
 	private function print_scripts() {
297 297
 		$gravityview_view = GravityView_View::getInstance();
298 298
 
299
-		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
+		wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
300 300
 
301
-		GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false);
301
+		GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false );
302 302
 
303 303
 		wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) );
304 304
 
@@ -314,19 +314,19 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	private function process_save( $gv_data ) {
316 316
 
317
-		if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) {
317
+		if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) {
318 318
 			return;
319 319
 		}
320 320
 
321 321
 		// Make sure the entry, view, and form IDs are all correct
322 322
 		$valid = $this->verify_nonce();
323 323
 
324
-		if ( !$valid ) {
324
+		if ( ! $valid ) {
325 325
 			gravityview()->log->error( 'Nonce validation failed.' );
326 326
 			return;
327 327
 		}
328 328
 
329
-		if ( $this->entry['id'] !== $_POST['lid'] ) {
329
+		if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) {
330 330
 			gravityview()->log->error( 'Entry ID did not match posted entry ID.' );
331 331
 			return;
332 332
 		}
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 
338 338
 		$this->validate();
339 339
 
340
-		if( $this->is_valid ) {
340
+		if ( $this->is_valid ) {
341 341
 
342 342
 			gravityview()->log->debug( 'Submission is valid.' );
343 343
 
@@ -349,15 +349,15 @@  discard block
 block discarded – undo
349 349
 			/**
350 350
 			 * @hack to avoid the capability validation of the method save_lead for GF 1.9+
351 351
 			 */
352
-			unset( $_GET['page'] );
352
+			unset( $_GET[ 'page' ] );
353 353
 
354
-			$date_created = $this->entry['date_created'];
354
+			$date_created = $this->entry[ 'date_created' ];
355 355
 
356 356
 			/**
357 357
 			 * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead()
358 358
 			 * @since 1.17.2
359 359
 			 */
360
-			unset( $this->entry['date_created'] );
360
+			unset( $this->entry[ 'date_created' ] );
361 361
 
362 362
 			/**
363 363
 			 * @action `gravityview/edit_entry/before_update` Perform an action after the entry has been updated using Edit Entry
@@ -367,14 +367,14 @@  discard block
 block discarded – undo
367 367
 			 * @param GravityView_Edit_Entry_Render $this This object
368 368
 			 * @param GravityView_View_Data $gv_data The View data
369 369
 			 */
370
-			do_action( 'gravityview/edit_entry/before_update', $form, $this->entry['id'], $this, $gv_data );
370
+			do_action( 'gravityview/edit_entry/before_update', $form, $this->entry[ 'id' ], $this, $gv_data );
371 371
 
372 372
 			GFFormsModel::save_lead( $form, $this->entry );
373 373
 
374 374
 	        // Delete the values for hidden inputs
375 375
 	        $this->unset_hidden_field_values();
376 376
 			
377
-			$this->entry['date_created'] = $date_created;
377
+			$this->entry[ 'date_created' ] = $date_created;
378 378
 
379 379
 			// Process calculation fields
380 380
 			$this->update_calculation_fields();
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 			 * @param GravityView_Edit_Entry_Render $this This object
397 397
 			 * @param GravityView_View_Data $gv_data The View data
398 398
 			 */
399
-			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data );
399
+			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data );
400 400
 
401 401
 		} else {
402 402
 			gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) );
@@ -426,16 +426,16 @@  discard block
 block discarded – undo
426 426
 
427 427
 		$this->unset_hidden_calculations = array();
428 428
 
429
-		if( ! $unset_hidden_field_values ) {
429
+		if ( ! $unset_hidden_field_values ) {
430 430
 			return;
431 431
 		}
432 432
 
433 433
 		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
434 434
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
435
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) );
435
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) );
436 436
 		} else {
437 437
 			$lead_detail_table = GFFormsModel::get_lead_details_table_name();
438
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );
438
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) );
439 439
 		}
440 440
 
441 441
 	    foreach ( $this->entry as $input_id => $field_value ) {
@@ -452,11 +452,11 @@  discard block
 block discarded – undo
452 452
 
453 453
 				$empty_value = $field->get_value_save_entry(
454 454
 					is_array( $field->get_entry_inputs() ) ? array() : '',
455
-					$this->form, '', $this->entry['id'], $this->entry
455
+					$this->form, '', $this->entry[ 'id' ], $this->entry
456 456
 				);
457 457
 
458 458
 				if ( $field->has_calculation() ) {
459
-					$this->unset_hidden_calculations[] = $field->id; // Unset
459
+					$this->unset_hidden_calculations[ ] = $field->id; // Unset
460 460
 					$empty_value = '';
461 461
 				}
462 462
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 		}
528 528
 
529 529
 		/** No file is being uploaded. */
530
-		if ( empty( $_FILES[ $input_name ]['name'] ) ) {
530
+		if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) {
531 531
 			/** So return the original upload */
532 532
 			return $entry[ $input_id ];
533 533
 		}
@@ -545,11 +545,11 @@  discard block
 block discarded – undo
545 545
 	 * @return mixed
546 546
 	 */
547 547
 	public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) {
548
-		if( ! $this->is_edit_entry() ) {
548
+		if ( ! $this->is_edit_entry() ) {
549 549
 			return $plupload_init;
550 550
 		}
551 551
 
552
-		$plupload_init['gf_vars']['max_files'] = 0;
552
+		$plupload_init[ 'gf_vars' ][ 'max_files' ] = 0;
553 553
 
554 554
 		return $plupload_init;
555 555
 	}
@@ -564,27 +564,27 @@  discard block
 block discarded – undo
564 564
 		$form = $this->filter_conditional_logic( $this->form );
565 565
 
566 566
 	    /** @var GF_Field $field */
567
-		foreach( $form['fields'] as $k => &$field ) {
567
+		foreach ( $form[ 'fields' ] as $k => &$field ) {
568 568
 
569 569
 			/**
570 570
 			 * Remove the fields with calculation formulas before save to avoid conflicts with GF logic
571 571
 			 * @since 1.16.3
572 572
 			 * @var GF_Field $field
573 573
 			 */
574
-			if( $field->has_calculation() ) {
575
-				unset( $form['fields'][ $k ] );
574
+			if ( $field->has_calculation() ) {
575
+				unset( $form[ 'fields' ][ $k ] );
576 576
 			}
577 577
 
578 578
 			$field->adminOnly = false;
579 579
 
580
-			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
581
-				foreach( $field->inputs as $key => $input ) {
582
-				    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
580
+			if ( isset( $field->inputs ) && is_array( $field->inputs ) ) {
581
+				foreach ( $field->inputs as $key => $input ) {
582
+				    $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ];
583 583
 				}
584 584
 			}
585 585
 		}
586 586
 
587
-		$form['fields'] = array_values( $form['fields'] );
587
+		$form[ 'fields' ] = array_values( $form[ 'fields' ] );
588 588
 
589 589
 		return $form;
590 590
 	}
@@ -596,14 +596,14 @@  discard block
 block discarded – undo
596 596
 		$update = false;
597 597
 
598 598
 		// get the most up to date entry values
599
-		$entry = GFAPI::get_entry( $this->entry['id'] );
599
+		$entry = GFAPI::get_entry( $this->entry[ 'id' ] );
600 600
 
601 601
 		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
602 602
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
603
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) );
603
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) );
604 604
 		} else {
605 605
 			$lead_detail_table = GFFormsModel::get_lead_details_table_name();
606
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) );
606
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) );
607 607
 		}
608 608
 
609 609
 
@@ -620,24 +620,24 @@  discard block
 block discarded – undo
620 620
 				$inputs = $field->get_entry_inputs();
621 621
 				if ( is_array( $inputs ) ) {
622 622
 				    foreach ( $inputs as $input ) {
623
-						list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 );
623
+						list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 );
624 624
 
625 625
 						if ( 'product' === $field->type ) {
626
-							$input_name = 'input_' . str_replace( '.', '_', $input['id'] );
626
+							$input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] );
627 627
 
628 628
 							// Only allow quantity to be set if it's allowed to be edited
629 629
 							if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) {
630 630
 							} else { // otherwise set to what it previously was
631
-								$_POST[ $input_name ] = $entry[ $input['id'] ];
631
+								$_POST[ $input_name ] = $entry[ $input[ 'id' ] ];
632 632
 							}
633 633
 						} else {
634 634
 							// Set to what it previously was if it's not editable
635 635
 							if ( ! in_array( $field_id, $allowed_fields ) ) {
636
-								$_POST[ $input_name ] = $entry[ $input['id'] ];
636
+								$_POST[ $input_name ] = $entry[ $input[ 'id' ] ];
637 637
 							}
638 638
 						}
639 639
 
640
-						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] );
640
+						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] );
641 641
 				    }
642 642
 				} else {
643 643
 					// Set to what it previously was if it's not editable
@@ -677,19 +677,19 @@  discard block
 block discarded – undo
677 677
 
678 678
 		$input_name = 'input_' . $field_id;
679 679
 
680
-		if ( !empty( $_FILES[ $input_name ]['name'] ) ) {
680
+		if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
681 681
 
682 682
 			// We have a new image
683 683
 
684
-			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
684
+			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] );
685 685
 
686 686
 			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
687 687
 	        $ary = stripslashes_deep( $ary );
688 688
 			$img_url = \GV\Utils::get( $ary, 0 );
689 689
 
690
-			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
691
-			$img_caption     = count( $ary ) > 2 ? $ary[2] : '';
692
-			$img_description = count( $ary ) > 3 ? $ary[3] : '';
690
+			$img_title       = count( $ary ) > 1 ? $ary[ 1 ] : '';
691
+			$img_caption     = count( $ary ) > 2 ? $ary[ 2 ] : '';
692
+			$img_description = count( $ary ) > 3 ? $ary[ 3 ] : '';
693 693
 
694 694
 			$image_meta = array(
695 695
 				'post_excerpt' => $img_caption,
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 
699 699
 			//adding title only if it is not empty. It will default to the file name if it is not in the array
700 700
 			if ( ! empty( $img_title ) ) {
701
-				$image_meta['post_title'] = $img_title;
701
+				$image_meta[ 'post_title' ] = $img_title;
702 702
 			}
703 703
 
704 704
 			/**
@@ -756,15 +756,15 @@  discard block
 block discarded – undo
756 756
 	 */
757 757
 	private function maybe_update_post_fields( $form ) {
758 758
 
759
-		if( empty( $this->entry['post_id'] ) ) {
759
+		if ( empty( $this->entry[ 'post_id' ] ) ) {
760 760
 	        gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
761 761
 			return;
762 762
 		}
763 763
 
764
-		$post_id = $this->entry['post_id'];
764
+		$post_id = $this->entry[ 'post_id' ];
765 765
 
766 766
 		// Security check
767
-		if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
767
+		if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
768 768
 			gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) );
769 769
 			return;
770 770
 		}
@@ -777,25 +777,25 @@  discard block
 block discarded – undo
777 777
 
778 778
 			$field = RGFormsModel::get_field( $form, $field_id );
779 779
 
780
-			if( ! $field ) {
780
+			if ( ! $field ) {
781 781
 				continue;
782 782
 			}
783 783
 
784
-			if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
784
+			if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
785 785
 
786 786
 				// Get the value of the field, including $_POSTed value
787 787
 				$value = RGFormsModel::get_field_value( $field );
788 788
 
789 789
 				// Use temporary entry variable, to make values available to fill_post_template() and update_post_image()
790 790
 				$entry_tmp = $this->entry;
791
-				$entry_tmp["{$field_id}"] = $value;
791
+				$entry_tmp[ "{$field_id}" ] = $value;
792 792
 
793
-				switch( $field->type ) {
793
+				switch ( $field->type ) {
794 794
 
795 795
 				    case 'post_title':
796 796
 				        $post_title = $value;
797 797
 				        if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
798
-				            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
798
+				            $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp );
799 799
 				        }
800 800
 				        $updated_post->post_title = $post_title;
801 801
 				        $updated_post->post_name  = $post_title;
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 				    case 'post_content':
806 806
 				        $post_content = $value;
807 807
 				        if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
808
-				            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
808
+				            $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true );
809 809
 				        }
810 810
 				        $updated_post->post_content = $post_content;
811 811
 				        unset( $post_content );
@@ -823,11 +823,11 @@  discard block
 block discarded – undo
823 823
 							$value = $value[ $field_id ];
824 824
 						}
825 825
 
826
-				        if( ! empty( $field->customFieldTemplateEnabled ) ) {
826
+				        if ( ! empty( $field->customFieldTemplateEnabled ) ) {
827 827
 				            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
828 828
 				        }
829 829
 
830
-						$value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry );
830
+						$value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry );
831 831
 
832 832
 				        update_post_meta( $post_id, $field->postCustomFieldName, $value );
833 833
 				        break;
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
 				}
840 840
 
841 841
 				// update entry after
842
-				$this->entry["{$field_id}"] = $value;
842
+				$this->entry[ "{$field_id}" ] = $value;
843 843
 
844 844
 				$update_entry = true;
845 845
 
@@ -848,11 +848,11 @@  discard block
 block discarded – undo
848 848
 
849 849
 		}
850 850
 
851
-		if( $update_entry ) {
851
+		if ( $update_entry ) {
852 852
 
853 853
 			$return_entry = GFAPI::update_entry( $this->entry );
854 854
 
855
-			if( is_wp_error( $return_entry ) ) {
855
+			if ( is_wp_error( $return_entry ) ) {
856 856
 				gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) );
857 857
 			} else {
858 858
 				gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) );
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 
863 863
 		$return_post = wp_update_post( $updated_post, true );
864 864
 
865
-		if( is_wp_error( $return_post ) ) {
865
+		if ( is_wp_error( $return_post ) ) {
866 866
 			$return_post->add_data( $updated_post, '$updated_post' );
867 867
 			gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) );
868 868
 		} else {
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 		$output = GFCommon::replace_variables( $output, $form, $entry, false, false, false );
897 897
 
898 898
 		// replace conditional shortcodes
899
-		if( $do_shortcode ) {
899
+		if ( $do_shortcode ) {
900 900
 			$output = do_shortcode( $output );
901 901
 		}
902 902
 
@@ -915,19 +915,19 @@  discard block
 block discarded – undo
915 915
 	 */
916 916
 	private function after_update() {
917 917
 
918
-		do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry );
919
-		do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry );
918
+		do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry );
919
+		do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry );
920 920
 
921 921
 		// Re-define the entry now that we've updated it.
922
-		$entry = RGFormsModel::get_lead( $this->entry['id'] );
922
+		$entry = RGFormsModel::get_lead( $this->entry[ 'id' ] );
923 923
 
924 924
 		$entry = GFFormsModel::set_entry_meta( $entry, self::$original_form );
925 925
 
926 926
 		if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) {
927 927
 			// We need to clear the cache because Gravity Forms caches the field values, which
928 928
 			// we have just updated.
929
-			foreach ($this->form['fields'] as $key => $field) {
930
-				GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );
929
+			foreach ( $this->form[ 'fields' ] as $key => $field ) {
930
+				GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id );
931 931
 			}
932 932
 		}
933 933
 
@@ -937,11 +937,11 @@  discard block
 block discarded – undo
937 937
 		 * @since develop
938 938
 		 */
939 939
 		if ( $allowed_feeds = $this->view->settings->get( 'edit_feeds', array() ) ) {
940
-			$feeds = GFAPI::get_feeds( null, $entry['form_id'] );
940
+			$feeds = GFAPI::get_feeds( null, $entry[ 'form_id' ] );
941 941
 			if ( ! is_wp_error( $feeds ) ) {
942 942
 				$registered_feeds = array();
943 943
 				foreach ( GFAddOn::get_registered_addons() as $registered_feed ) {
944
-					if ( is_subclass_of( $registered_feed,  'GFFeedAddOn' ) ) {
944
+					if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) {
945 945
 						if ( method_exists( $registered_feed, 'get_instance' ) ) {
946 946
 							$registered_feed = call_user_func( array( $registered_feed, 'get_instance' ) );
947 947
 							$registered_feeds[ $registered_feed->get_slug() ] = $registered_feed;
@@ -949,8 +949,8 @@  discard block
 block discarded – undo
949 949
 					}
950 950
 				}
951 951
 				foreach ( $feeds as $feed ) {
952
-					if ( in_array( $feed['id'], $allowed_feeds ) ) {
953
-						if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed['addon_slug'] ) ) {
952
+					if ( in_array( $feed[ 'id' ], $allowed_feeds ) ) {
953
+						if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed[ 'addon_slug' ] ) ) {
954 954
 							$returned_entry = $feed_object->process_feed( $feed, $entry, self::$original_form );
955 955
 							if ( is_array( $returned_entry ) && rgar( $returned_entry, 'id' ) ) {
956 956
 								$entry = $returned_entry;
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
 
981 981
 		<div class="gv-edit-entry-wrapper"><?php
982 982
 
983
-			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );
983
+			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this );
984 984
 
985 985
 			/**
986 986
 			 * Fixes weird wpautop() issue
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
 				     * @param string $edit_entry_title Modify the "Edit Entry" title
997 997
 				     * @param GravityView_Edit_Entry_Render $this This object
998 998
 				     */
999
-				    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
999
+				    $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this );
1000 1000
 
1001 1001
 				    echo esc_attr( $edit_entry_title );
1002 1002
 			?></span>
@@ -1062,18 +1062,18 @@  discard block
 block discarded – undo
1062 1062
 				*/
1063 1063
 				$labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id );
1064 1064
 
1065
-				$this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit'];
1065
+				$this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels[ 'submit' ];
1066 1066
 			}
1067 1067
 
1068 1068
 			$back_link = remove_query_arg( array( 'page', 'view', 'edit' ) );
1069 1069
 
1070
-			if( ! $this->is_valid ){
1070
+			if ( ! $this->is_valid ) {
1071 1071
 
1072 1072
 				// Keeping this compatible with Gravity Forms.
1073
-				$validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
1074
-				$message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form);
1073
+				$validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>";
1074
+				$message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form );
1075 1075
 
1076
-				echo GVCommon::generate_notice( $message , 'gv-error' );
1076
+				echo GVCommon::generate_notice( $message, 'gv-error' );
1077 1077
 
1078 1078
 			} elseif ( false === $this->is_paged_submitted ) {
1079 1079
 				// Paged form that hasn't been submitted on the last page yet
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
 				 * @param int $view_id View ID
1087 1087
 				 * @param array $entry Gravity Forms entry array
1088 1088
 				 */
1089
-				$message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message , $this->view_id, $this->entry );
1089
+				$message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message, $this->view_id, $this->entry );
1090 1090
 
1091 1091
 				echo GVCommon::generate_notice( $message );
1092 1092
 			} else {
@@ -1098,23 +1098,23 @@  discard block
 block discarded – undo
1098 1098
 
1099 1099
                     case '0':
1100 1100
 	                    $redirect_url = $back_link;
1101
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
1101
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' );
1102 1102
                         break;
1103 1103
 
1104 1104
                     case '1':
1105 1105
 	                    $redirect_url = $directory_link = GravityView_API::directory_link();
1106
-	                    $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>' );
1106
+	                    $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>' );
1107 1107
 	                    break;
1108 1108
 
1109 1109
                     case '2':
1110 1110
 	                    $redirect_url = $edit_redirect_url;
1111 1111
 	                    $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
1112
-	                    $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>' );
1112
+	                    $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>' );
1113 1113
                         break;
1114 1114
 
1115 1115
                     case '':
1116 1116
                     default:
1117
-					    $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
1117
+					    $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' );
1118 1118
                         break;
1119 1119
 				}
1120 1120
 
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 				 * @param array $entry Gravity Forms entry array
1131 1131
 				 * @param string $back_link URL to return to the original entry. @since 1.6
1132 1132
 				 */
1133
-				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );
1133
+				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link );
1134 1134
 
1135 1135
 				echo GVCommon::generate_notice( $message );
1136 1136
 			}
@@ -1154,8 +1154,8 @@  discard block
 block discarded – undo
1154 1154
 		 */
1155 1155
 		do_action( 'gravityview/edit-entry/render/before', $this );
1156 1156
 
1157
-		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );
1158
-		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );
1157
+		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 );
1158
+		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
1159 1159
 		add_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) );
1160 1160
 		add_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) );
1161 1161
 		add_filter( 'gform_disable_view_counter', '__return_true' );
@@ -1164,14 +1164,14 @@  discard block
 block discarded – undo
1164 1164
 		add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );
1165 1165
 
1166 1166
 		// We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.
1167
-		unset( $_GET['page'] );
1167
+		unset( $_GET[ 'page' ] );
1168 1168
 
1169 1169
 		$this->show_next_button = false;
1170 1170
 		$this->show_previous_button = false;
1171 1171
 
1172 1172
 		// TODO: Verify multiple-page forms
1173 1173
 		if ( GFCommon::has_pages( $this->form ) && apply_filters( 'gravityview/features/paged-edit', false ) ) {
1174
-			if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form['id'], 0 ) ) ) {
1174
+			if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form[ 'id' ], 0 ) ) ) {
1175 1175
 
1176 1176
 				$labels = array(
1177 1177
 					'cancel'   => __( 'Cancel', 'gravityview' ),
@@ -1190,16 +1190,16 @@  discard block
 block discarded – undo
1190 1190
 				*/
1191 1191
 				$labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id );
1192 1192
 
1193
-				GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form;
1194
-				GFFormDisplay::$submission[ $this->form['id'] ][ 'is_valid' ] = true;
1193
+				GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'form' ] = $this->form;
1194
+				GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'is_valid' ] = true;
1195 1195
 
1196
-				if ( \GV\Utils::_POST( 'save' ) === $labels['next'] ) {
1196
+				if ( \GV\Utils::_POST( 'save' ) === $labels[ 'next' ] ) {
1197 1197
 					$page_number++;
1198
-				} elseif ( \GV\Utils::_POST( 'save' ) === $labels['previous'] ) {
1198
+				} elseif ( \GV\Utils::_POST( 'save' ) === $labels[ 'previous' ] ) {
1199 1199
 					$page_number--;
1200 1200
 				}
1201 1201
 
1202
-				GFFormDisplay::$submission[ $this->form['id'] ][ 'page_number' ] = $page_number;
1202
+				GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'page_number' ] = $page_number;
1203 1203
 			}
1204 1204
 
1205 1205
 			if ( ( $page_number = intval( $page_number ) ) < 2 ) {
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
 
1226 1226
 		ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic
1227 1227
 
1228
-		$html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );
1228
+		$html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry );
1229 1229
 
1230 1230
 		ob_get_clean();
1231 1231
 
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 	 * @return string
1254 1254
 	 */
1255 1255
 	public function render_form_buttons() {
1256
-		return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );
1256
+		return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this );
1257 1257
 	}
1258 1258
 
1259 1259
 
@@ -1273,10 +1273,10 @@  discard block
 block discarded – undo
1273 1273
 	public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) {
1274 1274
 
1275 1275
 		// In case we have validated the form, use it to inject the validation results into the form render
1276
-		if( isset( $this->form_after_validation ) && $this->form_after_validation['id'] === $form['id'] ) {
1276
+		if ( isset( $this->form_after_validation ) && $this->form_after_validation[ 'id' ] === $form[ 'id' ] ) {
1277 1277
 			$form = $this->form_after_validation;
1278 1278
 		} else {
1279
-			$form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );
1279
+			$form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id );
1280 1280
 		}
1281 1281
 
1282 1282
 		$form = $this->filter_conditional_logic( $form );
@@ -1284,8 +1284,8 @@  discard block
 block discarded – undo
1284 1284
 		$form = $this->prefill_conditional_logic( $form );
1285 1285
 
1286 1286
 		// for now we don't support Save and Continue feature.
1287
-		if( ! self::$supports_save_and_continue ) {
1288
-	        unset( $form['save'] );
1287
+		if ( ! self::$supports_save_and_continue ) {
1288
+	        unset( $form[ 'save' ] );
1289 1289
 		}
1290 1290
 
1291 1291
 		$form = $this->unselect_default_values( $form );
@@ -1308,31 +1308,31 @@  discard block
 block discarded – undo
1308 1308
 	 */
1309 1309
 	public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) {
1310 1310
 
1311
-		if( ! GFCommon::is_post_field( $field ) ) {
1311
+		if ( ! GFCommon::is_post_field( $field ) ) {
1312 1312
 			return $field_content;
1313 1313
 		}
1314 1314
 
1315 1315
         $message = null;
1316 1316
 
1317 1317
         // First, make sure they have the capability to edit the post.
1318
-        if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1318
+        if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) {
1319 1319
 
1320 1320
             /**
1321 1321
              * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1322 1322
              * @param string $message The existing "You don't have permission..." text
1323 1323
              */
1324
-            $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1324
+            $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don&rsquo;t have permission to edit this post.', 'gravityview' ) );
1325 1325
 
1326
-        } elseif( null === get_post( $this->entry['post_id'] ) ) {
1326
+        } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) {
1327 1327
             /**
1328 1328
              * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1329 1329
              * @param string $message The existing "This field is not editable; the post no longer exists." text
1330 1330
              */
1331
-            $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1331
+            $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) );
1332 1332
         }
1333 1333
 
1334
-        if( $message ) {
1335
-            $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1334
+        if ( $message ) {
1335
+            $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1336 1336
         }
1337 1337
 
1338 1338
         return $field_content;
@@ -1356,8 +1356,8 @@  discard block
 block discarded – undo
1356 1356
 
1357 1357
 		// If the form has been submitted, then we don't need to pre-fill the values,
1358 1358
 		// Except for fileupload type and when a field input is overridden- run always!!
1359
-		if(
1360
-			( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1359
+		if (
1360
+			( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1361 1361
 			&& false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) )
1362 1362
 			&& ! GFCommon::is_product_field( $field->type )
1363 1363
 			|| ! empty( $field_content )
@@ -1377,7 +1377,7 @@  discard block
 block discarded – undo
1377 1377
 	    $return = null;
1378 1378
 
1379 1379
 		/** @var GravityView_Field $gv_field */
1380
-		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1380
+		if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1381 1381
 			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1382 1382
 		} else {
1383 1383
 	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
@@ -1386,7 +1386,7 @@  discard block
 block discarded – undo
1386 1386
 	    // If there was output, it's an error
1387 1387
 	    $warnings = ob_get_clean();
1388 1388
 
1389
-	    if( !empty( $warnings ) ) {
1389
+	    if ( ! empty( $warnings ) ) {
1390 1390
 		    gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1391 1391
 	    }
1392 1392
 
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
 		$override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );
1412 1412
 
1413 1413
 		// We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)
1414
-		if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) {
1414
+		if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) {
1415 1415
 
1416 1416
 			$field_value = array();
1417 1417
 
@@ -1420,10 +1420,10 @@  discard block
 block discarded – undo
1420 1420
 
1421 1421
 			foreach ( (array)$field->inputs as $input ) {
1422 1422
 
1423
-				$input_id = strval( $input['id'] );
1423
+				$input_id = strval( $input[ 'id' ] );
1424 1424
 
1425 1425
 				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1426
-				    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1426
+				    $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1427 1427
 				    $allow_pre_populated = false;
1428 1428
 				}
1429 1429
 
@@ -1431,7 +1431,7 @@  discard block
 block discarded – undo
1431 1431
 
1432 1432
 			$pre_value = $field->get_value_submission( array(), false );
1433 1433
 
1434
-			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1434
+			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1435 1435
 
1436 1436
 		} else {
1437 1437
 
@@ -1442,13 +1442,13 @@  discard block
 block discarded – undo
1442 1442
 
1443 1443
 			// saved field entry value (if empty, fallback to the pre-populated value, if exists)
1444 1444
 			// or pre-populated value if not empty and set to override saved value
1445
-			$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;
1445
+			$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;
1446 1446
 
1447 1447
 			// in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.
1448
-			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1448
+			if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) {
1449 1449
 				$categories = array();
1450 1450
 				foreach ( explode( ',', $field_value ) as $cat_string ) {
1451
-				    $categories[] = GFCommon::format_post_category( $cat_string, true );
1451
+				    $categories[ ] = GFCommon::format_post_category( $cat_string, true );
1452 1452
 				}
1453 1453
 				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1454 1454
 			}
@@ -1476,7 +1476,7 @@  discard block
 block discarded – undo
1476 1476
 	     * @param GF_Field $field Gravity Forms field object
1477 1477
 	     * @param GravityView_Edit_Entry_Render $this Current object
1478 1478
 	     */
1479
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1479
+	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this );
1480 1480
 
1481 1481
 		return $field_value;
1482 1482
 	}
@@ -1493,12 +1493,12 @@  discard block
 block discarded – undo
1493 1493
 	 */
1494 1494
 	public function gform_pre_validation( $form ) {
1495 1495
 
1496
-		if( ! $this->verify_nonce() ) {
1496
+		if ( ! $this->verify_nonce() ) {
1497 1497
 			return $form;
1498 1498
 		}
1499 1499
 
1500 1500
 		// Fix PHP warning regarding undefined index.
1501
-		foreach ( $form['fields'] as &$field) {
1501
+		foreach ( $form[ 'fields' ] as &$field ) {
1502 1502
 
1503 1503
 			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1504 1504
 			// expects certain field array items to be set.
@@ -1506,7 +1506,7 @@  discard block
 block discarded – undo
1506 1506
 	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1507 1507
 			}
1508 1508
 
1509
-			switch( RGFormsModel::get_input_type( $field ) ) {
1509
+			switch ( RGFormsModel::get_input_type( $field ) ) {
1510 1510
 
1511 1511
 				/**
1512 1512
 				 * 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.
@@ -1520,26 +1520,26 @@  discard block
 block discarded – undo
1520 1520
 				    // Set the previous value
1521 1521
 				    $entry = $this->get_entry();
1522 1522
 
1523
-				    $input_name = 'input_'.$field->id;
1524
-				    $form_id = $form['id'];
1523
+				    $input_name = 'input_' . $field->id;
1524
+				    $form_id = $form[ 'id' ];
1525 1525
 
1526 1526
 				    $value = NULL;
1527 1527
 
1528 1528
 				    // Use the previous entry value as the default.
1529
-				    if( isset( $entry[ $field->id ] ) ) {
1529
+				    if ( isset( $entry[ $field->id ] ) ) {
1530 1530
 				        $value = $entry[ $field->id ];
1531 1531
 				    }
1532 1532
 
1533 1533
 				    // If this is a single upload file
1534
-				    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1535
-				        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1536
-				        $value = $file_path['url'];
1534
+				    if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
1535
+				        $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] );
1536
+				        $value = $file_path[ 'url' ];
1537 1537
 
1538 1538
 				    } else {
1539 1539
 
1540 1540
 				        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1541 1541
 				        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1542
-				        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1542
+				        $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' );
1543 1543
 
1544 1544
 				    }
1545 1545
 
@@ -1547,10 +1547,10 @@  discard block
 block discarded – undo
1547 1547
 
1548 1548
 				        // If there are fresh uploads, process and merge them.
1549 1549
 				        // Otherwise, use the passed values, which should be json-encoded array of URLs
1550
-				        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1550
+				        if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) {
1551 1551
 				            $value = empty( $value ) ? '[]' : $value;
1552 1552
 				            $value = stripslashes_deep( $value );
1553
-				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1553
+				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() );
1554 1554
 				        }
1555 1555
 
1556 1556
 				    } else {
@@ -1568,8 +1568,8 @@  discard block
 block discarded – undo
1568 1568
 
1569 1569
 				case 'number':
1570 1570
 				    // Fix "undefined index" issue at line 1286 in form_display.php
1571
-				    if( !isset( $_POST['input_'.$field->id ] ) ) {
1572
-				        $_POST['input_'.$field->id ] = NULL;
1571
+				    if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) {
1572
+				        $_POST[ 'input_' . $field->id ] = NULL;
1573 1573
 				    }
1574 1574
 				    break;
1575 1575
 			}
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
 		 * You can enter whatever you want!
1607 1607
 		 * We try validating, and customize the results using `self::custom_validation()`
1608 1608
 		 */
1609
-		add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);
1609
+		add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 );
1610 1610
 
1611 1611
 		// Needed by the validate funtion
1612 1612
 		$failed_validation_page = NULL;
@@ -1614,14 +1614,14 @@  discard block
 block discarded – undo
1614 1614
 
1615 1615
 		// Prevent entry limit from running when editing an entry, also
1616 1616
 		// prevent form scheduling from preventing editing
1617
-		unset( $this->form['limitEntries'], $this->form['scheduleForm'] );
1617
+		unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] );
1618 1618
 
1619 1619
 		// Hide fields depending on Edit Entry settings
1620
-		$this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1620
+		$this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1621 1621
 
1622 1622
 		$this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );
1623 1623
 
1624
-		remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 );
1624
+		remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 );
1625 1625
 	}
1626 1626
 
1627 1627
 
@@ -1644,7 +1644,7 @@  discard block
 block discarded – undo
1644 1644
 
1645 1645
 		$gv_valid = true;
1646 1646
 
1647
-		foreach ( $validation_results['form']['fields'] as $key => &$field ) {
1647
+		foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) {
1648 1648
 
1649 1649
 			$value = RGFormsModel::get_field_value( $field );
1650 1650
 			$field_type = RGFormsModel::get_input_type( $field );
@@ -1657,22 +1657,22 @@  discard block
 block discarded – undo
1657 1657
 				case 'post_image':
1658 1658
 
1659 1659
 				    // in case nothing is uploaded but there are already files saved
1660
-				    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1660
+				    if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) {
1661 1661
 				        $field->failed_validation = false;
1662 1662
 				        unset( $field->validation_message );
1663 1663
 				    }
1664 1664
 
1665 1665
 				    // validate if multi file upload reached max number of files [maxFiles] => 2
1666
-				    if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1666
+				    if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) {
1667 1667
 
1668 1668
 				        $input_name = 'input_' . $field->id;
1669 1669
 				        //uploaded
1670
-				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1670
+				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array();
1671 1671
 
1672 1672
 				        //existent
1673 1673
 				        $entry = $this->get_entry();
1674 1674
 				        $value = NULL;
1675
-				        if( isset( $entry[ $field->id ] ) ) {
1675
+				        if ( isset( $entry[ $field->id ] ) ) {
1676 1676
 				            $value = json_decode( $entry[ $field->id ], true );
1677 1677
 				        }
1678 1678
 
@@ -1680,13 +1680,13 @@  discard block
 block discarded – undo
1680 1680
 				        $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) +
1681 1681
 						               ( is_array( $value ) ? count( $value ) : 0 );
1682 1682
 
1683
-				        if( $count_files > $field->maxFiles ) {
1683
+				        if ( $count_files > $field->maxFiles ) {
1684 1684
 				            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1685 1685
 				            $field->failed_validation = 1;
1686 1686
 				            $gv_valid = false;
1687 1687
 
1688 1688
 				            // in case of error make sure the newest upload files are removed from the upload input
1689
-				            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1689
+				            GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null;
1690 1690
 				        }
1691 1691
 
1692 1692
 				    }
@@ -1697,7 +1697,7 @@  discard block
 block discarded – undo
1697 1697
 			}
1698 1698
 
1699 1699
 			// This field has failed validation.
1700
-			if( !empty( $field->failed_validation ) ) {
1700
+			if ( ! empty( $field->failed_validation ) ) {
1701 1701
 
1702 1702
 				gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) );
1703 1703
 
@@ -1715,19 +1715,19 @@  discard block
 block discarded – undo
1715 1715
 				}
1716 1716
 
1717 1717
 				// You can't continue inside a switch, so we do it after.
1718
-				if( empty( $field->failed_validation ) ) {
1718
+				if ( empty( $field->failed_validation ) ) {
1719 1719
 				    continue;
1720 1720
 				}
1721 1721
 
1722 1722
 				// checks if the No Duplicates option is not validating entry against itself, since
1723 1723
 				// we're editing a stored entry, it would also assume it's a duplicate.
1724
-				if( !empty( $field->noDuplicates ) ) {
1724
+				if ( ! empty( $field->noDuplicates ) ) {
1725 1725
 
1726 1726
 				    $entry = $this->get_entry();
1727 1727
 
1728 1728
 				    // If the value of the entry is the same as the stored value
1729 1729
 				    // Then we can assume it's not a duplicate, it's the same.
1730
-				    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1730
+				    if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) {
1731 1731
 				        //if value submitted was not changed, then don't validate
1732 1732
 				        $field->failed_validation = false;
1733 1733
 
@@ -1740,7 +1740,7 @@  discard block
 block discarded – undo
1740 1740
 				}
1741 1741
 
1742 1742
 				// if here then probably we are facing the validation 'At least one field must be filled out'
1743
-				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1743
+				if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) {
1744 1744
 				    unset( $field->validation_message );
1745 1745
 	                $field->validation_message = false;
1746 1746
 				    continue;
@@ -1752,12 +1752,12 @@  discard block
 block discarded – undo
1752 1752
 
1753 1753
 		}
1754 1754
 
1755
-		$validation_results['is_valid'] = $gv_valid;
1755
+		$validation_results[ 'is_valid' ] = $gv_valid;
1756 1756
 
1757 1757
 		gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) );
1758 1758
 
1759 1759
 		// We'll need this result when rendering the form ( on GFFormDisplay::get_form )
1760
-		$this->form_after_validation = $validation_results['form'];
1760
+		$this->form_after_validation = $validation_results[ 'form' ];
1761 1761
 
1762 1762
 		return $validation_results;
1763 1763
 	}
@@ -1770,7 +1770,7 @@  discard block
 block discarded – undo
1770 1770
 	 */
1771 1771
 	public function get_entry() {
1772 1772
 
1773
-		if( empty( $this->entry ) ) {
1773
+		if ( empty( $this->entry ) ) {
1774 1774
 			// Get the database value of the entry that's being edited
1775 1775
 			$this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );
1776 1776
 		}
@@ -1802,10 +1802,10 @@  discard block
 block discarded – undo
1802 1802
 		}
1803 1803
 
1804 1804
 		// If edit tab not yet configured, show all fields
1805
-		$edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;
1805
+		$edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL;
1806 1806
 
1807 1807
 		// Hide fields depending on admin settings
1808
-		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1808
+		$fields = $this->filter_fields( $form[ 'fields' ], $edit_fields );
1809 1809
 
1810 1810
 	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1811 1811
 	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
@@ -1838,7 +1838,7 @@  discard block
 block discarded – undo
1838 1838
 	 */
1839 1839
 	private function filter_fields( $fields, $configured_fields ) {
1840 1840
 
1841
-		if( empty( $fields ) || !is_array( $fields ) ) {
1841
+		if ( empty( $fields ) || ! is_array( $fields ) ) {
1842 1842
 			return $fields;
1843 1843
 		}
1844 1844
 
@@ -1855,12 +1855,12 @@  discard block
 block discarded – undo
1855 1855
 
1856 1856
 			// Remove the fields that have calculation properties and keep them to be used later
1857 1857
 			// @since 1.16.2
1858
-			if( $field->has_calculation() ) {
1859
-				$this->fields_with_calculation[] = $field;
1858
+			if ( $field->has_calculation() ) {
1859
+				$this->fields_with_calculation[ ] = $field;
1860 1860
 				// don't remove the calculation fields on form render.
1861 1861
 			}
1862 1862
 
1863
-			if( in_array( $field->type, $field_type_blacklist ) ) {
1863
+			if ( in_array( $field->type, $field_type_blacklist ) ) {
1864 1864
 				unset( $fields[ $key ] );
1865 1865
 			}
1866 1866
 		}
@@ -1878,7 +1878,7 @@  discard block
 block discarded – undo
1878 1878
 					continue; // Same
1879 1879
 				}
1880 1880
 
1881
-				$out_fields[] = $field;
1881
+				$out_fields[ ] = $field;
1882 1882
 			}
1883 1883
 
1884 1884
 			return array_values( $out_fields );
@@ -1889,8 +1889,8 @@  discard block
 block discarded – undo
1889 1889
 
1890 1890
 	        /** @var GF_Field $field */
1891 1891
 	        foreach ( $fields as $field ) {
1892
-				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1893
-				    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1892
+				if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1893
+				    $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field );
1894 1894
 				    break;
1895 1895
 				}
1896 1896
 
@@ -1913,14 +1913,14 @@  discard block
 block discarded – undo
1913 1913
 
1914 1914
 		$return_field = $field;
1915 1915
 
1916
-		if( empty( $field_setting['show_label'] ) ) {
1916
+		if ( empty( $field_setting[ 'show_label' ] ) ) {
1917 1917
 			$return_field->label = '';
1918
-		} elseif ( !empty( $field_setting['custom_label'] ) ) {
1919
-			$return_field->label = $field_setting['custom_label'];
1918
+		} elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) {
1919
+			$return_field->label = $field_setting[ 'custom_label' ];
1920 1920
 		}
1921 1921
 
1922
-		if( !empty( $field_setting['custom_class'] ) ) {
1923
-			$return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );
1922
+		if ( ! empty( $field_setting[ 'custom_class' ] ) ) {
1923
+			$return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] );
1924 1924
 		}
1925 1925
 
1926 1926
 		/**
@@ -1958,16 +1958,16 @@  discard block
 block discarded – undo
1958 1958
 	     */
1959 1959
 	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1960 1960
 
1961
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1962
-			foreach( $fields as $k => $field ) {
1963
-				if( $field->adminOnly ) {
1961
+	    if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) {
1962
+			foreach ( $fields as $k => $field ) {
1963
+				if ( $field->adminOnly ) {
1964 1964
 				    unset( $fields[ $k ] );
1965 1965
 				}
1966 1966
 			}
1967 1967
 			return array_values( $fields );
1968 1968
 		}
1969 1969
 
1970
-	    foreach( $fields as &$field ) {
1970
+	    foreach ( $fields as &$field ) {
1971 1971
 		    $field->adminOnly = false;
1972 1972
 		}
1973 1973
 
@@ -1988,7 +1988,7 @@  discard block
 block discarded – undo
1988 1988
 	 */
1989 1989
 	private function unselect_default_values( $form ) {
1990 1990
 
1991
-	    foreach ( $form['fields'] as &$field ) {
1991
+	    foreach ( $form[ 'fields' ] as &$field ) {
1992 1992
 
1993 1993
 			if ( empty( $field->choices ) ) {
1994 1994
                 continue;
@@ -1996,7 +1996,7 @@  discard block
 block discarded – undo
1996 1996
 
1997 1997
             foreach ( $field->choices as &$choice ) {
1998 1998
 				if ( \GV\Utils::get( $choice, 'isSelected' ) ) {
1999
-					$choice['isSelected'] = false;
1999
+					$choice[ 'isSelected' ] = false;
2000 2000
 				}
2001 2001
 			}
2002 2002
 		}
@@ -2021,22 +2021,22 @@  discard block
 block discarded – undo
2021 2021
 	 */
2022 2022
 	function prefill_conditional_logic( $form ) {
2023 2023
 
2024
-		if( ! GFFormDisplay::has_conditional_logic( $form ) ) {
2024
+		if ( ! GFFormDisplay::has_conditional_logic( $form ) ) {
2025 2025
 			return $form;
2026 2026
 		}
2027 2027
 
2028 2028
 		// Have Conditional Logic pre-fill fields as if the data were default values
2029 2029
 		/** @var GF_Field $field */
2030
-		foreach ( $form['fields'] as &$field ) {
2030
+		foreach ( $form[ 'fields' ] as &$field ) {
2031 2031
 
2032
-			if( 'checkbox' === $field->type ) {
2032
+			if ( 'checkbox' === $field->type ) {
2033 2033
 				foreach ( $field->get_entry_inputs() as $key => $input ) {
2034
-				    $input_id = $input['id'];
2034
+				    $input_id = $input[ 'id' ];
2035 2035
 				    $choice = $field->choices[ $key ];
2036 2036
 				    $value = \GV\Utils::get( $this->entry, $input_id );
2037 2037
 				    $match = RGFormsModel::choice_value_match( $field, $choice, $value );
2038
-				    if( $match ) {
2039
-				        $field->choices[ $key ]['isSelected'] = true;
2038
+				    if ( $match ) {
2039
+				        $field->choices[ $key ][ 'isSelected' ] = true;
2040 2040
 				    }
2041 2041
 				}
2042 2042
 			} else {
@@ -2044,15 +2044,15 @@  discard block
 block discarded – undo
2044 2044
 				// We need to run through each field to set the default values
2045 2045
 				foreach ( $this->entry as $field_id => $field_value ) {
2046 2046
 
2047
-				    if( floatval( $field_id ) === floatval( $field->id ) ) {
2047
+				    if ( floatval( $field_id ) === floatval( $field->id ) ) {
2048 2048
 
2049
-				        if( 'list' === $field->type ) {
2049
+				        if ( 'list' === $field->type ) {
2050 2050
 				            $list_rows = maybe_unserialize( $field_value );
2051 2051
 
2052 2052
 				            $list_field_value = array();
2053
-				            foreach ( (array) $list_rows as $row ) {
2054
-				                foreach ( (array) $row as $column ) {
2055
-				                    $list_field_value[] = $column;
2053
+				            foreach ( (array)$list_rows as $row ) {
2054
+				                foreach ( (array)$row as $column ) {
2055
+				                    $list_field_value[ ] = $column;
2056 2056
 				                }
2057 2057
 				            }
2058 2058
 
@@ -2085,32 +2085,32 @@  discard block
 block discarded – undo
2085 2085
 		 * @see https://github.com/gravityview/GravityView/issues/840
2086 2086
 		 * @since develop
2087 2087
 		 */
2088
-		$the_form = GFAPI::get_form( $form['id'] );
2088
+		$the_form = GFAPI::get_form( $form[ 'id' ] );
2089 2089
 		$editable_ids = array();
2090
-		foreach ( $form['fields'] as $field ) {
2091
-			$editable_ids[] = $field['id']; // wp_list_pluck is destructive in this context
2090
+		foreach ( $form[ 'fields' ] as $field ) {
2091
+			$editable_ids[ ] = $field[ 'id' ]; // wp_list_pluck is destructive in this context
2092 2092
 		}
2093 2093
 		$remove_conditions_rule = array();
2094
-		foreach ( $the_form['fields'] as $field ) {
2095
-			if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic['rules'] ) ) {
2096
-				foreach ( $field->conditionalLogic['rules'] as $i => $rule ) {
2097
-					if ( ! in_array( $rule['fieldId'], $editable_ids ) ) {
2094
+		foreach ( $the_form[ 'fields' ] as $field ) {
2095
+			if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic[ 'rules' ] ) ) {
2096
+				foreach ( $field->conditionalLogic[ 'rules' ] as $i => $rule ) {
2097
+					if ( ! in_array( $rule[ 'fieldId' ], $editable_ids ) ) {
2098 2098
 						/**
2099 2099
 						 * This conditional field is not editable in this View.
2100 2100
 						 * We need to remove the rule, but only if it matches.
2101 2101
 						 */
2102
-						if ( $_field = GFAPI::get_field( $the_form, $rule['fieldId'] ) ) {
2102
+						if ( $_field = GFAPI::get_field( $the_form, $rule[ 'fieldId' ] ) ) {
2103 2103
 							$value = $_field->get_value_export( $this->entry );
2104
-						} elseif ( isset( $this->entry[ $rule['fieldId'] ] ) ) {
2105
-							$value = $this->entry[ $rule['fieldId'] ];
2104
+						} elseif ( isset( $this->entry[ $rule[ 'fieldId' ] ] ) ) {
2105
+							$value = $this->entry[ $rule[ 'fieldId' ] ];
2106 2106
 						} else {
2107
-							$value = gform_get_meta( $this->entry['id'], $rule['fieldId'] );
2107
+							$value = gform_get_meta( $this->entry[ 'id' ], $rule[ 'fieldId' ] );
2108 2108
 						}
2109 2109
 
2110
-						$match = GFFormsModel::matches_operation( $value, $rule['value'], $rule['operator'] );
2110
+						$match = GFFormsModel::matches_operation( $value, $rule[ 'value' ], $rule[ 'operator' ] );
2111 2111
 						
2112 2112
 						if ( $match ) {
2113
-							$remove_conditions_rule[] = array( $field['id'], $i );
2113
+							$remove_conditions_rule[ ] = array( $field[ 'id' ], $i );
2114 2114
 						}
2115 2115
 					}
2116 2116
 				}
@@ -2118,21 +2118,21 @@  discard block
 block discarded – undo
2118 2118
 		}
2119 2119
 
2120 2120
 		if ( $remove_conditions_rule ) {
2121
-			foreach ( $form['fields'] as &$field ) {
2121
+			foreach ( $form[ 'fields' ] as &$field ) {
2122 2122
 				foreach ( $remove_conditions_rule as $_remove_conditions_r ) {
2123 2123
 
2124 2124
 				    list( $rule_field_id, $rule_i ) = $_remove_conditions_r;
2125 2125
 
2126
-					if ( $field['id'] == $rule_field_id ) {
2127
-						unset( $field->conditionalLogic['rules'][ $rule_i ] );
2128
-						gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field['id'] ) );
2126
+					if ( $field[ 'id' ] == $rule_field_id ) {
2127
+						unset( $field->conditionalLogic[ 'rules' ][ $rule_i ] );
2128
+						gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field[ 'id' ] ) );
2129 2129
 					}
2130 2130
 				}
2131 2131
 			}
2132 2132
 		}
2133 2133
 
2134 2134
 		/** Normalize the indices... */
2135
-		$form['fields'] = array_values( $form['fields'] );
2135
+		$form[ 'fields' ] = array_values( $form[ 'fields' ] );
2136 2136
 
2137 2137
 		/**
2138 2138
 		 * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields?
@@ -2142,16 +2142,16 @@  discard block
 block discarded – undo
2142 2142
 		 */
2143 2143
 		$use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );
2144 2144
 
2145
-		if( $use_conditional_logic ) {
2145
+		if ( $use_conditional_logic ) {
2146 2146
 			return $form;
2147 2147
 		}
2148 2148
 
2149
-		foreach( $form['fields'] as &$field ) {
2149
+		foreach ( $form[ 'fields' ] as &$field ) {
2150 2150
 			/* @var GF_Field $field */
2151 2151
 			$field->conditionalLogic = null;
2152 2152
 		}
2153 2153
 
2154
-		unset( $form['button']['conditionalLogic'] );
2154
+		unset( $form[ 'button' ][ 'conditionalLogic' ] );
2155 2155
 
2156 2156
 		return $form;
2157 2157
 
@@ -2168,7 +2168,7 @@  discard block
 block discarded – undo
2168 2168
 	 */
2169 2169
 	public function manage_conditional_logic( $has_conditional_logic, $form ) {
2170 2170
 
2171
-		if( ! $this->is_edit_entry() ) {
2171
+		if ( ! $this->is_edit_entry() ) {
2172 2172
 			return $has_conditional_logic;
2173 2173
 		}
2174 2174
 
@@ -2200,44 +2200,44 @@  discard block
 block discarded – undo
2200 2200
 		 *  2. There are two entries embedded using oEmbed
2201 2201
 		 *  3. One of the entries has just been saved
2202 2202
 		 */
2203
-		if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) {
2203
+		if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) {
2204 2204
 
2205 2205
 			$error = true;
2206 2206
 
2207 2207
 		}
2208 2208
 
2209
-		if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) {
2209
+		if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) {
2210 2210
 
2211 2211
 			$error = true;
2212 2212
 
2213
-		} elseif( ! $this->verify_nonce() ) {
2213
+		} elseif ( ! $this->verify_nonce() ) {
2214 2214
 
2215 2215
 			/**
2216 2216
 			 * If the Entry is embedded, there may be two entries on the same page.
2217 2217
 			 * If that's the case, and one is being edited, the other should fail gracefully and not display an error.
2218 2218
 			 */
2219
-			if( GravityView_oEmbed::getInstance()->get_entry_id() ) {
2219
+			if ( GravityView_oEmbed::getInstance()->get_entry_id() ) {
2220 2220
 				$error = true;
2221 2221
 			} else {
2222
-				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');
2222
+				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' );
2223 2223
 			}
2224 2224
 
2225 2225
 		}
2226 2226
 
2227
-		if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
2228
-			$error = __( 'You do not have permission to edit this entry.', 'gravityview');
2227
+		if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
2228
+			$error = __( 'You do not have permission to edit this entry.', 'gravityview' );
2229 2229
 		}
2230 2230
 
2231
-		if( $this->entry['status'] === 'trash' ) {
2232
-			$error = __('You cannot edit the entry; it is in the trash.', 'gravityview' );
2231
+		if ( $this->entry[ 'status' ] === 'trash' ) {
2232
+			$error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' );
2233 2233
 		}
2234 2234
 
2235 2235
 		// No errors; everything's fine here!
2236
-		if( empty( $error ) ) {
2236
+		if ( empty( $error ) ) {
2237 2237
 			return true;
2238 2238
 		}
2239 2239
 
2240
-		if( $echo && $error !== true ) {
2240
+		if ( $echo && $error !== true ) {
2241 2241
 
2242 2242
 	        $error = esc_html( $error );
2243 2243
 
@@ -2245,10 +2245,10 @@  discard block
 block discarded – undo
2245 2245
 	         * @since 1.9
2246 2246
 	         */
2247 2247
 	        if ( ! empty( $this->entry ) ) {
2248
-		        $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;" ) );
2248
+		        $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;" ) );
2249 2249
 	        }
2250 2250
 
2251
-			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
2251
+			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' );
2252 2252
 		}
2253 2253
 
2254 2254
 		gravityview()->log->error( '{error}', array( 'error' => $error ) );
@@ -2268,17 +2268,17 @@  discard block
 block discarded – undo
2268 2268
 
2269 2269
 		$error = NULL;
2270 2270
 
2271
-		if( ! $this->check_user_cap_edit_field( $field ) ) {
2272
-			$error = __( 'You do not have permission to edit this field.', 'gravityview');
2271
+		if ( ! $this->check_user_cap_edit_field( $field ) ) {
2272
+			$error = __( 'You do not have permission to edit this field.', 'gravityview' );
2273 2273
 		}
2274 2274
 
2275 2275
 		// No errors; everything's fine here!
2276
-		if( empty( $error ) ) {
2276
+		if ( empty( $error ) ) {
2277 2277
 			return true;
2278 2278
 		}
2279 2279
 
2280
-		if( $echo ) {
2281
-			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');
2280
+		if ( $echo ) {
2281
+			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' );
2282 2282
 		}
2283 2283
 
2284 2284
 		gravityview()->log->error( '{error}', array( 'error' => $error ) );
@@ -2299,14 +2299,14 @@  discard block
 block discarded – undo
2299 2299
 	private function check_user_cap_edit_field( $field ) {
2300 2300
 
2301 2301
 		// If they can edit any entries (as defined in Gravity Forms), we're good.
2302
-		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
2302
+		if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
2303 2303
 			return true;
2304 2304
 		}
2305 2305
 
2306
-		$field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;
2306
+		$field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false;
2307 2307
 
2308
-		if( $field_cap ) {
2309
-			return GVCommon::has_cap( $field['allow_edit_cap'] );
2308
+		if ( $field_cap ) {
2309
+			return GVCommon::has_cap( $field[ 'allow_edit_cap' ] );
2310 2310
 		}
2311 2311
 
2312 2312
 		return false;
@@ -2320,17 +2320,17 @@  discard block
 block discarded – undo
2320 2320
 	public function verify_nonce() {
2321 2321
 
2322 2322
 		// Verify form submitted for editing single
2323
-		if( $this->is_edit_entry_submission() ) {
2323
+		if ( $this->is_edit_entry_submission() ) {
2324 2324
 			$valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );
2325 2325
 		}
2326 2326
 
2327 2327
 		// Verify
2328
-		else if( ! $this->is_edit_entry() ) {
2328
+		else if ( ! $this->is_edit_entry() ) {
2329 2329
 			$valid = false;
2330 2330
 		}
2331 2331
 
2332 2332
 		else {
2333
-			$valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
2333
+			$valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key );
2334 2334
 		}
2335 2335
 
2336 2336
 		/**
Please login to merge, or discard this patch.