Completed
Pull Request — master (#1171)
by Gennady
73:03 queued 17:46
created
includes/extensions/edit-entry/class-edit-entry-render.php 1 patch
Indentation   +287 added lines, -287 removed lines patch added patch discarded remove patch
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
 
95 95
 	/**
96 96
 	 * ID of the current post. May also be ID of the current View.
97
-     *
98
-     * @since 2.0.13
99
-     * 
100
-     * @var int
97
+	 *
98
+	 * @since 2.0.13
99
+	 * 
100
+	 * @var int
101 101
 	 */
102 102
 	public $post_id;
103 103
 
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
 	public function prevent_maybe_process_form() {
170 170
 
171 171
 		if( ! empty( $_POST ) ) {
172
-	        gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) );
172
+			gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) );
173 173
 		}
174 174
 
175 175
 		if( $this->is_edit_entry_submission() ) {
176 176
 			remove_action( 'wp',  array( 'RGForms', 'maybe_process_form'), 9 );
177
-	        remove_action( 'wp',  array( 'GFForms', 'maybe_process_form'), 9 );
177
+			remove_action( 'wp',  array( 'GFForms', 'maybe_process_form'), 9 );
178 178
 		}
179 179
 	}
180 180
 
@@ -202,14 +202,14 @@  discard block
 block discarded – undo
202 202
 	 * When Edit entry view is requested setup the vars
203 203
 	 */
204 204
 	private function setup_vars() {
205
-        global $post;
205
+		global $post;
206 206
 
207 207
 		$gravityview_view = GravityView_View::getInstance();
208 208
 
209 209
 
210 210
 		$entries = $gravityview_view->getEntries();
211
-	    self::$original_entry = $entries[0];
212
-	    $this->entry = $entries[0];
211
+		self::$original_entry = $entries[0];
212
+		$this->entry = $entries[0];
213 213
 
214 214
 		self::$original_form = $gravityview_view->getForm();
215 215
 		$this->form = $gravityview_view->getForm();
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
 
334 334
 			GFFormsModel::save_lead( $form, $this->entry );
335 335
 
336
-	        // Delete the values for hidden inputs
337
-	        $this->unset_hidden_field_values();
336
+			// Delete the values for hidden inputs
337
+			$this->unset_hidden_field_values();
338 338
 			
339 339
 			$this->entry['date_created'] = $date_created;
340 340
 
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 			// Perform actions normally performed after updating a lead
348 348
 			$this->after_update();
349 349
 
350
-	        /**
350
+			/**
351 351
 			 * Must be AFTER after_update()!
352 352
 			 * @see https://github.com/gravityview/GravityView/issues/764
353 353
 			 */
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 
356 356
 			/**
357 357
 			 * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry
358
-             * @since 2.1 Added $gv_data parameter
358
+			 * @since 2.1 Added $gv_data parameter
359 359
 			 * @param array $form Gravity Forms form array
360 360
 			 * @param string $entry_id Numeric ID of the entry that was updated
361 361
 			 * @param GravityView_Edit_Entry_Render $this This object
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 	 * @return void
380 380
 	 */
381 381
 	private function unset_hidden_field_values() {
382
-	    global $wpdb;
382
+		global $wpdb;
383 383
 
384 384
 		/**
385 385
 		 * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic
@@ -401,27 +401,27 @@  discard block
 block discarded – undo
401 401
 			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );
402 402
 		}
403 403
 
404
-	    foreach ( $this->entry as $input_id => $field_value ) {
404
+		foreach ( $this->entry as $input_id => $field_value ) {
405 405
 
406
-		    $field = RGFormsModel::get_field( $this->form, $input_id );
406
+			$field = RGFormsModel::get_field( $this->form, $input_id );
407 407
 
408
-		    // Reset fields that are hidden
409
-		    // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic
410
-		    if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) {
408
+			// Reset fields that are hidden
409
+			// Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic
410
+			if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) {
411 411
 
412
-		        // List fields are stored as empty arrays when empty
413
-			    $empty_value = $this->is_field_json_encoded( $field ) ? '[]' : '';
412
+				// List fields are stored as empty arrays when empty
413
+				$empty_value = $this->is_field_json_encoded( $field ) ? '[]' : '';
414 414
 
415
-			    $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
415
+				$lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
416 416
 
417
-			    GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );
417
+				GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );
418 418
 
419
-			    // Prevent the $_POST values of hidden fields from being used as default values when rendering the form
419
+				// Prevent the $_POST values of hidden fields from being used as default values when rendering the form
420 420
 				// after submission
421
-			    $post_input_id = 'input_' . str_replace( '.', '_', $input_id );
422
-			    $_POST[ $post_input_id ] = '';
423
-		    }
424
-	    }
421
+				$post_input_id = 'input_' . str_replace( '.', '_', $input_id );
422
+				$_POST[ $post_input_id ] = '';
423
+			}
424
+		}
425 425
 	}
426 426
 
427 427
 	/**
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 
516 516
 		$form = $this->form;
517 517
 
518
-	    /** @var GF_Field $field */
518
+		/** @var GF_Field $field */
519 519
 		foreach( $form['fields'] as $k => &$field ) {
520 520
 
521 521
 			/**
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 
532 532
 			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
533 533
 				foreach( $field->inputs as $key => $input ) {
534
-				    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
534
+					$field->inputs[ $key ][ 'id' ] = (string)$input['id'];
535 535
 				}
536 536
 			}
537 537
 		}
@@ -552,13 +552,13 @@  discard block
 block discarded – undo
552 552
 			foreach ( $this->fields_with_calculation as $calc_field ) {
553 553
 				$inputs = $calc_field->get_entry_inputs();
554 554
 				if ( is_array( $inputs ) ) {
555
-				    foreach ( $inputs as $input ) {
556
-				        $input_name = 'input_' . str_replace( '.', '_', $input['id'] );
557
-				        $entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );
558
-				    }
555
+					foreach ( $inputs as $input ) {
556
+						$input_name = 'input_' . str_replace( '.', '_', $input['id'] );
557
+						$entry[ strval( $input['id'] ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );
558
+					}
559 559
 				} else {
560
-				    $input_name = 'input_' . str_replace( '.', '_', $calc_field->id);
561
-				    $entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );
560
+					$input_name = 'input_' . str_replace( '.', '_', $calc_field->id);
561
+					$entry[ strval( $calc_field->id ) ] = RGFormsModel::prepare_value( $form, $calc_field, '', $input_name, $entry['id'], $entry );
562 562
 				}
563 563
 			}
564 564
 		}
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
622 622
 
623 623
 			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
624
-	        $ary = stripslashes_deep( $ary );
624
+			$ary = stripslashes_deep( $ary );
625 625
 			$img_url = \GV\Utils::get( $ary, 0 );
626 626
 
627 627
 			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
 	private function maybe_update_post_fields( $form ) {
695 695
 
696 696
 		if( empty( $this->entry['post_id'] ) ) {
697
-	        gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
697
+			gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
698 698
 			return;
699 699
 		}
700 700
 
@@ -729,51 +729,51 @@  discard block
 block discarded – undo
729 729
 
730 730
 				switch( $field->type ) {
731 731
 
732
-				    case 'post_title':
733
-				        $post_title = $value;
734
-				        if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
735
-				            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
736
-				        }
737
-				        $updated_post->post_title = $post_title;
738
-				        $updated_post->post_name  = $post_title;
739
-				        unset( $post_title );
740
-				        break;
741
-
742
-				    case 'post_content':
743
-				        $post_content = $value;
744
-				        if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
745
-				            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
746
-				        }
747
-				        $updated_post->post_content = $post_content;
748
-				        unset( $post_content );
749
-				        break;
750
-				    case 'post_excerpt':
751
-				        $updated_post->post_excerpt = $value;
752
-				        break;
753
-				    case 'post_tags':
754
-				        wp_set_post_tags( $post_id, $value, false );
755
-				        break;
756
-				    case 'post_category':
757
-				        break;
758
-				    case 'post_custom_field':
732
+					case 'post_title':
733
+						$post_title = $value;
734
+						if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
735
+							$post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
736
+						}
737
+						$updated_post->post_title = $post_title;
738
+						$updated_post->post_name  = $post_title;
739
+						unset( $post_title );
740
+						break;
741
+
742
+					case 'post_content':
743
+						$post_content = $value;
744
+						if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
745
+							$post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
746
+						}
747
+						$updated_post->post_content = $post_content;
748
+						unset( $post_content );
749
+						break;
750
+					case 'post_excerpt':
751
+						$updated_post->post_excerpt = $value;
752
+						break;
753
+					case 'post_tags':
754
+						wp_set_post_tags( $post_id, $value, false );
755
+						break;
756
+					case 'post_category':
757
+						break;
758
+					case 'post_custom_field':
759 759
 						if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) {
760 760
 							$value = $value[ $field_id ];
761 761
 						}
762 762
 
763
-				        if( ! empty( $field->customFieldTemplateEnabled ) ) {
764
-				            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
765
-				        }
763
+						if( ! empty( $field->customFieldTemplateEnabled ) ) {
764
+							$value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
765
+						}
766 766
 
767
-	                    if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) {
768
-		                    $value = wp_json_encode( $value );
769
-	                    }
767
+						if ( $this->is_field_json_encoded( $field ) && ! is_string( $value ) ) {
768
+							$value = wp_json_encode( $value );
769
+						}
770 770
 
771
-				        update_post_meta( $post_id, $field->postCustomFieldName, $value );
772
-				        break;
771
+						update_post_meta( $post_id, $field->postCustomFieldName, $value );
772
+						break;
773 773
 
774
-				    case 'post_image':
775
-				        $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
776
-				        break;
774
+					case 'post_image':
775
+						$value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
776
+						break;
777 777
 
778 778
 				}
779 779
 
@@ -818,20 +818,20 @@  discard block
 block discarded – undo
818 818
 	 */
819 819
 	private function is_field_json_encoded( $field ) {
820 820
 
821
-	    $json_encoded = false;
821
+		$json_encoded = false;
822 822
 
823 823
 		$input_type = RGFormsModel::get_input_type( $field );
824 824
 
825
-	    // Only certain custom field types are supported
826
-	    switch( $input_type ) {
827
-		    case 'fileupload':
828
-		    case 'list':
829
-		    case 'multiselect':
830
-			    $json_encoded = true;
831
-			    break;
832
-	    }
825
+		// Only certain custom field types are supported
826
+		switch( $input_type ) {
827
+			case 'fileupload':
828
+			case 'list':
829
+			case 'multiselect':
830
+				$json_encoded = true;
831
+				break;
832
+		}
833 833
 
834
-	    return $json_encoded;
834
+		return $json_encoded;
835 835
 	}
836 836
 
837 837
 	/**
@@ -921,14 +921,14 @@  discard block
 block discarded – undo
921 921
 			?><h2 class="gv-edit-entry-title">
922 922
 				<span><?php
923 923
 
924
-				    /**
925
-				     * @filter `gravityview_edit_entry_title` Modify the edit entry title
926
-				     * @param string $edit_entry_title Modify the "Edit Entry" title
927
-				     * @param GravityView_Edit_Entry_Render $this This object
928
-				     */
929
-				    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
924
+					/**
925
+					 * @filter `gravityview_edit_entry_title` Modify the edit entry title
926
+					 * @param string $edit_entry_title Modify the "Edit Entry" title
927
+					 * @param GravityView_Edit_Entry_Render $this This object
928
+					 */
929
+					$edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
930 930
 
931
-				    echo esc_attr( $edit_entry_title );
931
+					echo esc_attr( $edit_entry_title );
932 932
 			?></span>
933 933
 			</h2>
934 934
 
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 
1038 1038
 		ob_get_clean();
1039 1039
 
1040
-	    remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
1040
+		remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
1041 1041
 		remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
1042 1042
 		remove_filter( 'gform_disable_view_counter', '__return_true' );
1043 1043
 		remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 );
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
 
1092 1092
 		// for now we don't support Save and Continue feature.
1093 1093
 		if( ! self::$supports_save_and_continue ) {
1094
-	        unset( $form['save'] );
1094
+			unset( $form['save'] );
1095 1095
 		}
1096 1096
 
1097 1097
 		$form = $this->unselect_default_values( $form );
@@ -1118,30 +1118,30 @@  discard block
 block discarded – undo
1118 1118
 			return $field_content;
1119 1119
 		}
1120 1120
 
1121
-        $message = null;
1121
+		$message = null;
1122 1122
 
1123
-        // First, make sure they have the capability to edit the post.
1124
-        if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1123
+		// First, make sure they have the capability to edit the post.
1124
+		if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1125 1125
 
1126
-            /**
1127
-             * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1128
-             * @param string $message The existing "You don't have permission..." text
1129
-             */
1130
-            $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1126
+			/**
1127
+			 * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1128
+			 * @param string $message The existing "You don't have permission..." text
1129
+			 */
1130
+			$message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1131 1131
 
1132
-        } elseif( null === get_post( $this->entry['post_id'] ) ) {
1133
-            /**
1134
-             * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1135
-             * @param string $message The existing "This field is not editable; the post no longer exists." text
1136
-             */
1137
-            $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1138
-        }
1132
+		} elseif( null === get_post( $this->entry['post_id'] ) ) {
1133
+			/**
1134
+			 * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1135
+			 * @param string $message The existing "This field is not editable; the post no longer exists." text
1136
+			 */
1137
+			$message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1138
+		}
1139 1139
 
1140
-        if( $message ) {
1141
-            $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1142
-        }
1140
+		if( $message ) {
1141
+			$field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1142
+		}
1143 1143
 
1144
-        return $field_content;
1144
+		return $field_content;
1145 1145
 	}
1146 1146
 
1147 1147
 	/**
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 			|| ! empty( $field_content )
1170 1170
 			|| in_array( $field->type, array( 'honeypot' ) )
1171 1171
 		) {
1172
-	        return $field_content;
1172
+			return $field_content;
1173 1173
 		}
1174 1174
 
1175 1175
 		// SET SOME FIELD DEFAULTS TO PREVENT ISSUES
@@ -1177,24 +1177,24 @@  discard block
 block discarded – undo
1177 1177
 
1178 1178
 		$field_value = $this->get_field_value( $field );
1179 1179
 
1180
-	    // Prevent any PHP warnings, like undefined index
1181
-	    ob_start();
1180
+		// Prevent any PHP warnings, like undefined index
1181
+		ob_start();
1182 1182
 
1183
-	    $return = null;
1183
+		$return = null;
1184 1184
 
1185 1185
 		/** @var GravityView_Field $gv_field */
1186 1186
 		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1187 1187
 			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1188 1188
 		} else {
1189
-	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
1190
-	    }
1189
+			$return = $field->get_field_input( $this->form, $field_value, $this->entry );
1190
+		}
1191 1191
 
1192
-	    // If there was output, it's an error
1193
-	    $warnings = ob_get_clean();
1192
+		// If there was output, it's an error
1193
+		$warnings = ob_get_clean();
1194 1194
 
1195
-	    if( !empty( $warnings ) ) {
1196
-		    gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1197
-	    }
1195
+		if( !empty( $warnings ) ) {
1196
+			gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1197
+		}
1198 1198
 
1199 1199
 		return $return;
1200 1200
 	}
@@ -1229,8 +1229,8 @@  discard block
 block discarded – undo
1229 1229
 				$input_id = strval( $input['id'] );
1230 1230
 				
1231 1231
 				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1232
-				    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1233
-				    $allow_pre_populated = false;
1232
+					$field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1233
+					$allow_pre_populated = false;
1234 1234
 				}
1235 1235
 
1236 1236
 			}
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
 			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1255 1255
 				$categories = array();
1256 1256
 				foreach ( explode( ',', $field_value ) as $cat_string ) {
1257
-				    $categories[] = GFCommon::format_post_category( $cat_string, true );
1257
+					$categories[] = GFCommon::format_post_category( $cat_string, true );
1258 1258
 				}
1259 1259
 				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1260 1260
 			}
@@ -1264,25 +1264,25 @@  discard block
 block discarded – undo
1264 1264
 		// if value is empty get the default value if defined
1265 1265
 		$field_value = $field->get_value_default_if_empty( $field_value );
1266 1266
 
1267
-	    /**
1268
-	     * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1269
-	     * @since 1.11
1270
-	     * @since 1.20 Added third param
1271
-	     * @param mixed $field_value field value used to populate the input
1272
-	     * @param object $field Gravity Forms field object ( Class GF_Field )
1273
-	     * @param GravityView_Edit_Entry_Render $this Current object
1274
-	     */
1275
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this );
1276
-
1277
-	    /**
1278
-	     * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1279
-	     * @since 1.17
1280
-	     * @since 1.20 Added third param
1281
-	     * @param mixed $field_value field value used to populate the input
1282
-	     * @param GF_Field $field Gravity Forms field object
1283
-	     * @param GravityView_Edit_Entry_Render $this Current object
1284
-	     */
1285
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1267
+		/**
1268
+		 * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1269
+		 * @since 1.11
1270
+		 * @since 1.20 Added third param
1271
+		 * @param mixed $field_value field value used to populate the input
1272
+		 * @param object $field Gravity Forms field object ( Class GF_Field )
1273
+		 * @param GravityView_Edit_Entry_Render $this Current object
1274
+		 */
1275
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this );
1276
+
1277
+		/**
1278
+		 * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1279
+		 * @since 1.17
1280
+		 * @since 1.20 Added third param
1281
+		 * @param mixed $field_value field value used to populate the input
1282
+		 * @param GF_Field $field Gravity Forms field object
1283
+		 * @param GravityView_Edit_Entry_Render $this Current object
1284
+		 */
1285
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1286 1286
 
1287 1287
 		return $field_value;
1288 1288
 	}
@@ -1309,7 +1309,7 @@  discard block
 block discarded – undo
1309 1309
 			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1310 1310
 			// expects certain field array items to be set.
1311 1311
 			foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) {
1312
-	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1312
+				$field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1313 1313
 			}
1314 1314
 
1315 1315
 			switch( RGFormsModel::get_input_type( $field ) ) {
@@ -1323,61 +1323,61 @@  discard block
 block discarded – undo
1323 1323
 				 */
1324 1324
 				case 'fileupload':
1325 1325
 
1326
-				    // Set the previous value
1327
-				    $entry = $this->get_entry();
1326
+					// Set the previous value
1327
+					$entry = $this->get_entry();
1328 1328
 
1329
-				    $input_name = 'input_'.$field->id;
1330
-				    $form_id = $form['id'];
1329
+					$input_name = 'input_'.$field->id;
1330
+					$form_id = $form['id'];
1331 1331
 
1332
-				    $value = NULL;
1332
+					$value = NULL;
1333 1333
 
1334
-				    // Use the previous entry value as the default.
1335
-				    if( isset( $entry[ $field->id ] ) ) {
1336
-				        $value = $entry[ $field->id ];
1337
-				    }
1334
+					// Use the previous entry value as the default.
1335
+					if( isset( $entry[ $field->id ] ) ) {
1336
+						$value = $entry[ $field->id ];
1337
+					}
1338 1338
 
1339
-				    // If this is a single upload file
1340
-				    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1341
-				        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1342
-				        $value = $file_path['url'];
1339
+					// If this is a single upload file
1340
+					if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1341
+						$file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1342
+						$value = $file_path['url'];
1343 1343
 
1344
-				    } else {
1344
+					} else {
1345 1345
 
1346
-				        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1347
-				        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1348
-				        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1346
+						// Fix PHP warning on line 1498 of form_display.php for post_image fields
1347
+						// Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1348
+						$_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1349 1349
 
1350
-				    }
1350
+					}
1351 1351
 
1352
-				    if ( \GV\Utils::get( $field, "multipleFiles" ) ) {
1352
+					if ( \GV\Utils::get( $field, "multipleFiles" ) ) {
1353 1353
 
1354
-				        // If there are fresh uploads, process and merge them.
1355
-				        // Otherwise, use the passed values, which should be json-encoded array of URLs
1356
-				        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1357
-				            $value = empty( $value ) ? '[]' : $value;
1358
-				            $value = stripslashes_deep( $value );
1359
-				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1360
-				        }
1354
+						// If there are fresh uploads, process and merge them.
1355
+						// Otherwise, use the passed values, which should be json-encoded array of URLs
1356
+						if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1357
+							$value = empty( $value ) ? '[]' : $value;
1358
+							$value = stripslashes_deep( $value );
1359
+							$value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1360
+						}
1361 1361
 
1362
-				    } else {
1362
+					} else {
1363 1363
 
1364
-				        // A file already exists when editing an entry
1365
-				        // We set this to solve issue when file upload fields are required.
1366
-				        GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1364
+						// A file already exists when editing an entry
1365
+						// We set this to solve issue when file upload fields are required.
1366
+						GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1367 1367
 
1368
-				    }
1368
+					}
1369 1369
 
1370
-				    $this->entry[ $input_name ] = $value;
1371
-				    $_POST[ $input_name ] = $value;
1370
+					$this->entry[ $input_name ] = $value;
1371
+					$_POST[ $input_name ] = $value;
1372 1372
 
1373
-				    break;
1373
+					break;
1374 1374
 
1375 1375
 				case 'number':
1376
-				    // Fix "undefined index" issue at line 1286 in form_display.php
1377
-				    if( !isset( $_POST['input_'.$field->id ] ) ) {
1378
-				        $_POST['input_'.$field->id ] = NULL;
1379
-				    }
1380
-				    break;
1376
+					// Fix "undefined index" issue at line 1286 in form_display.php
1377
+					if( !isset( $_POST['input_'.$field->id ] ) ) {
1378
+						$_POST['input_'.$field->id ] = NULL;
1379
+					}
1380
+					break;
1381 1381
 			}
1382 1382
 
1383 1383
 		}
@@ -1462,42 +1462,42 @@  discard block
 block discarded – undo
1462 1462
 				case 'fileupload' :
1463 1463
 				case 'post_image':
1464 1464
 
1465
-				    // in case nothing is uploaded but there are already files saved
1466
-				    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1467
-				        $field->failed_validation = false;
1468
-				        unset( $field->validation_message );
1469
-				    }
1465
+					// in case nothing is uploaded but there are already files saved
1466
+					if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1467
+						$field->failed_validation = false;
1468
+						unset( $field->validation_message );
1469
+					}
1470 1470
 
1471
-				    // validate if multi file upload reached max number of files [maxFiles] => 2
1472
-				    if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1471
+					// validate if multi file upload reached max number of files [maxFiles] => 2
1472
+					if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1473 1473
 
1474
-				        $input_name = 'input_' . $field->id;
1475
-				        //uploaded
1476
-				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1474
+						$input_name = 'input_' . $field->id;
1475
+						//uploaded
1476
+						$file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1477 1477
 
1478
-				        //existent
1479
-				        $entry = $this->get_entry();
1480
-				        $value = NULL;
1481
-				        if( isset( $entry[ $field->id ] ) ) {
1482
-				            $value = json_decode( $entry[ $field->id ], true );
1483
-				        }
1478
+						//existent
1479
+						$entry = $this->get_entry();
1480
+						$value = NULL;
1481
+						if( isset( $entry[ $field->id ] ) ) {
1482
+							$value = json_decode( $entry[ $field->id ], true );
1483
+						}
1484 1484
 
1485
-				        // count uploaded files and existent entry files
1486
-				        $count_files = count( $file_names ) + count( $value );
1485
+						// count uploaded files and existent entry files
1486
+						$count_files = count( $file_names ) + count( $value );
1487 1487
 
1488
-				        if( $count_files > $field->maxFiles ) {
1489
-				            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1490
-				            $field->failed_validation = 1;
1491
-				            $gv_valid = false;
1488
+						if( $count_files > $field->maxFiles ) {
1489
+							$field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1490
+							$field->failed_validation = 1;
1491
+							$gv_valid = false;
1492 1492
 
1493
-				            // in case of error make sure the newest upload files are removed from the upload input
1494
-				            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1495
-				        }
1493
+							// in case of error make sure the newest upload files are removed from the upload input
1494
+							GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1495
+						}
1496 1496
 
1497
-				    }
1497
+					}
1498 1498
 
1499 1499
 
1500
-				    break;
1500
+					break;
1501 1501
 
1502 1502
 			}
1503 1503
 
@@ -1508,47 +1508,47 @@  discard block
 block discarded – undo
1508 1508
 
1509 1509
 				switch ( $field_type ) {
1510 1510
 
1511
-				    // Captchas don't need to be re-entered.
1512
-				    case 'captcha':
1511
+					// Captchas don't need to be re-entered.
1512
+					case 'captcha':
1513 1513
 
1514
-				        // Post Image fields aren't editable, so we un-fail them.
1515
-				    case 'post_image':
1516
-				        $field->failed_validation = false;
1517
-				        unset( $field->validation_message );
1518
-				        break;
1514
+						// Post Image fields aren't editable, so we un-fail them.
1515
+					case 'post_image':
1516
+						$field->failed_validation = false;
1517
+						unset( $field->validation_message );
1518
+						break;
1519 1519
 
1520 1520
 				}
1521 1521
 
1522 1522
 				// You can't continue inside a switch, so we do it after.
1523 1523
 				if( empty( $field->failed_validation ) ) {
1524
-				    continue;
1524
+					continue;
1525 1525
 				}
1526 1526
 
1527 1527
 				// checks if the No Duplicates option is not validating entry against itself, since
1528 1528
 				// we're editing a stored entry, it would also assume it's a duplicate.
1529 1529
 				if( !empty( $field->noDuplicates ) ) {
1530 1530
 
1531
-				    $entry = $this->get_entry();
1531
+					$entry = $this->get_entry();
1532 1532
 
1533
-				    // If the value of the entry is the same as the stored value
1534
-				    // Then we can assume it's not a duplicate, it's the same.
1535
-				    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1536
-				        //if value submitted was not changed, then don't validate
1537
-				        $field->failed_validation = false;
1533
+					// If the value of the entry is the same as the stored value
1534
+					// Then we can assume it's not a duplicate, it's the same.
1535
+					if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1536
+						//if value submitted was not changed, then don't validate
1537
+						$field->failed_validation = false;
1538 1538
 
1539
-				        unset( $field->validation_message );
1539
+						unset( $field->validation_message );
1540 1540
 
1541
-				        gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) );
1541
+						gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) );
1542 1542
 
1543
-				        continue;
1544
-				    }
1543
+						continue;
1544
+					}
1545 1545
 				}
1546 1546
 
1547 1547
 				// if here then probably we are facing the validation 'At least one field must be filled out'
1548 1548
 				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1549
-				    unset( $field->validation_message );
1550
-	                $field->validation_message = false;
1551
-				    continue;
1549
+					unset( $field->validation_message );
1550
+					$field->validation_message = false;
1551
+					continue;
1552 1552
 				}
1553 1553
 
1554 1554
 				$gv_valid = false;
@@ -1612,8 +1612,8 @@  discard block
 block discarded – undo
1612 1612
 		// Hide fields depending on admin settings
1613 1613
 		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1614 1614
 
1615
-	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1616
-	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1615
+		// If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1616
+		$fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1617 1617
 
1618 1618
 		/**
1619 1619
 		 * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form
@@ -1673,11 +1673,11 @@  discard block
 block discarded – undo
1673 1673
 		// The edit tab has been configured, so we loop through to configured settings
1674 1674
 		foreach ( $configured_fields as $configured_field ) {
1675 1675
 
1676
-	        /** @var GF_Field $field */
1677
-	        foreach ( $fields as $field ) {
1676
+			/** @var GF_Field $field */
1677
+			foreach ( $fields as $field ) {
1678 1678
 				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1679
-				    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1680
-				    break;
1679
+					$edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1680
+					break;
1681 1681
 				}
1682 1682
 
1683 1683
 			}
@@ -1733,28 +1733,28 @@  discard block
 block discarded – undo
1733 1733
 	 */
1734 1734
 	private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) {
1735 1735
 
1736
-	    /**
1736
+		/**
1737 1737
 		 * @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
1738
-	     * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1739
-	     * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1740
-	     * @since 1.9.1
1741
-	     * @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.
1742
-	     * @param array $form GF Form array
1743
-	     * @param int $view_id View ID
1744
-	     */
1745
-	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1746
-
1747
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1738
+		 * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1739
+		 * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1740
+		 * @since 1.9.1
1741
+		 * @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.
1742
+		 * @param array $form GF Form array
1743
+		 * @param int $view_id View ID
1744
+		 */
1745
+		$use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1746
+
1747
+		if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1748 1748
 			foreach( $fields as $k => $field ) {
1749 1749
 				if( $field->adminOnly ) {
1750
-				    unset( $fields[ $k ] );
1750
+					unset( $fields[ $k ] );
1751 1751
 				}
1752 1752
 			}
1753 1753
 			return $fields;
1754 1754
 		}
1755 1755
 
1756
-	    foreach( $fields as &$field ) {
1757
-		    $field->adminOnly = false;
1756
+		foreach( $fields as &$field ) {
1757
+			$field->adminOnly = false;
1758 1758
 		}
1759 1759
 
1760 1760
 		return $fields;
@@ -1774,13 +1774,13 @@  discard block
 block discarded – undo
1774 1774
 	 */
1775 1775
 	private function unselect_default_values( $form ) {
1776 1776
 
1777
-	    foreach ( $form['fields'] as &$field ) {
1777
+		foreach ( $form['fields'] as &$field ) {
1778 1778
 
1779 1779
 			if ( empty( $field->choices ) ) {
1780
-                continue;
1780
+				continue;
1781 1781
 			}
1782 1782
 
1783
-            foreach ( $field->choices as &$choice ) {
1783
+			foreach ( $field->choices as &$choice ) {
1784 1784
 				if ( \GV\Utils::get( $choice, 'isSelected' ) ) {
1785 1785
 					$choice['isSelected'] = false;
1786 1786
 				}
@@ -1817,36 +1817,36 @@  discard block
 block discarded – undo
1817 1817
 
1818 1818
 			if( 'checkbox' === $field->type ) {
1819 1819
 				foreach ( $field->get_entry_inputs() as $key => $input ) {
1820
-				    $input_id = $input['id'];
1821
-				    $choice = $field->choices[ $key ];
1822
-				    $value = \GV\Utils::get( $this->entry, $input_id );
1823
-				    $match = RGFormsModel::choice_value_match( $field, $choice, $value );
1824
-				    if( $match ) {
1825
-				        $field->choices[ $key ]['isSelected'] = true;
1826
-				    }
1820
+					$input_id = $input['id'];
1821
+					$choice = $field->choices[ $key ];
1822
+					$value = \GV\Utils::get( $this->entry, $input_id );
1823
+					$match = RGFormsModel::choice_value_match( $field, $choice, $value );
1824
+					if( $match ) {
1825
+						$field->choices[ $key ]['isSelected'] = true;
1826
+					}
1827 1827
 				}
1828 1828
 			} else {
1829 1829
 
1830 1830
 				// We need to run through each field to set the default values
1831 1831
 				foreach ( $this->entry as $field_id => $field_value ) {
1832 1832
 
1833
-				    if( floatval( $field_id ) === floatval( $field->id ) ) {
1833
+					if( floatval( $field_id ) === floatval( $field->id ) ) {
1834 1834
 
1835
-				        if( 'list' === $field->type ) {
1836
-				            $list_rows = maybe_unserialize( $field_value );
1835
+						if( 'list' === $field->type ) {
1836
+							$list_rows = maybe_unserialize( $field_value );
1837 1837
 
1838
-				            $list_field_value = array();
1839
-				            foreach ( (array) $list_rows as $row ) {
1840
-				                foreach ( (array) $row as $column ) {
1841
-				                    $list_field_value[] = $column;
1842
-				                }
1843
-				            }
1838
+							$list_field_value = array();
1839
+							foreach ( (array) $list_rows as $row ) {
1840
+								foreach ( (array) $row as $column ) {
1841
+									$list_field_value[] = $column;
1842
+								}
1843
+							}
1844 1844
 
1845
-				            $field->defaultValue = serialize( $list_field_value );
1846
-				        } else {
1847
-				            $field->defaultValue = $field_value;
1848
-				        }
1849
-				    }
1845
+							$field->defaultValue = serialize( $list_field_value );
1846
+						} else {
1847
+							$field->defaultValue = $field_value;
1848
+						}
1849
+					}
1850 1850
 				}
1851 1851
 			}
1852 1852
 		}
@@ -1903,7 +1903,7 @@  discard block
 block discarded – undo
1903 1903
 			return $has_conditional_logic;
1904 1904
 		}
1905 1905
 
1906
-	    /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */
1906
+		/** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */
1907 1907
 		return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form );
1908 1908
 	}
1909 1909
 
@@ -1970,14 +1970,14 @@  discard block
 block discarded – undo
1970 1970
 
1971 1971
 		if( $echo && $error !== true ) {
1972 1972
 
1973
-	        $error = esc_html( $error );
1973
+			$error = esc_html( $error );
1974 1974
 
1975
-	        /**
1976
-	         * @since 1.9
1977
-	         */
1978
-	        if ( ! empty( $this->entry ) ) {
1979
-		        $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;" ) );
1980
-	        }
1975
+			/**
1976
+			 * @since 1.9
1977
+			 */
1978
+			if ( ! empty( $this->entry ) ) {
1979
+				$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;" ) );
1980
+			}
1981 1981
 
1982 1982
 			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
1983 1983
 		}
Please login to merge, or discard this patch.
future/includes/class-gv-request.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -128,10 +128,10 @@
 block discarded – undo
128 128
 	 */
129 129
 	public function is_edit_entry( $form_id = 0 ) {
130 130
 		/**
131
-		* @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n
132
-		* The Edit Entry functionality overrides this value.
133
-		* @param boolean $is_edit_entry
134
-		*/
131
+		 * @filter `gravityview_is_edit_entry` Whether we're currently on the Edit Entry screen \n
132
+		 * The Edit Entry functionality overrides this value.
133
+		 * @param boolean $is_edit_entry
134
+		 */
135 135
 		if ( ( $entry = $this->is_entry( $form_id ) ) && apply_filters( 'gravityview_is_edit_entry', false ) ) {
136 136
 			return $entry;
137 137
 		}
Please login to merge, or discard this patch.
includes/class-admin-views.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -63,28 +63,28 @@  discard block
 block discarded – undo
63 63
 	}
64 64
 
65 65
 	/**
66
-     * When on the Add/Edit View screen, suggest most popular articles related to that
67
-     *
66
+	 * When on the Add/Edit View screen, suggest most popular articles related to that
67
+	 *
68 68
 	 * @param array $localization_data Data to be passed to the Support Port JS
69 69
 	 *
70 70
 	 * @return array
71 71
 	 */
72 72
 	function suggest_support_articles( $localization_data = array() ) {
73 73
 
74
-	    if( ! gravityview()->request->is_view() ) {
75
-	        return $localization_data;
76
-        }
74
+		if( ! gravityview()->request->is_view() ) {
75
+			return $localization_data;
76
+		}
77 77
 
78 78
 		$localization_data['suggest'] = array(
79
-            '57ef23539033602e61d4a560',
80
-            '54c67bb9e4b0512429885513',
81
-            '54c67bb9e4b0512429885512',
82
-            '54c67bbbe4b07997ea3f3f6b',
83
-            '54d1a33ae4b086c0c0964ce9',
84
-            '57ef253c9033602e61d4a563',
85
-            '552355bfe4b0221aadf2572b',
86
-            '54c67bcde4b051242988553e',
87
-        );
79
+			'57ef23539033602e61d4a560',
80
+			'54c67bb9e4b0512429885513',
81
+			'54c67bb9e4b0512429885512',
82
+			'54c67bbbe4b07997ea3f3f6b',
83
+			'54d1a33ae4b086c0c0964ce9',
84
+			'57ef253c9033602e61d4a563',
85
+			'552355bfe4b0221aadf2572b',
86
+			'54c67bcde4b051242988553e',
87
+		);
88 88
 
89 89
 		return $localization_data;
90 90
 	}
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
 
171 171
 		if( 'form_list' === GFForms::get_page() ) {
172 172
 			$priority = 790;
173
-        }
173
+		}
174 174
 
175 175
 		if( empty( $connected_views ) ) {
176 176
 
177
-		    $menu_items['gravityview'] = array(
177
+			$menu_items['gravityview'] = array(
178 178
 				'label'          => esc_attr__( 'Create a View', 'gravityview' ),
179 179
 				'icon'           => '<i class="fa fa-lg gv-icon-astronaut-head gv-icon"></i>',
180 180
 				'title'          => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ),
@@ -205,13 +205,13 @@  discard block
 block discarded – undo
205 205
 		// If there were no items added, then let's create the parent menu
206 206
 		if( $sub_menu_items ) {
207 207
 
208
-		    $sub_menu_items[] = array(
209
-			    'label' => esc_attr__( 'Create a View', 'gravityview' ),
210
-                'link_class' => 'gv-create-view',
211
-			    'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ),
212
-			    'url'   => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ),
213
-			    'capabilities'   => array( 'edit_gravityviews' ),
214
-            );
208
+			$sub_menu_items[] = array(
209
+				'label' => esc_attr__( 'Create a View', 'gravityview' ),
210
+				'link_class' => 'gv-create-view',
211
+				'title' => esc_attr__( 'Create a View using this form as a data source', 'gravityview' ),
212
+				'url'   => admin_url( 'post-new.php?post_type=gravityview&form_id=' . $id ),
213
+				'capabilities'   => array( 'edit_gravityviews' ),
214
+			);
215 215
 
216 216
 			// Make sure Gravity Forms uses the submenu; if there's only one item, it uses a link instead of a dropdown
217 217
 			$sub_menu_items[] = array(
@@ -596,12 +596,12 @@  discard block
 block discarded – undo
596 596
 	 * Render html for displaying available fields based on a Form ID
597 597
 	 * $blacklist_field_types - contains the field types which are not proper to be shown in a directory.
598 598
 	 *
599
-     * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action
599
+	 * @see GravityView_Ajax::get_available_fields_html() Triggers `gravityview_render_available_fields` action
600 600
 	 * @access public
601
-     *
601
+	 *
602 602
 	 * @param int $form Gravity Forms Form ID (default: '')
603 603
 	 * @param string $context (default: 'single')
604
-     *
604
+	 *
605 605
 	 * @return void
606 606
 	 */
607 607
 	function render_available_fields( $form = 0, $context = 'single' ) {
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
 
616 616
 		if ( ! is_array( $blacklist_field_types ) ) {
617 617
 
618
-		    gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) );
618
+			gravityview()->log->error( '$blacklist_field_types is not an array', array( 'data' => print_r( $blacklist_field_types, true ) ) );
619 619
 
620 620
 			$blacklist_field_types = array();
621 621
 		}
@@ -747,12 +747,12 @@  discard block
 block discarded – undo
747 747
 				/**
748 748
 				 * @since 1.7.2
749 749
 				 */
750
-			    'other_entries' => array(
751
-				    'label'	=> __('Other Entries', 'gravityview'),
752
-				    'type'	=> 'other_entries',
753
-				    'desc'	=> __('Display other entries created by the entry creator.', 'gravityview'),
754
-			    ),
755
-	        );
750
+				'other_entries' => array(
751
+					'label'	=> __('Other Entries', 'gravityview'),
752
+					'type'	=> 'other_entries',
753
+					'desc'	=> __('Display other entries created by the entry creator.', 'gravityview'),
754
+				),
755
+			);
756 756
 
757 757
 			if( 'single' !== $zone) {
758 758
 
@@ -885,9 +885,9 @@  discard block
 block discarded – undo
885 885
 
886 886
 				$joined_forms = gravityview_get_joined_forms( $post->ID );
887 887
 
888
-                foreach ( $joined_forms as $form ) {
889
-                    $available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone );
890
-                }
888
+				foreach ( $joined_forms as $form ) {
889
+					$available_items[ $form->ID ] = $this->get_available_fields( $form->ID, $zone );
890
+				}
891 891
 			} else {
892 892
 				$available_items[ $form ] = $this->get_registered_widgets();
893 893
 			}
@@ -917,9 +917,9 @@  discard block
 block discarded – undo
917 917
 
918 918
 										if ( $form_id ) {
919 919
 											$original_item = isset( $available_items[ $form_id ] [ $field['id'] ] ) ? $available_items[ $form_id ] [ $field['id'] ] : false ;
920
-                                        } else {
920
+										} else {
921 921
 											$original_item = isset( $available_items[ $field['id'] ] ) ? $available_items[ $field['id'] ] : false ;
922
-                                        }
922
+										}
923 923
 
924 924
 										if ( !$original_item ) {
925 925
 											gravityview()->log->error( 'An item was not available when rendering the output; maybe it was added by a plugin that is now de-activated.', array(' data' => array('available_items' => $available_items, 'field' => $field ) ) );
@@ -1001,13 +1001,13 @@  discard block
 block discarded – undo
1001 1001
 	}
1002 1002
 
1003 1003
 	/**
1004
-     * Renders "Add Field" tooltips
1005
-     *
1006
-     * @since 2.0.11
1007
-     *
1004
+	 * Renders "Add Field" tooltips
1005
+	 *
1006
+	 * @since 2.0.11
1007
+	 *
1008 1008
 	 * @param string $context "directory", "single", or "edit"
1009
-     *
1010
-     * @return void
1009
+	 *
1010
+	 * @return void
1011 1011
 	 */
1012 1012
 	function render_field_pickers( $context = 'directory' ) {
1013 1013
 
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
             </div>
1035 1035
 			<?php
1036 1036
 		}
1037
-    }
1037
+	}
1038 1038
 
1039 1039
 	/**
1040 1040
 	 * Render the Template Active Areas and configured active fields for a given template id and post id
@@ -1100,7 +1100,7 @@  discard block
 block discarded – undo
1100 1100
 		$is_widgets_page = ( $pagenow === 'widgets.php' );
1101 1101
 
1102 1102
 		// Add the GV font (with the Astronaut)
1103
-        wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version );
1103
+		wp_enqueue_style( 'gravityview_global', plugins_url('assets/css/admin-global.css', GRAVITYVIEW_FILE), array(), \GV\Plugin::$version );
1104 1104
 		wp_register_style( 'gravityview_views_styles', plugins_url( 'assets/css/admin-views.css', GRAVITYVIEW_FILE ), array( 'dashicons', 'wp-jquery-ui-dialog' ), \GV\Plugin::$version );
1105 1105
 
1106 1106
 		wp_register_script( 'gravityview-jquery-cookie', plugins_url('assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE), array( 'jquery' ), \GV\Plugin::$version, true );
@@ -1108,63 +1108,63 @@  discard block
 block discarded – undo
1108 1108
 		if( GFForms::get_page() === 'form_list' ) {
1109 1109
 			wp_enqueue_style( 'gravityview_views_styles' );
1110 1110
 			return;
1111
-        }
1111
+		}
1112 1112
 
1113 1113
 		// Don't process any scripts below here if it's not a GravityView page.
1114 1114
 		if( ! gravityview()->request->is_admin( $hook, 'single' ) && ! $is_widgets_page ) {
1115
-		    return;
1115
+			return;
1116 1116
 		}
1117 1117
 
1118
-        wp_enqueue_script( 'jquery-ui-datepicker' );
1119
-        wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version );
1120
-
1121
-        $script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
1122
-
1123
-        //enqueue scripts
1124
-        wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), \GV\Plugin::$version );
1125
-
1126
-        wp_localize_script('gravityview_views_scripts', 'gvGlobals', array(
1127
-            'cookiepath' => COOKIEPATH,
1128
-            'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ),
1129
-            'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ),
1130
-            'label_viewname' => __( 'Enter View name here', 'gravityview' ),
1131
-            'label_close' => __( 'Close', 'gravityview' ),
1132
-            'label_cancel' => __( 'Cancel', 'gravityview' ),
1133
-            'label_continue' => __( 'Continue', 'gravityview' ),
1134
-            'label_ok' => __( 'Ok', 'gravityview' ),
1135
-            'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ),
1136
-            'loading_text' => esc_html__( 'Loading&hellip;', 'gravityview' ),
1137
-            'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ),
1138
-            'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ),
1139
-            'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ),
1140
-        ));
1118
+		wp_enqueue_script( 'jquery-ui-datepicker' );
1119
+		wp_enqueue_style( 'gravityview_views_datepicker', plugins_url('assets/css/admin-datepicker.css', GRAVITYVIEW_FILE), \GV\Plugin::$version );
1120
+
1121
+		$script_debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min';
1122
+
1123
+		//enqueue scripts
1124
+		wp_enqueue_script( 'gravityview_views_scripts', plugins_url( 'assets/js/admin-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), array( 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-ui-tooltip', 'jquery-ui-dialog', 'gravityview-jquery-cookie', 'jquery-ui-datepicker', 'underscore' ), \GV\Plugin::$version );
1125
+
1126
+		wp_localize_script('gravityview_views_scripts', 'gvGlobals', array(
1127
+			'cookiepath' => COOKIEPATH,
1128
+			'passed_form_id' => (bool) \GV\Utils::_GET( 'form_id' ),
1129
+			'nonce' => wp_create_nonce( 'gravityview_ajaxviews' ),
1130
+			'label_viewname' => __( 'Enter View name here', 'gravityview' ),
1131
+			'label_close' => __( 'Close', 'gravityview' ),
1132
+			'label_cancel' => __( 'Cancel', 'gravityview' ),
1133
+			'label_continue' => __( 'Continue', 'gravityview' ),
1134
+			'label_ok' => __( 'Ok', 'gravityview' ),
1135
+			'label_publisherror' => __( 'Error while creating the View for you. Check the settings or contact GravityView support.', 'gravityview' ),
1136
+			'loading_text' => esc_html__( 'Loading&hellip;', 'gravityview' ),
1137
+			'loading_error' => esc_html__( 'There was an error loading dynamic content.', 'gravityview' ),
1138
+			'field_loaderror' => __( 'Error while adding the field. Please try again or contact GravityView support.', 'gravityview' ),
1139
+			'remove_all_fields' => __( 'Would you like to remove all fields in this zone? (You are seeing this message because you were holding down the ALT key)', 'gravityview' ),
1140
+		));
1141 1141
 
1142 1142
 		wp_enqueue_style( 'gravityview_views_styles' );
1143 1143
 
1144
-        // Enqueue scripts needed for merge tags
1145
-        self::enqueue_gravity_forms_scripts();
1144
+		// Enqueue scripts needed for merge tags
1145
+		self::enqueue_gravity_forms_scripts();
1146 1146
 	}
1147 1147
 
1148 1148
 	/**
1149 1149
 	 * Enqueue Gravity Forms scripts, needed for Merge Tags
1150
-     *
1151
-     * @since 1.0.5-beta
1152
-     *
1153
-     * @return void
1150
+	 *
1151
+	 * @since 1.0.5-beta
1152
+	 *
1153
+	 * @return void
1154 1154
 	 */
1155 1155
 	static function enqueue_gravity_forms_scripts() {
1156 1156
 		GFForms::register_scripts();
1157 1157
 
1158 1158
 		$scripts = array(
1159
-		    'sack',
1160
-		    'gform_gravityforms',
1161
-		    'gform_forms',
1162
-		    'gform_form_admin',
1163
-		    'jquery-ui-autocomplete'
1159
+			'sack',
1160
+			'gform_gravityforms',
1161
+			'gform_forms',
1162
+			'gform_form_admin',
1163
+			'jquery-ui-autocomplete'
1164 1164
 		);
1165 1165
 
1166 1166
 		if ( wp_is_mobile() ) {
1167
-		    $scripts[] = 'jquery-touch-punch';
1167
+			$scripts[] = 'jquery-touch-punch';
1168 1168
 		}
1169 1169
 
1170 1170
 		wp_enqueue_script( $scripts );
Please login to merge, or discard this patch.