Completed
Push — develop ( 44f410...383617 )
by Gennady
17:13
created
includes/extensions/edit-entry/class-edit-entry-render.php 2 patches
Indentation   +289 added lines, -289 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
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	public function prevent_maybe_process_form() {
178 178
 
179
-	    if( ! $this->is_edit_entry_submission() ) {
179
+		if( ! $this->is_edit_entry_submission() ) {
180 180
 			return;
181 181
 		}
182 182
 
@@ -210,14 +210,14 @@  discard block
 block discarded – undo
210 210
 	 * When Edit entry view is requested setup the vars
211 211
 	 */
212 212
 	private function setup_vars() {
213
-        global $post;
213
+		global $post;
214 214
 
215 215
 		$gravityview_view = GravityView_View::getInstance();
216 216
 
217 217
 
218 218
 		$entries = $gravityview_view->getEntries();
219
-	    self::$original_entry = $entries[0];
220
-	    $this->entry = $entries[0];
219
+		self::$original_entry = $entries[0];
220
+		$this->entry = $entries[0];
221 221
 
222 222
 		self::$original_form = $gravityview_view->getForm();
223 223
 		$this->form = $gravityview_view->getForm();
@@ -359,8 +359,8 @@  discard block
 block discarded – undo
359 359
 
360 360
 			GFFormsModel::save_lead( $form, $this->entry );
361 361
 
362
-	        // Delete the values for hidden inputs
363
-	        $this->unset_hidden_field_values();
362
+			// Delete the values for hidden inputs
363
+			$this->unset_hidden_field_values();
364 364
 			
365 365
 			$this->entry['date_created'] = $date_created;
366 366
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 			// Perform actions normally performed after updating a lead
371 371
 			$this->after_update();
372 372
 
373
-	        /**
373
+			/**
374 374
 			 * Must be AFTER after_update()!
375 375
 			 * @see https://github.com/gravityview/GravityView/issues/764
376 376
 			 */
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 
379 379
 			/**
380 380
 			 * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry
381
-             * @since 2.1 Added $gv_data parameter
381
+			 * @since 2.1 Added $gv_data parameter
382 382
 			 * @param array $form Gravity Forms form array
383 383
 			 * @param string $entry_id Numeric ID of the entry that was updated
384 384
 			 * @param GravityView_Edit_Entry_Render $this This object
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 	 * @return void
403 403
 	 */
404 404
 	private function unset_hidden_field_values() {
405
-	    global $wpdb;
405
+		global $wpdb;
406 406
 
407 407
 		/**
408 408
 		 * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic
@@ -426,17 +426,17 @@  discard block
 block discarded – undo
426 426
 			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );
427 427
 		}
428 428
 
429
-	    foreach ( $this->entry as $input_id => $field_value ) {
429
+		foreach ( $this->entry as $input_id => $field_value ) {
430 430
 
431 431
 			if ( ! is_numeric( $input_id ) ) {
432 432
 				continue;
433 433
 			}
434 434
 
435
-		    $field = RGFormsModel::get_field( $this->form, $input_id );
435
+			$field = RGFormsModel::get_field( $this->form, $input_id );
436 436
 
437
-		    // Reset fields that are hidden
438
-		    // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic
439
-		    if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) {
437
+			// Reset fields that are hidden
438
+			// Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic
439
+			if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) {
440 440
 
441 441
 				$empty_value = $field->get_value_save_entry(
442 442
 					is_array( $field->get_entry_inputs() ) ? array() : '',
@@ -448,16 +448,16 @@  discard block
 block discarded – undo
448 448
 					$empty_value = '';
449 449
 				}
450 450
 
451
-			    $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
451
+				$lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
452 452
 
453
-			    GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );
453
+				GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );
454 454
 
455
-			    // Prevent the $_POST values of hidden fields from being used as default values when rendering the form
455
+				// Prevent the $_POST values of hidden fields from being used as default values when rendering the form
456 456
 				// after submission
457
-			    $post_input_id = 'input_' . str_replace( '.', '_', $input_id );
458
-			    $_POST[ $post_input_id ] = '';
459
-		    }
460
-	    }
457
+				$post_input_id = 'input_' . str_replace( '.', '_', $input_id );
458
+				$_POST[ $post_input_id ] = '';
459
+			}
460
+		}
461 461
 	}
462 462
 
463 463
 	/**
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 
552 552
 		$form = $this->filter_conditional_logic( $this->form );
553 553
 
554
-	    /** @var GF_Field $field */
554
+		/** @var GF_Field $field */
555 555
 		foreach( $form['fields'] as $k => &$field ) {
556 556
 
557 557
 			/**
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 
568 568
 			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
569 569
 				foreach( $field->inputs as $key => $input ) {
570
-				    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
570
+					$field->inputs[ $key ][ 'id' ] = (string)$input['id'];
571 571
 				}
572 572
 			}
573 573
 		}
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
 
608 608
 				$inputs = $field->get_entry_inputs();
609 609
 				if ( is_array( $inputs ) ) {
610
-				    foreach ( $inputs as $input ) {
610
+					foreach ( $inputs as $input ) {
611 611
 						list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 );
612 612
 
613 613
 						if ( 'product' === $field->type ) {
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 						}
627 627
 
628 628
 						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] );
629
-				    }
629
+					}
630 630
 				} else {
631 631
 					// Set to what it previously was if it's not editable
632 632
 					if ( ! in_array( $field->id, $allowed_fields ) ) {
@@ -672,7 +672,7 @@  discard block
 block discarded – undo
672 672
 			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
673 673
 
674 674
 			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
675
-	        $ary = stripslashes_deep( $ary );
675
+			$ary = stripslashes_deep( $ary );
676 676
 			$img_url = \GV\Utils::get( $ary, 0 );
677 677
 
678 678
 			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 	private function maybe_update_post_fields( $form ) {
746 746
 
747 747
 		if( empty( $this->entry['post_id'] ) ) {
748
-	        gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
748
+			gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
749 749
 			return;
750 750
 		}
751 751
 
@@ -780,49 +780,49 @@  discard block
 block discarded – undo
780 780
 
781 781
 				switch( $field->type ) {
782 782
 
783
-				    case 'post_title':
784
-				        $post_title = $value;
785
-				        if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
786
-				            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
787
-				        }
788
-				        $updated_post->post_title = $post_title;
789
-				        $updated_post->post_name  = $post_title;
790
-				        unset( $post_title );
791
-				        break;
792
-
793
-				    case 'post_content':
794
-				        $post_content = $value;
795
-				        if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
796
-				            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
797
-				        }
798
-				        $updated_post->post_content = $post_content;
799
-				        unset( $post_content );
800
-				        break;
801
-				    case 'post_excerpt':
802
-				        $updated_post->post_excerpt = $value;
803
-				        break;
804
-				    case 'post_tags':
805
-				        wp_set_post_tags( $post_id, $value, false );
806
-				        break;
807
-				    case 'post_category':
808
-				        break;
809
-				    case 'post_custom_field':
783
+					case 'post_title':
784
+						$post_title = $value;
785
+						if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
786
+							$post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
787
+						}
788
+						$updated_post->post_title = $post_title;
789
+						$updated_post->post_name  = $post_title;
790
+						unset( $post_title );
791
+						break;
792
+
793
+					case 'post_content':
794
+						$post_content = $value;
795
+						if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
796
+							$post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
797
+						}
798
+						$updated_post->post_content = $post_content;
799
+						unset( $post_content );
800
+						break;
801
+					case 'post_excerpt':
802
+						$updated_post->post_excerpt = $value;
803
+						break;
804
+					case 'post_tags':
805
+						wp_set_post_tags( $post_id, $value, false );
806
+						break;
807
+					case 'post_category':
808
+						break;
809
+					case 'post_custom_field':
810 810
 						if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) {
811 811
 							$value = $value[ $field_id ];
812 812
 						}
813 813
 
814
-				        if( ! empty( $field->customFieldTemplateEnabled ) ) {
815
-				            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
816
-				        }
814
+						if( ! empty( $field->customFieldTemplateEnabled ) ) {
815
+							$value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
816
+						}
817 817
 
818 818
 						$value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry );
819 819
 
820
-				        update_post_meta( $post_id, $field->postCustomFieldName, $value );
821
-				        break;
820
+						update_post_meta( $post_id, $field->postCustomFieldName, $value );
821
+						break;
822 822
 
823
-				    case 'post_image':
824
-				        $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
825
-				        break;
823
+					case 'post_image':
824
+						$value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
825
+						break;
826 826
 
827 827
 				}
828 828
 
@@ -979,14 +979,14 @@  discard block
 block discarded – undo
979 979
 			?><h2 class="gv-edit-entry-title">
980 980
 				<span><?php
981 981
 
982
-				    /**
983
-				     * @filter `gravityview_edit_entry_title` Modify the edit entry title
984
-				     * @param string $edit_entry_title Modify the "Edit Entry" title
985
-				     * @param GravityView_Edit_Entry_Render $this This object
986
-				     */
987
-				    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
982
+					/**
983
+					 * @filter `gravityview_edit_entry_title` Modify the edit entry title
984
+					 * @param string $edit_entry_title Modify the "Edit Entry" title
985
+					 * @param GravityView_Edit_Entry_Render $this This object
986
+					 */
987
+					$edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
988 988
 
989
-				    echo esc_attr( $edit_entry_title );
989
+					echo esc_attr( $edit_entry_title );
990 990
 			?></span>
991 991
 			</h2>
992 992
 
@@ -1049,26 +1049,26 @@  discard block
 block discarded – undo
1049 1049
 
1050 1050
 				switch ( $edit_redirect ) {
1051 1051
 
1052
-                    case '0':
1053
-	                    $redirect_url = $back_link;
1054
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
1055
-                        break;
1056
-
1057
-                    case '1':
1058
-	                    $redirect_url = $directory_link = GravityView_API::directory_link();
1059
-	                    $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>' );
1060
-	                    break;
1061
-
1062
-                    case '2':
1063
-	                    $redirect_url = $edit_redirect_url;
1064
-	                    $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
1065
-	                    $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>' );
1066
-                        break;
1067
-
1068
-                    case '':
1069
-                    default:
1070
-					    $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
1071
-                        break;
1052
+					case '0':
1053
+						$redirect_url = $back_link;
1054
+						$entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
1055
+						break;
1056
+
1057
+					case '1':
1058
+						$redirect_url = $directory_link = GravityView_API::directory_link();
1059
+						$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>' );
1060
+						break;
1061
+
1062
+					case '2':
1063
+						$redirect_url = $edit_redirect_url;
1064
+						$redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
1065
+						$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>' );
1066
+						break;
1067
+
1068
+					case '':
1069
+					default:
1070
+						$entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
1071
+						break;
1072 1072
 				}
1073 1073
 
1074 1074
 				if ( isset( $redirect_url ) ) {
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
 
1126 1126
 		ob_get_clean();
1127 1127
 
1128
-	    remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
1128
+		remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
1129 1129
 		remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
1130 1130
 		remove_filter( 'gform_disable_view_counter', '__return_true' );
1131 1131
 		remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 );
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
 
1180 1180
 		// for now we don't support Save and Continue feature.
1181 1181
 		if( ! self::$supports_save_and_continue ) {
1182
-	        unset( $form['save'] );
1182
+			unset( $form['save'] );
1183 1183
 		}
1184 1184
 
1185 1185
 		$form = $this->unselect_default_values( $form );
@@ -1206,30 +1206,30 @@  discard block
 block discarded – undo
1206 1206
 			return $field_content;
1207 1207
 		}
1208 1208
 
1209
-        $message = null;
1209
+		$message = null;
1210 1210
 
1211
-        // First, make sure they have the capability to edit the post.
1212
-        if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1211
+		// First, make sure they have the capability to edit the post.
1212
+		if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1213 1213
 
1214
-            /**
1215
-             * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1216
-             * @param string $message The existing "You don't have permission..." text
1217
-             */
1218
-            $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1214
+			/**
1215
+			 * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1216
+			 * @param string $message The existing "You don't have permission..." text
1217
+			 */
1218
+			$message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1219 1219
 
1220
-        } elseif( null === get_post( $this->entry['post_id'] ) ) {
1221
-            /**
1222
-             * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1223
-             * @param string $message The existing "This field is not editable; the post no longer exists." text
1224
-             */
1225
-            $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1226
-        }
1220
+		} elseif( null === get_post( $this->entry['post_id'] ) ) {
1221
+			/**
1222
+			 * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1223
+			 * @param string $message The existing "This field is not editable; the post no longer exists." text
1224
+			 */
1225
+			$message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1226
+		}
1227 1227
 
1228
-        if( $message ) {
1229
-            $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1230
-        }
1228
+		if( $message ) {
1229
+			$field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1230
+		}
1231 1231
 
1232
-        return $field_content;
1232
+		return $field_content;
1233 1233
 	}
1234 1234
 
1235 1235
 	/**
@@ -1257,7 +1257,7 @@  discard block
 block discarded – undo
1257 1257
 			|| ! empty( $field_content )
1258 1258
 			|| in_array( $field->type, array( 'honeypot' ) )
1259 1259
 		) {
1260
-	        return $field_content;
1260
+			return $field_content;
1261 1261
 		}
1262 1262
 
1263 1263
 		// SET SOME FIELD DEFAULTS TO PREVENT ISSUES
@@ -1265,24 +1265,24 @@  discard block
 block discarded – undo
1265 1265
 
1266 1266
 		$field_value = $this->get_field_value( $field );
1267 1267
 
1268
-	    // Prevent any PHP warnings, like undefined index
1269
-	    ob_start();
1268
+		// Prevent any PHP warnings, like undefined index
1269
+		ob_start();
1270 1270
 
1271
-	    $return = null;
1271
+		$return = null;
1272 1272
 
1273 1273
 		/** @var GravityView_Field $gv_field */
1274 1274
 		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1275 1275
 			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1276 1276
 		} else {
1277
-	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
1278
-	    }
1277
+			$return = $field->get_field_input( $this->form, $field_value, $this->entry );
1278
+		}
1279 1279
 
1280
-	    // If there was output, it's an error
1281
-	    $warnings = ob_get_clean();
1280
+		// If there was output, it's an error
1281
+		$warnings = ob_get_clean();
1282 1282
 
1283
-	    if( !empty( $warnings ) ) {
1284
-		    gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1285
-	    }
1283
+		if( !empty( $warnings ) ) {
1284
+			gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1285
+		}
1286 1286
 
1287 1287
 		return $return;
1288 1288
 	}
@@ -1317,8 +1317,8 @@  discard block
 block discarded – undo
1317 1317
 				$input_id = strval( $input['id'] );
1318 1318
 
1319 1319
 				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1320
-				    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1321
-				    $allow_pre_populated = false;
1320
+					$field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1321
+					$allow_pre_populated = false;
1322 1322
 				}
1323 1323
 
1324 1324
 			}
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
 			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1343 1343
 				$categories = array();
1344 1344
 				foreach ( explode( ',', $field_value ) as $cat_string ) {
1345
-				    $categories[] = GFCommon::format_post_category( $cat_string, true );
1345
+					$categories[] = GFCommon::format_post_category( $cat_string, true );
1346 1346
 				}
1347 1347
 				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1348 1348
 			}
@@ -1352,25 +1352,25 @@  discard block
 block discarded – undo
1352 1352
 		// if value is empty get the default value if defined
1353 1353
 		$field_value = $field->get_value_default_if_empty( $field_value );
1354 1354
 
1355
-	    /**
1356
-	     * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1357
-	     * @since 1.11
1358
-	     * @since 1.20 Added third param
1359
-	     * @param mixed $field_value field value used to populate the input
1360
-	     * @param object $field Gravity Forms field object ( Class GF_Field )
1361
-	     * @param GravityView_Edit_Entry_Render $this Current object
1362
-	     */
1363
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this );
1364
-
1365
-	    /**
1366
-	     * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1367
-	     * @since 1.17
1368
-	     * @since 1.20 Added third param
1369
-	     * @param mixed $field_value field value used to populate the input
1370
-	     * @param GF_Field $field Gravity Forms field object
1371
-	     * @param GravityView_Edit_Entry_Render $this Current object
1372
-	     */
1373
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1355
+		/**
1356
+		 * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1357
+		 * @since 1.11
1358
+		 * @since 1.20 Added third param
1359
+		 * @param mixed $field_value field value used to populate the input
1360
+		 * @param object $field Gravity Forms field object ( Class GF_Field )
1361
+		 * @param GravityView_Edit_Entry_Render $this Current object
1362
+		 */
1363
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this );
1364
+
1365
+		/**
1366
+		 * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1367
+		 * @since 1.17
1368
+		 * @since 1.20 Added third param
1369
+		 * @param mixed $field_value field value used to populate the input
1370
+		 * @param GF_Field $field Gravity Forms field object
1371
+		 * @param GravityView_Edit_Entry_Render $this Current object
1372
+		 */
1373
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1374 1374
 
1375 1375
 		return $field_value;
1376 1376
 	}
@@ -1397,7 +1397,7 @@  discard block
 block discarded – undo
1397 1397
 			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1398 1398
 			// expects certain field array items to be set.
1399 1399
 			foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) {
1400
-	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1400
+				$field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1401 1401
 			}
1402 1402
 
1403 1403
 			switch( RGFormsModel::get_input_type( $field ) ) {
@@ -1411,61 +1411,61 @@  discard block
 block discarded – undo
1411 1411
 				 */
1412 1412
 				case 'fileupload':
1413 1413
 
1414
-				    // Set the previous value
1415
-				    $entry = $this->get_entry();
1414
+					// Set the previous value
1415
+					$entry = $this->get_entry();
1416 1416
 
1417
-				    $input_name = 'input_'.$field->id;
1418
-				    $form_id = $form['id'];
1417
+					$input_name = 'input_'.$field->id;
1418
+					$form_id = $form['id'];
1419 1419
 
1420
-				    $value = NULL;
1420
+					$value = NULL;
1421 1421
 
1422
-				    // Use the previous entry value as the default.
1423
-				    if( isset( $entry[ $field->id ] ) ) {
1424
-				        $value = $entry[ $field->id ];
1425
-				    }
1422
+					// Use the previous entry value as the default.
1423
+					if( isset( $entry[ $field->id ] ) ) {
1424
+						$value = $entry[ $field->id ];
1425
+					}
1426 1426
 
1427
-				    // If this is a single upload file
1428
-				    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1429
-				        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1430
-				        $value = $file_path['url'];
1427
+					// If this is a single upload file
1428
+					if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1429
+						$file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1430
+						$value = $file_path['url'];
1431 1431
 
1432
-				    } else {
1432
+					} else {
1433 1433
 
1434
-				        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1435
-				        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1436
-				        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1434
+						// Fix PHP warning on line 1498 of form_display.php for post_image fields
1435
+						// Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1436
+						$_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1437 1437
 
1438
-				    }
1438
+					}
1439 1439
 
1440
-				    if ( \GV\Utils::get( $field, "multipleFiles" ) ) {
1440
+					if ( \GV\Utils::get( $field, "multipleFiles" ) ) {
1441 1441
 
1442
-				        // If there are fresh uploads, process and merge them.
1443
-				        // Otherwise, use the passed values, which should be json-encoded array of URLs
1444
-				        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1445
-				            $value = empty( $value ) ? '[]' : $value;
1446
-				            $value = stripslashes_deep( $value );
1447
-				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1448
-				        }
1442
+						// If there are fresh uploads, process and merge them.
1443
+						// Otherwise, use the passed values, which should be json-encoded array of URLs
1444
+						if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1445
+							$value = empty( $value ) ? '[]' : $value;
1446
+							$value = stripslashes_deep( $value );
1447
+							$value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1448
+						}
1449 1449
 
1450
-				    } else {
1450
+					} else {
1451 1451
 
1452
-				        // A file already exists when editing an entry
1453
-				        // We set this to solve issue when file upload fields are required.
1454
-				        GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1452
+						// A file already exists when editing an entry
1453
+						// We set this to solve issue when file upload fields are required.
1454
+						GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1455 1455
 
1456
-				    }
1456
+					}
1457 1457
 
1458
-				    $this->entry[ $input_name ] = $value;
1459
-				    $_POST[ $input_name ] = $value;
1458
+					$this->entry[ $input_name ] = $value;
1459
+					$_POST[ $input_name ] = $value;
1460 1460
 
1461
-				    break;
1461
+					break;
1462 1462
 
1463 1463
 				case 'number':
1464
-				    // Fix "undefined index" issue at line 1286 in form_display.php
1465
-				    if( !isset( $_POST['input_'.$field->id ] ) ) {
1466
-				        $_POST['input_'.$field->id ] = NULL;
1467
-				    }
1468
-				    break;
1464
+					// Fix "undefined index" issue at line 1286 in form_display.php
1465
+					if( !isset( $_POST['input_'.$field->id ] ) ) {
1466
+						$_POST['input_'.$field->id ] = NULL;
1467
+					}
1468
+					break;
1469 1469
 			}
1470 1470
 
1471 1471
 		}
@@ -1550,43 +1550,43 @@  discard block
 block discarded – undo
1550 1550
 				case 'fileupload' :
1551 1551
 				case 'post_image':
1552 1552
 
1553
-				    // in case nothing is uploaded but there are already files saved
1554
-				    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1555
-				        $field->failed_validation = false;
1556
-				        unset( $field->validation_message );
1557
-				    }
1553
+					// in case nothing is uploaded but there are already files saved
1554
+					if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1555
+						$field->failed_validation = false;
1556
+						unset( $field->validation_message );
1557
+					}
1558 1558
 
1559
-				    // validate if multi file upload reached max number of files [maxFiles] => 2
1560
-				    if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1559
+					// validate if multi file upload reached max number of files [maxFiles] => 2
1560
+					if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1561 1561
 
1562
-				        $input_name = 'input_' . $field->id;
1563
-				        //uploaded
1564
-				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1562
+						$input_name = 'input_' . $field->id;
1563
+						//uploaded
1564
+						$file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1565 1565
 
1566
-				        //existent
1567
-				        $entry = $this->get_entry();
1568
-				        $value = NULL;
1569
-				        if( isset( $entry[ $field->id ] ) ) {
1570
-				            $value = json_decode( $entry[ $field->id ], true );
1571
-				        }
1566
+						//existent
1567
+						$entry = $this->get_entry();
1568
+						$value = NULL;
1569
+						if( isset( $entry[ $field->id ] ) ) {
1570
+							$value = json_decode( $entry[ $field->id ], true );
1571
+						}
1572 1572
 
1573
-				        // count uploaded files and existent entry files
1574
-				        $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) +
1575
-						               ( is_array( $value ) ? count( $value ) : 0 );
1573
+						// count uploaded files and existent entry files
1574
+						$count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) +
1575
+									   ( is_array( $value ) ? count( $value ) : 0 );
1576 1576
 
1577
-				        if( $count_files > $field->maxFiles ) {
1578
-				            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1579
-				            $field->failed_validation = 1;
1580
-				            $gv_valid = false;
1577
+						if( $count_files > $field->maxFiles ) {
1578
+							$field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1579
+							$field->failed_validation = 1;
1580
+							$gv_valid = false;
1581 1581
 
1582
-				            // in case of error make sure the newest upload files are removed from the upload input
1583
-				            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1584
-				        }
1582
+							// in case of error make sure the newest upload files are removed from the upload input
1583
+							GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1584
+						}
1585 1585
 
1586
-				    }
1586
+					}
1587 1587
 
1588 1588
 
1589
-				    break;
1589
+					break;
1590 1590
 
1591 1591
 			}
1592 1592
 
@@ -1597,47 +1597,47 @@  discard block
 block discarded – undo
1597 1597
 
1598 1598
 				switch ( $field_type ) {
1599 1599
 
1600
-				    // Captchas don't need to be re-entered.
1601
-				    case 'captcha':
1600
+					// Captchas don't need to be re-entered.
1601
+					case 'captcha':
1602 1602
 
1603
-				        // Post Image fields aren't editable, so we un-fail them.
1604
-				    case 'post_image':
1605
-				        $field->failed_validation = false;
1606
-				        unset( $field->validation_message );
1607
-				        break;
1603
+						// Post Image fields aren't editable, so we un-fail them.
1604
+					case 'post_image':
1605
+						$field->failed_validation = false;
1606
+						unset( $field->validation_message );
1607
+						break;
1608 1608
 
1609 1609
 				}
1610 1610
 
1611 1611
 				// You can't continue inside a switch, so we do it after.
1612 1612
 				if( empty( $field->failed_validation ) ) {
1613
-				    continue;
1613
+					continue;
1614 1614
 				}
1615 1615
 
1616 1616
 				// checks if the No Duplicates option is not validating entry against itself, since
1617 1617
 				// we're editing a stored entry, it would also assume it's a duplicate.
1618 1618
 				if( !empty( $field->noDuplicates ) ) {
1619 1619
 
1620
-				    $entry = $this->get_entry();
1620
+					$entry = $this->get_entry();
1621 1621
 
1622
-				    // If the value of the entry is the same as the stored value
1623
-				    // Then we can assume it's not a duplicate, it's the same.
1624
-				    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1625
-				        //if value submitted was not changed, then don't validate
1626
-				        $field->failed_validation = false;
1622
+					// If the value of the entry is the same as the stored value
1623
+					// Then we can assume it's not a duplicate, it's the same.
1624
+					if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1625
+						//if value submitted was not changed, then don't validate
1626
+						$field->failed_validation = false;
1627 1627
 
1628
-				        unset( $field->validation_message );
1628
+						unset( $field->validation_message );
1629 1629
 
1630
-				        gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) );
1630
+						gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) );
1631 1631
 
1632
-				        continue;
1633
-				    }
1632
+						continue;
1633
+					}
1634 1634
 				}
1635 1635
 
1636 1636
 				// if here then probably we are facing the validation 'At least one field must be filled out'
1637 1637
 				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1638
-				    unset( $field->validation_message );
1639
-	                $field->validation_message = false;
1640
-				    continue;
1638
+					unset( $field->validation_message );
1639
+					$field->validation_message = false;
1640
+					continue;
1641 1641
 				}
1642 1642
 
1643 1643
 				$gv_valid = false;
@@ -1701,8 +1701,8 @@  discard block
 block discarded – undo
1701 1701
 		// Hide fields depending on admin settings
1702 1702
 		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1703 1703
 
1704
-	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1705
-	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1704
+		// If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1705
+		$fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1706 1706
 
1707 1707
 		/**
1708 1708
 		 * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form
@@ -1777,11 +1777,11 @@  discard block
 block discarded – undo
1777 1777
 		// The edit tab has been configured, so we loop through to configured settings
1778 1778
 		foreach ( $configured_fields as $configured_field ) {
1779 1779
 
1780
-	        /** @var GF_Field $field */
1781
-	        foreach ( $fields as $field ) {
1780
+			/** @var GF_Field $field */
1781
+			foreach ( $fields as $field ) {
1782 1782
 				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1783
-				    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1784
-				    break;
1783
+					$edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1784
+					break;
1785 1785
 				}
1786 1786
 
1787 1787
 			}
@@ -1837,28 +1837,28 @@  discard block
 block discarded – undo
1837 1837
 	 */
1838 1838
 	private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) {
1839 1839
 
1840
-	    /**
1840
+		/**
1841 1841
 		 * @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
1842
-	     * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1843
-	     * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1844
-	     * @since 1.9.1
1845
-	     * @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.
1846
-	     * @param array $form GF Form array
1847
-	     * @param int $view_id View ID
1848
-	     */
1849
-	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1850
-
1851
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1842
+		 * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1843
+		 * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1844
+		 * @since 1.9.1
1845
+		 * @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.
1846
+		 * @param array $form GF Form array
1847
+		 * @param int $view_id View ID
1848
+		 */
1849
+		$use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1850
+
1851
+		if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1852 1852
 			foreach( $fields as $k => $field ) {
1853 1853
 				if( $field->adminOnly ) {
1854
-				    unset( $fields[ $k ] );
1854
+					unset( $fields[ $k ] );
1855 1855
 				}
1856 1856
 			}
1857 1857
 			return array_values( $fields );
1858 1858
 		}
1859 1859
 
1860
-	    foreach( $fields as &$field ) {
1861
-		    $field->adminOnly = false;
1860
+		foreach( $fields as &$field ) {
1861
+			$field->adminOnly = false;
1862 1862
 		}
1863 1863
 
1864 1864
 		return $fields;
@@ -1878,13 +1878,13 @@  discard block
 block discarded – undo
1878 1878
 	 */
1879 1879
 	private function unselect_default_values( $form ) {
1880 1880
 
1881
-	    foreach ( $form['fields'] as &$field ) {
1881
+		foreach ( $form['fields'] as &$field ) {
1882 1882
 
1883 1883
 			if ( empty( $field->choices ) ) {
1884
-                continue;
1884
+				continue;
1885 1885
 			}
1886 1886
 
1887
-            foreach ( $field->choices as &$choice ) {
1887
+			foreach ( $field->choices as &$choice ) {
1888 1888
 				if ( \GV\Utils::get( $choice, 'isSelected' ) ) {
1889 1889
 					$choice['isSelected'] = false;
1890 1890
 				}
@@ -1921,36 +1921,36 @@  discard block
 block discarded – undo
1921 1921
 
1922 1922
 			if( 'checkbox' === $field->type ) {
1923 1923
 				foreach ( $field->get_entry_inputs() as $key => $input ) {
1924
-				    $input_id = $input['id'];
1925
-				    $choice = $field->choices[ $key ];
1926
-				    $value = \GV\Utils::get( $this->entry, $input_id );
1927
-				    $match = RGFormsModel::choice_value_match( $field, $choice, $value );
1928
-				    if( $match ) {
1929
-				        $field->choices[ $key ]['isSelected'] = true;
1930
-				    }
1924
+					$input_id = $input['id'];
1925
+					$choice = $field->choices[ $key ];
1926
+					$value = \GV\Utils::get( $this->entry, $input_id );
1927
+					$match = RGFormsModel::choice_value_match( $field, $choice, $value );
1928
+					if( $match ) {
1929
+						$field->choices[ $key ]['isSelected'] = true;
1930
+					}
1931 1931
 				}
1932 1932
 			} else {
1933 1933
 
1934 1934
 				// We need to run through each field to set the default values
1935 1935
 				foreach ( $this->entry as $field_id => $field_value ) {
1936 1936
 
1937
-				    if( floatval( $field_id ) === floatval( $field->id ) ) {
1937
+					if( floatval( $field_id ) === floatval( $field->id ) ) {
1938 1938
 
1939
-				        if( 'list' === $field->type ) {
1940
-				            $list_rows = maybe_unserialize( $field_value );
1939
+						if( 'list' === $field->type ) {
1940
+							$list_rows = maybe_unserialize( $field_value );
1941 1941
 
1942
-				            $list_field_value = array();
1943
-				            foreach ( (array) $list_rows as $row ) {
1944
-				                foreach ( (array) $row as $column ) {
1945
-				                    $list_field_value[] = $column;
1946
-				                }
1947
-				            }
1942
+							$list_field_value = array();
1943
+							foreach ( (array) $list_rows as $row ) {
1944
+								foreach ( (array) $row as $column ) {
1945
+									$list_field_value[] = $column;
1946
+								}
1947
+							}
1948 1948
 
1949
-				            $field->defaultValue = serialize( $list_field_value );
1950
-				        } else {
1951
-				            $field->defaultValue = $field_value;
1952
-				        }
1953
-				    }
1949
+							$field->defaultValue = serialize( $list_field_value );
1950
+						} else {
1951
+							$field->defaultValue = $field_value;
1952
+						}
1953
+					}
1954 1954
 				}
1955 1955
 			}
1956 1956
 		}
@@ -2011,7 +2011,7 @@  discard block
 block discarded – undo
2011 2011
 			foreach ( $form['fields'] as &$field ) {
2012 2012
 				foreach ( $remove_conditions_rule as $_remove_conditions_r ) {
2013 2013
 
2014
-				    list( $rule_field_id, $rule_i ) = $_remove_conditions_r;
2014
+					list( $rule_field_id, $rule_i ) = $_remove_conditions_r;
2015 2015
 
2016 2016
 					if ( $field['id'] == $rule_field_id ) {
2017 2017
 						unset( $field->conditionalLogic['rules'][ $rule_i ] );
@@ -2062,7 +2062,7 @@  discard block
 block discarded – undo
2062 2062
 			return $has_conditional_logic;
2063 2063
 		}
2064 2064
 
2065
-	    /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */
2065
+		/** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */
2066 2066
 		return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form );
2067 2067
 	}
2068 2068
 
@@ -2129,14 +2129,14 @@  discard block
 block discarded – undo
2129 2129
 
2130 2130
 		if( $echo && $error !== true ) {
2131 2131
 
2132
-	        $error = esc_html( $error );
2132
+			$error = esc_html( $error );
2133 2133
 
2134
-	        /**
2135
-	         * @since 1.9
2136
-	         */
2137
-	        if ( ! empty( $this->entry ) ) {
2138
-		        $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;" ) );
2139
-	        }
2134
+			/**
2135
+			 * @since 1.9
2136
+			 */
2137
+			if ( ! empty( $this->entry ) ) {
2138
+				$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;" ) );
2139
+			}
2140 2140
 
2141 2141
 			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
2142 2142
 		}
Please login to merge, or discard this patch.
Spacing   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -123,16 +123,16 @@  discard block
 block discarded – undo
123 123
 	function load() {
124 124
 
125 125
 		/** @define "GRAVITYVIEW_DIR" "../../../" */
126
-		include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' );
126
+		include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' );
127 127
 
128 128
 		// Don't display an embedded form when editing an entry
129 129
 		add_action( 'wp_head', array( $this, 'prevent_render_form' ) );
130 130
 		add_action( 'wp_footer', array( $this, 'prevent_render_form' ) );
131 131
 
132 132
 		// Stop Gravity Forms processing what is ours!
133
-		add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 );
133
+		add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 );
134 134
 
135
-		add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') );
135
+		add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) );
136 136
 
137 137
 		add_action( 'gravityview_edit_entry', array( $this, 'init' ), 10, 4 );
138 138
 
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 );
144 144
 
145 145
 		// Add fields expected by GFFormDisplay::validate()
146
-		add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') );
146
+		add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) );
147 147
 
148 148
 		// Fix multiselect value for GF 2.2
149 149
 		add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 );
@@ -160,8 +160,8 @@  discard block
 block discarded – undo
160 160
 	 * @return void
161 161
 	 */
162 162
 	public function prevent_render_form() {
163
-		if( $this->is_edit_entry() ) {
164
-			if( 'wp_head' === current_filter() ) {
163
+		if ( $this->is_edit_entry() ) {
164
+			if ( 'wp_head' === current_filter() ) {
165 165
 				add_filter( 'gform_shortcode_form', '__return_empty_string' );
166 166
 			} else {
167 167
 				remove_filter( 'gform_shortcode_form', '__return_empty_string' );
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	public function prevent_maybe_process_form() {
178 178
 
179
-	    if( ! $this->is_edit_entry_submission() ) {
179
+	    if ( ! $this->is_edit_entry_submission() ) {
180 180
 			return;
181 181
 		}
182 182
 
183 183
 		gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] Removing GFForms::maybe_process_form() action.' );
184 184
 
185
-		remove_action( 'wp',  array( 'RGForms', 'maybe_process_form'), 9 );
186
-		remove_action( 'wp',  array( 'GFForms', 'maybe_process_form'), 9 );
185
+		remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 );
186
+		remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 );
187 187
 	}
188 188
 
189 189
 	/**
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 */
193 193
 	public function is_edit_entry() {
194 194
 
195
-		$is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] );
195
+		$is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] );
196 196
 
197 197
 		return ( $is_edit_entry || $this->is_edit_entry_submission() );
198 198
 	}
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @return boolean
204 204
 	 */
205 205
 	public function is_edit_entry_submission() {
206
-		return !empty( $_POST[ self::$nonce_field ] );
206
+		return ! empty( $_POST[ self::$nonce_field ] );
207 207
 	}
208 208
 
209 209
 	/**
@@ -216,16 +216,16 @@  discard block
 block discarded – undo
216 216
 
217 217
 
218 218
 		$entries = $gravityview_view->getEntries();
219
-	    self::$original_entry = $entries[0];
220
-	    $this->entry = $entries[0];
219
+	    self::$original_entry = $entries[ 0 ];
220
+	    $this->entry = $entries[ 0 ];
221 221
 
222 222
 		self::$original_form = $gravityview_view->getForm();
223 223
 		$this->form = $gravityview_view->getForm();
224
-		$this->form_id = $this->entry['form_id'];
224
+		$this->form_id = $this->entry[ 'form_id' ];
225 225
 		$this->view_id = $gravityview_view->getViewId();
226 226
 		$this->post_id = \GV\Utils::get( $post, 'ID', null );
227 227
 
228
-		self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] );
228
+		self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] );
229 229
 	}
230 230
 
231 231
 
@@ -284,9 +284,9 @@  discard block
 block discarded – undo
284 284
 	private function print_scripts() {
285 285
 		$gravityview_view = GravityView_View::getInstance();
286 286
 
287
-		wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
287
+		wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
288 288
 
289
-		GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false);
289
+		GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false );
290 290
 
291 291
 		wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) );
292 292
 
@@ -302,19 +302,19 @@  discard block
 block discarded – undo
302 302
 	 */
303 303
 	private function process_save( $gv_data ) {
304 304
 
305
-		if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) {
305
+		if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) {
306 306
 			return;
307 307
 		}
308 308
 
309 309
 		// Make sure the entry, view, and form IDs are all correct
310 310
 		$valid = $this->verify_nonce();
311 311
 
312
-		if ( !$valid ) {
312
+		if ( ! $valid ) {
313 313
 			gravityview()->log->error( 'Nonce validation failed.' );
314 314
 			return;
315 315
 		}
316 316
 
317
-		if ( $this->entry['id'] !== $_POST['lid'] ) {
317
+		if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) {
318 318
 			gravityview()->log->error( 'Entry ID did not match posted entry ID.' );
319 319
 			return;
320 320
 		}
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 
326 326
 		$this->validate();
327 327
 
328
-		if( $this->is_valid ) {
328
+		if ( $this->is_valid ) {
329 329
 
330 330
 			gravityview()->log->debug( 'Submission is valid.' );
331 331
 
@@ -337,15 +337,15 @@  discard block
 block discarded – undo
337 337
 			/**
338 338
 			 * @hack to avoid the capability validation of the method save_lead for GF 1.9+
339 339
 			 */
340
-			unset( $_GET['page'] );
340
+			unset( $_GET[ 'page' ] );
341 341
 
342
-			$date_created = $this->entry['date_created'];
342
+			$date_created = $this->entry[ 'date_created' ];
343 343
 
344 344
 			/**
345 345
 			 * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead()
346 346
 			 * @since 1.17.2
347 347
 			 */
348
-			unset( $this->entry['date_created'] );
348
+			unset( $this->entry[ 'date_created' ] );
349 349
 
350 350
 			/**
351 351
 			 * @action `gravityview/edit_entry/before_update` Perform an action after the entry has been updated using Edit Entry
@@ -355,14 +355,14 @@  discard block
 block discarded – undo
355 355
 			 * @param GravityView_Edit_Entry_Render $this This object
356 356
 			 * @param GravityView_View_Data $gv_data The View data
357 357
 			 */
358
-			do_action( 'gravityview/edit_entry/before_update', $form, $this->entry['id'], $this, $gv_data );
358
+			do_action( 'gravityview/edit_entry/before_update', $form, $this->entry[ 'id' ], $this, $gv_data );
359 359
 
360 360
 			GFFormsModel::save_lead( $form, $this->entry );
361 361
 
362 362
 	        // Delete the values for hidden inputs
363 363
 	        $this->unset_hidden_field_values();
364 364
 			
365
-			$this->entry['date_created'] = $date_created;
365
+			$this->entry[ 'date_created' ] = $date_created;
366 366
 
367 367
 			// Process calculation fields
368 368
 			$this->update_calculation_fields();
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 			 * @param GravityView_Edit_Entry_Render $this This object
385 385
 			 * @param GravityView_View_Data $gv_data The View data
386 386
 			 */
387
-			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data );
387
+			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data );
388 388
 
389 389
 		} else {
390 390
 			gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) );
@@ -414,16 +414,16 @@  discard block
 block discarded – undo
414 414
 
415 415
 		$this->unset_hidden_calculations = array();
416 416
 
417
-		if( ! $unset_hidden_field_values ) {
417
+		if ( ! $unset_hidden_field_values ) {
418 418
 			return;
419 419
 		}
420 420
 
421 421
 		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
422 422
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
423
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) );
423
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) );
424 424
 		} else {
425 425
 			$lead_detail_table = GFFormsModel::get_lead_details_table_name();
426
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );
426
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) );
427 427
 		}
428 428
 
429 429
 	    foreach ( $this->entry as $input_id => $field_value ) {
@@ -440,11 +440,11 @@  discard block
 block discarded – undo
440 440
 
441 441
 				$empty_value = $field->get_value_save_entry(
442 442
 					is_array( $field->get_entry_inputs() ) ? array() : '',
443
-					$this->form, '', $this->entry['id'], $this->entry
443
+					$this->form, '', $this->entry[ 'id' ], $this->entry
444 444
 				);
445 445
 
446 446
 				if ( $field->has_calculation() ) {
447
-					$this->unset_hidden_calculations[] = $field->id; // Unset
447
+					$this->unset_hidden_calculations[ ] = $field->id; // Unset
448 448
 					$empty_value = '';
449 449
 				}
450 450
 
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 		}
516 516
 
517 517
 		/** No file is being uploaded. */
518
-		if ( empty( $_FILES[ $input_name ]['name'] ) ) {
518
+		if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) {
519 519
 			/** So return the original upload */
520 520
 			return $entry[ $input_id ];
521 521
 		}
@@ -533,11 +533,11 @@  discard block
 block discarded – undo
533 533
 	 * @return mixed
534 534
 	 */
535 535
 	public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) {
536
-		if( ! $this->is_edit_entry() ) {
536
+		if ( ! $this->is_edit_entry() ) {
537 537
 			return $plupload_init;
538 538
 		}
539 539
 
540
-		$plupload_init['gf_vars']['max_files'] = 0;
540
+		$plupload_init[ 'gf_vars' ][ 'max_files' ] = 0;
541 541
 
542 542
 		return $plupload_init;
543 543
 	}
@@ -552,27 +552,27 @@  discard block
 block discarded – undo
552 552
 		$form = $this->filter_conditional_logic( $this->form );
553 553
 
554 554
 	    /** @var GF_Field $field */
555
-		foreach( $form['fields'] as $k => &$field ) {
555
+		foreach ( $form[ 'fields' ] as $k => &$field ) {
556 556
 
557 557
 			/**
558 558
 			 * Remove the fields with calculation formulas before save to avoid conflicts with GF logic
559 559
 			 * @since 1.16.3
560 560
 			 * @var GF_Field $field
561 561
 			 */
562
-			if( $field->has_calculation() ) {
563
-				unset( $form['fields'][ $k ] );
562
+			if ( $field->has_calculation() ) {
563
+				unset( $form[ 'fields' ][ $k ] );
564 564
 			}
565 565
 
566 566
 			$field->adminOnly = false;
567 567
 
568
-			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
569
-				foreach( $field->inputs as $key => $input ) {
570
-				    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
568
+			if ( isset( $field->inputs ) && is_array( $field->inputs ) ) {
569
+				foreach ( $field->inputs as $key => $input ) {
570
+				    $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ];
571 571
 				}
572 572
 			}
573 573
 		}
574 574
 
575
-		$form['fields'] = array_values( $form['fields'] );
575
+		$form[ 'fields' ] = array_values( $form[ 'fields' ] );
576 576
 
577 577
 		return $form;
578 578
 	}
@@ -584,14 +584,14 @@  discard block
 block discarded – undo
584 584
 		$update = false;
585 585
 
586 586
 		// get the most up to date entry values
587
-		$entry = GFAPI::get_entry( $this->entry['id'] );
587
+		$entry = GFAPI::get_entry( $this->entry[ 'id' ] );
588 588
 
589 589
 		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
590 590
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
591
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) );
591
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) );
592 592
 		} else {
593 593
 			$lead_detail_table = GFFormsModel::get_lead_details_table_name();
594
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) );
594
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) );
595 595
 		}
596 596
 
597 597
 
@@ -608,24 +608,24 @@  discard block
 block discarded – undo
608 608
 				$inputs = $field->get_entry_inputs();
609 609
 				if ( is_array( $inputs ) ) {
610 610
 				    foreach ( $inputs as $input ) {
611
-						list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 );
611
+						list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 );
612 612
 
613 613
 						if ( 'product' === $field->type ) {
614
-							$input_name = 'input_' . str_replace( '.', '_', $input['id'] );
614
+							$input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] );
615 615
 
616 616
 							// Only allow quantity to be set if it's allowed to be edited
617 617
 							if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) {
618 618
 							} else { // otherwise set to what it previously was
619
-								$_POST[ $input_name ] = $entry[ $input['id'] ];
619
+								$_POST[ $input_name ] = $entry[ $input[ 'id' ] ];
620 620
 							}
621 621
 						} else {
622 622
 							// Set to what it previously was if it's not editable
623 623
 							if ( ! in_array( $field_id, $allowed_fields ) ) {
624
-								$_POST[ $input_name ] = $entry[ $input['id'] ];
624
+								$_POST[ $input_name ] = $entry[ $input[ 'id' ] ];
625 625
 							}
626 626
 						}
627 627
 
628
-						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] );
628
+						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] );
629 629
 				    }
630 630
 				} else {
631 631
 					// Set to what it previously was if it's not editable
@@ -665,19 +665,19 @@  discard block
 block discarded – undo
665 665
 
666 666
 		$input_name = 'input_' . $field_id;
667 667
 
668
-		if ( !empty( $_FILES[ $input_name ]['name'] ) ) {
668
+		if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
669 669
 
670 670
 			// We have a new image
671 671
 
672
-			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
672
+			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] );
673 673
 
674 674
 			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
675 675
 	        $ary = stripslashes_deep( $ary );
676 676
 			$img_url = \GV\Utils::get( $ary, 0 );
677 677
 
678
-			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
679
-			$img_caption     = count( $ary ) > 2 ? $ary[2] : '';
680
-			$img_description = count( $ary ) > 3 ? $ary[3] : '';
678
+			$img_title       = count( $ary ) > 1 ? $ary[ 1 ] : '';
679
+			$img_caption     = count( $ary ) > 2 ? $ary[ 2 ] : '';
680
+			$img_description = count( $ary ) > 3 ? $ary[ 3 ] : '';
681 681
 
682 682
 			$image_meta = array(
683 683
 				'post_excerpt' => $img_caption,
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 
687 687
 			//adding title only if it is not empty. It will default to the file name if it is not in the array
688 688
 			if ( ! empty( $img_title ) ) {
689
-				$image_meta['post_title'] = $img_title;
689
+				$image_meta[ 'post_title' ] = $img_title;
690 690
 			}
691 691
 
692 692
 			/**
@@ -744,15 +744,15 @@  discard block
 block discarded – undo
744 744
 	 */
745 745
 	private function maybe_update_post_fields( $form ) {
746 746
 
747
-		if( empty( $this->entry['post_id'] ) ) {
747
+		if ( empty( $this->entry[ 'post_id' ] ) ) {
748 748
 	        gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
749 749
 			return;
750 750
 		}
751 751
 
752
-		$post_id = $this->entry['post_id'];
752
+		$post_id = $this->entry[ 'post_id' ];
753 753
 
754 754
 		// Security check
755
-		if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
755
+		if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
756 756
 			gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) );
757 757
 			return;
758 758
 		}
@@ -765,25 +765,25 @@  discard block
 block discarded – undo
765 765
 
766 766
 			$field = RGFormsModel::get_field( $form, $field_id );
767 767
 
768
-			if( ! $field ) {
768
+			if ( ! $field ) {
769 769
 				continue;
770 770
 			}
771 771
 
772
-			if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
772
+			if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
773 773
 
774 774
 				// Get the value of the field, including $_POSTed value
775 775
 				$value = RGFormsModel::get_field_value( $field );
776 776
 
777 777
 				// Use temporary entry variable, to make values available to fill_post_template() and update_post_image()
778 778
 				$entry_tmp = $this->entry;
779
-				$entry_tmp["{$field_id}"] = $value;
779
+				$entry_tmp[ "{$field_id}" ] = $value;
780 780
 
781
-				switch( $field->type ) {
781
+				switch ( $field->type ) {
782 782
 
783 783
 				    case 'post_title':
784 784
 				        $post_title = $value;
785 785
 				        if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
786
-				            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
786
+				            $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp );
787 787
 				        }
788 788
 				        $updated_post->post_title = $post_title;
789 789
 				        $updated_post->post_name  = $post_title;
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
 				    case 'post_content':
794 794
 				        $post_content = $value;
795 795
 				        if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
796
-				            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
796
+				            $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true );
797 797
 				        }
798 798
 				        $updated_post->post_content = $post_content;
799 799
 				        unset( $post_content );
@@ -811,11 +811,11 @@  discard block
 block discarded – undo
811 811
 							$value = $value[ $field_id ];
812 812
 						}
813 813
 
814
-				        if( ! empty( $field->customFieldTemplateEnabled ) ) {
814
+				        if ( ! empty( $field->customFieldTemplateEnabled ) ) {
815 815
 				            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
816 816
 				        }
817 817
 
818
-						$value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry );
818
+						$value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry );
819 819
 
820 820
 				        update_post_meta( $post_id, $field->postCustomFieldName, $value );
821 821
 				        break;
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 				}
828 828
 
829 829
 				// update entry after
830
-				$this->entry["{$field_id}"] = $value;
830
+				$this->entry[ "{$field_id}" ] = $value;
831 831
 
832 832
 				$update_entry = true;
833 833
 
@@ -836,11 +836,11 @@  discard block
 block discarded – undo
836 836
 
837 837
 		}
838 838
 
839
-		if( $update_entry ) {
839
+		if ( $update_entry ) {
840 840
 
841 841
 			$return_entry = GFAPI::update_entry( $this->entry );
842 842
 
843
-			if( is_wp_error( $return_entry ) ) {
843
+			if ( is_wp_error( $return_entry ) ) {
844 844
 				gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) );
845 845
 			} else {
846 846
 				gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) );
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 
851 851
 		$return_post = wp_update_post( $updated_post, true );
852 852
 
853
-		if( is_wp_error( $return_post ) ) {
853
+		if ( is_wp_error( $return_post ) ) {
854 854
 			$return_post->add_data( $updated_post, '$updated_post' );
855 855
 			gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) );
856 856
 		} else {
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 		$output = GFCommon::replace_variables( $output, $form, $entry, false, false, false );
885 885
 
886 886
 		// replace conditional shortcodes
887
-		if( $do_shortcode ) {
887
+		if ( $do_shortcode ) {
888 888
 			$output = do_shortcode( $output );
889 889
 		}
890 890
 
@@ -903,19 +903,19 @@  discard block
 block discarded – undo
903 903
 	 */
904 904
 	private function after_update() {
905 905
 
906
-		do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry );
907
-		do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry );
906
+		do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry );
907
+		do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry );
908 908
 
909 909
 		// Re-define the entry now that we've updated it.
910
-		$entry = RGFormsModel::get_lead( $this->entry['id'] );
910
+		$entry = RGFormsModel::get_lead( $this->entry[ 'id' ] );
911 911
 
912 912
 		$entry = GFFormsModel::set_entry_meta( $entry, self::$original_form );
913 913
 
914 914
 		if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) {
915 915
 			// We need to clear the cache because Gravity Forms caches the field values, which
916 916
 			// we have just updated.
917
-			foreach ($this->form['fields'] as $key => $field) {
918
-				GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );
917
+			foreach ( $this->form[ 'fields' ] as $key => $field ) {
918
+				GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id );
919 919
 			}
920 920
 		}
921 921
 
@@ -925,11 +925,11 @@  discard block
 block discarded – undo
925 925
 		 * @since develop
926 926
 		 */
927 927
 		if ( $allowed_feeds = $this->view->settings->get( 'edit_feeds', array() ) ) {
928
-			$feeds = GFAPI::get_feeds( null, $entry['form_id'] );
928
+			$feeds = GFAPI::get_feeds( null, $entry[ 'form_id' ] );
929 929
 			if ( ! is_wp_error( $feeds ) ) {
930 930
 				$registered_feeds = array();
931 931
 				foreach ( GFAddOn::get_registered_addons() as $registered_feed ) {
932
-					if ( is_subclass_of( $registered_feed,  'GFFeedAddOn' ) ) {
932
+					if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) {
933 933
 						if ( method_exists( $registered_feed, 'get_instance' ) ) {
934 934
 							$registered_feed = call_user_func( array( $registered_feed, 'get_instance' ) );
935 935
 							$registered_feeds[ $registered_feed->get_slug() ] = $registered_feed;
@@ -937,8 +937,8 @@  discard block
 block discarded – undo
937 937
 					}
938 938
 				}
939 939
 				foreach ( $feeds as $feed ) {
940
-					if ( in_array( $feed['id'], $allowed_feeds ) ) {
941
-						if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed['addon_slug'] ) ) {
940
+					if ( in_array( $feed[ 'id' ], $allowed_feeds ) ) {
941
+						if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed[ 'addon_slug' ] ) ) {
942 942
 							$returned_entry = $feed_object->process_feed( $feed, $entry, self::$original_form );
943 943
 							if ( is_array( $returned_entry ) && rgar( $returned_entry, 'id' ) ) {
944 944
 								$entry = $returned_entry;
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 
969 969
 		<div class="gv-edit-entry-wrapper"><?php
970 970
 
971
-			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );
971
+			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this );
972 972
 
973 973
 			/**
974 974
 			 * Fixes weird wpautop() issue
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 				     * @param string $edit_entry_title Modify the "Edit Entry" title
985 985
 				     * @param GravityView_Edit_Entry_Render $this This object
986 986
 				     */
987
-				    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
987
+				    $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this );
988 988
 
989 989
 				    echo esc_attr( $edit_entry_title );
990 990
 			?></span>
@@ -1034,13 +1034,13 @@  discard block
 block discarded – undo
1034 1034
 
1035 1035
 			$back_link = remove_query_arg( array( 'page', 'view', 'edit' ) );
1036 1036
 
1037
-			if( ! $this->is_valid ){
1037
+			if ( ! $this->is_valid ) {
1038 1038
 
1039 1039
 				// Keeping this compatible with Gravity Forms.
1040
-				$validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
1041
-				$message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form);
1040
+				$validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>";
1041
+				$message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form );
1042 1042
 
1043
-				echo GVCommon::generate_notice( $message , 'gv-error' );
1043
+				echo GVCommon::generate_notice( $message, 'gv-error' );
1044 1044
 
1045 1045
 			} else {
1046 1046
 				$view = \GV\View::by_id( $this->view_id );
@@ -1051,23 +1051,23 @@  discard block
 block discarded – undo
1051 1051
 
1052 1052
                     case '0':
1053 1053
 	                    $redirect_url = $back_link;
1054
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
1054
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' );
1055 1055
                         break;
1056 1056
 
1057 1057
                     case '1':
1058 1058
 	                    $redirect_url = $directory_link = GravityView_API::directory_link();
1059
-	                    $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>' );
1059
+	                    $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>' );
1060 1060
 	                    break;
1061 1061
 
1062 1062
                     case '2':
1063 1063
 	                    $redirect_url = $edit_redirect_url;
1064 1064
 	                    $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
1065
-	                    $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>' );
1065
+	                    $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>' );
1066 1066
                         break;
1067 1067
 
1068 1068
                     case '':
1069 1069
                     default:
1070
-					    $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
1070
+					    $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' );
1071 1071
                         break;
1072 1072
 				}
1073 1073
 
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
 				 * @param array $entry Gravity Forms entry array
1084 1084
 				 * @param string $back_link URL to return to the original entry. @since 1.6
1085 1085
 				 */
1086
-				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );
1086
+				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link );
1087 1087
 
1088 1088
 				echo GVCommon::generate_notice( $message );
1089 1089
 			}
@@ -1107,21 +1107,21 @@  discard block
 block discarded – undo
1107 1107
 		 */
1108 1108
 		do_action( 'gravityview/edit-entry/render/before', $this );
1109 1109
 
1110
-		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );
1111
-		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );
1110
+		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 );
1111
+		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
1112 1112
 		add_filter( 'gform_disable_view_counter', '__return_true' );
1113 1113
 
1114 1114
 		add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 );
1115 1115
 		add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );
1116 1116
 
1117 1117
 		// We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.
1118
-		unset( $_GET['page'] );
1118
+		unset( $_GET[ 'page' ] );
1119 1119
 
1120 1120
 		// TODO: Verify multiple-page forms
1121 1121
 
1122 1122
 		ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic
1123 1123
 
1124
-		$html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );
1124
+		$html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry );
1125 1125
 
1126 1126
 		ob_get_clean();
1127 1127
 
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
 	 * @return string
1148 1148
 	 */
1149 1149
 	public function render_form_buttons() {
1150
-		return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );
1150
+		return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this );
1151 1151
 	}
1152 1152
 
1153 1153
 
@@ -1167,10 +1167,10 @@  discard block
 block discarded – undo
1167 1167
 	public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) {
1168 1168
 
1169 1169
 		// In case we have validated the form, use it to inject the validation results into the form render
1170
-		if( isset( $this->form_after_validation ) && $this->form_after_validation['id'] === $form['id'] ) {
1170
+		if ( isset( $this->form_after_validation ) && $this->form_after_validation[ 'id' ] === $form[ 'id' ] ) {
1171 1171
 			$form = $this->form_after_validation;
1172 1172
 		} else {
1173
-			$form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );
1173
+			$form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id );
1174 1174
 		}
1175 1175
 
1176 1176
 		$form = $this->filter_conditional_logic( $form );
@@ -1178,8 +1178,8 @@  discard block
 block discarded – undo
1178 1178
 		$form = $this->prefill_conditional_logic( $form );
1179 1179
 
1180 1180
 		// for now we don't support Save and Continue feature.
1181
-		if( ! self::$supports_save_and_continue ) {
1182
-	        unset( $form['save'] );
1181
+		if ( ! self::$supports_save_and_continue ) {
1182
+	        unset( $form[ 'save' ] );
1183 1183
 		}
1184 1184
 
1185 1185
 		$form = $this->unselect_default_values( $form );
@@ -1202,31 +1202,31 @@  discard block
 block discarded – undo
1202 1202
 	 */
1203 1203
 	public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) {
1204 1204
 
1205
-		if( ! GFCommon::is_post_field( $field ) ) {
1205
+		if ( ! GFCommon::is_post_field( $field ) ) {
1206 1206
 			return $field_content;
1207 1207
 		}
1208 1208
 
1209 1209
         $message = null;
1210 1210
 
1211 1211
         // First, make sure they have the capability to edit the post.
1212
-        if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1212
+        if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) {
1213 1213
 
1214 1214
             /**
1215 1215
              * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1216 1216
              * @param string $message The existing "You don't have permission..." text
1217 1217
              */
1218
-            $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1218
+            $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don&rsquo;t have permission to edit this post.', 'gravityview' ) );
1219 1219
 
1220
-        } elseif( null === get_post( $this->entry['post_id'] ) ) {
1220
+        } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) {
1221 1221
             /**
1222 1222
              * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1223 1223
              * @param string $message The existing "This field is not editable; the post no longer exists." text
1224 1224
              */
1225
-            $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1225
+            $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) );
1226 1226
         }
1227 1227
 
1228
-        if( $message ) {
1229
-            $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1228
+        if ( $message ) {
1229
+            $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1230 1230
         }
1231 1231
 
1232 1232
         return $field_content;
@@ -1250,8 +1250,8 @@  discard block
 block discarded – undo
1250 1250
 
1251 1251
 		// If the form has been submitted, then we don't need to pre-fill the values,
1252 1252
 		// Except for fileupload type and when a field input is overridden- run always!!
1253
-		if(
1254
-			( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1253
+		if (
1254
+			( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1255 1255
 			&& false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) )
1256 1256
 			&& ! GFCommon::is_product_field( $field->type )
1257 1257
 			|| ! empty( $field_content )
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
 	    $return = null;
1272 1272
 
1273 1273
 		/** @var GravityView_Field $gv_field */
1274
-		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1274
+		if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1275 1275
 			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1276 1276
 		} else {
1277 1277
 	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
@@ -1280,7 +1280,7 @@  discard block
 block discarded – undo
1280 1280
 	    // If there was output, it's an error
1281 1281
 	    $warnings = ob_get_clean();
1282 1282
 
1283
-	    if( !empty( $warnings ) ) {
1283
+	    if ( ! empty( $warnings ) ) {
1284 1284
 		    gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1285 1285
 	    }
1286 1286
 
@@ -1305,7 +1305,7 @@  discard block
 block discarded – undo
1305 1305
 		$override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );
1306 1306
 
1307 1307
 		// We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)
1308
-		if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) {
1308
+		if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) {
1309 1309
 
1310 1310
 			$field_value = array();
1311 1311
 
@@ -1314,10 +1314,10 @@  discard block
 block discarded – undo
1314 1314
 
1315 1315
 			foreach ( (array)$field->inputs as $input ) {
1316 1316
 
1317
-				$input_id = strval( $input['id'] );
1317
+				$input_id = strval( $input[ 'id' ] );
1318 1318
 
1319 1319
 				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1320
-				    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1320
+				    $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1321 1321
 				    $allow_pre_populated = false;
1322 1322
 				}
1323 1323
 
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
 
1326 1326
 			$pre_value = $field->get_value_submission( array(), false );
1327 1327
 
1328
-			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1328
+			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1329 1329
 
1330 1330
 		} else {
1331 1331
 
@@ -1336,13 +1336,13 @@  discard block
 block discarded – undo
1336 1336
 
1337 1337
 			// saved field entry value (if empty, fallback to the pre-populated value, if exists)
1338 1338
 			// or pre-populated value if not empty and set to override saved value
1339
-			$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;
1339
+			$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;
1340 1340
 
1341 1341
 			// in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.
1342
-			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1342
+			if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) {
1343 1343
 				$categories = array();
1344 1344
 				foreach ( explode( ',', $field_value ) as $cat_string ) {
1345
-				    $categories[] = GFCommon::format_post_category( $cat_string, true );
1345
+				    $categories[ ] = GFCommon::format_post_category( $cat_string, true );
1346 1346
 				}
1347 1347
 				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1348 1348
 			}
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
 	     * @param GF_Field $field Gravity Forms field object
1371 1371
 	     * @param GravityView_Edit_Entry_Render $this Current object
1372 1372
 	     */
1373
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1373
+	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this );
1374 1374
 
1375 1375
 		return $field_value;
1376 1376
 	}
@@ -1387,12 +1387,12 @@  discard block
 block discarded – undo
1387 1387
 	 */
1388 1388
 	public function gform_pre_validation( $form ) {
1389 1389
 
1390
-		if( ! $this->verify_nonce() ) {
1390
+		if ( ! $this->verify_nonce() ) {
1391 1391
 			return $form;
1392 1392
 		}
1393 1393
 
1394 1394
 		// Fix PHP warning regarding undefined index.
1395
-		foreach ( $form['fields'] as &$field) {
1395
+		foreach ( $form[ 'fields' ] as &$field ) {
1396 1396
 
1397 1397
 			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1398 1398
 			// expects certain field array items to be set.
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1401 1401
 			}
1402 1402
 
1403
-			switch( RGFormsModel::get_input_type( $field ) ) {
1403
+			switch ( RGFormsModel::get_input_type( $field ) ) {
1404 1404
 
1405 1405
 				/**
1406 1406
 				 * 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.
@@ -1414,26 +1414,26 @@  discard block
 block discarded – undo
1414 1414
 				    // Set the previous value
1415 1415
 				    $entry = $this->get_entry();
1416 1416
 
1417
-				    $input_name = 'input_'.$field->id;
1418
-				    $form_id = $form['id'];
1417
+				    $input_name = 'input_' . $field->id;
1418
+				    $form_id = $form[ 'id' ];
1419 1419
 
1420 1420
 				    $value = NULL;
1421 1421
 
1422 1422
 				    // Use the previous entry value as the default.
1423
-				    if( isset( $entry[ $field->id ] ) ) {
1423
+				    if ( isset( $entry[ $field->id ] ) ) {
1424 1424
 				        $value = $entry[ $field->id ];
1425 1425
 				    }
1426 1426
 
1427 1427
 				    // If this is a single upload file
1428
-				    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1429
-				        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1430
-				        $value = $file_path['url'];
1428
+				    if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
1429
+				        $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] );
1430
+				        $value = $file_path[ 'url' ];
1431 1431
 
1432 1432
 				    } else {
1433 1433
 
1434 1434
 				        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1435 1435
 				        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1436
-				        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1436
+				        $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' );
1437 1437
 
1438 1438
 				    }
1439 1439
 
@@ -1441,10 +1441,10 @@  discard block
 block discarded – undo
1441 1441
 
1442 1442
 				        // If there are fresh uploads, process and merge them.
1443 1443
 				        // Otherwise, use the passed values, which should be json-encoded array of URLs
1444
-				        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1444
+				        if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) {
1445 1445
 				            $value = empty( $value ) ? '[]' : $value;
1446 1446
 				            $value = stripslashes_deep( $value );
1447
-				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1447
+				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() );
1448 1448
 				        }
1449 1449
 
1450 1450
 				    } else {
@@ -1462,8 +1462,8 @@  discard block
 block discarded – undo
1462 1462
 
1463 1463
 				case 'number':
1464 1464
 				    // Fix "undefined index" issue at line 1286 in form_display.php
1465
-				    if( !isset( $_POST['input_'.$field->id ] ) ) {
1466
-				        $_POST['input_'.$field->id ] = NULL;
1465
+				    if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) {
1466
+				        $_POST[ 'input_' . $field->id ] = NULL;
1467 1467
 				    }
1468 1468
 				    break;
1469 1469
 			}
@@ -1500,7 +1500,7 @@  discard block
 block discarded – undo
1500 1500
 		 * You can enter whatever you want!
1501 1501
 		 * We try validating, and customize the results using `self::custom_validation()`
1502 1502
 		 */
1503
-		add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);
1503
+		add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 );
1504 1504
 
1505 1505
 		// Needed by the validate funtion
1506 1506
 		$failed_validation_page = NULL;
@@ -1508,14 +1508,14 @@  discard block
 block discarded – undo
1508 1508
 
1509 1509
 		// Prevent entry limit from running when editing an entry, also
1510 1510
 		// prevent form scheduling from preventing editing
1511
-		unset( $this->form['limitEntries'], $this->form['scheduleForm'] );
1511
+		unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] );
1512 1512
 
1513 1513
 		// Hide fields depending on Edit Entry settings
1514
-		$this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1514
+		$this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1515 1515
 
1516 1516
 		$this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );
1517 1517
 
1518
-		remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 );
1518
+		remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 );
1519 1519
 	}
1520 1520
 
1521 1521
 
@@ -1538,7 +1538,7 @@  discard block
 block discarded – undo
1538 1538
 
1539 1539
 		$gv_valid = true;
1540 1540
 
1541
-		foreach ( $validation_results['form']['fields'] as $key => &$field ) {
1541
+		foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) {
1542 1542
 
1543 1543
 			$value = RGFormsModel::get_field_value( $field );
1544 1544
 			$field_type = RGFormsModel::get_input_type( $field );
@@ -1551,22 +1551,22 @@  discard block
 block discarded – undo
1551 1551
 				case 'post_image':
1552 1552
 
1553 1553
 				    // in case nothing is uploaded but there are already files saved
1554
-				    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1554
+				    if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) {
1555 1555
 				        $field->failed_validation = false;
1556 1556
 				        unset( $field->validation_message );
1557 1557
 				    }
1558 1558
 
1559 1559
 				    // validate if multi file upload reached max number of files [maxFiles] => 2
1560
-				    if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1560
+				    if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) {
1561 1561
 
1562 1562
 				        $input_name = 'input_' . $field->id;
1563 1563
 				        //uploaded
1564
-				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1564
+				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array();
1565 1565
 
1566 1566
 				        //existent
1567 1567
 				        $entry = $this->get_entry();
1568 1568
 				        $value = NULL;
1569
-				        if( isset( $entry[ $field->id ] ) ) {
1569
+				        if ( isset( $entry[ $field->id ] ) ) {
1570 1570
 				            $value = json_decode( $entry[ $field->id ], true );
1571 1571
 				        }
1572 1572
 
@@ -1574,13 +1574,13 @@  discard block
 block discarded – undo
1574 1574
 				        $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) +
1575 1575
 						               ( is_array( $value ) ? count( $value ) : 0 );
1576 1576
 
1577
-				        if( $count_files > $field->maxFiles ) {
1577
+				        if ( $count_files > $field->maxFiles ) {
1578 1578
 				            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1579 1579
 				            $field->failed_validation = 1;
1580 1580
 				            $gv_valid = false;
1581 1581
 
1582 1582
 				            // in case of error make sure the newest upload files are removed from the upload input
1583
-				            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1583
+				            GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null;
1584 1584
 				        }
1585 1585
 
1586 1586
 				    }
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
 			}
1592 1592
 
1593 1593
 			// This field has failed validation.
1594
-			if( !empty( $field->failed_validation ) ) {
1594
+			if ( ! empty( $field->failed_validation ) ) {
1595 1595
 
1596 1596
 				gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) );
1597 1597
 
@@ -1609,19 +1609,19 @@  discard block
 block discarded – undo
1609 1609
 				}
1610 1610
 
1611 1611
 				// You can't continue inside a switch, so we do it after.
1612
-				if( empty( $field->failed_validation ) ) {
1612
+				if ( empty( $field->failed_validation ) ) {
1613 1613
 				    continue;
1614 1614
 				}
1615 1615
 
1616 1616
 				// checks if the No Duplicates option is not validating entry against itself, since
1617 1617
 				// we're editing a stored entry, it would also assume it's a duplicate.
1618
-				if( !empty( $field->noDuplicates ) ) {
1618
+				if ( ! empty( $field->noDuplicates ) ) {
1619 1619
 
1620 1620
 				    $entry = $this->get_entry();
1621 1621
 
1622 1622
 				    // If the value of the entry is the same as the stored value
1623 1623
 				    // Then we can assume it's not a duplicate, it's the same.
1624
-				    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1624
+				    if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) {
1625 1625
 				        //if value submitted was not changed, then don't validate
1626 1626
 				        $field->failed_validation = false;
1627 1627
 
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
 				}
1635 1635
 
1636 1636
 				// if here then probably we are facing the validation 'At least one field must be filled out'
1637
-				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1637
+				if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) {
1638 1638
 				    unset( $field->validation_message );
1639 1639
 	                $field->validation_message = false;
1640 1640
 				    continue;
@@ -1646,12 +1646,12 @@  discard block
 block discarded – undo
1646 1646
 
1647 1647
 		}
1648 1648
 
1649
-		$validation_results['is_valid'] = $gv_valid;
1649
+		$validation_results[ 'is_valid' ] = $gv_valid;
1650 1650
 
1651 1651
 		gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) );
1652 1652
 
1653 1653
 		// We'll need this result when rendering the form ( on GFFormDisplay::get_form )
1654
-		$this->form_after_validation = $validation_results['form'];
1654
+		$this->form_after_validation = $validation_results[ 'form' ];
1655 1655
 
1656 1656
 		return $validation_results;
1657 1657
 	}
@@ -1664,7 +1664,7 @@  discard block
 block discarded – undo
1664 1664
 	 */
1665 1665
 	public function get_entry() {
1666 1666
 
1667
-		if( empty( $this->entry ) ) {
1667
+		if ( empty( $this->entry ) ) {
1668 1668
 			// Get the database value of the entry that's being edited
1669 1669
 			$this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );
1670 1670
 		}
@@ -1696,10 +1696,10 @@  discard block
 block discarded – undo
1696 1696
 		}
1697 1697
 
1698 1698
 		// If edit tab not yet configured, show all fields
1699
-		$edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;
1699
+		$edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL;
1700 1700
 
1701 1701
 		// Hide fields depending on admin settings
1702
-		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1702
+		$fields = $this->filter_fields( $form[ 'fields' ], $edit_fields );
1703 1703
 
1704 1704
 	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1705 1705
 	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
@@ -1732,7 +1732,7 @@  discard block
 block discarded – undo
1732 1732
 	 */
1733 1733
 	private function filter_fields( $fields, $configured_fields ) {
1734 1734
 
1735
-		if( empty( $fields ) || !is_array( $fields ) ) {
1735
+		if ( empty( $fields ) || ! is_array( $fields ) ) {
1736 1736
 			return $fields;
1737 1737
 		}
1738 1738
 
@@ -1745,12 +1745,12 @@  discard block
 block discarded – undo
1745 1745
 
1746 1746
 			// Remove the fields that have calculation properties and keep them to be used later
1747 1747
 			// @since 1.16.2
1748
-			if( $field->has_calculation() ) {
1749
-				$this->fields_with_calculation[] = $field;
1748
+			if ( $field->has_calculation() ) {
1749
+				$this->fields_with_calculation[ ] = $field;
1750 1750
 				// don't remove the calculation fields on form render.
1751 1751
 			}
1752 1752
 
1753
-			if( in_array( $field->type, $field_type_blacklist ) ) {
1753
+			if ( in_array( $field->type, $field_type_blacklist ) ) {
1754 1754
 				unset( $fields[ $key ] );
1755 1755
 			}
1756 1756
 		}
@@ -1768,7 +1768,7 @@  discard block
 block discarded – undo
1768 1768
 					continue; // Same
1769 1769
 				}
1770 1770
 
1771
-				$out_fields[] = $field;
1771
+				$out_fields[ ] = $field;
1772 1772
 			}
1773 1773
 
1774 1774
 			return array_values( $out_fields );
@@ -1779,8 +1779,8 @@  discard block
 block discarded – undo
1779 1779
 
1780 1780
 	        /** @var GF_Field $field */
1781 1781
 	        foreach ( $fields as $field ) {
1782
-				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1783
-				    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1782
+				if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1783
+				    $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field );
1784 1784
 				    break;
1785 1785
 				}
1786 1786
 
@@ -1803,14 +1803,14 @@  discard block
 block discarded – undo
1803 1803
 
1804 1804
 		$return_field = $field;
1805 1805
 
1806
-		if( empty( $field_setting['show_label'] ) ) {
1806
+		if ( empty( $field_setting[ 'show_label' ] ) ) {
1807 1807
 			$return_field->label = '';
1808
-		} elseif ( !empty( $field_setting['custom_label'] ) ) {
1809
-			$return_field->label = $field_setting['custom_label'];
1808
+		} elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) {
1809
+			$return_field->label = $field_setting[ 'custom_label' ];
1810 1810
 		}
1811 1811
 
1812
-		if( !empty( $field_setting['custom_class'] ) ) {
1813
-			$return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );
1812
+		if ( ! empty( $field_setting[ 'custom_class' ] ) ) {
1813
+			$return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] );
1814 1814
 		}
1815 1815
 
1816 1816
 		/**
@@ -1848,16 +1848,16 @@  discard block
 block discarded – undo
1848 1848
 	     */
1849 1849
 	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1850 1850
 
1851
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1852
-			foreach( $fields as $k => $field ) {
1853
-				if( $field->adminOnly ) {
1851
+	    if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) {
1852
+			foreach ( $fields as $k => $field ) {
1853
+				if ( $field->adminOnly ) {
1854 1854
 				    unset( $fields[ $k ] );
1855 1855
 				}
1856 1856
 			}
1857 1857
 			return array_values( $fields );
1858 1858
 		}
1859 1859
 
1860
-	    foreach( $fields as &$field ) {
1860
+	    foreach ( $fields as &$field ) {
1861 1861
 		    $field->adminOnly = false;
1862 1862
 		}
1863 1863
 
@@ -1878,7 +1878,7 @@  discard block
 block discarded – undo
1878 1878
 	 */
1879 1879
 	private function unselect_default_values( $form ) {
1880 1880
 
1881
-	    foreach ( $form['fields'] as &$field ) {
1881
+	    foreach ( $form[ 'fields' ] as &$field ) {
1882 1882
 
1883 1883
 			if ( empty( $field->choices ) ) {
1884 1884
                 continue;
@@ -1886,7 +1886,7 @@  discard block
 block discarded – undo
1886 1886
 
1887 1887
             foreach ( $field->choices as &$choice ) {
1888 1888
 				if ( \GV\Utils::get( $choice, 'isSelected' ) ) {
1889
-					$choice['isSelected'] = false;
1889
+					$choice[ 'isSelected' ] = false;
1890 1890
 				}
1891 1891
 			}
1892 1892
 		}
@@ -1911,22 +1911,22 @@  discard block
 block discarded – undo
1911 1911
 	 */
1912 1912
 	function prefill_conditional_logic( $form ) {
1913 1913
 
1914
-		if( ! GFFormDisplay::has_conditional_logic( $form ) ) {
1914
+		if ( ! GFFormDisplay::has_conditional_logic( $form ) ) {
1915 1915
 			return $form;
1916 1916
 		}
1917 1917
 
1918 1918
 		// Have Conditional Logic pre-fill fields as if the data were default values
1919 1919
 		/** @var GF_Field $field */
1920
-		foreach ( $form['fields'] as &$field ) {
1920
+		foreach ( $form[ 'fields' ] as &$field ) {
1921 1921
 
1922
-			if( 'checkbox' === $field->type ) {
1922
+			if ( 'checkbox' === $field->type ) {
1923 1923
 				foreach ( $field->get_entry_inputs() as $key => $input ) {
1924
-				    $input_id = $input['id'];
1924
+				    $input_id = $input[ 'id' ];
1925 1925
 				    $choice = $field->choices[ $key ];
1926 1926
 				    $value = \GV\Utils::get( $this->entry, $input_id );
1927 1927
 				    $match = RGFormsModel::choice_value_match( $field, $choice, $value );
1928
-				    if( $match ) {
1929
-				        $field->choices[ $key ]['isSelected'] = true;
1928
+				    if ( $match ) {
1929
+				        $field->choices[ $key ][ 'isSelected' ] = true;
1930 1930
 				    }
1931 1931
 				}
1932 1932
 			} else {
@@ -1934,15 +1934,15 @@  discard block
 block discarded – undo
1934 1934
 				// We need to run through each field to set the default values
1935 1935
 				foreach ( $this->entry as $field_id => $field_value ) {
1936 1936
 
1937
-				    if( floatval( $field_id ) === floatval( $field->id ) ) {
1937
+				    if ( floatval( $field_id ) === floatval( $field->id ) ) {
1938 1938
 
1939
-				        if( 'list' === $field->type ) {
1939
+				        if ( 'list' === $field->type ) {
1940 1940
 				            $list_rows = maybe_unserialize( $field_value );
1941 1941
 
1942 1942
 				            $list_field_value = array();
1943
-				            foreach ( (array) $list_rows as $row ) {
1944
-				                foreach ( (array) $row as $column ) {
1945
-				                    $list_field_value[] = $column;
1943
+				            foreach ( (array)$list_rows as $row ) {
1944
+				                foreach ( (array)$row as $column ) {
1945
+				                    $list_field_value[ ] = $column;
1946 1946
 				                }
1947 1947
 				            }
1948 1948
 
@@ -1975,32 +1975,32 @@  discard block
 block discarded – undo
1975 1975
 		 * @see https://github.com/gravityview/GravityView/issues/840
1976 1976
 		 * @since develop
1977 1977
 		 */
1978
-		$the_form = GFAPI::get_form( $form['id'] );
1978
+		$the_form = GFAPI::get_form( $form[ 'id' ] );
1979 1979
 		$editable_ids = array();
1980
-		foreach ( $form['fields'] as $field ) {
1981
-			$editable_ids[] = $field['id']; // wp_list_pluck is destructive in this context
1980
+		foreach ( $form[ 'fields' ] as $field ) {
1981
+			$editable_ids[ ] = $field[ 'id' ]; // wp_list_pluck is destructive in this context
1982 1982
 		}
1983 1983
 		$remove_conditions_rule = array();
1984
-		foreach ( $the_form['fields'] as $field ) {
1985
-			if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic['rules'] ) ) {
1986
-				foreach ( $field->conditionalLogic['rules'] as $i => $rule ) {
1987
-					if ( ! in_array( $rule['fieldId'], $editable_ids ) ) {
1984
+		foreach ( $the_form[ 'fields' ] as $field ) {
1985
+			if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic[ 'rules' ] ) ) {
1986
+				foreach ( $field->conditionalLogic[ 'rules' ] as $i => $rule ) {
1987
+					if ( ! in_array( $rule[ 'fieldId' ], $editable_ids ) ) {
1988 1988
 						/**
1989 1989
 						 * This conditional field is not editable in this View.
1990 1990
 						 * We need to remove the rule, but only if it matches.
1991 1991
 						 */
1992
-						if ( $_field = GFAPI::get_field( $the_form, $rule['fieldId'] ) ) {
1992
+						if ( $_field = GFAPI::get_field( $the_form, $rule[ 'fieldId' ] ) ) {
1993 1993
 							$value = $_field->get_value_export( $this->entry );
1994
-						} elseif ( isset( $this->entry[ $rule['fieldId'] ] ) ) {
1995
-							$value = $this->entry[ $rule['fieldId'] ];
1994
+						} elseif ( isset( $this->entry[ $rule[ 'fieldId' ] ] ) ) {
1995
+							$value = $this->entry[ $rule[ 'fieldId' ] ];
1996 1996
 						} else {
1997
-							$value = gform_get_meta( $this->entry['id'], $rule['fieldId'] );
1997
+							$value = gform_get_meta( $this->entry[ 'id' ], $rule[ 'fieldId' ] );
1998 1998
 						}
1999 1999
 
2000
-						$match = GFFormsModel::matches_operation( $value, $rule['value'], $rule['operator'] );
2000
+						$match = GFFormsModel::matches_operation( $value, $rule[ 'value' ], $rule[ 'operator' ] );
2001 2001
 						
2002 2002
 						if ( $match ) {
2003
-							$remove_conditions_rule[] = array( $field['id'], $i );
2003
+							$remove_conditions_rule[ ] = array( $field[ 'id' ], $i );
2004 2004
 						}
2005 2005
 					}
2006 2006
 				}
@@ -2008,21 +2008,21 @@  discard block
 block discarded – undo
2008 2008
 		}
2009 2009
 
2010 2010
 		if ( $remove_conditions_rule ) {
2011
-			foreach ( $form['fields'] as &$field ) {
2011
+			foreach ( $form[ 'fields' ] as &$field ) {
2012 2012
 				foreach ( $remove_conditions_rule as $_remove_conditions_r ) {
2013 2013
 
2014 2014
 				    list( $rule_field_id, $rule_i ) = $_remove_conditions_r;
2015 2015
 
2016
-					if ( $field['id'] == $rule_field_id ) {
2017
-						unset( $field->conditionalLogic['rules'][ $rule_i ] );
2018
-						gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field['id'] ) );
2016
+					if ( $field[ 'id' ] == $rule_field_id ) {
2017
+						unset( $field->conditionalLogic[ 'rules' ][ $rule_i ] );
2018
+						gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field[ 'id' ] ) );
2019 2019
 					}
2020 2020
 				}
2021 2021
 			}
2022 2022
 		}
2023 2023
 
2024 2024
 		/** Normalize the indices... */
2025
-		$form['fields'] = array_values( $form['fields'] );
2025
+		$form[ 'fields' ] = array_values( $form[ 'fields' ] );
2026 2026
 
2027 2027
 		/**
2028 2028
 		 * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields?
@@ -2032,16 +2032,16 @@  discard block
 block discarded – undo
2032 2032
 		 */
2033 2033
 		$use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );
2034 2034
 
2035
-		if( $use_conditional_logic ) {
2035
+		if ( $use_conditional_logic ) {
2036 2036
 			return $form;
2037 2037
 		}
2038 2038
 
2039
-		foreach( $form['fields'] as &$field ) {
2039
+		foreach ( $form[ 'fields' ] as &$field ) {
2040 2040
 			/* @var GF_Field $field */
2041 2041
 			$field->conditionalLogic = null;
2042 2042
 		}
2043 2043
 
2044
-		unset( $form['button']['conditionalLogic'] );
2044
+		unset( $form[ 'button' ][ 'conditionalLogic' ] );
2045 2045
 
2046 2046
 		return $form;
2047 2047
 
@@ -2058,7 +2058,7 @@  discard block
 block discarded – undo
2058 2058
 	 */
2059 2059
 	public function manage_conditional_logic( $has_conditional_logic, $form ) {
2060 2060
 
2061
-		if( ! $this->is_edit_entry() ) {
2061
+		if ( ! $this->is_edit_entry() ) {
2062 2062
 			return $has_conditional_logic;
2063 2063
 		}
2064 2064
 
@@ -2090,44 +2090,44 @@  discard block
 block discarded – undo
2090 2090
 		 *  2. There are two entries embedded using oEmbed
2091 2091
 		 *  3. One of the entries has just been saved
2092 2092
 		 */
2093
-		if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) {
2093
+		if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) {
2094 2094
 
2095 2095
 			$error = true;
2096 2096
 
2097 2097
 		}
2098 2098
 
2099
-		if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) {
2099
+		if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) {
2100 2100
 
2101 2101
 			$error = true;
2102 2102
 
2103
-		} elseif( ! $this->verify_nonce() ) {
2103
+		} elseif ( ! $this->verify_nonce() ) {
2104 2104
 
2105 2105
 			/**
2106 2106
 			 * If the Entry is embedded, there may be two entries on the same page.
2107 2107
 			 * If that's the case, and one is being edited, the other should fail gracefully and not display an error.
2108 2108
 			 */
2109
-			if( GravityView_oEmbed::getInstance()->get_entry_id() ) {
2109
+			if ( GravityView_oEmbed::getInstance()->get_entry_id() ) {
2110 2110
 				$error = true;
2111 2111
 			} else {
2112
-				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');
2112
+				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' );
2113 2113
 			}
2114 2114
 
2115 2115
 		}
2116 2116
 
2117
-		if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
2118
-			$error = __( 'You do not have permission to edit this entry.', 'gravityview');
2117
+		if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
2118
+			$error = __( 'You do not have permission to edit this entry.', 'gravityview' );
2119 2119
 		}
2120 2120
 
2121
-		if( $this->entry['status'] === 'trash' ) {
2122
-			$error = __('You cannot edit the entry; it is in the trash.', 'gravityview' );
2121
+		if ( $this->entry[ 'status' ] === 'trash' ) {
2122
+			$error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' );
2123 2123
 		}
2124 2124
 
2125 2125
 		// No errors; everything's fine here!
2126
-		if( empty( $error ) ) {
2126
+		if ( empty( $error ) ) {
2127 2127
 			return true;
2128 2128
 		}
2129 2129
 
2130
-		if( $echo && $error !== true ) {
2130
+		if ( $echo && $error !== true ) {
2131 2131
 
2132 2132
 	        $error = esc_html( $error );
2133 2133
 
@@ -2135,10 +2135,10 @@  discard block
 block discarded – undo
2135 2135
 	         * @since 1.9
2136 2136
 	         */
2137 2137
 	        if ( ! empty( $this->entry ) ) {
2138
-		        $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;" ) );
2138
+		        $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;" ) );
2139 2139
 	        }
2140 2140
 
2141
-			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
2141
+			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' );
2142 2142
 		}
2143 2143
 
2144 2144
 		gravityview()->log->error( '{error}', array( 'error' => $error ) );
@@ -2158,17 +2158,17 @@  discard block
 block discarded – undo
2158 2158
 
2159 2159
 		$error = NULL;
2160 2160
 
2161
-		if( ! $this->check_user_cap_edit_field( $field ) ) {
2162
-			$error = __( 'You do not have permission to edit this field.', 'gravityview');
2161
+		if ( ! $this->check_user_cap_edit_field( $field ) ) {
2162
+			$error = __( 'You do not have permission to edit this field.', 'gravityview' );
2163 2163
 		}
2164 2164
 
2165 2165
 		// No errors; everything's fine here!
2166
-		if( empty( $error ) ) {
2166
+		if ( empty( $error ) ) {
2167 2167
 			return true;
2168 2168
 		}
2169 2169
 
2170
-		if( $echo ) {
2171
-			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');
2170
+		if ( $echo ) {
2171
+			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' );
2172 2172
 		}
2173 2173
 
2174 2174
 		gravityview()->log->error( '{error}', array( 'error' => $error ) );
@@ -2189,14 +2189,14 @@  discard block
 block discarded – undo
2189 2189
 	private function check_user_cap_edit_field( $field ) {
2190 2190
 
2191 2191
 		// If they can edit any entries (as defined in Gravity Forms), we're good.
2192
-		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
2192
+		if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
2193 2193
 			return true;
2194 2194
 		}
2195 2195
 
2196
-		$field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;
2196
+		$field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false;
2197 2197
 
2198
-		if( $field_cap ) {
2199
-			return GVCommon::has_cap( $field['allow_edit_cap'] );
2198
+		if ( $field_cap ) {
2199
+			return GVCommon::has_cap( $field[ 'allow_edit_cap' ] );
2200 2200
 		}
2201 2201
 
2202 2202
 		return false;
@@ -2210,17 +2210,17 @@  discard block
 block discarded – undo
2210 2210
 	public function verify_nonce() {
2211 2211
 
2212 2212
 		// Verify form submitted for editing single
2213
-		if( $this->is_edit_entry_submission() ) {
2213
+		if ( $this->is_edit_entry_submission() ) {
2214 2214
 			$valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );
2215 2215
 		}
2216 2216
 
2217 2217
 		// Verify
2218
-		else if( ! $this->is_edit_entry() ) {
2218
+		else if ( ! $this->is_edit_entry() ) {
2219 2219
 			$valid = false;
2220 2220
 		}
2221 2221
 
2222 2222
 		else {
2223
-			$valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
2223
+			$valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key );
2224 2224
 		}
2225 2225
 
2226 2226
 		/**
Please login to merge, or discard this patch.