Completed
Push — master ( 9b310a...05ab62 )
by Zack
46:38 queued 42:54
created
includes/widgets/poll/class-gravityview-widget-poll.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
 	function __construct() {
23 23
 
24 24
 		$this->widget_id = 'poll';
25
-		$this->widget_description = __('Displays the results of Poll Fields that exist in the form.', 'gravityview' );
26
-		$this->widget_subtitle = sprintf( _x('Note: this will display poll results for %sall form entries%s, not only the entries displayed in the View.', 'The string placeholders are for emphasis HTML', 'gravityview' ), '<em>', '</em>' );
25
+		$this->widget_description = __( 'Displays the results of Poll Fields that exist in the form.', 'gravityview' );
26
+		$this->widget_subtitle = sprintf( _x( 'Note: this will display poll results for %sall form entries%s, not only the entries displayed in the View.', 'The string placeholders are for emphasis HTML', 'gravityview' ), '<em>', '</em>' );
27 27
 
28 28
 		$default_values = array(
29 29
 			'header' => 1,
@@ -32,27 +32,27 @@  discard block
 block discarded – undo
32 32
 
33 33
 		$settings = array(
34 34
 			'percentages' => array(
35
-				'label' => __('Display Percentages', 'gravityview'),
35
+				'label' => __( 'Display Percentages', 'gravityview' ),
36 36
 				'type' => 'checkbox',
37 37
 				'value' => true,
38 38
 				'tooltip' => __( 'Display results percentages as part of results? Supported values are: true, false. Defaults to "true".', 'gravityview' ),
39 39
 			),
40 40
 			'counts' => array(
41
-				'label' => __('Display Counts', 'gravityview'),
41
+				'label' => __( 'Display Counts', 'gravityview' ),
42 42
 				'type' => 'checkbox',
43 43
 				'value' => true,
44 44
 				'tooltip' => __( 'Display number of times each choice has been selected when displaying results? Supported values are: true, false. Defaults to "true".', 'gravityview' ),
45 45
 			),
46 46
 			'style' => array(
47 47
 				'type' => 'select',
48
-				'label' => __('Style', 'gravityview'),
48
+				'label' => __( 'Style', 'gravityview' ),
49 49
 				'tooltip' => __( 'The Polls Add-On currently supports 4 built in styles: red, green, orange, blue. Defaults to "green".', 'gravityview' ),
50 50
 				'value' => 'green',
51 51
 				'choices' => array(
52
-					'green' => __('Green', 'gravityview'),
53
-					'blue' => __('Blue', 'gravityview'),
54
-					'red' => __('Red', 'gravityview'),
55
-					'orange' => __('Orange', 'gravityview'),
52
+					'green' => __( 'Green', 'gravityview' ),
53
+					'blue' => __( 'Blue', 'gravityview' ),
54
+					'red' => __( 'Red', 'gravityview' ),
55
+					'orange' => __( 'Orange', 'gravityview' ),
56 56
 				),
57 57
 			),
58 58
 		);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 			add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
63 63
 		}
64 64
 
65
-		parent::__construct( __( 'Poll Results', 'gravityview' ) , null, $default_values, $settings );
65
+		parent::__construct( __( 'Poll Results', 'gravityview' ), null, $default_values, $settings );
66 66
 	}
67 67
 
68 68
 	/**
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 
90 90
 		$GFPolls = GFPolls::get_instance();
91 91
 
92
-		wp_enqueue_script('gpoll_js', $GFPolls->get_base_url() . '/js/gpoll.js', array('jquery'), $GFPolls->_version);
92
+		wp_enqueue_script( 'gpoll_js', $GFPolls->get_base_url() . '/js/gpoll.js', array( 'jquery' ), $GFPolls->_version );
93 93
 
94 94
 		$GFPolls->localize_scripts();
95 95
 
96
-		wp_enqueue_style('gpoll_css', $GFPolls->get_base_url() . '/css/gpoll.css', null, $GFPolls->_version);
96
+		wp_enqueue_style( 'gpoll_css', $GFPolls->get_base_url() . '/css/gpoll.css', null, $GFPolls->_version );
97 97
 	}
98 98
 
99 99
 	/**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 */
104 104
 	public function pre_render_frontend() {
105 105
 
106
-		if( ! class_exists('GFPolls') ) {
106
+		if ( ! class_exists( 'GFPolls' ) ) {
107 107
 
108 108
 			gravityview()->log->error( 'Poll Widget not displayed; the Poll Addon is not loaded' );
109 109
 
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 
113 113
 		$view = gravityview()->views->get();
114 114
 
115
-		$poll_fields = array( $view->form->form['id'] => GFCommon::get_fields_by_type( $view->form, array( 'poll' ) ) );
115
+		$poll_fields = array( $view->form->form[ 'id' ] => GFCommon::get_fields_by_type( $view->form, array( 'poll' ) ) );
116 116
 
117 117
 		foreach ( $view->joins as $join ) {
118
-			$poll_fields[ $join->join_on->form['id'] ] = GFCommon::get_fields_by_type( $join->join_on->form, array( 'poll' ) );
118
+			$poll_fields[ $join->join_on->form[ 'id' ] ] = GFCommon::get_fields_by_type( $join->join_on->form, array( 'poll' ) );
119 119
 		}
120 120
 
121 121
 		$poll_fields = array_filter( $poll_fields );
@@ -167,12 +167,12 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	public function render_frontend( $widget_args, $content = '', $context = '' ) {
169 169
 
170
-		if( ! $this->pre_render_frontend() ) {
170
+		if ( ! $this->pre_render_frontend() ) {
171 171
 			return;
172 172
 		}
173 173
 
174 174
 		// Make sure the class is loaded in DataTables
175
-		if( !class_exists( 'GFFormDisplay' ) ) {
175
+		if ( ! class_exists( 'GFFormDisplay' ) ) {
176 176
 			include_once( GFCommon::get_base_path() . '/form_display.php' );
177 177
 		}
178 178
 
@@ -180,14 +180,14 @@  discard block
 block discarded – undo
180 180
 
181 181
 		$settings = $this->get_frontend_settings( $widget_args );
182 182
 
183
-		$percentages = empty( $settings['percentages'] ) ? 'false' : 'true';
183
+		$percentages = empty( $settings[ 'percentages' ] ) ? 'false' : 'true';
184 184
 
185
-		$counts = empty( $settings['counts'] ) ? 'false' : 'true';
185
+		$counts = empty( $settings[ 'counts' ] ) ? 'false' : 'true';
186 186
 
187
-		if( !empty( $settings['field'] ) ) {
188
-			$merge_tag = sprintf( '{gpoll: field="%d" style="%s" percentages="%s" counts="%s"}', $settings['field'], $settings['style'], $percentages, $counts );
187
+		if ( ! empty( $settings[ 'field' ] ) ) {
188
+			$merge_tag = sprintf( '{gpoll: field="%d" style="%s" percentages="%s" counts="%s"}', $settings[ 'field' ], $settings[ 'style' ], $percentages, $counts );
189 189
 		} else {
190
-			$merge_tag = sprintf( '{all_poll_results: style="%s" percentages="%s" counts="%s"}', $settings['style'], $percentages, $counts );
190
+			$merge_tag = sprintf( '{all_poll_results: style="%s" percentages="%s" counts="%s"}', $settings[ 'style' ], $percentages, $counts );
191 191
 		}
192 192
 
193 193
 		$gravityview_view = GravityView_View::getInstance();
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 		$gravityview_view->poll_settings = $settings;
198 198
 		$gravityview_view->poll_fields = $this->poll_fields;
199 199
 
200
-		$gravityview_view->render('widget', 'poll', false );
200
+		$gravityview_view->render( 'widget', 'poll', false );
201 201
 
202 202
 		unset( $gravityview_view->poll_merge_tag, $gravityview_view->poll_settings, $gravityview_view->poll_form, $gravityview_view->poll_fields );
203 203
 	}
Please login to merge, or discard this patch.
future/_mocks.php 1 patch
Spacing   +44 added lines, -47 removed lines patch added patch discarded remove patch
@@ -102,8 +102,7 @@  discard block
 block discarded – undo
102 102
 			$entries = $view->get_entries( gravityview()->request );
103 103
 		}
104 104
 
105
-		$page = \GV\Utils::get( $parameters['paging'], 'current_page' ) ?
106
-			: ( ( ( $parameters['paging']['offset'] - $view->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 );
105
+		$page = \GV\Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $view->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 );
107 106
 
108 107
 		/** Set paging, count and unwrap the entries. */
109 108
 		$paging = array(
@@ -142,17 +141,17 @@  discard block
 block discarded – undo
142 141
  * @return null|string The value of a field in an entry.
143 142
  */
144 143
 function GravityView_API_field_value( $entry, $field_settings, $format ) {
145
-	if ( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) {
144
+	if ( empty( $entry[ 'form_id' ] ) || empty( $field_settings[ 'id' ] ) ) {
146 145
 		gravityview()->log->error( 'No entry or field_settings[id] supplied', array( 'data' => array( func_get_args() ) ) );
147 146
 		return null;
148 147
 	}
149 148
 
150
-	if ( ! empty( $entry['_multi'] ) && ! empty( $field_settings['form_id'] ) && ! empty( $entry['_multi'][ $field_settings['form_id'] ] ) ) {
151
-		$multientry = \GV\Multi_Entry::from_entries( array_map( '\GV\GF_Entry::from_entry', $entry['_multi'] ) );
152
-		$entry = $entry['_multi'][ $field_settings['form_id'] ];
149
+	if ( ! empty( $entry[ '_multi' ] ) && ! empty( $field_settings[ 'form_id' ] ) && ! empty( $entry[ '_multi' ][ $field_settings[ 'form_id' ] ] ) ) {
150
+		$multientry = \GV\Multi_Entry::from_entries( array_map( '\GV\GF_Entry::from_entry', $entry[ '_multi' ] ) );
151
+		$entry = $entry[ '_multi' ][ $field_settings[ 'form_id' ] ];
153 152
 	}
154 153
 
155
-	if ( empty( $entry['id'] ) || ! $entry = \GV\GF_Entry::by_id( $entry['id'] ) ) {
154
+	if ( empty( $entry[ 'id' ] ) || ! $entry = \GV\GF_Entry::by_id( $entry[ 'id' ] ) ) {
156 155
 		gravityview()->log->error( 'Invalid \GV\GF_Entry supplied', array( 'data' => $entry ) );
157 156
 		return null;
158 157
 	}
@@ -162,18 +161,18 @@  discard block
 block discarded – undo
162 161
 	 *
163 162
 	 * Fields with a numeric ID are Gravity Forms ones.
164 163
 	 */
165
-	$source = is_numeric( $field_settings['id'] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL;;
164
+	$source = is_numeric( $field_settings[ 'id' ] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL; ;
166 165
 
167 166
 	/** Initialize the future field. */
168 167
 	switch ( $source ):
169 168
 		/** The Gravity Forms backend. */
170 169
 		case \GV\Source::BACKEND_GRAVITYFORMS:
171
-			if ( ! $form = \GV\GF_Form::by_id( $entry['form_id'] ) ) {
170
+			if ( ! $form = \GV\GF_Form::by_id( $entry[ 'form_id' ] ) ) {
172 171
 				gravityview()->log->error( 'No form Gravity Form found for entry', array( 'data' => $entry ) );
173 172
 				return null;
174 173
 			}
175 174
 
176
-			if ( ! $field = $form::get_field( $form, $field_settings['id'] ) ) {
175
+			if ( ! $field = $form::get_field( $form, $field_settings[ 'id' ] ) ) {
177 176
 				return null;
178 177
 			}
179 178
 
@@ -181,7 +180,7 @@  discard block
 block discarded – undo
181 180
 
182 181
 		/** Our internal backend. */
183 182
 		case \GV\Source::BACKEND_INTERNAL:
184
-			if ( ! $field = \GV\Internal_Source::get_field( $field_settings['id'] ) ) {
183
+			if ( ! $field = \GV\Internal_Source::get_field( $field_settings[ 'id' ] ) ) {
185 184
 				return null;
186 185
 			}
187 186
 
@@ -215,13 +214,13 @@  discard block
 block discarded – undo
215 214
 
216 215
 	/** A bail condition. */
217 216
 	$bail = function( $label, $field_settings, $entry, $force_show_label, $form ) {
218
-		if ( ! empty( $field_settings['show_label'] ) || $force_show_label ) {
217
+		if ( ! empty( $field_settings[ 'show_label' ] ) || $force_show_label ) {
219 218
 
220
-			$label = isset( $field_settings['label'] ) ? $field_settings['label'] : '';
219
+			$label = isset( $field_settings[ 'label' ] ) ? $field_settings[ 'label' ] : '';
221 220
 
222 221
 			// Use Gravity Forms label by default, but if a custom label is defined in GV, use it.
223
-			if ( ! empty( $field_settings['custom_label'] ) ) {
224
-				$label = \GravityView_API::replace_variables( $field_settings['custom_label'], $form, $entry );
222
+			if ( ! empty( $field_settings[ 'custom_label' ] ) ) {
223
+				$label = \GravityView_API::replace_variables( $field_settings[ 'custom_label' ], $form, $entry );
225 224
 			}
226 225
 
227 226
 			/**
@@ -247,19 +246,19 @@  discard block
 block discarded – undo
247 246
 
248 247
 	$label = '';
249 248
 
250
-	if ( ! empty( $entry['_multi'] ) && ! empty( $field_settings['form_id'] ) && ! empty( $entry['_multi'][ $field_settings['form_id'] ] ) ) {
251
-		$entry = $entry['_multi'][ $field_settings['form_id'] ];
252
-		if ( $_form = \GV\GF_Form::by_id( $field_settings['form_id'] ) ) {
249
+	if ( ! empty( $entry[ '_multi' ] ) && ! empty( $field_settings[ 'form_id' ] ) && ! empty( $entry[ '_multi' ][ $field_settings[ 'form_id' ] ] ) ) {
250
+		$entry = $entry[ '_multi' ][ $field_settings[ 'form_id' ] ];
251
+		if ( $_form = \GV\GF_Form::by_id( $field_settings[ 'form_id' ] ) ) {
253 252
 			$form = $_form->form;
254 253
 		}
255 254
 	}
256 255
 
257
-	if ( empty( $entry['form_id'] ) || empty( $field_settings['id'] ) ) {
256
+	if ( empty( $entry[ 'form_id' ] ) || empty( $field_settings[ 'id' ] ) ) {
258 257
 		gravityview()->log->error( 'No entry or field_settings[id] supplied', array( 'data' => array( func_get_args() ) ) );
259 258
 		return $bail( $label, $field_settings, $entry, $force_show_label, $form );
260 259
 	}
261 260
 
262
-	if ( empty( $entry['id'] ) || ! $gv_entry = \GV\GF_Entry::by_id( $entry['id'] ) ) {
261
+	if ( empty( $entry[ 'id' ] ) || ! $gv_entry = \GV\GF_Entry::by_id( $entry[ 'id' ] ) ) {
263 262
 		gravityview()->log->error( 'Invalid \GV\GF_Entry supplied', array( 'data' => $entry ) );
264 263
 		return $bail( $label, $field_settings, $entry, $force_show_label, $form );
265 264
 	}
@@ -271,31 +270,31 @@  discard block
 block discarded – undo
271 270
 	 *
272 271
 	 * Fields with a numeric ID are Gravity Forms ones.
273 272
 	 */
274
-	$source = is_numeric( $field_settings['id'] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL;
273
+	$source = is_numeric( $field_settings[ 'id' ] ) ? \GV\Source::BACKEND_GRAVITYFORMS : \GV\Source::BACKEND_INTERNAL;
275 274
 
276 275
 	/** Initialize the future field. */
277 276
 	switch ( $source ):
278 277
 		/** The Gravity Forms backend. */
279 278
 		case \GV\Source::BACKEND_GRAVITYFORMS:
280
-			if ( ! $gf_form = \GV\GF_Form::by_id( $entry['form_id'] ) ) {
279
+			if ( ! $gf_form = \GV\GF_Form::by_id( $entry[ 'form_id' ] ) ) {
281 280
 				gravityview()->log->error( 'No form Gravity Form found for entry', array( 'data' => $entry ) );
282 281
 				return $bail( $label, $field_settings, $entry->as_entry(), $force_show_label, $form );
283 282
 			}
284 283
 
285
-			if ( ! $field = $gf_form::get_field( $gf_form, $field_settings['id'] ) ) {
286
-				gravityview()->log->error( 'No field found for specified form and field ID #{field_id}', array( 'field_id' => $field_settings['id'], 'data' => $form ) );
284
+			if ( ! $field = $gf_form::get_field( $gf_form, $field_settings[ 'id' ] ) ) {
285
+				gravityview()->log->error( 'No field found for specified form and field ID #{field_id}', array( 'field_id' => $field_settings[ 'id' ], 'data' => $form ) );
287 286
 				return $bail( $label, $field_settings, $entry->as_entry(), $force_show_label, $gf_form->form );
288 287
 			}
289
-			if ( empty( $field_settings['show_label'] ) ) {
288
+			if ( empty( $field_settings[ 'show_label' ] ) ) {
290 289
 				/** The label never wins... */
291
-				$field_settings['label'] = '';
290
+				$field_settings[ 'label' ] = '';
292 291
 			}
293 292
 
294 293
 			break;
295 294
 
296 295
 		/** Our internal backend. */
297 296
 		case \GV\Source::BACKEND_INTERNAL:
298
-			if ( ! $field = \GV\Internal_Source::get_field( $field_settings['id'] ) ) {
297
+			if ( ! $field = \GV\Internal_Source::get_field( $field_settings[ 'id' ] ) ) {
299 298
 				return $bail( $label, $field_settings, $entry->as_entry(), $force_show_label, $form );
300 299
 			}
301 300
 			break;
@@ -307,8 +306,8 @@  discard block
 block discarded – undo
307 306
 			break;
308 307
 	endswitch;
309 308
 
310
-	if( $force_show_label ) {
311
-		$field_settings['show_label'] = '1';
309
+	if ( $force_show_label ) {
310
+		$field_settings[ 'show_label' ] = '1';
312 311
 	}
313 312
 
314 313
 	/** Add the field settings. */
@@ -443,7 +442,7 @@  discard block
 block discarded – undo
443 442
 			'\GravityView_frontend::entry' => \GravityView_frontend::getInstance()->getEntry(),
444 443
 			'\GravityView_View::_current_entry' => \GravityView_View::getInstance()->getCurrentEntry(),
445 444
 			'\GravityView_View::fields' => \GravityView_View::getInstance()->getFields(),
446
-			'wp_actions[loop_start]' => empty( $wp_actions['loop_start'] ) ? 0 : $wp_actions['loop_start'],
445
+			'wp_actions[loop_start]' => empty( $wp_actions[ 'loop_start' ] ) ? 0 : $wp_actions[ 'loop_start' ],
447 446
 			'wp_query::in_the_loop' => $wp_query->in_the_loop,
448 447
 		);
449 448
 	}
@@ -531,7 +530,7 @@  discard block
 block discarded – undo
531 530
 					break;
532 531
 				case 'wp_actions[loop_start]':
533 532
 					global $wp_actions;
534
-					$wp_actions['loop_start'] = $value;
533
+					$wp_actions[ 'loop_start' ] = $value;
535 534
 					break;
536 535
 				case 'wp_query::in_the_loop':
537 536
 					global $wp_query;
@@ -627,9 +626,7 @@  discard block
 block discarded – undo
627 626
 				case 'request':
628 627
 					self::thaw( array(
629 628
 						'\GravityView_View::context' => (
630
-							$value->is_entry() ? 'single' :
631
-							( $value->is_edit_entry() ? 'edit' :
632
-									( $value->is_view() ? 'directory': null )
629
+							$value->is_entry() ? 'single' : ( $value->is_edit_entry() ? 'edit' : ( $value->is_view() ? 'directory' : null )
633 630
 								)
634 631
 						),
635 632
 						'\GravityView_frontend::is_search' => $value->is_search(),
@@ -683,14 +680,14 @@  discard block
 block discarded – undo
683 680
 		global $wp_query, $wp_actions;
684 681
 
685 682
 		$wp_query->in_the_loop = false;
686
-		$wp_actions['loop_start'] = 0;
683
+		$wp_actions[ 'loop_start' ] = 0;
687 684
 	}
688 685
 }
689 686
 
690 687
 
691 688
 /** Add some global fix for field capability discrepancies. */
692 689
 add_filter( 'gravityview/configuration/fields', function( $fields ) {
693
-	if ( empty( $fields  ) ) {
690
+	if ( empty( $fields ) ) {
694 691
 		return $fields;
695 692
 	}
696 693
 
@@ -717,11 +714,11 @@  discard block
 block discarded – undo
717 714
 		}
718 715
 
719 716
 		foreach ( $_fields as $uid => &$_field ) {
720
-			if ( ! isset( $_field['only_loggedin'] ) ) {
717
+			if ( ! isset( $_field[ 'only_loggedin' ] ) ) {
721 718
 				continue;
722 719
 			}
723 720
 			/** If we do not require login, we don't require a cap. */
724
-			$_field['only_loggedin'] != '1' && ( $_field['only_loggedin_cap'] = '' );
721
+			$_field[ 'only_loggedin' ] != '1' && ( $_field[ 'only_loggedin_cap' ] = '' );
725 722
 		}
726 723
 	}
727 724
 	return $fields;
@@ -752,8 +749,8 @@  discard block
 block discarded – undo
752 749
 		}
753 750
 
754 751
 		foreach ( $_fields as $uid => &$_field ) {
755
-			if ( ! empty( $_field['id'] ) && is_numeric( $_field['id'] ) && empty( $_field['form_id'] ) ) {
756
-				$_field['form_id'] = $view->form->ID;
752
+			if ( ! empty( $_field[ 'id' ] ) && is_numeric( $_field[ 'id' ] ) && empty( $_field[ 'form_id' ] ) ) {
753
+				$_field[ 'form_id' ] = $view->form->ID;
757 754
 			}
758 755
 		}
759 756
 	}
@@ -767,25 +764,25 @@  discard block
 block discarded – undo
767 764
 	if ( class_exists( '\GravityView_frontend' ) ) {
768 765
 		global $wp_filter;
769 766
 
770
-		if ( empty( $wp_filter['gravityview_after'] ) ) {
767
+		if ( empty( $wp_filter[ 'gravityview_after' ] ) ) {
771 768
 			return;
772 769
 		}
773 770
 
774 771
 		/** WordPress 4.6 and lower compatibility, when WP_Hook classes were still absent. */
775
-		if ( is_array( $wp_filter['gravityview_after'] ) ) {
776
-			if ( ! empty( $wp_filter['gravityview_after'][10] ) ) {
777
-				foreach ( $wp_filter['gravityview_after'][10] as $function_key => $callback ) {
772
+		if ( is_array( $wp_filter[ 'gravityview_after' ] ) ) {
773
+			if ( ! empty( $wp_filter[ 'gravityview_after' ][ 10 ] ) ) {
774
+				foreach ( $wp_filter[ 'gravityview_after' ][ 10 ] as $function_key => $callback ) {
778 775
 					if ( strpos( $function_key, 'context_not_configured_warning' ) ) {
779
-						unset( $wp_filter['gravityview_after'][10][ $function_key ] );
776
+						unset( $wp_filter[ 'gravityview_after' ][ 10 ][ $function_key ] );
780 777
 					}
781 778
 				}
782 779
 			}
783 780
 			return;
784 781
 		}
785 782
 
786
-		foreach ( $wp_filter['gravityview_after']->callbacks[10] as $function_key => $callback ) {
783
+		foreach ( $wp_filter[ 'gravityview_after' ]->callbacks[ 10 ] as $function_key => $callback ) {
787 784
 			if ( strpos( $function_key, 'context_not_configured_warning' ) ) {
788
-				unset( $wp_filter['gravityview_after']->callbacks[10][ $function_key ] );
785
+				unset( $wp_filter[ 'gravityview_after' ]->callbacks[ 10 ][ $function_key ] );
789 786
 			}
790 787
 		}
791 788
 	}
Please login to merge, or discard this patch.
includes/widgets/search-widget/class-search-widget.php 1 patch
Spacing   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 				'type' => 'radio',
65 65
 				'full_width' => true,
66 66
 				'label' => esc_html__( 'Search Mode', 'gravityview' ),
67
-				'desc' => __('Should search results match all search fields, or any?', 'gravityview'),
67
+				'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ),
68 68
 				'value' => 'any',
69 69
 				'class' => 'hide-if-js',
70 70
 				'options' => array(
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
 			// admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999
88 88
 			add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 );
89
-			add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') );
89
+			add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) );
90 90
 			add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) );
91 91
 
92 92
 			// ajax - get the searchable fields
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 		$script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
230 230
 		$script_source = empty( $script_min ) ? '/source' : '';
231 231
 
232
-		wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version );
232
+		wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version );
233 233
 
234 234
 		wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array(
235 235
 			'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ),
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * @return array Scripts allowed in no-conflict mode, plus the search widget script
252 252
 	 */
253 253
 	public function register_no_conflict( $allowed ) {
254
-		$allowed[] = 'gravityview_searchwidget_admin';
254
+		$allowed[ ] = 'gravityview_searchwidget_admin';
255 255
 		return $allowed;
256 256
 	}
257 257
 
@@ -264,24 +264,24 @@  discard block
 block discarded – undo
264 264
 	 */
265 265
 	public static function get_searchable_fields() {
266 266
 
267
-		if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) {
267
+		if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) {
268 268
 			exit( '0' );
269 269
 		}
270 270
 
271 271
 		$form = '';
272 272
 
273 273
 		// Fetch the form for the current View
274
-		if ( ! empty( $_POST['view_id'] ) ) {
274
+		if ( ! empty( $_POST[ 'view_id' ] ) ) {
275 275
 
276
-			$form = gravityview_get_form_id( $_POST['view_id'] );
276
+			$form = gravityview_get_form_id( $_POST[ 'view_id' ] );
277 277
 
278
-		} elseif ( ! empty( $_POST['formid'] ) ) {
278
+		} elseif ( ! empty( $_POST[ 'formid' ] ) ) {
279 279
 
280
-			$form = (int) $_POST['formid'];
280
+			$form = (int)$_POST[ 'formid' ];
281 281
 
282
-		} elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) {
282
+		} elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) {
283 283
 
284
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
284
+			$form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] );
285 285
 
286 286
 		}
287 287
 
@@ -331,14 +331,14 @@  discard block
 block discarded – undo
331 331
 		);
332 332
 
333 333
 		if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) {
334
-			$custom_fields['is_approved'] = array(
334
+			$custom_fields[ 'is_approved' ] = array(
335 335
 				'text' => esc_html__( 'Approval Status', 'gravityview' ),
336 336
 				'type' => 'multi',
337 337
 			);
338 338
 		}
339 339
 
340
-		foreach( $custom_fields as $custom_field_key => $custom_field ) {
341
-			$output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] );
340
+		foreach ( $custom_fields as $custom_field_key => $custom_field ) {
341
+			$output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field[ 'type' ], self::get_field_label( array( 'field' => $custom_field_key ) ), $custom_field[ 'text' ] );
342 342
 		}
343 343
 
344 344
 		// Get fields with sub-inputs and no parent
@@ -360,13 +360,13 @@  discard block
 block discarded – undo
360 360
 
361 361
 			foreach ( $fields as $id => $field ) {
362 362
 
363
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
363
+				if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
364 364
 					continue;
365 365
 				}
366 366
 
367
-				$types = self::get_search_input_types( $id, $field['type'] );
367
+				$types = self::get_search_input_types( $id, $field[ 'type' ] );
368 368
 
369
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>';
369
+				$output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>';
370 370
 			}
371 371
 		}
372 372
 
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 	public static function get_search_input_types( $field_id = '', $field_type = null ) {
390 390
 
391 391
 		// @todo - This needs to be improved - many fields have . including products and addresses
392
-		if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) {
392
+		if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) {
393 393
 			$input_type = 'boolean'; // on/off checkbox
394 394
 		} elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) {
395 395
 			$input_type = 'multi'; //multiselect
@@ -433,19 +433,19 @@  discard block
 block discarded – undo
433 433
 			$post_id = 0;
434 434
 
435 435
 			// We're in the WordPress Widget context, and an overriding post ID has been set.
436
-			if ( ! empty( $widget_args['post_id'] ) ) {
437
-				$post_id = absint( $widget_args['post_id'] );
436
+			if ( ! empty( $widget_args[ 'post_id' ] ) ) {
437
+				$post_id = absint( $widget_args[ 'post_id' ] );
438 438
 			}
439 439
 			// We're in the WordPress Widget context, and the base View ID should be used
440
-			else if ( ! empty( $widget_args['view_id'] ) ) {
441
-				$post_id = absint( $widget_args['view_id'] );
440
+			else if ( ! empty( $widget_args[ 'view_id' ] ) ) {
441
+				$post_id = absint( $widget_args[ 'view_id' ] );
442 442
 			}
443 443
 
444 444
 			$args = gravityview_get_permalink_query_args( $post_id );
445 445
 
446 446
 			// Add hidden fields to the search form
447 447
 			foreach ( $args as $key => $value ) {
448
-				$search_fields[] = array(
448
+				$search_fields[ ] = array(
449 449
 					'name'  => $key,
450 450
 					'input' => 'hidden',
451 451
 					'value' => $value,
@@ -484,28 +484,28 @@  discard block
 block discarded – undo
484 484
 		/**
485 485
 		 * Include the sidebar Widgets.
486 486
 		 */
487
-		$widgets = (array) get_option( 'widget_gravityview_search', array() );
487
+		$widgets = (array)get_option( 'widget_gravityview_search', array() );
488 488
 
489 489
 		foreach ( $widgets as $widget ) {
490
-			if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) {
491
-				if( $_fields = json_decode( $widget['search_fields'], true ) ) {
490
+			if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) {
491
+				if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) {
492 492
 					foreach ( $_fields as $field ) {
493
-						if ( empty( $field['form_id'] ) ) {
494
-							$field['form_id'] = $view->form ? $view->form->ID : 0;
493
+						if ( empty( $field[ 'form_id' ] ) ) {
494
+							$field[ 'form_id' ] = $view->form ? $view->form->ID : 0;
495 495
 						}
496
-						$searchable_fields[] = $with_full_field ? $field : $field['field'];
496
+						$searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ];
497 497
 					}
498 498
 				}
499 499
 			}
500 500
 		}
501 501
 
502 502
 		foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) {
503
-			if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) {
503
+			if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) {
504 504
 				foreach ( $_fields as $field ) {
505
-					if ( empty( $field['form_id'] ) ) {
506
-						$field['form_id'] = $view->form ? $view->form->ID : 0;
505
+					if ( empty( $field[ 'form_id' ] ) ) {
506
+						$field[ 'form_id' ] = $view->form ? $view->form->ID : 0;
507 507
 					}
508
-					$searchable_fields[] = $with_full_field ? $field : $field['field'];
508
+					$searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ];
509 509
 				}
510 510
 			}
511 511
 		}
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 			return $search_criteria; // Return the original criteria, GF_Query modification kicks in later
536 536
 		}
537 537
 
538
-		if( 'post' === $this->search_method ) {
538
+		if ( 'post' === $this->search_method ) {
539 539
 			$get = $_POST;
540 540
 		} else {
541 541
 			$get = $_GET;
@@ -554,15 +554,15 @@  discard block
 block discarded – undo
554 554
 		$get = gv_map_deep( $get, 'rawurldecode' );
555 555
 
556 556
 		// Make sure array key is set up
557
-		$search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() );
557
+		$search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() );
558 558
 
559 559
 		$searchable_fields = $this->get_view_searchable_fields( $view );
560 560
 		$searchable_field_objects = $this->get_view_searchable_fields( $view, true );
561 561
 
562 562
 		// add free search
563
-		if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) {
563
+		if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) {
564 564
 
565
-			$search_all_value = trim( $get['gv_search'] );
565
+			$search_all_value = trim( $get[ 'gv_search' ] );
566 566
 
567 567
 			/**
568 568
 			 * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase?
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 			}
588 588
 
589 589
 			foreach ( $words as $word ) {
590
-				$search_criteria['field_filters'][] = array(
590
+				$search_criteria[ 'field_filters' ][ ] = array(
591 591
 					'key' => null, // The field ID to search
592 592
 					'value' => $word, // The value to search
593 593
 					'operator' => 'contains', // What to search in. Options: `is` or `contains`
@@ -600,14 +600,14 @@  discard block
 block discarded – undo
600 600
 			/**
601 601
 			 * Get and normalize the dates according to the input format.
602 602
 			 */
603
-			if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) {
604
-				if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) {
603
+			if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) {
604
+				if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) {
605 605
 					$curr_start = $curr_start_date->format( 'Y-m-d' );
606 606
 				}
607 607
 			}
608 608
 
609
-			if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) {
610
-				if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) {
609
+			if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) {
610
+				if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) {
611 611
 					$curr_end = $curr_end_date->format( 'Y-m-d' );
612 612
 				}
613 613
 			}
@@ -642,22 +642,22 @@  discard block
 block discarded – undo
642 642
 			 */
643 643
 			if ( ! empty( $curr_start ) ) {
644 644
 				$curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) );
645
-				$search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
645
+				$search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
646 646
 			}
647 647
 
648 648
 			if ( ! empty( $curr_end ) ) {
649 649
 				// Fast-forward 24 hour on the end time
650 650
 				$curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS );
651
-				$search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
652
-				if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056
653
-					$search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 );
651
+				$search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
652
+				if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056
653
+					$search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 );
654 654
 				}
655 655
 			}
656 656
 		}
657 657
 
658 658
 		// search for a specific entry ID
659 659
 		if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) {
660
-			$search_criteria['field_filters'][] = array(
660
+			$search_criteria[ 'field_filters' ][ ] = array(
661 661
 				'key' => 'id',
662 662
 				'value' => absint( $get[ 'gv_id' ] ),
663 663
 				'operator' => '=',
@@ -666,20 +666,20 @@  discard block
 block discarded – undo
666 666
 
667 667
 		// search for a specific Created_by ID
668 668
 		if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) {
669
-			$search_criteria['field_filters'][] = array(
669
+			$search_criteria[ 'field_filters' ][ ] = array(
670 670
 				'key' => 'created_by',
671
-				'value' => $get['gv_by'],
671
+				'value' => $get[ 'gv_by' ],
672 672
 				'operator' => '=',
673 673
 			);
674 674
 		}
675 675
 
676 676
 		// Get search mode passed in URL
677
-		$mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ?  $get['mode'] : 'any';
677
+		$mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any';
678 678
 
679 679
 		// get the other search filters
680 680
 		foreach ( $get as $key => $value ) {
681 681
 
682
-			if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) {
682
+			if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) {
683 683
 				continue;
684 684
 			}
685 685
 
@@ -689,15 +689,15 @@  discard block
 block discarded – undo
689 689
 				continue;
690 690
 			}
691 691
 
692
-			if ( isset( $filter[0]['value'] ) ) {
693
-				$search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter );
692
+			if ( isset( $filter[ 0 ][ 'value' ] ) ) {
693
+				$search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter );
694 694
 
695 695
 				// if date range type, set search mode to ALL
696
-				if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) {
696
+				if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) {
697 697
 					$mode = 'all';
698 698
 				}
699
-			} elseif( !empty( $filter ) ) {
700
-				$search_criteria['field_filters'][] = $filter;
699
+			} elseif ( ! empty( $filter ) ) {
700
+				$search_criteria[ 'field_filters' ][ ] = $filter;
701 701
 			}
702 702
 		}
703 703
 
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 		 * @since 1.5.1
707 707
 		 * @param[out,in] string $mode Search mode (`any` vs `all`)
708 708
 		 */
709
-		$search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode );
709
+		$search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode );
710 710
 
711 711
 		gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) );
712 712
 
@@ -733,19 +733,19 @@  discard block
 block discarded – undo
733 733
 
734 734
 		$query_class = $view->get_query_class();
735 735
 
736
-		if ( empty( $search_criteria['field_filters'] ) ) {
736
+		if ( empty( $search_criteria[ 'field_filters' ] ) ) {
737 737
 			return;
738 738
 		}
739 739
 
740 740
 		$widgets = $view->widgets->by_id( $this->widget_id );
741 741
 		if ( $widgets->count() ) {
742 742
 			$widgets = $widgets->all();
743
-			$widget  = $widgets[0];
743
+			$widget  = $widgets[ 0 ];
744 744
 
745 745
 			$search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true );
746 746
 
747
-			foreach ( (array) $search_fields as $search_field ) {
748
-				if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) {
747
+			foreach ( (array)$search_fields as $search_field ) {
748
+				if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) {
749 749
 					$created_by_text_mode = true;
750 750
 				}
751 751
 			}
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 		$extra_conditions = array();
755 755
 		$mode = 'any';
756 756
 
757
-		foreach ( $search_criteria['field_filters'] as &$filter ) {
757
+		foreach ( $search_criteria[ 'field_filters' ] as &$filter ) {
758 758
 			if ( ! is_array( $filter ) ) {
759 759
 				if ( in_array( strtolower( $filter ), array( 'any', 'all' ) ) ) {
760 760
 					$mode = $filter;
@@ -763,13 +763,13 @@  discard block
 block discarded – undo
763 763
 			}
764 764
 
765 765
 			// Construct a manual query for unapproved statuses
766
-			if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'] ) ) {
767
-				$_tmp_query       = new $query_class( $view->form->ID, array(
766
+			if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array)$filter[ 'value' ] ) ) {
767
+				$_tmp_query = new $query_class( $view->form->ID, array(
768 768
 					'field_filters' => array(
769 769
 						array(
770 770
 							'operator' => 'in',
771 771
 							'key'      => 'is_approved',
772
-							'value'    => (array) $filter['value'],
772
+							'value'    => (array)$filter[ 'value' ],
773 773
 						),
774 774
 						array(
775 775
 							'operator' => 'is',
@@ -781,30 +781,30 @@  discard block
 block discarded – undo
781 781
 				) );
782 782
 				$_tmp_query_parts = $_tmp_query->_introspect();
783 783
 
784
-				$extra_conditions[] = $_tmp_query_parts['where'];
784
+				$extra_conditions[ ] = $_tmp_query_parts[ 'where' ];
785 785
 
786 786
 				$filter = false;
787 787
 				continue;
788 788
 			}
789 789
 
790 790
 			// Construct manual query for text mode creator search
791
-			if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) {
792
-				$extra_conditions[] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view );
791
+			if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) {
792
+				$extra_conditions[ ] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view );
793 793
 				$filter = false;
794 794
 				continue;
795 795
 			}
796 796
 
797 797
 			// By default, we want searches to be wildcard for each field.
798
-			$filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator'];
798
+			$filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ];
799 799
 
800 800
 			// For multichoice, let's have an in (OR) search.
801
-			if ( is_array( $filter['value'] ) ) {
802
-				$filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)?
801
+			if ( is_array( $filter[ 'value' ] ) ) {
802
+				$filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)?
803 803
 			}
804 804
 
805 805
 			// Default form with joins functionality
806
-			if ( empty( $filter['form_id'] ) ) {
807
-				$filter['form_id'] = $view->form ? $view->form->ID : 0;
806
+			if ( empty( $filter[ 'form_id' ] ) ) {
807
+				$filter[ 'form_id' ] = $view->form ? $view->form->ID : 0;
808 808
 			}
809 809
 
810 810
 			/**
@@ -812,12 +812,12 @@  discard block
 block discarded – undo
812 812
 			 * @param string $operator Existing search operator
813 813
 			 * @param array $filter array with `key`, `value`, `operator`, `type` keys
814 814
 			 */
815
-			$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter );
815
+			$filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter );
816 816
 		}
817 817
 
818 818
 		$search_conditions = array();
819 819
 
820
-		if ( $filters = array_filter( $search_criteria['field_filters'] ) ) {
820
+		if ( $filters = array_filter( $search_criteria[ 'field_filters' ] ) ) {
821 821
 
822 822
 			foreach ( $filters as $filter ) {
823 823
 				if ( ! is_array( $filter ) ) {
@@ -830,22 +830,22 @@  discard block
 block discarded – undo
830 830
 				 * code by reusing what's inside GF_Query already as they
831 831
 				 * take care of many small things like forcing numeric, etc.
832 832
 				 */
833
-				$_tmp_query       = new $query_class( $filter['form_id'], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) );
833
+				$_tmp_query       = new $query_class( $filter[ 'form_id' ], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) );
834 834
 				$_tmp_query_parts = $_tmp_query->_introspect();
835
-				$search_condition = $_tmp_query_parts['where'];
835
+				$search_condition = $_tmp_query_parts[ 'where' ];
836 836
 
837
-				if ( empty( $filter['key'] ) &&  $search_condition->expressions ) {
837
+				if ( empty( $filter[ 'key' ] ) && $search_condition->expressions ) {
838 838
 					 foreach ( $search_condition->expressions as $condition ) {
839
-						$search_conditions[] = new GravityView_Widget_Search_All_GF_Query_Condition( $condition, $view );
839
+						$search_conditions[ ] = new GravityView_Widget_Search_All_GF_Query_Condition( $condition, $view );
840 840
 					 }
841 841
 				} else {
842 842
 					$left = $search_condition->left;
843 843
 					$alias = $query->_alias( $left->field_id, $left->source, $left->is_entry_column() ? 't' : 'm' );
844 844
 
845 845
 					if ( $view->joins && $left->field_id == GF_Query_Column::META ) {
846
-						$search_conditions[] = new GravityView_Widget_Search_All_GF_Query_Condition( $search_condition, $view );
846
+						$search_conditions[ ] = new GravityView_Widget_Search_All_GF_Query_Condition( $search_condition, $view );
847 847
 					} else {
848
-						$search_conditions[] = new GF_Query_Condition(
848
+						$search_conditions[ ] = new GF_Query_Condition(
849 849
 							new GF_Query_Column( $left->field_id, $left->source, $alias ),
850 850
 							$search_condition->operator,
851 851
 							$search_condition->right
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
 		/**
868 868
 		 * Combine the parts as a new WHERE clause.
869 869
 		 */
870
-		$where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'] ), $search_conditions, $extra_conditions ) );
870
+		$where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ] ), $search_conditions, $extra_conditions ) );
871 871
 		$query->where( $where );
872 872
 	}
873 873
 
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
 		$field_id = str_replace( 'filter_', '', $key );
891 891
 
892 892
 		// calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox )
893
-		if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) {
893
+		if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) {
894 894
 			$field_id = str_replace( '_', '.', $field_id );
895 895
 		}
896 896
 
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 			// form is in searchable fields
943 943
 			$found = false;
944 944
 			foreach ( $searchable_fields as $field ) {
945
-				if ( $field_id == $field['field'] && $form->ID == $field['form_id'] ) {
945
+				if ( $field_id == $field[ 'field' ] && $form->ID == $field[ 'form_id' ] ) {
946 946
 					$found = true;
947 947
 					break;
948 948
 				}
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
 
979 979
 			case 'select':
980 980
 			case 'radio':
981
-				$filter['operator'] = 'is';
981
+				$filter[ 'operator' ] = 'is';
982 982
 				break;
983 983
 
984 984
 			case 'post_category':
@@ -992,7 +992,7 @@  discard block
 block discarded – undo
992 992
 
993 993
 				foreach ( $value as $val ) {
994 994
 					$cat = get_term( $val, 'category' );
995
-					$filter[] = array(
995
+					$filter[ ] = array(
996 996
 						'key'      => $field_id,
997 997
 						'value'    => esc_attr( $cat->name ) . ':' . $val,
998 998
 						'operator' => 'is',
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
 				$filter = array();
1012 1012
 
1013 1013
 				foreach ( $value as $val ) {
1014
-					$filter[] = array( 'key' => $field_id, 'value' => $val );
1014
+					$filter[ ] = array( 'key' => $field_id, 'value' => $val );
1015 1015
 				}
1016 1016
 
1017 1017
 				break;
@@ -1020,9 +1020,9 @@  discard block
 block discarded – undo
1020 1020
 				// convert checkbox on/off into the correct search filter
1021 1021
 				if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) {
1022 1022
 					foreach ( $form_field->inputs as $k => $input ) {
1023
-						if ( $input['id'] == $field_id ) {
1024
-							$filter['value'] = $form_field->choices[ $k ]['value'];
1025
-							$filter['operator'] = 'is';
1023
+						if ( $input[ 'id' ] == $field_id ) {
1024
+							$filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ];
1025
+							$filter[ 'operator' ] = 'is';
1026 1026
 							break;
1027 1027
 						}
1028 1028
 					}
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
 					$filter = array();
1033 1033
 
1034 1034
 					foreach ( $value as $val ) {
1035
-						$filter[] = array(
1035
+						$filter[ ] = array(
1036 1036
 							'key'      => $field_id,
1037 1037
 							'value'    => $val,
1038 1038
 							'operator' => 'is',
@@ -1053,9 +1053,9 @@  discard block
 block discarded – undo
1053 1053
 					foreach ( $words as $word ) {
1054 1054
 						if ( ! empty( $word ) && strlen( $word ) > 1 ) {
1055 1055
 							// Keep the same key for each filter
1056
-							$filter['value'] = $word;
1056
+							$filter[ 'value' ] = $word;
1057 1057
 							// Add a search for the value
1058
-							$filters[] = $filter;
1058
+							$filters[ ] = $filter;
1059 1059
 						}
1060 1060
 					}
1061 1061
 
@@ -1069,19 +1069,19 @@  discard block
 block discarded – undo
1069 1069
 
1070 1070
 					foreach ( $searchable_fields as $searchable_field ) {
1071 1071
 
1072
-						if( $form_field->ID !== $searchable_field['field'] ) {
1072
+						if ( $form_field->ID !== $searchable_field[ 'field' ] ) {
1073 1073
 							continue;
1074 1074
 						}
1075 1075
 
1076 1076
 						// Only exact-match dropdowns, not text search
1077
-						if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) {
1077
+						if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) {
1078 1078
 							continue;
1079 1079
 						}
1080 1080
 
1081 1081
 						$input_id = gravityview_get_input_id_from_id( $form_field->ID );
1082 1082
 
1083 1083
 						if ( 4 === $input_id ) {
1084
-							$filter['operator'] = 'is';
1084
+							$filter[ 'operator' ] = 'is';
1085 1085
 						};
1086 1086
 					}
1087 1087
 				}
@@ -1108,12 +1108,12 @@  discard block
 block discarded – undo
1108 1108
 						 * @since 1.16.3
1109 1109
 						 * Safeguard until GF implements '<=' operator
1110 1110
 						 */
1111
-						if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
1111
+						if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
1112 1112
 							$operator = '<';
1113 1113
 							$date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) );
1114 1114
 						}
1115 1115
 
1116
-						$filter[] = array(
1116
+						$filter[ ] = array(
1117 1117
 							'key'      => $field_id,
1118 1118
 							'value'    => self::get_formatted_date( $date, 'Y-m-d', $date_format ),
1119 1119
 							'operator' => $operator,
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 					}
1122 1122
 				} else {
1123 1123
 					$date = $value;
1124
-					$filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format );
1124
+					$filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format );
1125 1125
 				}
1126 1126
 
1127 1127
 				break;
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 			'ymd_dot' => 'Y.m.d',
1153 1153
 		);
1154 1154
 
1155
-		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){
1155
+		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) {
1156 1156
 			$format = $datepicker[ $field->dateFormat ];
1157 1157
 		}
1158 1158
 
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
 	public function add_template_path( $file_paths ) {
1190 1190
 
1191 1191
 		// Index 100 is the default GravityView template path.
1192
-		$file_paths[102] = self::$file . 'templates/';
1192
+		$file_paths[ 102 ] = self::$file . 'templates/';
1193 1193
 
1194 1194
 		return $file_paths;
1195 1195
 	}
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
 		$has_date = false;
1209 1209
 
1210 1210
 		foreach ( $search_fields as $k => $field ) {
1211
-			if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) {
1211
+			if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) {
1212 1212
 				$has_date = true;
1213 1213
 				break;
1214 1214
 			}
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
 		}
1236 1236
 
1237 1237
 		// get configured search fields
1238
-		$search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : '';
1238
+		$search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : '';
1239 1239
 
1240 1240
 		if ( empty( $search_fields ) || ! is_array( $search_fields ) ) {
1241 1241
 			gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) );
@@ -1250,40 +1250,40 @@  discard block
 block discarded – undo
1250 1250
 
1251 1251
 			$updated_field = $this->get_search_filter_details( $updated_field );
1252 1252
 
1253
-			switch ( $field['field'] ) {
1253
+			switch ( $field[ 'field' ] ) {
1254 1254
 
1255 1255
 				case 'search_all':
1256
-					$updated_field['key'] = 'search_all';
1257
-					$updated_field['input'] = 'search_all';
1258
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' );
1256
+					$updated_field[ 'key' ] = 'search_all';
1257
+					$updated_field[ 'input' ] = 'search_all';
1258
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' );
1259 1259
 					break;
1260 1260
 
1261 1261
 				case 'entry_date':
1262
-					$updated_field['key'] = 'entry_date';
1263
-					$updated_field['input'] = 'entry_date';
1264
-					$updated_field['value'] = array(
1262
+					$updated_field[ 'key' ] = 'entry_date';
1263
+					$updated_field[ 'input' ] = 'entry_date';
1264
+					$updated_field[ 'value' ] = array(
1265 1265
 						'start' => $this->rgget_or_rgpost( 'gv_start' ),
1266 1266
 						'end' => $this->rgget_or_rgpost( 'gv_end' ),
1267 1267
 					);
1268 1268
 					break;
1269 1269
 
1270 1270
 				case 'entry_id':
1271
-					$updated_field['key'] = 'entry_id';
1272
-					$updated_field['input'] = 'entry_id';
1273
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' );
1271
+					$updated_field[ 'key' ] = 'entry_id';
1272
+					$updated_field[ 'input' ] = 'entry_id';
1273
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' );
1274 1274
 					break;
1275 1275
 
1276 1276
 				case 'created_by':
1277
-					$updated_field['key'] = 'created_by';
1278
-					$updated_field['name'] = 'gv_by';
1279
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' );
1280
-					$updated_field['choices'] = self::get_created_by_choices();
1277
+					$updated_field[ 'key' ] = 'created_by';
1278
+					$updated_field[ 'name' ] = 'gv_by';
1279
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' );
1280
+					$updated_field[ 'choices' ] = self::get_created_by_choices();
1281 1281
 					break;
1282 1282
 				
1283 1283
 				case 'is_approved':
1284
-					$updated_field['key'] = 'is_approved';
1285
-					$updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' );
1286
-					$updated_field['choices'] = self::get_is_approved_choices();
1284
+					$updated_field[ 'key' ] = 'is_approved';
1285
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' );
1286
+					$updated_field[ 'choices' ] = self::get_is_approved_choices();
1287 1287
 					break;
1288 1288
 			}
1289 1289
 
@@ -1302,16 +1302,16 @@  discard block
 block discarded – undo
1302 1302
 		 */
1303 1303
 		$gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context );
1304 1304
 
1305
-		$gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal';
1305
+		$gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal';
1306 1306
 
1307 1307
 		/** @since 1.14 */
1308
-		$gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any';
1308
+		$gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any';
1309 1309
 
1310
-		$custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : '';
1310
+		$custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : '';
1311 1311
 
1312 1312
 		$gravityview_view->search_class = self::get_search_class( $custom_class );
1313 1313
 
1314
-		$gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false;
1314
+		$gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false;
1315 1315
 
1316 1316
 		if ( $this->has_date_field( $search_fields ) ) {
1317 1317
 			// enqueue datepicker stuff only if needed!
@@ -1333,10 +1333,10 @@  discard block
 block discarded – undo
1333 1333
 	public static function get_search_class( $custom_class = '' ) {
1334 1334
 		$gravityview_view = GravityView_View::getInstance();
1335 1335
 
1336
-		$search_class = 'gv-search-'.$gravityview_view->search_layout;
1336
+		$search_class = 'gv-search-' . $gravityview_view->search_layout;
1337 1337
 
1338
-		if ( ! empty( $custom_class )  ) {
1339
-			$search_class .= ' '.$custom_class;
1338
+		if ( ! empty( $custom_class ) ) {
1339
+			$search_class .= ' ' . $custom_class;
1340 1340
 		}
1341 1341
 
1342 1342
 		/**
@@ -1380,9 +1380,9 @@  discard block
 block discarded – undo
1380 1380
 
1381 1381
 		if ( ! $label ) {
1382 1382
 
1383
-			$label = isset( $form_field['label'] ) ? $form_field['label'] : '';
1383
+			$label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : '';
1384 1384
 
1385
-			switch( $field['field'] ) {
1385
+			switch ( $field[ 'field' ] ) {
1386 1386
 				case 'search_all':
1387 1387
 					$label = __( 'Search Entries:', 'gravityview' );
1388 1388
 					break;
@@ -1394,10 +1394,10 @@  discard block
 block discarded – undo
1394 1394
 					break;
1395 1395
 				default:
1396 1396
 					// If this is a field input, not a field
1397
-					if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) {
1397
+					if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) {
1398 1398
 
1399 1399
 						// Get the label for the field in question, which returns an array
1400
-						$items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) );
1400
+						$items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) );
1401 1401
 
1402 1402
 						// Get the item with the `label` key
1403 1403
 						$values = wp_list_pluck( $items, 'label' );
@@ -1436,32 +1436,32 @@  discard block
 block discarded – undo
1436 1436
 		$form = $gravityview_view->getForm();
1437 1437
 
1438 1438
 		// for advanced field ids (eg, first name / last name )
1439
-		$name = 'filter_' . str_replace( '.', '_', $field['field'] );
1439
+		$name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] );
1440 1440
 
1441 1441
 		// get searched value from $_GET/$_POST (string or array)
1442 1442
 		$value = $this->rgget_or_rgpost( $name );
1443 1443
 
1444 1444
 		// get form field details
1445
-		$form_field = gravityview_get_field( $form, $field['field'] );
1445
+		$form_field = gravityview_get_field( $form, $field[ 'field' ] );
1446 1446
 
1447 1447
 		$filter = array(
1448
-			'key' => $field['field'],
1448
+			'key' => $field[ 'field' ],
1449 1449
 			'name' => $name,
1450 1450
 			'label' => self::get_field_label( $field, $form_field ),
1451
-			'input' => $field['input'],
1451
+			'input' => $field[ 'input' ],
1452 1452
 			'value' => $value,
1453
-			'type' => $form_field['type'],
1453
+			'type' => $form_field[ 'type' ],
1454 1454
 		);
1455 1455
 
1456 1456
 		// collect choices
1457
-		if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) {
1458
-			$filter['choices'] = gravityview_get_terms_choices();
1459
-		} elseif ( ! empty( $form_field['choices'] ) ) {
1460
-			$filter['choices'] = $form_field['choices'];
1457
+		if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) {
1458
+			$filter[ 'choices' ] = gravityview_get_terms_choices();
1459
+		} elseif ( ! empty( $form_field[ 'choices' ] ) ) {
1460
+			$filter[ 'choices' ] = $form_field[ 'choices' ];
1461 1461
 		}
1462 1462
 
1463
-		if ( 'date_range' === $field['input'] && empty( $value ) ) {
1464
-			$filter['value'] = array( 'start' => '', 'end' => '' );
1463
+		if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) {
1464
+			$filter[ 'value' ] = array( 'start' => '', 'end' => '' );
1465 1465
 		}
1466 1466
 
1467 1467
 		return $filter;
@@ -1485,7 +1485,7 @@  discard block
 block discarded – undo
1485 1485
 
1486 1486
 		$choices = array();
1487 1487
 		foreach ( $users as $user ) {
1488
-			$choices[] = array(
1488
+			$choices[ ] = array(
1489 1489
 				'value' => $user->ID,
1490 1490
 				'text' => $user->display_name,
1491 1491
 			);
@@ -1505,9 +1505,9 @@  discard block
 block discarded – undo
1505 1505
 
1506 1506
 		$choices = array();
1507 1507
 		foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) {
1508
-			$choices[] = array(
1509
-				'value' => $status['value'],
1510
-				'text' => $status['label'],
1508
+			$choices[ ] = array(
1509
+				'value' => $status[ 'value' ],
1510
+				'text' => $status[ 'label' ],
1511 1511
 			);
1512 1512
 		}
1513 1513
 
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
 	 */
1560 1560
 	public function add_datepicker_js_dependency( $js_dependencies ) {
1561 1561
 
1562
-		$js_dependencies[] = 'jquery-ui-datepicker';
1562
+		$js_dependencies[ ] = 'jquery-ui-datepicker';
1563 1563
 
1564 1564
 		return $js_dependencies;
1565 1565
 	}
@@ -1603,7 +1603,7 @@  discard block
 block discarded – undo
1603 1603
 			'isRTL'             => is_rtl(),
1604 1604
 		), $view_data );
1605 1605
 
1606
-		$localizations['datepicker'] = $datepicker_settings;
1606
+		$localizations[ 'datepicker' ] = $datepicker_settings;
1607 1607
 
1608 1608
 		return $localizations;
1609 1609
 
@@ -1630,7 +1630,7 @@  discard block
 block discarded – undo
1630 1630
 	 * @return void
1631 1631
 	 */
1632 1632
 	private function maybe_enqueue_flexibility() {
1633
-		if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) {
1633
+		if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
1634 1634
 			wp_enqueue_script( 'gv-flexibility' );
1635 1635
 		}
1636 1636
 	}
@@ -1652,7 +1652,7 @@  discard block
 block discarded – undo
1652 1652
 		add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 );
1653 1653
 
1654 1654
 		$scheme = is_ssl() ? 'https://' : 'http://';
1655
-		wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1655
+		wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1656 1656
 
1657 1657
 		/**
1658 1658
 		 * @filter `gravityview_search_datepicker_class`
@@ -1731,7 +1731,7 @@  discard block
 block discarded – undo
1731 1731
 	public function add_preview_inputs() {
1732 1732
 		global $wp;
1733 1733
 
1734
-		if ( ! is_preview() || ! current_user_can( 'publish_gravityviews') ) {
1734
+		if ( ! is_preview() || ! current_user_can( 'publish_gravityviews' ) ) {
1735 1735
 			return;
1736 1736
 		}
1737 1737
 
@@ -1756,7 +1756,7 @@  discard block
 block discarded – undo
1756 1756
  */
1757 1757
 class GravityView_Widget_Search_Author_GF_Query_Condition extends \GF_Query_Condition {
1758 1758
 	public function __construct( $filter, $view ) {
1759
-		$this->value = $filter['value'];
1759
+		$this->value = $filter[ 'value' ];
1760 1760
 		$this->view = $view;
1761 1761
 	}
1762 1762
 
@@ -1788,11 +1788,11 @@  discard block
 block discarded – undo
1788 1788
 		$conditions = array();
1789 1789
 
1790 1790
 		foreach ( $user_fields as $user_field ) {
1791
-			$conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) .  '%' );
1791
+			$conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' );
1792 1792
 		}
1793 1793
 
1794 1794
 		foreach ( $user_meta_fields as $meta_field ) {
1795
-			$conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) .  '%' );
1795
+			$conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' );
1796 1796
 		}
1797 1797
 
1798 1798
 		$conditions = '(' . implode( ' OR ', $conditions ) . ')';
@@ -1821,9 +1821,9 @@  discard block
 block discarded – undo
1821 1821
 
1822 1822
 		$conditions = array();
1823 1823
 
1824
-		foreach ( $parameters['aliases'] as $key => $alias ) {
1825
-			if ( 'm' == $alias[0] && preg_match( '#\d+_\d+#', $key ) ) {
1826
-				$conditions[] = sprintf( "EXISTS(SELECT * FROM `$table` WHERE `meta_value` %s %s AND `entry_id` = `%s`.`entry_id`)",
1824
+		foreach ( $parameters[ 'aliases' ] as $key => $alias ) {
1825
+			if ( 'm' == $alias[ 0 ] && preg_match( '#\d+_\d+#', $key ) ) {
1826
+				$conditions[ ] = sprintf( "EXISTS(SELECT * FROM `$table` WHERE `meta_value` %s %s AND `entry_id` = `%s`.`entry_id`)",
1827 1827
 					$this->search_condition->operator, $this->search_condition->right->sql( $query ), $alias );
1828 1828
 			}
1829 1829
 		}
Please login to merge, or discard this patch.
includes/class-api.php 1 patch
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
 		$form = $gravityview_view->getForm();
33 33
 
34
-		if ( defined( 'DOING_GRAVITYVIEW_TESTS' ) && ! empty( $GLOBALS['GravityView_API_field_label_override'] ) ) {
34
+		if ( defined( 'DOING_GRAVITYVIEW_TESTS' ) && ! empty( $GLOBALS[ 'GravityView_API_field_label_override' ] ) ) {
35 35
 			/** Allow to fall through for back compatibility testing purposes. */
36 36
 		} else {
37 37
 			return \GV\Mocks\GravityView_API_field_label( $form, $field, $entry, $force_show_label );
@@ -39,29 +39,29 @@  discard block
 block discarded – undo
39 39
 
40 40
 		$label = '';
41 41
 
42
-		if( !empty( $field['show_label'] ) || $force_show_label ) {
42
+		if ( ! empty( $field[ 'show_label' ] ) || $force_show_label ) {
43 43
 
44
-			$label = $field['label'];
44
+			$label = $field[ 'label' ];
45 45
 
46 46
 			// Support Gravity Forms 1.9+
47
-			if( class_exists( 'GF_Field' ) ) {
47
+			if ( class_exists( 'GF_Field' ) ) {
48 48
 
49
-				$field_object = RGFormsModel::get_field( $form, $field['id'] );
49
+				$field_object = RGFormsModel::get_field( $form, $field[ 'id' ] );
50 50
 
51
-				if( $field_object ) {
51
+				if ( $field_object ) {
52 52
 
53
-					$input = GFFormsModel::get_input( $field_object, $field['id'] );
53
+					$input = GFFormsModel::get_input( $field_object, $field[ 'id' ] );
54 54
 
55 55
 					// This is a complex field, with labels on a per-input basis
56
-					if( $input ) {
56
+					if ( $input ) {
57 57
 
58 58
 						// Does the input have a custom label on a per-input basis? Otherwise, default label.
59
-						$label = ! empty( $input['customLabel'] ) ? $input['customLabel'] : $input['label'];
59
+						$label = ! empty( $input[ 'customLabel' ] ) ? $input[ 'customLabel' ] : $input[ 'label' ];
60 60
 
61 61
 					} else {
62 62
 
63 63
 						// This is a field with one label
64
-						$label = $field_object->get_field_label( true, $field['label'] );
64
+						$label = $field_object->get_field_label( true, $field[ 'label' ] );
65 65
 
66 66
 					}
67 67
 
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 			}
71 71
 
72 72
 			// Use Gravity Forms label by default, but if a custom label is defined in GV, use it.
73
-			if ( !empty( $field['custom_label'] ) ) {
73
+			if ( ! empty( $field[ 'custom_label' ] ) ) {
74 74
 
75
-				$label = self::replace_variables( $field['custom_label'], $form, $entry );
75
+				$label = self::replace_variables( $field[ 'custom_label' ], $form, $entry );
76 76
 
77 77
 			}
78 78
 
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
 
135 135
 		$width = NULL;
136 136
 
137
-		if( !empty( $field['width'] ) ) {
138
-			$width = absint( $field['width'] );
137
+		if ( ! empty( $field[ 'width' ] ) ) {
138
+			$width = absint( $field[ 'width' ] );
139 139
 
140 140
 			// If using percentages, limit to 100%
141
-			if( '%d%%' === $format && $width > 100 ) {
141
+			if ( '%d%%' === $format && $width > 100 ) {
142 142
 				$width = 100;
143 143
 			}
144 144
 
@@ -159,42 +159,42 @@  discard block
 block discarded – undo
159 159
 	public static function field_class( $field, $form = NULL, $entry = NULL ) {
160 160
 		$classes = array();
161 161
 
162
-		if( !empty( $field['custom_class'] ) ) {
162
+		if ( ! empty( $field[ 'custom_class' ] ) ) {
163 163
 
164
-            $custom_class = $field['custom_class'];
164
+            $custom_class = $field[ 'custom_class' ];
165 165
 
166
-            if( !empty( $entry ) ) {
166
+            if ( ! empty( $entry ) ) {
167 167
 
168 168
                 // We want the merge tag to be formatted as a class. The merge tag may be
169 169
                 // replaced by a multiple-word value that should be output as a single class.
170 170
                 // "Office Manager" will be formatted as `.OfficeManager`, not `.Office` and `.Manager`
171
-                add_filter('gform_merge_tag_filter', 'sanitize_html_class');
171
+                add_filter( 'gform_merge_tag_filter', 'sanitize_html_class' );
172 172
 
173
-                $custom_class = self::replace_variables( $custom_class, $form, $entry);
173
+                $custom_class = self::replace_variables( $custom_class, $form, $entry );
174 174
 
175 175
                 // And then we want life to return to normal
176
-                remove_filter('gform_merge_tag_filter', 'sanitize_html_class');
176
+                remove_filter( 'gform_merge_tag_filter', 'sanitize_html_class' );
177 177
             }
178 178
 
179 179
 			// And now we want the spaces to be handled nicely.
180
-			$classes[] = gravityview_sanitize_html_class( $custom_class );
180
+			$classes[ ] = gravityview_sanitize_html_class( $custom_class );
181 181
 
182 182
 		}
183 183
 
184
-		if(!empty($field['id'])) {
185
-			if( !empty( $form ) && !empty( $form['id'] ) ) {
186
-				$form_id = '-'.$form['id'];
184
+		if ( ! empty( $field[ 'id' ] ) ) {
185
+			if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) {
186
+				$form_id = '-' . $form[ 'id' ];
187 187
 			} else {
188 188
 				// @deprecated path. Form should always be given.
189 189
 				gravityview()->log->warning( 'GravityView_View::getInstance() legacy API called' );
190 190
 				$gravityview_view = GravityView_View::getInstance();
191
-				$form_id = $gravityview_view->getFormId() ? '-'. $gravityview_view->getFormId() : '';
191
+				$form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : '';
192 192
 			}
193 193
 
194
-			$classes[] = 'gv-field'.$form_id.'-'.$field['id'];
194
+			$classes[ ] = 'gv-field' . $form_id . '-' . $field[ 'id' ];
195 195
 		}
196 196
 
197
-		return esc_attr(implode(' ', $classes));
197
+		return esc_attr( implode( ' ', $classes ) );
198 198
 	}
199 199
 
200 200
 	/**
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
 	 * @return string Sanitized unique HTML `id` attribute for the field
211 211
 	 */
212 212
 	public static function field_html_attr_id( $field, $form = array(), $entry = array() ) {
213
-		$id = $field['id'];
213
+		$id = $field[ 'id' ];
214 214
 
215 215
 		if ( ! empty( $id ) ) {
216
-			if ( ! empty( $form ) && ! empty( $form['id'] ) ) {
217
-				$form_id = '-' . $form['id'];
216
+			if ( ! empty( $form ) && ! empty( $form[ 'id' ] ) ) {
217
+				$form_id = '-' . $form[ 'id' ];
218 218
 			} else {
219 219
 				// @deprecated path. Form should always be given.
220 220
 				gravityview()->log->warning( 'GravityView_View::getInstance() legacy API called' );
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 				$form_id = $gravityview_view->getFormId() ? '-' . $gravityview_view->getFormId() : '';
223 223
 			}
224 224
 
225
-			$id = 'gv-field' . $form_id . '-' . $field['id'];
225
+			$id = 'gv-field' . $form_id . '-' . $field[ 'id' ];
226 226
 		}
227 227
 
228 228
 		return esc_attr( $id );
@@ -262,14 +262,14 @@  discard block
 block discarded – undo
262 262
 	 */
263 263
 	public static function entry_link_html( $entry = array(), $anchor_text = '', $passed_tag_atts = array(), $field_settings = array(), $base_id = null ) {
264 264
 
265
-		if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry['id'] ) ) {
265
+		if ( empty( $entry ) || ! is_array( $entry ) || ! isset( $entry[ 'id' ] ) ) {
266 266
 			gravityview()->log->debug( 'Entry not defined; returning null', array( 'data' => $entry ) );
267 267
 			return NULL;
268 268
 		}
269 269
 
270 270
 		$href = self::entry_link( $entry, $base_id );
271 271
 
272
-		if( '' === $href ) {
272
+		if ( '' === $href ) {
273 273
 			return NULL;
274 274
 		}
275 275
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 		} else {
307 307
 			$gravityview_view = GravityView_View::getInstance();
308 308
 
309
-			if( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) {
309
+			if ( $gravityview_view && ( $gravityview_view->curr_start || $gravityview_view->curr_end || $gravityview_view->curr_search ) ) {
310 310
 				$is_search = true;
311 311
 			}
312 312
 		}
@@ -403,9 +403,9 @@  discard block
 block discarded – undo
403 403
 
404 404
 		// If we've saved the permalink in memory, use it
405 405
 		// @since 1.3
406
-		$link = wp_cache_get( 'gv_directory_link_'.$post_id );
406
+		$link = wp_cache_get( 'gv_directory_link_' . $post_id );
407 407
 
408
-		if ( (int) $post_id === (int) get_option( 'page_on_front' ) ) {
408
+		if ( (int)$post_id === (int)get_option( 'page_on_front' ) ) {
409 409
 			$link = home_url();
410 410
 		}
411 411
 
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 
415 415
 			// If not yet saved, cache the permalink.
416 416
 			// @since 1.3
417
-			wp_cache_set( 'gv_directory_link_'.$post_id, $link );
417
+			wp_cache_set( 'gv_directory_link_' . $post_id, $link );
418 418
 		}
419 419
 
420 420
 		// Deal with returning to proper pagination for embedded views
@@ -422,13 +422,13 @@  discard block
 block discarded – undo
422 422
 
423 423
 			$args = array();
424 424
 
425
-			if( $pagenum = \GV\Utils::_GET( 'pagenum' ) ) {
426
-				$args['pagenum'] = intval( $pagenum );
425
+			if ( $pagenum = \GV\Utils::_GET( 'pagenum' ) ) {
426
+				$args[ 'pagenum' ] = intval( $pagenum );
427 427
 			}
428 428
 
429
-			if( $sort = \GV\Utils::_GET( 'sort' ) ) {
430
-				$args['sort'] = $sort;
431
-				$args['dir'] = \GV\Utils::_GET( 'dir' );
429
+			if ( $sort = \GV\Utils::_GET( 'sort' ) ) {
430
+				$args[ 'sort' ] = $sort;
431
+				$args[ 'dir' ] = \GV\Utils::_GET( 'dir' );
432 432
 			}
433 433
 
434 434
 			$link = add_query_arg( $args, $link );
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 	private static function get_custom_entry_slug( $id, $entry = array() ) {
466 466
 
467 467
 		// Generate an unique hash to use as the default value
468
-		$slug = substr( wp_hash( $id, 'gravityview'.$id ), 0, 8 );
468
+		$slug = substr( wp_hash( $id, 'gravityview' . $id ), 0, 8 );
469 469
 
470 470
 		/**
471 471
 		 * @filter `gravityview_entry_slug` Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as `{entryid}-{first-name}` or even, if unique, `{first-name}-{last-name}`
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 		$slug = apply_filters( 'gravityview_entry_slug', $slug, $id, $entry );
477 477
 
478 478
 		// Make sure we have something - use the original ID as backup.
479
-		if( empty( $slug ) ) {
479
+		if ( empty( $slug ) ) {
480 480
 			$slug = $id;
481 481
 		}
482 482
 
@@ -570,15 +570,15 @@  discard block
 block discarded – undo
570 570
          * @param boolean $custom Should we process the custom entry slug?
571 571
          */
572 572
         $custom = apply_filters( 'gravityview_custom_entry_slug', false );
573
-        if( $custom ) {
573
+        if ( $custom ) {
574 574
             // create the gravityview_unique_id and save it
575 575
 
576 576
             // Get the entry hash
577
-            $hash = self::get_custom_entry_slug( $entry['id'], $entry );
577
+            $hash = self::get_custom_entry_slug( $entry[ 'id' ], $entry );
578 578
 
579
-	        gravityview()->log->debug( 'Setting hash for entry {entry_id}: {hash}', array( 'entry_id' => $entry['id'], 'hash' => $hash ) );
579
+	        gravityview()->log->debug( 'Setting hash for entry {entry_id}: {hash}', array( 'entry_id' => $entry[ 'id' ], 'hash' => $hash ) );
580 580
 
581
-            gform_update_meta( $entry['id'], 'gravityview_unique_id', $hash, \GV\Utils::get( $entry, 'form_id' ) );
581
+            gform_update_meta( $entry[ 'id' ], 'gravityview_unique_id', $hash, \GV\Utils::get( $entry, 'form_id' ) );
582 582
 
583 583
         }
584 584
     }
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 
598 598
 		if ( ! empty( $entry ) && ! is_array( $entry ) ) {
599 599
 			$entry = GVCommon::get_entry( $entry );
600
-		} else if( empty( $entry ) ) {
600
+		} else if ( empty( $entry ) ) {
601 601
 			// @deprecated path
602 602
 			$entry = GravityView_frontend::getInstance()->getEntry();
603 603
 		}
@@ -617,18 +617,18 @@  discard block
 block discarded – undo
617 617
 
618 618
 		$query_arg_name = \GV\Entry::get_endpoint_name();
619 619
 
620
-		if ( ! empty( $entry['_multi'] ) ) {
620
+		if ( ! empty( $entry[ '_multi' ] ) ) {
621 621
 			$entry_slugs = array();
622
-			foreach ( $entry['_multi'] as $_multi ) {
623
-				$entry_slugs[] = self::get_entry_slug( $_multi['id'], $_multi );
624
-				$forms[] = $_multi['form_id'];
622
+			foreach ( $entry[ '_multi' ] as $_multi ) {
623
+				$entry_slugs[ ] = self::get_entry_slug( $_multi[ 'id' ], $_multi );
624
+				$forms[ ] = $_multi[ 'form_id' ];
625 625
 			}
626 626
 			$entry_slug = implode( ',', $entry_slugs );
627 627
 		} else {
628
-			$entry_slug = self::get_entry_slug( $entry['id'], $entry );
628
+			$entry_slug = self::get_entry_slug( $entry[ 'id' ], $entry );
629 629
 		}
630 630
 
631
-		if ( get_option('permalink_structure') && !is_preview() ) {
631
+		if ( get_option( 'permalink_structure' ) && ! is_preview() ) {
632 632
 
633 633
 			$args = array();
634 634
 
@@ -638,9 +638,9 @@  discard block
 block discarded – undo
638 638
 			 */
639 639
 			$link_parts = explode( '?', $directory_link );
640 640
 
641
-			$query = !empty( $link_parts[1] ) ? '?'.$link_parts[1] : '';
641
+			$query = ! empty( $link_parts[ 1 ] ) ? '?' . $link_parts[ 1 ] : '';
642 642
 
643
-			$directory_link = trailingslashit( $link_parts[0] ) . $query_arg_name . '/'. $entry_slug .'/' . $query;
643
+			$directory_link = trailingslashit( $link_parts[ 0 ] ) . $query_arg_name . '/' . $entry_slug . '/' . $query;
644 644
 
645 645
 		} else {
646 646
 
@@ -652,21 +652,21 @@  discard block
 block discarded – undo
652 652
 		 */
653 653
 		if ( $add_directory_args ) {
654 654
 
655
-			if ( ! empty( $_GET['pagenum'] ) ) {
656
-				$args['pagenum'] = intval( $_GET['pagenum'] );
655
+			if ( ! empty( $_GET[ 'pagenum' ] ) ) {
656
+				$args[ 'pagenum' ] = intval( $_GET[ 'pagenum' ] );
657 657
 			}
658 658
 
659 659
 			/**
660 660
 			 * @since 1.7
661 661
 			 */
662 662
 			if ( $sort = \GV\Utils::_GET( 'sort' ) ) {
663
-				$args['sort'] = $sort;
664
-				$args['dir'] = \GV\Utils::_GET( 'dir' );
663
+				$args[ 'sort' ] = $sort;
664
+				$args[ 'dir' ] = \GV\Utils::_GET( 'dir' );
665 665
 			}
666 666
 
667 667
 		}
668 668
 
669
-		if( $post_id ) {
669
+		if ( $post_id ) {
670 670
 			$passed_post = get_post( $post_id );
671 671
 			$views       = \GV\View_Collection::from_post( $passed_post );
672 672
 			$has_multiple_views = $views->count() > 1;
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 		}
676 676
 
677 677
 		if ( $has_multiple_views ) {
678
-			$args['gvid'] = gravityview_get_view_id();
678
+			$args[ 'gvid' ] = gravityview_get_view_id();
679 679
 		}
680 680
 
681 681
 		return add_query_arg( $args, $directory_link );
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 }
697 697
 
698 698
 function gv_class( $field, $form = NULL, $entry = array() ) {
699
-	return GravityView_API::field_class( $field, $form, $entry  );
699
+	return GravityView_API::field_class( $field, $form, $entry );
700 700
 }
701 701
 
702 702
 /**
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 		$view_id = 0;
720 720
 		if ( $context->view ) {
721 721
 			$view_id = $context->view->ID;
722
-			if( $context->view->settings->get( 'hide_until_searched' ) ) {
722
+			if ( $context->view->settings->get( 'hide_until_searched' ) ) {
723 723
 				$hide_until_searched = ( empty( $context->entry ) && ! $context->request->is_search() );
724 724
 			}
725 725
 		}
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 		$default_css_class .= ' gv-container-no-results';
748 748
 	}
749 749
 
750
-	$css_class = trim( $passed_css_class . ' '. $default_css_class );
750
+	$css_class = trim( $passed_css_class . ' ' . $default_css_class );
751 751
 
752 752
 	/**
753 753
 	 * @filter `gravityview/render/container/class` Modify the CSS class to be added to the wrapper <div> of a View
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
 
775 775
 	$value = GravityView_API::field_value( $entry, $field );
776 776
 
777
-	if( $value === '' ) {
777
+	if ( $value === '' ) {
778 778
 		/**
779 779
 		 * @filter `gravityview_empty_value` What to display when a field is empty
780 780
 		 * @param string $value (empty string)
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
  */
888 888
 function gravityview_get_field_value( $entry, $field_id, $display_value ) {
889 889
 
890
-	if( floatval( $field_id ) === floor( floatval( $field_id ) ) ) {
890
+	if ( floatval( $field_id ) === floor( floatval( $field_id ) ) ) {
891 891
 
892 892
 		// For the complete field value as generated by Gravity Forms
893 893
 		return $display_value;
@@ -921,16 +921,16 @@  discard block
 block discarded – undo
921 921
 		$terms = explode( ', ', $value );
922 922
 	}
923 923
 
924
-	foreach ($terms as $term_name ) {
924
+	foreach ( $terms as $term_name ) {
925 925
 
926 926
 		// If we're processing a category,
927
-		if( $taxonomy === 'category' ) {
927
+		if ( $taxonomy === 'category' ) {
928 928
 
929 929
 			// Use rgexplode to prevent errors if : doesn't exist
930 930
 			list( $term_name, $term_id ) = rgexplode( ':', $term_name, 2 );
931 931
 
932 932
 			// The explode was succesful; we have the category ID
933
-			if( !empty( $term_id )) {
933
+			if ( ! empty( $term_id ) ) {
934 934
 				$term = get_term_by( 'id', $term_id, $taxonomy );
935 935
 			} else {
936 936
 			// We have to fall back to the name
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 		}
944 944
 
945 945
 		// There's still a tag/category here.
946
-		if( $term ) {
946
+		if ( $term ) {
947 947
 
948 948
 			$term_link = get_term_link( $term, $taxonomy );
949 949
 
@@ -952,11 +952,11 @@  discard block
 block discarded – undo
952 952
 			    continue;
953 953
 			}
954 954
 
955
-			$output[] = gravityview_get_link( $term_link, esc_html( $term->name ) );
955
+			$output[ ] = gravityview_get_link( $term_link, esc_html( $term->name ) );
956 956
 		}
957 957
 	}
958 958
 
959
-	return implode(', ', $output );
959
+	return implode( ', ', $output );
960 960
 }
961 961
 
962 962
 /**
@@ -970,8 +970,8 @@  discard block
 block discarded – undo
970 970
 
971 971
 	$output = get_the_term_list( $post_id, $taxonomy, NULL, ', ' );
972 972
 
973
-	if( empty( $link ) ) {
974
-		return strip_tags( $output);
973
+	if ( empty( $link ) ) {
974
+		return strip_tags( $output );
975 975
 	}
976 976
 
977 977
 	return $output;
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
 	$fe = GravityView_frontend::getInstance();
991 991
 
992 992
 	// Solve problem when loading content via admin-ajax.php
993
-	if( ! $fe->getGvOutputData() ) {
993
+	if ( ! $fe->getGvOutputData() ) {
994 994
 
995 995
 		gravityview()->log->debug( 'gv_output_data not defined; parsing content.' );
996 996
 
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
 	}
999 999
 
1000 1000
 	// Make 100% sure that we're dealing with a properly called situation
1001
-	if( !is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) {
1001
+	if ( ! is_a( $fe->getGvOutputData(), 'GravityView_View_Data' ) ) {
1002 1002
 
1003 1003
 		gravityview()->log->debug( 'gv_output_data not an object or get_view not callable.', array( 'data' => $fe->getGvOutputData() ) );
1004 1004
 
@@ -1220,12 +1220,12 @@  discard block
 block discarded – undo
1220 1220
 function gravityview_get_files_array( $value, $gv_class = '', $context = null ) {
1221 1221
 	/** @define "GRAVITYVIEW_DIR" "../" */
1222 1222
 
1223
-	if( !class_exists( 'GravityView_Field' ) ) {
1224
-		include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field.php' );
1223
+	if ( ! class_exists( 'GravityView_Field' ) ) {
1224
+		include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field.php' );
1225 1225
 	}
1226 1226
 
1227
-	if( !class_exists( 'GravityView_Field_FileUpload' ) ) {
1228
-		include_once( GRAVITYVIEW_DIR .'includes/fields/class-gravityview-field-fileupload.php' );
1227
+	if ( ! class_exists( 'GravityView_Field_FileUpload' ) ) {
1228
+		include_once( GRAVITYVIEW_DIR . 'includes/fields/class-gravityview-field-fileupload.php' );
1229 1229
 	}
1230 1230
 
1231 1231
 	if ( is_null( $context ) ) {
@@ -1328,21 +1328,21 @@  discard block
 block discarded – undo
1328 1328
 	} else {
1329 1329
 		// @deprecated path
1330 1330
 		// Required fields.
1331
-		if ( empty( $args['field'] ) || empty( $args['form'] ) ) {
1331
+		if ( empty( $args[ 'field' ] ) || empty( $args[ 'form' ] ) ) {
1332 1332
 			gravityview()->log->error( 'Field or form are empty.', array( 'data' => $args ) );
1333 1333
 			return '';
1334 1334
 		}
1335 1335
 	}
1336 1336
 
1337 1337
 	if ( $context instanceof \GV\Template_Context ) {
1338
-		$entry = $args['entry'] ? : ( $context->entry ? $context->entry->as_entry() : array() );
1339
-		$field = $args['field'] ? : ( $context->field ? $context->field->as_configuration() : array() );
1340
-		$form = $args['form'] ? : ( $context->view->form ? $context->view->form->form : array() );
1338
+		$entry = $args[ 'entry' ] ?: ( $context->entry ? $context->entry->as_entry() : array() );
1339
+		$field = $args[ 'field' ] ?: ( $context->field ? $context->field->as_configuration() : array() );
1340
+		$form = $args[ 'form' ] ?: ( $context->view->form ? $context->view->form->form : array() );
1341 1341
 	} else {
1342 1342
 		// @deprecated path
1343
-		$entry = empty( $args['entry'] ) ? array() : $args['entry'];
1344
-		$field = $args['field'];
1345
-		$form = $args['form'];
1343
+		$entry = empty( $args[ 'entry' ] ) ? array() : $args[ 'entry' ];
1344
+		$field = $args[ 'field' ];
1345
+		$form = $args[ 'form' ];
1346 1346
 	}
1347 1347
 
1348 1348
 	/**
@@ -1362,43 +1362,43 @@  discard block
 block discarded – undo
1362 1362
 	);
1363 1363
 
1364 1364
 	if ( $context instanceof \GV\Template_Context ) {
1365
-		$placeholders['value'] = \GV\Utils::get( $args, 'value', '' );
1365
+		$placeholders[ 'value' ] = \GV\Utils::get( $args, 'value', '' );
1366 1366
 	} else {
1367 1367
 		// @deprecated path
1368
-		$placeholders['value'] = gv_value( $entry, $field );
1368
+		$placeholders[ 'value' ] = gv_value( $entry, $field );
1369 1369
 	}
1370 1370
 
1371 1371
 	// If the value is empty and we're hiding empty, return empty.
1372
-	if ( $placeholders['value'] === '' && ! empty( $args['hide_empty'] ) ) {
1372
+	if ( $placeholders[ 'value' ] === '' && ! empty( $args[ 'hide_empty' ] ) ) {
1373 1373
 		return '';
1374 1374
 	}
1375 1375
 
1376
-	if ( $placeholders['value'] !== '' && ! empty( $args['wpautop'] ) ) {
1377
-		$placeholders['value'] = wpautop( $placeholders['value'] );
1376
+	if ( $placeholders[ 'value' ] !== '' && ! empty( $args[ 'wpautop' ] ) ) {
1377
+		$placeholders[ 'value' ] = wpautop( $placeholders[ 'value' ] );
1378 1378
 	}
1379 1379
 
1380 1380
 	// Get width setting, if exists
1381
-	$placeholders['width'] = GravityView_API::field_width( $field );
1381
+	$placeholders[ 'width' ] = GravityView_API::field_width( $field );
1382 1382
 
1383 1383
 	// If replacing with CSS inline formatting, let's do it.
1384
-	$placeholders['width:style'] = GravityView_API::field_width( $field, 'width:' . $placeholders['width'] . '%;' );
1384
+	$placeholders[ 'width:style' ] = GravityView_API::field_width( $field, 'width:' . $placeholders[ 'width' ] . '%;' );
1385 1385
 
1386 1386
 	// Grab the Class using `gv_class`
1387
-	$placeholders['class'] = gv_class( $field, $form, $entry );
1388
-	$placeholders['field_id'] = GravityView_API::field_html_attr_id( $field, $form, $entry );
1387
+	$placeholders[ 'class' ] = gv_class( $field, $form, $entry );
1388
+	$placeholders[ 'field_id' ] = GravityView_API::field_html_attr_id( $field, $form, $entry );
1389 1389
 
1390 1390
 	if ( $context instanceof \GV\Template_Context ) {
1391
-		$placeholders['label_value'] = \GV\Utils::get( $args, 'label' );
1391
+		$placeholders[ 'label_value' ] = \GV\Utils::get( $args, 'label' );
1392 1392
 	} else {
1393 1393
 		// Default Label value
1394
-		$placeholders['label_value'] = gv_label( $field, $entry );
1394
+		$placeholders[ 'label_value' ] = gv_label( $field, $entry );
1395 1395
 	}
1396 1396
 
1397
-	$placeholders['label_value:data-label'] = trim( esc_attr( strip_tags( str_replace( '>&nbsp;', '>', $placeholders['label_value'] ) ) ) );
1398
-	$placeholders['label_value:esc_attr'] = esc_attr( $placeholders['label_value'] );
1397
+	$placeholders[ 'label_value:data-label' ] = trim( esc_attr( strip_tags( str_replace( '>&nbsp;', '>', $placeholders[ 'label_value' ] ) ) ) );
1398
+	$placeholders[ 'label_value:esc_attr' ] = esc_attr( $placeholders[ 'label_value' ] );
1399 1399
 
1400
-	if ( empty( $placeholders['label'] ) && ! empty( $placeholders['label_value'] ) ){
1401
-		$placeholders['label'] = '<span class="gv-field-label">{{ label_value }}</span>';
1400
+	if ( empty( $placeholders[ 'label' ] ) && ! empty( $placeholders[ 'label_value' ] ) ) {
1401
+		$placeholders[ 'label' ] = '<span class="gv-field-label">{{ label_value }}</span>';
1402 1402
 	}
1403 1403
 
1404 1404
 	/**
@@ -1409,7 +1409,7 @@  discard block
 block discarded – undo
1409 1409
 	 * @since 2.0
1410 1410
 	 * @param \GV\Template_Context $context The context.
1411 1411
 	 */
1412
-	$html = apply_filters( 'gravityview/field_output/pre_html', $args['markup'], $args, $context );
1412
+	$html = apply_filters( 'gravityview/field_output/pre_html', $args[ 'markup' ], $args, $context );
1413 1413
 
1414 1414
 	/**
1415 1415
 	 * @filter `gravityview/field_output/open_tag` Modify the opening tags for the template content placeholders
@@ -1436,7 +1436,7 @@  discard block
 block discarded – undo
1436 1436
 	foreach ( $placeholders as $tag => $value ) {
1437 1437
 
1438 1438
 		// If the tag doesn't exist just skip it
1439
-		if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ){
1439
+		if ( false === strpos( $html, $open_tag . $tag . $close_tag ) && false === strpos( $html, $open_tag . ' ' . $tag . ' ' . $close_tag ) ) {
1440 1440
 			continue;
1441 1441
 		}
1442 1442
 
Please login to merge, or discard this patch.
future/includes/class-gv-template-entry-table.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 */
27 27
 	public function the_field( \GV\Field $field ) {
28 28
 		$renderer = new Field_Renderer();
29
-		$source = is_numeric( $field->ID ) ? ( GF_Form::by_id( $field->form_id ) ? : $this->view->form ) : new Internal_Source();
29
+		$source = is_numeric( $field->ID ) ? ( GF_Form::by_id( $field->form_id ) ?: $this->view->form ) : new Internal_Source();
30 30
 
31 31
 		return $renderer->render( $field, $this->view, $source, $this->entry->from_field( $field ), $this->request );
32 32
 	}
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		foreach ( $fields->all() as $field ) {
64 64
 			$context = Template_Context::from_template( $this, compact( 'field' ) );
65 65
 
66
-			$form = \GV\GF_Form::by_id( $field->form_id ) ? : $this->view->form;
66
+			$form = \GV\GF_Form::by_id( $field->form_id ) ?: $this->view->form;
67 67
 			$entry = $this->entry->from_field( $field );
68 68
 
69 69
 			if ( ! $entry ) {
Please login to merge, or discard this patch.
future/includes/class-gv-request.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 */
46 46
 	public static function is_add_oembed_preview() {
47 47
 		/** The preview request is a parse-embed AJAX call without a type set. */
48
-		return ( self::is_ajax() && ! empty( $_POST['action'] ) && $_POST['action'] == 'parse-embed' && ! isset( $_POST['type'] ) );
48
+		return ( self::is_ajax() && ! empty( $_POST[ 'action' ] ) && $_POST[ 'action' ] == 'parse-embed' && ! isset( $_POST[ 'type' ] ) );
49 49
 	}
50 50
 
51 51
 	/**
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @return boolean
64 64
 	 */
65 65
 	public static function is_rest() {
66
-		return ! empty( $GLOBALS['wp']->query_vars['rest_route'] );
66
+		return ! empty( $GLOBALS[ 'wp' ]->query_vars[ 'rest_route' ] );
67 67
 	}
68 68
 
69 69
 	/**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 						return false;
126 126
 					}
127 127
 
128
-					if ( ! in_array( $e['form_id'], $valid_forms ) ) {
128
+					if ( ! in_array( $e[ 'form_id' ], $valid_forms ) ) {
129 129
 						return false;
130 130
 					}
131 131
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 				}
142 142
 
143 143
 				$entry = Multi_Entry::from_entries( array_filter( $multientry ) );
144
-			}  else {
144
+			} else {
145 145
 				/**
146 146
 				 * A regular one.
147 147
 				 */
@@ -196,15 +196,15 @@  discard block
 block discarded – undo
196 196
 			$get = $_GET;
197 197
 		}
198 198
 
199
-		unset( $get['mode'] );
199
+		unset( $get[ 'mode' ] );
200 200
 
201 201
 		$get = array_filter( $get, 'gravityview_is_not_empty_string' );
202 202
 
203
-		if( $has_field_key = $this->_has_field_key( $get ) ) {
203
+		if ( $has_field_key = $this->_has_field_key( $get ) ) {
204 204
 			return true;
205 205
 		}
206 206
 
207
-		return isset( $get['gv_search'] ) || isset( $get['gv_start'] ) || isset( $get['gv_end'] ) || isset( $get['gv_by'] ) || isset( $get['gv_id'] );
207
+		return isset( $get[ 'gv_search' ] ) || isset( $get[ 'gv_start' ] ) || isset( $get[ 'gv_end' ] ) || isset( $get[ 'gv_by' ] ) || isset( $get[ 'gv_id' ] );
208 208
 	}
209 209
 
210 210
 	/**
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
 
228 228
 		$meta = array();
229 229
 		foreach ( $fields as $field ) {
230
-			if( empty( $field->_gf_field_class_name ) ) {
231
-				$meta[] = preg_quote( $field->name );
230
+			if ( empty( $field->_gf_field_class_name ) ) {
231
+				$meta[ ] = preg_quote( $field->name );
232 232
 			}
233 233
 		}
234 234
 
235 235
 		foreach ( $get as $key => $value ) {
236
-			if ( preg_match('/^filter_(([0-9_]+)|'. implode( '|', $meta ) .')$/sm', $key ) ) {
236
+			if ( preg_match( '/^filter_(([0-9_]+)|' . implode( '|', $meta ) . ')$/sm', $key ) ) {
237 237
 				$has_field_key = true;
238 238
 				break;
239 239
 			}
Please login to merge, or discard this patch.
future/includes/class-gv-template-entry-list.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @return string
27 27
 	 */
28 28
 	public function the_field( \GV\Field $field, $extras = null ) {
29
-		$form = \GV\GF_Form::by_id( $field->form_id ) ? : $this->view->form;
29
+		$form = \GV\GF_Form::by_id( $field->form_id ) ?: $this->view->form;
30 30
 		$entry = $this->entry->from_field( $field );
31 31
 
32 32
 		if ( ! $entry ) {
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 		}
35 35
 
36 36
 		$renderer = new Field_Renderer();
37
-		$source = is_numeric( $field->ID ) ? ( GF_Form::by_id( $field->form_id ) ? : $this->view->form ) : new Internal_Source();
37
+		$source = is_numeric( $field->ID ) ? ( GF_Form::by_id( $field->form_id ) ?: $this->view->form ) : new Internal_Source();
38 38
 		
39 39
 		$value = $renderer->render( $field, $this->view, $source, $entry, $this->request );
40 40
 		
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
 		$hide_empty = apply_filters( 'gravityview/render/hide-empty-zone', Utils::get( $extras, 'hide_empty', $this->view->settings->get( 'hide_empty', false ) ), $context );
63 63
 
64 64
 		if ( is_numeric( $field->ID ) ) {
65
-			$extras['field'] = $field->as_configuration();
65
+			$extras[ 'field' ] = $field->as_configuration();
66 66
 		}
67 67
 
68
-		$extras['entry'] = $this->entry->as_entry();
69
-		$extras['hide_empty'] = $hide_empty;
70
-		$extras['label'] = $label;
71
-		$extras['value'] = $value;
68
+		$extras[ 'entry' ] = $this->entry->as_entry();
69
+		$extras[ 'hide_empty' ] = $hide_empty;
70
+		$extras[ 'label' ] = $label;
71
+		$extras[ 'value' ] = $value;
72 72
 
73 73
 		return \gravityview_field_output( $extras, $context );
74 74
 	}
Please login to merge, or discard this patch.
includes/class-gravityview-entry-approval.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 	private function add_hooks() {
40 40
 
41 41
 		// in case entry is edited (on admin or frontend)
42
-		add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2);
42
+		add_action( 'gform_after_update_entry', array( $this, 'after_update_entry_update_approved_meta' ), 10, 2 );
43 43
 
44 44
 		// when using the User opt-in field, check on entry submission
45 45
 		add_action( 'gform_after_submission', array( $this, 'after_submission' ), 10, 2 );
46 46
 
47 47
 		// process ajax approve entry requests
48
-		add_action('wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved'));
48
+		add_action( 'wp_ajax_gv_update_approved', array( $this, 'ajax_update_approved' ) );
49 49
 
50 50
 		// autounapprove
51 51
 		add_action( 'gravityview/edit_entry/after_update', array( __CLASS__, 'autounapprove' ), 10, 4 );
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
 			return;
95 95
 		}
96 96
 
97
-		$form = GFAPI::get_form( $entry['form_id'] );
97
+		$form = GFAPI::get_form( $entry[ 'form_id' ] );
98 98
 
99 99
 		if ( ! $form ) {
100
-			gravityview()->log->error( 'Form not found at ID #{form_id} for entry #{entry_id}', array( 'form_id' => $entry['form_id'], 'entry_id' => $entry_id ) );
100
+			gravityview()->log->error( 'Form not found at ID #{form_id} for entry #{entry_id}', array( 'form_id' => $entry[ 'form_id' ], 'entry_id' => $entry_id ) );
101 101
 			return;
102 102
 		}
103 103
 
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	public static function add_approval_notification_events( $notification_events = array(), $form = array() ) {
116 116
 
117
-		$notification_events['gravityview/approve_entries/approved'] = 'GravityView - ' . esc_html_x( 'Entry is approved', 'The title for an event in a notifications drop down list.', 'gravityview' );
118
-		$notification_events['gravityview/approve_entries/disapproved'] = 'GravityView - ' . esc_html_x( 'Entry is disapproved', 'The title for an event in a notifications drop down list.', 'gravityview' );
119
-		$notification_events['gravityview/approve_entries/unapproved'] = 'GravityView - ' . esc_html_x( 'Entry approval is reset', 'The title for an event in a notifications drop down list.', 'gravityview' );
120
-		$notification_events['gravityview/approve_entries/updated'] = 'GravityView - ' . esc_html_x( 'Entry approval is changed', 'The title for an event in a notifications drop down list.', 'gravityview' );
117
+		$notification_events[ 'gravityview/approve_entries/approved' ] = 'GravityView - ' . esc_html_x( 'Entry is approved', 'The title for an event in a notifications drop down list.', 'gravityview' );
118
+		$notification_events[ 'gravityview/approve_entries/disapproved' ] = 'GravityView - ' . esc_html_x( 'Entry is disapproved', 'The title for an event in a notifications drop down list.', 'gravityview' );
119
+		$notification_events[ 'gravityview/approve_entries/unapproved' ] = 'GravityView - ' . esc_html_x( 'Entry approval is reset', 'The title for an event in a notifications drop down list.', 'gravityview' );
120
+		$notification_events[ 'gravityview/approve_entries/updated' ] = 'GravityView - ' . esc_html_x( 'Entry approval is changed', 'The title for an event in a notifications drop down list.', 'gravityview' );
121 121
 
122 122
 		return $notification_events;
123 123
 	}
@@ -135,13 +135,13 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	public static function get_entry_status( $entry, $value_or_label = 'label' ) {
137 137
 
138
-		$entry_id = is_array( $entry ) ? $entry['id'] : GVCommon::get_entry_id( $entry, true );
138
+		$entry_id = is_array( $entry ) ? $entry[ 'id' ] : GVCommon::get_entry_id( $entry, true );
139 139
 
140 140
 		$status = gform_get_meta( $entry_id, self::meta_key );
141 141
 
142 142
 		$status = GravityView_Entry_Approval_Status::maybe_convert_status( $status );
143 143
 
144
-		if( 'value' === $value_or_label ) {
144
+		if ( 'value' === $value_or_label ) {
145 145
 			return $status;
146 146
 		}
147 147
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		$nonce = \GV\Utils::_POST( 'nonce' );
180 180
 
181 181
 		// Valid status
182
-		if( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) {
182
+		if ( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) {
183 183
 
184 184
 			gravityview()->log->error( 'Invalid approval status', array( 'data' => $_POST ) );
185 185
 
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 
211 211
 			gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' );
212 212
 
213
-			$result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview') );
213
+			$result = new WP_Error( 'Missing Cap: gravityview_moderate_entries', __( 'You do not have permission to edit this entry.', 'gravityview' ) );
214 214
 
215 215
 		}
216 216
 
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
 		}
262 262
 
263 263
 		// Set default
264
-		self::update_approved_meta( $entry['id'], $default_status, $entry['form_id'] );
264
+		self::update_approved_meta( $entry[ 'id' ], $default_status, $entry[ 'form_id' ] );
265 265
 
266 266
 		// Then check for if there is an approval column, and use that value instead
267
-		$this->after_update_entry_update_approved_meta( $form , $entry['id'] );
267
+		$this->after_update_entry_update_approved_meta( $form, $entry[ 'id' ] );
268 268
 	}
269 269
 
270 270
 	/**
@@ -278,12 +278,12 @@  discard block
 block discarded – undo
278 278
 	 */
279 279
 	public function after_update_entry_update_approved_meta( $form, $entry_id = NULL ) {
280 280
 
281
-		$approved_column = self::get_approved_column( $form['id'] );
281
+		$approved_column = self::get_approved_column( $form[ 'id' ] );
282 282
 
283 283
 		/**
284 284
 		 * If the form doesn't contain the approve field, don't assume anything.
285 285
 		 */
286
-		if( empty( $approved_column ) ) {
286
+		if ( empty( $approved_column ) ) {
287 287
 			return;
288 288
 		}
289 289
 
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 			$value = GravityView_Entry_Approval_Status::APPROVED;
298 298
 		}
299 299
 
300
-		self::update_approved_meta( $entry_id, $value, $form['id'] );
300
+		self::update_approved_meta( $entry_id, $value, $form[ 'id' ] );
301 301
 	}
302 302
 
303 303
 	/**
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
 	 */
316 316
 	public static function update_bulk( $entries = array(), $approved, $form_id ) {
317 317
 
318
-		if( empty($entries) || ( $entries !== true && !is_array($entries) ) ) {
318
+		if ( empty( $entries ) || ( $entries !== true && ! is_array( $entries ) ) ) {
319 319
 			gravityview()->log->error( 'Entries were empty or malformed.', array( 'data' => $entries ) );
320 320
 			return NULL;
321 321
 		}
322 322
 
323
-		if( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) {
323
+		if ( ! GVCommon::has_cap( 'gravityview_moderate_entries' ) ) {
324 324
 			gravityview()->log->error( 'User does not have the `gravityview_moderate_entries` capability.' );
325 325
 			return NULL;
326 326
 		}
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
 		$approved_column_id = self::get_approved_column( $form_id );
336 336
 
337 337
 		$success = true;
338
-		foreach( $entries as $entry_id ) {
338
+		foreach ( $entries as $entry_id ) {
339 339
 			$update_success = self::update_approved( (int)$entry_id, $approved, $form_id, $approved_column_id );
340 340
 
341
-			if( ! $update_success ) {
341
+			if ( ! $update_success ) {
342 342
 				$success = false;
343 343
 			}
344 344
 		}
@@ -362,12 +362,12 @@  discard block
 block discarded – undo
362 362
 	 */
363 363
 	public static function update_approved( $entry_id = 0, $approved = 2, $form_id = 0, $approvedcolumn = 0 ) {
364 364
 
365
-		if( !class_exists( 'GFAPI' ) ) {
365
+		if ( ! class_exists( 'GFAPI' ) ) {
366 366
 			gravityview()->log->error( 'GFAPI does not exist' );
367 367
 			return false;
368 368
 		}
369 369
 
370
-		if( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) {
370
+		if ( ! GravityView_Entry_Approval_Status::is_valid( $approved ) ) {
371 371
 			gravityview()->log->error( 'Not a valid approval value.' );
372 372
 			return false;
373 373
 		}
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 		// If the form has an Approve/Reject field, update that value
385 385
 		$result = self::update_approved_column( $entry_id, $approved, $form_id, $approvedcolumn );
386 386
 
387
-		if( is_wp_error( $result ) ) {
387
+		if ( is_wp_error( $result ) ) {
388 388
 			gravityview()->log->error( 'Entry approval not updated: {error}', array( 'error' => $result->get_error_message() ) );
389 389
 			return false;
390 390
 		}
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 
397 397
 		// add note to entry if approval field updating worked or there was no approved field
398 398
 		// There's no validation for the meta
399
-		if( true === $result ) {
399
+		if ( true === $result ) {
400 400
 
401 401
 			// Add an entry note
402 402
 			self::add_approval_status_updated_note( $entry_id, $approved );
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 
450 450
 		$note_id = false;
451 451
 
452
-		if( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) {
452
+		if ( $add_note && class_exists( 'GravityView_Entry_Notes' ) ) {
453 453
 
454 454
 			$current_user = wp_get_current_user();
455 455
 
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	 */
472 472
 	private static function update_approved_column( $entry_id = 0, $status = '0', $form_id = 0, $approvedcolumn = 0 ) {
473 473
 
474
-		if( empty( $approvedcolumn ) ) {
474
+		if ( empty( $approvedcolumn ) ) {
475 475
 			$approvedcolumn = self::get_approved_column( $form_id );
476 476
 		}
477 477
 
@@ -494,12 +494,12 @@  discard block
 block discarded – undo
494 494
 		$status = GravityView_Entry_Approval_Status::maybe_convert_status( $status );
495 495
 
496 496
 		$new_value = '';
497
-		if( GravityView_Entry_Approval_Status::APPROVED === $status ) {
497
+		if ( GravityView_Entry_Approval_Status::APPROVED === $status ) {
498 498
 			$new_value = self::get_approved_column_input_label( $form_id, $approvedcolumn );
499 499
 		}
500 500
 
501 501
 		//update entry
502
-		$entry["{$approvedcolumn}"] = $new_value;
502
+		$entry[ "{$approvedcolumn}" ] = $new_value;
503 503
 
504 504
 		/**
505 505
 		 * Note: GFAPI::update_entry() doesn't trigger `gform_after_update_entry`, so we trigger updating the meta ourselves
@@ -530,12 +530,12 @@  discard block
 block discarded – undo
530 530
 		// If the user has enabled a different value than the label (for some reason), use it.
531 531
 		// This is highly unlikely
532 532
 		if ( is_array( $field->choices ) && ! empty( $field->choices ) ) {
533
-			return isset( $field->choices[0]['value'] ) ? $field->choices[0]['value'] : $field->choices[0]['text'];
533
+			return isset( $field->choices[ 0 ][ 'value' ] ) ? $field->choices[ 0 ][ 'value' ] : $field->choices[ 0 ][ 'text' ];
534 534
 		}
535 535
 
536 536
 		// Otherwise, fall back on the inputs array
537 537
 		if ( is_array( $field->inputs ) && ! empty( $field->inputs ) ) {
538
-			return $field->inputs[0]['label'];
538
+			return $field->inputs[ 0 ][ 'label' ];
539 539
 		}
540 540
 
541 541
 		return null;
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 		 * @since 1.18 Added "unapproved"
588 588
 		 * @param  int $entry_id ID of the Gravity Forms entry
589 589
 		 */
590
-		do_action( 'gravityview/approve_entries/' . $action , $entry_id );
590
+		do_action( 'gravityview/approve_entries/' . $action, $entry_id );
591 591
 	}
592 592
 
593 593
 	/**
@@ -600,11 +600,11 @@  discard block
 block discarded – undo
600 600
 	 */
601 601
 	static public function get_approved_column( $form ) {
602 602
 
603
-		if( empty( $form ) ) {
603
+		if ( empty( $form ) ) {
604 604
 			return null;
605 605
 		}
606 606
 
607
-		if( !is_array( $form ) ) {
607
+		if ( ! is_array( $form ) ) {
608 608
 			$form = GVCommon::get_form( $form );
609 609
 		}
610 610
 
@@ -614,22 +614,22 @@  discard block
 block discarded – undo
614 614
 		 * @var string $key
615 615
 		 * @var GF_Field $field
616 616
 		 */
617
-		foreach( $form['fields'] as $key => $field ) {
617
+		foreach ( $form[ 'fields' ] as $key => $field ) {
618 618
 
619 619
 			$inputs = $field->get_entry_inputs();
620 620
 
621
-			if( !empty( $field->gravityview_approved ) ) {
622
-				if ( ! empty( $inputs ) && !empty( $inputs[0]['id'] ) ) {
623
-					$approved_column_id = $inputs[0]['id'];
621
+			if ( ! empty( $field->gravityview_approved ) ) {
622
+				if ( ! empty( $inputs ) && ! empty( $inputs[ 0 ][ 'id' ] ) ) {
623
+					$approved_column_id = $inputs[ 0 ][ 'id' ];
624 624
 					break;
625 625
 				}
626 626
 			}
627 627
 
628 628
 			// Note: This is just for backward compatibility from GF Directory plugin and old GV versions - when using i18n it may not work..
629
-			if( 'checkbox' === $field->type && ! empty( $inputs ) ) {
629
+			if ( 'checkbox' === $field->type && ! empty( $inputs ) ) {
630 630
 				foreach ( $inputs as $input ) {
631
-					if ( 'approved' === strtolower( $input['label'] ) ) {
632
-						$approved_column_id = $input['id'];
631
+					if ( 'approved' === strtolower( $input[ 'label' ] ) ) {
632
+						$approved_column_id = $input[ 'id' ];
633 633
 						break;
634 634
 					}
635 635
 				}
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 
656 656
 		$view_keys = array_keys( $gv_data->get_views() );
657 657
 
658
-		$view = \GV\View::by_id( $view_keys[0] );
658
+		$view = \GV\View::by_id( $view_keys[ 0 ] );
659 659
 
660 660
 		if ( ! $view->settings->get( 'unapprove_edit' ) ) {
661 661
 			return;
@@ -680,11 +680,11 @@  discard block
 block discarded – undo
680 680
 			return;
681 681
 		}
682 682
 
683
-		if( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) {
683
+		if ( ! GravityView_Entry_Approval_Status::is_valid( $approval_status ) ) {
684 684
 			$approval_status = GravityView_Entry_Approval_Status::UNAPPROVED;
685 685
 		}
686 686
 
687
-		self::update_approved_meta( $entry_id, $approval_status, $form['id'] );
687
+		self::update_approved_meta( $entry_id, $approval_status, $form[ 'id' ] );
688 688
 	}
689 689
 
690 690
 }
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry-render.php 3 patches
Indentation   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
 
95 95
 	/**
96 96
 	 * ID of the current post. May also be ID of the current View.
97
-     *
98
-     * @since 2.0.13
99
-     * 
100
-     * @var int
97
+	 *
98
+	 * @since 2.0.13
99
+	 * 
100
+	 * @var int
101 101
 	 */
102 102
 	public $post_id;
103 103
 
@@ -169,12 +169,12 @@  discard block
 block discarded – undo
169 169
 	public function prevent_maybe_process_form() {
170 170
 
171 171
 		if( ! empty( $_POST ) ) {
172
-	        gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) );
172
+			gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) );
173 173
 		}
174 174
 
175 175
 		if( $this->is_edit_entry_submission() ) {
176 176
 			remove_action( 'wp',  array( 'RGForms', 'maybe_process_form'), 9 );
177
-	        remove_action( 'wp',  array( 'GFForms', 'maybe_process_form'), 9 );
177
+			remove_action( 'wp',  array( 'GFForms', 'maybe_process_form'), 9 );
178 178
 		}
179 179
 	}
180 180
 
@@ -202,14 +202,14 @@  discard block
 block discarded – undo
202 202
 	 * When Edit entry view is requested setup the vars
203 203
 	 */
204 204
 	private function setup_vars() {
205
-        global $post;
205
+		global $post;
206 206
 
207 207
 		$gravityview_view = GravityView_View::getInstance();
208 208
 
209 209
 
210 210
 		$entries = $gravityview_view->getEntries();
211
-	    self::$original_entry = $entries[0];
212
-	    $this->entry = $entries[0];
211
+		self::$original_entry = $entries[0];
212
+		$this->entry = $entries[0];
213 213
 
214 214
 		self::$original_form = $gravityview_view->getForm();
215 215
 		$this->form = $gravityview_view->getForm();
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
 
334 334
 			GFFormsModel::save_lead( $form, $this->entry );
335 335
 
336
-	        // Delete the values for hidden inputs
337
-	        $this->unset_hidden_field_values();
336
+			// Delete the values for hidden inputs
337
+			$this->unset_hidden_field_values();
338 338
 			
339 339
 			$this->entry['date_created'] = $date_created;
340 340
 
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 			// Perform actions normally performed after updating a lead
345 345
 			$this->after_update();
346 346
 
347
-	        /**
347
+			/**
348 348
 			 * Must be AFTER after_update()!
349 349
 			 * @see https://github.com/gravityview/GravityView/issues/764
350 350
 			 */
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 
353 353
 			/**
354 354
 			 * @action `gravityview/edit_entry/after_update` Perform an action after the entry has been updated using Edit Entry
355
-             * @since 2.1 Added $gv_data parameter
355
+			 * @since 2.1 Added $gv_data parameter
356 356
 			 * @param array $form Gravity Forms form array
357 357
 			 * @param string $entry_id Numeric ID of the entry that was updated
358 358
 			 * @param GravityView_Edit_Entry_Render $this This object
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	 * @return void
377 377
 	 */
378 378
 	private function unset_hidden_field_values() {
379
-	    global $wpdb;
379
+		global $wpdb;
380 380
 
381 381
 		/**
382 382
 		 * @filter `gravityview/edit_entry/unset_hidden_field_values` Whether to delete values of fields hidden by conditional logic
@@ -398,29 +398,29 @@  discard block
 block discarded – undo
398 398
 			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );
399 399
 		}
400 400
 
401
-	    foreach ( $this->entry as $input_id => $field_value ) {
401
+		foreach ( $this->entry as $input_id => $field_value ) {
402 402
 
403
-		    $field = RGFormsModel::get_field( $this->form, $input_id );
403
+			$field = RGFormsModel::get_field( $this->form, $input_id );
404 404
 
405
-		    // Reset fields that are hidden
406
-		    // Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic
407
-		    if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) {
405
+			// Reset fields that are hidden
406
+			// Don't pass $entry as fourth parameter; force using $_POST values to calculate conditional logic
407
+			if ( GFFormsModel::is_field_hidden( $this->form, $field, array(), NULL ) ) {
408 408
 
409 409
 				$empty_value = $field->get_value_save_entry(
410 410
 					is_array( $field->get_entry_inputs() ) ? array() : '',
411 411
 					$this->form, '', $this->entry['id'], $this->entry
412 412
 				);
413 413
 
414
-			    $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
414
+				$lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
415 415
 
416
-			    GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );
416
+				GFFormsModel::update_lead_field_value( $this->form, $this->entry, $field, $lead_detail_id, $input_id, $empty_value );
417 417
 
418
-			    // Prevent the $_POST values of hidden fields from being used as default values when rendering the form
418
+				// Prevent the $_POST values of hidden fields from being used as default values when rendering the form
419 419
 				// after submission
420
-			    $post_input_id = 'input_' . str_replace( '.', '_', $input_id );
421
-			    $_POST[ $post_input_id ] = '';
422
-		    }
423
-	    }
420
+				$post_input_id = 'input_' . str_replace( '.', '_', $input_id );
421
+				$_POST[ $post_input_id ] = '';
422
+			}
423
+		}
424 424
 	}
425 425
 
426 426
 	/**
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 
515 515
 		$form = $this->form;
516 516
 
517
-	    /** @var GF_Field $field */
517
+		/** @var GF_Field $field */
518 518
 		foreach( $form['fields'] as $k => &$field ) {
519 519
 
520 520
 			/**
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 
531 531
 			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
532 532
 				foreach( $field->inputs as $key => $input ) {
533
-				    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
533
+					$field->inputs[ $key ][ 'id' ] = (string)$input['id'];
534 534
 				}
535 535
 			}
536 536
 		}
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 			foreach ( $this->fields_with_calculation as $field ) {
566 566
 				$inputs = $field->get_entry_inputs();
567 567
 				if ( is_array( $inputs ) ) {
568
-				    foreach ( $inputs as $input ) {
568
+					foreach ( $inputs as $input ) {
569 569
 						list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 );
570 570
 
571 571
 						if ( 'product' === $field->type ) {
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 						}
585 585
 
586 586
 						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] );
587
-				    }
587
+					}
588 588
 				} else {
589 589
 					// Set to what it previously was if it's not editable
590 590
 					if ( ! in_array( $field->id, $allowed_fields ) ) {
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
631 631
 
632 632
 			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
633
-	        $ary = stripslashes_deep( $ary );
633
+			$ary = stripslashes_deep( $ary );
634 634
 			$img_url = \GV\Utils::get( $ary, 0 );
635 635
 
636 636
 			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 	private function maybe_update_post_fields( $form ) {
704 704
 
705 705
 		if( empty( $this->entry['post_id'] ) ) {
706
-	        gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
706
+			gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
707 707
 			return;
708 708
 		}
709 709
 
@@ -738,49 +738,49 @@  discard block
 block discarded – undo
738 738
 
739 739
 				switch( $field->type ) {
740 740
 
741
-				    case 'post_title':
742
-				        $post_title = $value;
743
-				        if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
744
-				            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
745
-				        }
746
-				        $updated_post->post_title = $post_title;
747
-				        $updated_post->post_name  = $post_title;
748
-				        unset( $post_title );
749
-				        break;
750
-
751
-				    case 'post_content':
752
-				        $post_content = $value;
753
-				        if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
754
-				            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
755
-				        }
756
-				        $updated_post->post_content = $post_content;
757
-				        unset( $post_content );
758
-				        break;
759
-				    case 'post_excerpt':
760
-				        $updated_post->post_excerpt = $value;
761
-				        break;
762
-				    case 'post_tags':
763
-				        wp_set_post_tags( $post_id, $value, false );
764
-				        break;
765
-				    case 'post_category':
766
-				        break;
767
-				    case 'post_custom_field':
741
+					case 'post_title':
742
+						$post_title = $value;
743
+						if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
744
+							$post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
745
+						}
746
+						$updated_post->post_title = $post_title;
747
+						$updated_post->post_name  = $post_title;
748
+						unset( $post_title );
749
+						break;
750
+
751
+					case 'post_content':
752
+						$post_content = $value;
753
+						if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
754
+							$post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
755
+						}
756
+						$updated_post->post_content = $post_content;
757
+						unset( $post_content );
758
+						break;
759
+					case 'post_excerpt':
760
+						$updated_post->post_excerpt = $value;
761
+						break;
762
+					case 'post_tags':
763
+						wp_set_post_tags( $post_id, $value, false );
764
+						break;
765
+					case 'post_category':
766
+						break;
767
+					case 'post_custom_field':
768 768
 						if ( is_array( $value ) && ( floatval( $field_id ) !== floatval( $field->id ) ) ) {
769 769
 							$value = $value[ $field_id ];
770 770
 						}
771 771
 
772
-				        if( ! empty( $field->customFieldTemplateEnabled ) ) {
773
-				            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
774
-				        }
772
+						if( ! empty( $field->customFieldTemplateEnabled ) ) {
773
+							$value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
774
+						}
775 775
 
776 776
 						$value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry );
777 777
 
778
-				        update_post_meta( $post_id, $field->postCustomFieldName, $value );
779
-				        break;
778
+						update_post_meta( $post_id, $field->postCustomFieldName, $value );
779
+						break;
780 780
 
781
-				    case 'post_image':
782
-				        $value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
783
-				        break;
781
+					case 'post_image':
782
+						$value = $this->update_post_image( $form, $field, $field_id, $value, $this->entry, $post_id );
783
+						break;
784 784
 
785 785
 				}
786 786
 
@@ -903,14 +903,14 @@  discard block
 block discarded – undo
903 903
 			?><h2 class="gv-edit-entry-title">
904 904
 				<span><?php
905 905
 
906
-				    /**
907
-				     * @filter `gravityview_edit_entry_title` Modify the edit entry title
908
-				     * @param string $edit_entry_title Modify the "Edit Entry" title
909
-				     * @param GravityView_Edit_Entry_Render $this This object
910
-				     */
911
-				    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
906
+					/**
907
+					 * @filter `gravityview_edit_entry_title` Modify the edit entry title
908
+					 * @param string $edit_entry_title Modify the "Edit Entry" title
909
+					 * @param GravityView_Edit_Entry_Render $this This object
910
+					 */
911
+					$edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
912 912
 
913
-				    echo esc_attr( $edit_entry_title );
913
+					echo esc_attr( $edit_entry_title );
914 914
 			?></span>
915 915
 			</h2>
916 916
 
@@ -973,26 +973,26 @@  discard block
 block discarded – undo
973 973
 
974 974
 				switch ( $edit_redirect ) {
975 975
 
976
-                    case '0':
977
-	                    $redirect_url = $back_link;
978
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
979
-                        break;
980
-
981
-                    case '1':
982
-	                    $redirect_url = $directory_link = GravityView_API::directory_link();
983
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
984
-	                    break;
985
-
986
-                    case '2':
987
-	                    $redirect_url = $edit_redirect_url;
988
-	                    $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
989
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
990
-                        break;
991
-
992
-                    case '':
993
-                    default:
994
-					    $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
995
-                        break;
976
+					case '0':
977
+						$redirect_url = $back_link;
978
+						$entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
979
+						break;
980
+
981
+					case '1':
982
+						$redirect_url = $directory_link = GravityView_API::directory_link();
983
+						$entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
984
+						break;
985
+
986
+					case '2':
987
+						$redirect_url = $edit_redirect_url;
988
+						$redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
989
+						$entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
990
+						break;
991
+
992
+					case '':
993
+					default:
994
+						$entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
995
+						break;
996 996
 				}
997 997
 
998 998
 				if ( isset( $redirect_url ) ) {
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 
1050 1050
 		ob_get_clean();
1051 1051
 
1052
-	    remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
1052
+		remove_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000 );
1053 1053
 		remove_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
1054 1054
 		remove_filter( 'gform_disable_view_counter', '__return_true' );
1055 1055
 		remove_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5 );
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
 
1104 1104
 		// for now we don't support Save and Continue feature.
1105 1105
 		if( ! self::$supports_save_and_continue ) {
1106
-	        unset( $form['save'] );
1106
+			unset( $form['save'] );
1107 1107
 		}
1108 1108
 
1109 1109
 		$form = $this->unselect_default_values( $form );
@@ -1130,30 +1130,30 @@  discard block
 block discarded – undo
1130 1130
 			return $field_content;
1131 1131
 		}
1132 1132
 
1133
-        $message = null;
1133
+		$message = null;
1134 1134
 
1135
-        // First, make sure they have the capability to edit the post.
1136
-        if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1135
+		// First, make sure they have the capability to edit the post.
1136
+		if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1137 1137
 
1138
-            /**
1139
-             * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1140
-             * @param string $message The existing "You don't have permission..." text
1141
-             */
1142
-            $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1138
+			/**
1139
+			 * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1140
+			 * @param string $message The existing "You don't have permission..." text
1141
+			 */
1142
+			$message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1143 1143
 
1144
-        } elseif( null === get_post( $this->entry['post_id'] ) ) {
1145
-            /**
1146
-             * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1147
-             * @param string $message The existing "This field is not editable; the post no longer exists." text
1148
-             */
1149
-            $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1150
-        }
1144
+		} elseif( null === get_post( $this->entry['post_id'] ) ) {
1145
+			/**
1146
+			 * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1147
+			 * @param string $message The existing "This field is not editable; the post no longer exists." text
1148
+			 */
1149
+			$message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1150
+		}
1151 1151
 
1152
-        if( $message ) {
1153
-            $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1154
-        }
1152
+		if( $message ) {
1153
+			$field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1154
+		}
1155 1155
 
1156
-        return $field_content;
1156
+		return $field_content;
1157 1157
 	}
1158 1158
 
1159 1159
 	/**
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 			|| ! empty( $field_content )
1182 1182
 			|| in_array( $field->type, array( 'honeypot' ) )
1183 1183
 		) {
1184
-	        return $field_content;
1184
+			return $field_content;
1185 1185
 		}
1186 1186
 
1187 1187
 		// SET SOME FIELD DEFAULTS TO PREVENT ISSUES
@@ -1189,24 +1189,24 @@  discard block
 block discarded – undo
1189 1189
 
1190 1190
 		$field_value = $this->get_field_value( $field );
1191 1191
 
1192
-	    // Prevent any PHP warnings, like undefined index
1193
-	    ob_start();
1192
+		// Prevent any PHP warnings, like undefined index
1193
+		ob_start();
1194 1194
 
1195
-	    $return = null;
1195
+		$return = null;
1196 1196
 
1197 1197
 		/** @var GravityView_Field $gv_field */
1198 1198
 		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1199 1199
 			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1200 1200
 		} else {
1201
-	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
1202
-	    }
1201
+			$return = $field->get_field_input( $this->form, $field_value, $this->entry );
1202
+		}
1203 1203
 
1204
-	    // If there was output, it's an error
1205
-	    $warnings = ob_get_clean();
1204
+		// If there was output, it's an error
1205
+		$warnings = ob_get_clean();
1206 1206
 
1207
-	    if( !empty( $warnings ) ) {
1208
-		    gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1209
-	    }
1207
+		if( !empty( $warnings ) ) {
1208
+			gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1209
+		}
1210 1210
 
1211 1211
 		return $return;
1212 1212
 	}
@@ -1241,8 +1241,8 @@  discard block
 block discarded – undo
1241 1241
 				$input_id = strval( $input['id'] );
1242 1242
 
1243 1243
 				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1244
-				    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1245
-				    $allow_pre_populated = false;
1244
+					$field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1245
+					$allow_pre_populated = false;
1246 1246
 				}
1247 1247
 
1248 1248
 			}
@@ -1266,7 +1266,7 @@  discard block
 block discarded – undo
1266 1266
 			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1267 1267
 				$categories = array();
1268 1268
 				foreach ( explode( ',', $field_value ) as $cat_string ) {
1269
-				    $categories[] = GFCommon::format_post_category( $cat_string, true );
1269
+					$categories[] = GFCommon::format_post_category( $cat_string, true );
1270 1270
 				}
1271 1271
 				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1272 1272
 			}
@@ -1276,25 +1276,25 @@  discard block
 block discarded – undo
1276 1276
 		// if value is empty get the default value if defined
1277 1277
 		$field_value = $field->get_value_default_if_empty( $field_value );
1278 1278
 
1279
-	    /**
1280
-	     * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1281
-	     * @since 1.11
1282
-	     * @since 1.20 Added third param
1283
-	     * @param mixed $field_value field value used to populate the input
1284
-	     * @param object $field Gravity Forms field object ( Class GF_Field )
1285
-	     * @param GravityView_Edit_Entry_Render $this Current object
1286
-	     */
1287
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this );
1288
-
1289
-	    /**
1290
-	     * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1291
-	     * @since 1.17
1292
-	     * @since 1.20 Added third param
1293
-	     * @param mixed $field_value field value used to populate the input
1294
-	     * @param GF_Field $field Gravity Forms field object
1295
-	     * @param GravityView_Edit_Entry_Render $this Current object
1296
-	     */
1297
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1279
+		/**
1280
+		 * @filter `gravityview/edit_entry/field_value` Change the value of an Edit Entry field, if needed
1281
+		 * @since 1.11
1282
+		 * @since 1.20 Added third param
1283
+		 * @param mixed $field_value field value used to populate the input
1284
+		 * @param object $field Gravity Forms field object ( Class GF_Field )
1285
+		 * @param GravityView_Edit_Entry_Render $this Current object
1286
+		 */
1287
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value', $field_value, $field, $this );
1288
+
1289
+		/**
1290
+		 * @filter `gravityview/edit_entry/field_value_{field_type}` Change the value of an Edit Entry field for a specific field type
1291
+		 * @since 1.17
1292
+		 * @since 1.20 Added third param
1293
+		 * @param mixed $field_value field value used to populate the input
1294
+		 * @param GF_Field $field Gravity Forms field object
1295
+		 * @param GravityView_Edit_Entry_Render $this Current object
1296
+		 */
1297
+		$field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1298 1298
 
1299 1299
 		return $field_value;
1300 1300
 	}
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
 			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1322 1322
 			// expects certain field array items to be set.
1323 1323
 			foreach ( array( 'noDuplicates', 'adminOnly', 'inputType', 'isRequired', 'enablePrice', 'inputs', 'allowedExtensions' ) as $key ) {
1324
-	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1324
+				$field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1325 1325
 			}
1326 1326
 
1327 1327
 			switch( RGFormsModel::get_input_type( $field ) ) {
@@ -1335,61 +1335,61 @@  discard block
 block discarded – undo
1335 1335
 				 */
1336 1336
 				case 'fileupload':
1337 1337
 
1338
-				    // Set the previous value
1339
-				    $entry = $this->get_entry();
1338
+					// Set the previous value
1339
+					$entry = $this->get_entry();
1340 1340
 
1341
-				    $input_name = 'input_'.$field->id;
1342
-				    $form_id = $form['id'];
1341
+					$input_name = 'input_'.$field->id;
1342
+					$form_id = $form['id'];
1343 1343
 
1344
-				    $value = NULL;
1344
+					$value = NULL;
1345 1345
 
1346
-				    // Use the previous entry value as the default.
1347
-				    if( isset( $entry[ $field->id ] ) ) {
1348
-				        $value = $entry[ $field->id ];
1349
-				    }
1346
+					// Use the previous entry value as the default.
1347
+					if( isset( $entry[ $field->id ] ) ) {
1348
+						$value = $entry[ $field->id ];
1349
+					}
1350 1350
 
1351
-				    // If this is a single upload file
1352
-				    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1353
-				        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1354
-				        $value = $file_path['url'];
1351
+					// If this is a single upload file
1352
+					if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1353
+						$file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1354
+						$value = $file_path['url'];
1355 1355
 
1356
-				    } else {
1356
+					} else {
1357 1357
 
1358
-				        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1359
-				        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1360
-				        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1358
+						// Fix PHP warning on line 1498 of form_display.php for post_image fields
1359
+						// Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1360
+						$_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1361 1361
 
1362
-				    }
1362
+					}
1363 1363
 
1364
-				    if ( \GV\Utils::get( $field, "multipleFiles" ) ) {
1364
+					if ( \GV\Utils::get( $field, "multipleFiles" ) ) {
1365 1365
 
1366
-				        // If there are fresh uploads, process and merge them.
1367
-				        // Otherwise, use the passed values, which should be json-encoded array of URLs
1368
-				        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1369
-				            $value = empty( $value ) ? '[]' : $value;
1370
-				            $value = stripslashes_deep( $value );
1371
-				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1372
-				        }
1366
+						// If there are fresh uploads, process and merge them.
1367
+						// Otherwise, use the passed values, which should be json-encoded array of URLs
1368
+						if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1369
+							$value = empty( $value ) ? '[]' : $value;
1370
+							$value = stripslashes_deep( $value );
1371
+							$value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1372
+						}
1373 1373
 
1374
-				    } else {
1374
+					} else {
1375 1375
 
1376
-				        // A file already exists when editing an entry
1377
-				        // We set this to solve issue when file upload fields are required.
1378
-				        GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1376
+						// A file already exists when editing an entry
1377
+						// We set this to solve issue when file upload fields are required.
1378
+						GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] = $value;
1379 1379
 
1380
-				    }
1380
+					}
1381 1381
 
1382
-				    $this->entry[ $input_name ] = $value;
1383
-				    $_POST[ $input_name ] = $value;
1382
+					$this->entry[ $input_name ] = $value;
1383
+					$_POST[ $input_name ] = $value;
1384 1384
 
1385
-				    break;
1385
+					break;
1386 1386
 
1387 1387
 				case 'number':
1388
-				    // Fix "undefined index" issue at line 1286 in form_display.php
1389
-				    if( !isset( $_POST['input_'.$field->id ] ) ) {
1390
-				        $_POST['input_'.$field->id ] = NULL;
1391
-				    }
1392
-				    break;
1388
+					// Fix "undefined index" issue at line 1286 in form_display.php
1389
+					if( !isset( $_POST['input_'.$field->id ] ) ) {
1390
+						$_POST['input_'.$field->id ] = NULL;
1391
+					}
1392
+					break;
1393 1393
 			}
1394 1394
 
1395 1395
 		}
@@ -1474,42 +1474,42 @@  discard block
 block discarded – undo
1474 1474
 				case 'fileupload' :
1475 1475
 				case 'post_image':
1476 1476
 
1477
-				    // in case nothing is uploaded but there are already files saved
1478
-				    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1479
-				        $field->failed_validation = false;
1480
-				        unset( $field->validation_message );
1481
-				    }
1477
+					// in case nothing is uploaded but there are already files saved
1478
+					if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1479
+						$field->failed_validation = false;
1480
+						unset( $field->validation_message );
1481
+					}
1482 1482
 
1483
-				    // validate if multi file upload reached max number of files [maxFiles] => 2
1484
-				    if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1483
+					// validate if multi file upload reached max number of files [maxFiles] => 2
1484
+					if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1485 1485
 
1486
-				        $input_name = 'input_' . $field->id;
1487
-				        //uploaded
1488
-				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1486
+						$input_name = 'input_' . $field->id;
1487
+						//uploaded
1488
+						$file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1489 1489
 
1490
-				        //existent
1491
-				        $entry = $this->get_entry();
1492
-				        $value = NULL;
1493
-				        if( isset( $entry[ $field->id ] ) ) {
1494
-				            $value = json_decode( $entry[ $field->id ], true );
1495
-				        }
1490
+						//existent
1491
+						$entry = $this->get_entry();
1492
+						$value = NULL;
1493
+						if( isset( $entry[ $field->id ] ) ) {
1494
+							$value = json_decode( $entry[ $field->id ], true );
1495
+						}
1496 1496
 
1497
-				        // count uploaded files and existent entry files
1498
-				        $count_files = count( $file_names ) + count( $value );
1497
+						// count uploaded files and existent entry files
1498
+						$count_files = count( $file_names ) + count( $value );
1499 1499
 
1500
-				        if( $count_files > $field->maxFiles ) {
1501
-				            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1502
-				            $field->failed_validation = 1;
1503
-				            $gv_valid = false;
1500
+						if( $count_files > $field->maxFiles ) {
1501
+							$field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1502
+							$field->failed_validation = 1;
1503
+							$gv_valid = false;
1504 1504
 
1505
-				            // in case of error make sure the newest upload files are removed from the upload input
1506
-				            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1507
-				        }
1505
+							// in case of error make sure the newest upload files are removed from the upload input
1506
+							GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1507
+						}
1508 1508
 
1509
-				    }
1509
+					}
1510 1510
 
1511 1511
 
1512
-				    break;
1512
+					break;
1513 1513
 
1514 1514
 			}
1515 1515
 
@@ -1520,47 +1520,47 @@  discard block
 block discarded – undo
1520 1520
 
1521 1521
 				switch ( $field_type ) {
1522 1522
 
1523
-				    // Captchas don't need to be re-entered.
1524
-				    case 'captcha':
1523
+					// Captchas don't need to be re-entered.
1524
+					case 'captcha':
1525 1525
 
1526
-				        // Post Image fields aren't editable, so we un-fail them.
1527
-				    case 'post_image':
1528
-				        $field->failed_validation = false;
1529
-				        unset( $field->validation_message );
1530
-				        break;
1526
+						// Post Image fields aren't editable, so we un-fail them.
1527
+					case 'post_image':
1528
+						$field->failed_validation = false;
1529
+						unset( $field->validation_message );
1530
+						break;
1531 1531
 
1532 1532
 				}
1533 1533
 
1534 1534
 				// You can't continue inside a switch, so we do it after.
1535 1535
 				if( empty( $field->failed_validation ) ) {
1536
-				    continue;
1536
+					continue;
1537 1537
 				}
1538 1538
 
1539 1539
 				// checks if the No Duplicates option is not validating entry against itself, since
1540 1540
 				// we're editing a stored entry, it would also assume it's a duplicate.
1541 1541
 				if( !empty( $field->noDuplicates ) ) {
1542 1542
 
1543
-				    $entry = $this->get_entry();
1543
+					$entry = $this->get_entry();
1544 1544
 
1545
-				    // If the value of the entry is the same as the stored value
1546
-				    // Then we can assume it's not a duplicate, it's the same.
1547
-				    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1548
-				        //if value submitted was not changed, then don't validate
1549
-				        $field->failed_validation = false;
1545
+					// If the value of the entry is the same as the stored value
1546
+					// Then we can assume it's not a duplicate, it's the same.
1547
+					if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1548
+						//if value submitted was not changed, then don't validate
1549
+						$field->failed_validation = false;
1550 1550
 
1551
-				        unset( $field->validation_message );
1551
+						unset( $field->validation_message );
1552 1552
 
1553
-				        gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) );
1553
+						gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field not a duplicate; it is the same entry.', array( 'data' => $entry ) );
1554 1554
 
1555
-				        continue;
1556
-				    }
1555
+						continue;
1556
+					}
1557 1557
 				}
1558 1558
 
1559 1559
 				// if here then probably we are facing the validation 'At least one field must be filled out'
1560 1560
 				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1561
-				    unset( $field->validation_message );
1562
-	                $field->validation_message = false;
1563
-				    continue;
1561
+					unset( $field->validation_message );
1562
+					$field->validation_message = false;
1563
+					continue;
1564 1564
 				}
1565 1565
 
1566 1566
 				$gv_valid = false;
@@ -1624,8 +1624,8 @@  discard block
 block discarded – undo
1624 1624
 		// Hide fields depending on admin settings
1625 1625
 		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1626 1626
 
1627
-	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1628
-	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1627
+		// If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1628
+		$fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
1629 1629
 
1630 1630
 		/**
1631 1631
 		 * @filter `gravityview/edit_entry/form_fields` Modify the fields displayed in Edit Entry form
@@ -1685,11 +1685,11 @@  discard block
 block discarded – undo
1685 1685
 		// The edit tab has been configured, so we loop through to configured settings
1686 1686
 		foreach ( $configured_fields as $configured_field ) {
1687 1687
 
1688
-	        /** @var GF_Field $field */
1689
-	        foreach ( $fields as $field ) {
1688
+			/** @var GF_Field $field */
1689
+			foreach ( $fields as $field ) {
1690 1690
 				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1691
-				    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1692
-				    break;
1691
+					$edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1692
+					break;
1693 1693
 				}
1694 1694
 
1695 1695
 			}
@@ -1745,28 +1745,28 @@  discard block
 block discarded – undo
1745 1745
 	 */
1746 1746
 	private function filter_admin_only_fields( $fields = array(), $edit_fields = null, $form = array(), $view_id = 0 ) {
1747 1747
 
1748
-	    /**
1748
+		/**
1749 1749
 		 * @filter `gravityview/edit_entry/use_gf_admin_only_setting` When Edit tab isn't configured, should the Gravity Forms "Admin Only" field settings be used to control field display to non-admins? Default: true
1750
-	     * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1751
-	     * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1752
-	     * @since 1.9.1
1753
-	     * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions.
1754
-	     * @param array $form GF Form array
1755
-	     * @param int $view_id View ID
1756
-	     */
1757
-	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1758
-
1759
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1750
+		 * If the Edit Entry tab is not configured, adminOnly fields will not be shown to non-administrators.
1751
+		 * If the Edit Entry tab *is* configured, adminOnly fields will be shown to non-administrators, using the configured GV permissions
1752
+		 * @since 1.9.1
1753
+		 * @param boolean $use_gf_adminonly_setting True: Hide field if set to Admin Only in GF and the user is not an admin. False: show field based on GV permissions, ignoring GF permissions.
1754
+		 * @param array $form GF Form array
1755
+		 * @param int $view_id View ID
1756
+		 */
1757
+		$use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1758
+
1759
+		if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1760 1760
 			foreach( $fields as $k => $field ) {
1761 1761
 				if( $field->adminOnly ) {
1762
-				    unset( $fields[ $k ] );
1762
+					unset( $fields[ $k ] );
1763 1763
 				}
1764 1764
 			}
1765 1765
 			return array_values( $fields );
1766 1766
 		}
1767 1767
 
1768
-	    foreach( $fields as &$field ) {
1769
-		    $field->adminOnly = false;
1768
+		foreach( $fields as &$field ) {
1769
+			$field->adminOnly = false;
1770 1770
 		}
1771 1771
 
1772 1772
 		return $fields;
@@ -1786,13 +1786,13 @@  discard block
 block discarded – undo
1786 1786
 	 */
1787 1787
 	private function unselect_default_values( $form ) {
1788 1788
 
1789
-	    foreach ( $form['fields'] as &$field ) {
1789
+		foreach ( $form['fields'] as &$field ) {
1790 1790
 
1791 1791
 			if ( empty( $field->choices ) ) {
1792
-                continue;
1792
+				continue;
1793 1793
 			}
1794 1794
 
1795
-            foreach ( $field->choices as &$choice ) {
1795
+			foreach ( $field->choices as &$choice ) {
1796 1796
 				if ( \GV\Utils::get( $choice, 'isSelected' ) ) {
1797 1797
 					$choice['isSelected'] = false;
1798 1798
 				}
@@ -1829,36 +1829,36 @@  discard block
 block discarded – undo
1829 1829
 
1830 1830
 			if( 'checkbox' === $field->type ) {
1831 1831
 				foreach ( $field->get_entry_inputs() as $key => $input ) {
1832
-				    $input_id = $input['id'];
1833
-				    $choice = $field->choices[ $key ];
1834
-				    $value = \GV\Utils::get( $this->entry, $input_id );
1835
-				    $match = RGFormsModel::choice_value_match( $field, $choice, $value );
1836
-				    if( $match ) {
1837
-				        $field->choices[ $key ]['isSelected'] = true;
1838
-				    }
1832
+					$input_id = $input['id'];
1833
+					$choice = $field->choices[ $key ];
1834
+					$value = \GV\Utils::get( $this->entry, $input_id );
1835
+					$match = RGFormsModel::choice_value_match( $field, $choice, $value );
1836
+					if( $match ) {
1837
+						$field->choices[ $key ]['isSelected'] = true;
1838
+					}
1839 1839
 				}
1840 1840
 			} else {
1841 1841
 
1842 1842
 				// We need to run through each field to set the default values
1843 1843
 				foreach ( $this->entry as $field_id => $field_value ) {
1844 1844
 
1845
-				    if( floatval( $field_id ) === floatval( $field->id ) ) {
1845
+					if( floatval( $field_id ) === floatval( $field->id ) ) {
1846 1846
 
1847
-				        if( 'list' === $field->type ) {
1848
-				            $list_rows = maybe_unserialize( $field_value );
1847
+						if( 'list' === $field->type ) {
1848
+							$list_rows = maybe_unserialize( $field_value );
1849 1849
 
1850
-				            $list_field_value = array();
1851
-				            foreach ( (array) $list_rows as $row ) {
1852
-				                foreach ( (array) $row as $column ) {
1853
-				                    $list_field_value[] = $column;
1854
-				                }
1855
-				            }
1850
+							$list_field_value = array();
1851
+							foreach ( (array) $list_rows as $row ) {
1852
+								foreach ( (array) $row as $column ) {
1853
+									$list_field_value[] = $column;
1854
+								}
1855
+							}
1856 1856
 
1857
-				            $field->defaultValue = serialize( $list_field_value );
1858
-				        } else {
1859
-				            $field->defaultValue = $field_value;
1860
-				        }
1861
-				    }
1857
+							$field->defaultValue = serialize( $list_field_value );
1858
+						} else {
1859
+							$field->defaultValue = $field_value;
1860
+						}
1861
+					}
1862 1862
 				}
1863 1863
 			}
1864 1864
 		}
@@ -1915,7 +1915,7 @@  discard block
 block discarded – undo
1915 1915
 			return $has_conditional_logic;
1916 1916
 		}
1917 1917
 
1918
-	    /** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */
1918
+		/** @see GravityView_Edit_Entry_Render::filter_conditional_logic for filter documentation */
1919 1919
 		return apply_filters( 'gravityview/edit_entry/conditional_logic', $has_conditional_logic, $form );
1920 1920
 	}
1921 1921
 
@@ -1982,14 +1982,14 @@  discard block
 block discarded – undo
1982 1982
 
1983 1983
 		if( $echo && $error !== true ) {
1984 1984
 
1985
-	        $error = esc_html( $error );
1985
+			$error = esc_html( $error );
1986 1986
 
1987
-	        /**
1988
-	         * @since 1.9
1989
-	         */
1990
-	        if ( ! empty( $this->entry ) ) {
1991
-		        $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) );
1992
-	        }
1987
+			/**
1988
+			 * @since 1.9
1989
+			 */
1990
+			if ( ! empty( $this->entry ) ) {
1991
+				$error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) );
1992
+			}
1993 1993
 
1994 1994
 			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
1995 1995
 		}
Please login to merge, or discard this patch.
Spacing   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -115,16 +115,16 @@  discard block
 block discarded – undo
115 115
 	function load() {
116 116
 
117 117
 		/** @define "GRAVITYVIEW_DIR" "../../../" */
118
-		include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' );
118
+		include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' );
119 119
 
120 120
 		// Don't display an embedded form when editing an entry
121 121
 		add_action( 'wp_head', array( $this, 'prevent_render_form' ) );
122 122
 		add_action( 'wp_footer', array( $this, 'prevent_render_form' ) );
123 123
 
124 124
 		// Stop Gravity Forms processing what is ours!
125
-		add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 );
125
+		add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 );
126 126
 
127
-		add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') );
127
+		add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) );
128 128
 
129 129
 		add_action( 'gravityview_edit_entry', array( $this, 'init' ) );
130 130
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 );
136 136
 
137 137
 		// Add fields expected by GFFormDisplay::validate()
138
-		add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') );
138
+		add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) );
139 139
 
140 140
 		// Fix multiselect value for GF 2.2
141 141
 		add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 );
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 	 * @return void
153 153
 	 */
154 154
 	public function prevent_render_form() {
155
-		if( $this->is_edit_entry() ) {
156
-			if( 'wp_head' === current_filter() ) {
155
+		if ( $this->is_edit_entry() ) {
156
+			if ( 'wp_head' === current_filter() ) {
157 157
 				add_filter( 'gform_shortcode_form', '__return_empty_string' );
158 158
 			} else {
159 159
 				remove_filter( 'gform_shortcode_form', '__return_empty_string' );
@@ -168,13 +168,13 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	public function prevent_maybe_process_form() {
170 170
 
171
-		if( ! empty( $_POST ) ) {
171
+		if ( ! empty( $_POST ) ) {
172 172
 	        gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) );
173 173
 		}
174 174
 
175
-		if( $this->is_edit_entry_submission() ) {
176
-			remove_action( 'wp',  array( 'RGForms', 'maybe_process_form'), 9 );
177
-	        remove_action( 'wp',  array( 'GFForms', 'maybe_process_form'), 9 );
175
+		if ( $this->is_edit_entry_submission() ) {
176
+			remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 );
177
+	        remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 );
178 178
 		}
179 179
 	}
180 180
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	 */
185 185
 	public function is_edit_entry() {
186 186
 
187
-		$is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] );
187
+		$is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] );
188 188
 
189 189
 		return ( $is_edit_entry || $this->is_edit_entry_submission() );
190 190
 	}
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * @return boolean
196 196
 	 */
197 197
 	public function is_edit_entry_submission() {
198
-		return !empty( $_POST[ self::$nonce_field ] );
198
+		return ! empty( $_POST[ self::$nonce_field ] );
199 199
 	}
200 200
 
201 201
 	/**
@@ -208,16 +208,16 @@  discard block
 block discarded – undo
208 208
 
209 209
 
210 210
 		$entries = $gravityview_view->getEntries();
211
-	    self::$original_entry = $entries[0];
212
-	    $this->entry = $entries[0];
211
+	    self::$original_entry = $entries[ 0 ];
212
+	    $this->entry = $entries[ 0 ];
213 213
 
214 214
 		self::$original_form = $gravityview_view->getForm();
215 215
 		$this->form = $gravityview_view->getForm();
216
-		$this->form_id = $this->entry['form_id'];
216
+		$this->form_id = $this->entry[ 'form_id' ];
217 217
 		$this->view_id = $gravityview_view->getViewId();
218 218
 		$this->post_id = \GV\Utils::get( $post, 'ID', null );
219 219
 
220
-		self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] );
220
+		self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] );
221 221
 	}
222 222
 
223 223
 
@@ -268,9 +268,9 @@  discard block
 block discarded – undo
268 268
 	private function print_scripts() {
269 269
 		$gravityview_view = GravityView_View::getInstance();
270 270
 
271
-		wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
271
+		wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
272 272
 
273
-		GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false);
273
+		GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false );
274 274
 
275 275
 		wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) );
276 276
 
@@ -286,19 +286,19 @@  discard block
 block discarded – undo
286 286
 	 */
287 287
 	private function process_save( $gv_data ) {
288 288
 
289
-		if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) {
289
+		if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) {
290 290
 			return;
291 291
 		}
292 292
 
293 293
 		// Make sure the entry, view, and form IDs are all correct
294 294
 		$valid = $this->verify_nonce();
295 295
 
296
-		if ( !$valid ) {
296
+		if ( ! $valid ) {
297 297
 			gravityview()->log->error( 'Nonce validation failed.' );
298 298
 			return;
299 299
 		}
300 300
 
301
-		if ( $this->entry['id'] !== $_POST['lid'] ) {
301
+		if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) {
302 302
 			gravityview()->log->error( 'Entry ID did not match posted entry ID.' );
303 303
 			return;
304 304
 		}
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 
310 310
 		$this->validate();
311 311
 
312
-		if( $this->is_valid ) {
312
+		if ( $this->is_valid ) {
313 313
 
314 314
 			gravityview()->log->debug( 'Submission is valid.' );
315 315
 
@@ -321,22 +321,22 @@  discard block
 block discarded – undo
321 321
 			/**
322 322
 			 * @hack to avoid the capability validation of the method save_lead for GF 1.9+
323 323
 			 */
324
-			unset( $_GET['page'] );
324
+			unset( $_GET[ 'page' ] );
325 325
 
326
-			$date_created = $this->entry['date_created'];
326
+			$date_created = $this->entry[ 'date_created' ];
327 327
 
328 328
 			/**
329 329
 			 * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead()
330 330
 			 * @since 1.17.2
331 331
 			 */
332
-			unset( $this->entry['date_created'] );
332
+			unset( $this->entry[ 'date_created' ] );
333 333
 
334 334
 			GFFormsModel::save_lead( $form, $this->entry );
335 335
 
336 336
 	        // Delete the values for hidden inputs
337 337
 	        $this->unset_hidden_field_values();
338 338
 			
339
-			$this->entry['date_created'] = $date_created;
339
+			$this->entry[ 'date_created' ] = $date_created;
340 340
 
341 341
 			// Process calculation fields
342 342
 			$this->update_calculation_fields();
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 			 * @param GravityView_Edit_Entry_Render $this This object
359 359
 			 * @param GravityView_View_Data $gv_data The View data
360 360
 			 */
361
-			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data );
361
+			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data );
362 362
 
363 363
 		} else {
364 364
 			gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) );
@@ -386,16 +386,16 @@  discard block
 block discarded – undo
386 386
 		 */
387 387
 		$unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this );
388 388
 
389
-		if( ! $unset_hidden_field_values ) {
389
+		if ( ! $unset_hidden_field_values ) {
390 390
 			return;
391 391
 		}
392 392
 
393 393
 		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
394 394
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
395
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) );
395
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) );
396 396
 		} else {
397 397
 			$lead_detail_table = GFFormsModel::get_lead_details_table_name();
398
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );
398
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) );
399 399
 		}
400 400
 
401 401
 	    foreach ( $this->entry as $input_id => $field_value ) {
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 
409 409
 				$empty_value = $field->get_value_save_entry(
410 410
 					is_array( $field->get_entry_inputs() ) ? array() : '',
411
-					$this->form, '', $this->entry['id'], $this->entry
411
+					$this->form, '', $this->entry[ 'id' ], $this->entry
412 412
 				);
413 413
 
414 414
 			    $lead_detail_id = GFFormsModel::get_lead_detail_id( $current_fields, $input_id );
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 		}
479 479
 
480 480
 		/** No file is being uploaded. */
481
-		if ( empty( $_FILES[ $input_name ]['name'] ) ) {
481
+		if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) {
482 482
 			/** So return the original upload */
483 483
 			return $entry[ $input_id ];
484 484
 		}
@@ -496,11 +496,11 @@  discard block
 block discarded – undo
496 496
 	 * @return mixed
497 497
 	 */
498 498
 	public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) {
499
-		if( ! $this->is_edit_entry() ) {
499
+		if ( ! $this->is_edit_entry() ) {
500 500
 			return $plupload_init;
501 501
 		}
502 502
 
503
-		$plupload_init['gf_vars']['max_files'] = 0;
503
+		$plupload_init[ 'gf_vars' ][ 'max_files' ] = 0;
504 504
 
505 505
 		return $plupload_init;
506 506
 	}
@@ -515,27 +515,27 @@  discard block
 block discarded – undo
515 515
 		$form = $this->form;
516 516
 
517 517
 	    /** @var GF_Field $field */
518
-		foreach( $form['fields'] as $k => &$field ) {
518
+		foreach ( $form[ 'fields' ] as $k => &$field ) {
519 519
 
520 520
 			/**
521 521
 			 * Remove the fields with calculation formulas before save to avoid conflicts with GF logic
522 522
 			 * @since 1.16.3
523 523
 			 * @var GF_Field $field
524 524
 			 */
525
-			if( $field->has_calculation() ) {
526
-				unset( $form['fields'][ $k ] );
525
+			if ( $field->has_calculation() ) {
526
+				unset( $form[ 'fields' ][ $k ] );
527 527
 			}
528 528
 
529 529
 			$field->adminOnly = false;
530 530
 
531
-			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
532
-				foreach( $field->inputs as $key => $input ) {
533
-				    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
531
+			if ( isset( $field->inputs ) && is_array( $field->inputs ) ) {
532
+				foreach ( $field->inputs as $key => $input ) {
533
+				    $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ];
534 534
 				}
535 535
 			}
536 536
 		}
537 537
 
538
-		$form['fields'] = array_values( $form['fields'] );
538
+		$form[ 'fields' ] = array_values( $form[ 'fields' ] );
539 539
 
540 540
 		return $form;
541 541
 	}
@@ -547,14 +547,14 @@  discard block
 block discarded – undo
547 547
 		$update = false;
548 548
 
549 549
 		// get the most up to date entry values
550
-		$entry = GFAPI::get_entry( $this->entry['id'] );
550
+		$entry = GFAPI::get_entry( $this->entry[ 'id' ] );
551 551
 
552 552
 		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
553 553
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
554
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) );
554
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) );
555 555
 		} else {
556 556
 			$lead_detail_table = GFFormsModel::get_lead_details_table_name();
557
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) );
557
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) );
558 558
 		}
559 559
 
560 560
 
@@ -566,24 +566,24 @@  discard block
 block discarded – undo
566 566
 				$inputs = $field->get_entry_inputs();
567 567
 				if ( is_array( $inputs ) ) {
568 568
 				    foreach ( $inputs as $input ) {
569
-						list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 );
569
+						list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 );
570 570
 
571 571
 						if ( 'product' === $field->type ) {
572
-							$input_name = 'input_' . str_replace( '.', '_', $input['id'] );
572
+							$input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] );
573 573
 
574 574
 							// Only allow quantity to be set if it's allowed to be edited
575 575
 							if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) {
576 576
 							} else { // otherwise set to what it previously was
577
-								$_POST[ $input_name ] = $entry[ $input['id'] ];
577
+								$_POST[ $input_name ] = $entry[ $input[ 'id' ] ];
578 578
 							}
579 579
 						} else {
580 580
 							// Set to what it previously was if it's not editable
581 581
 							if ( ! in_array( $field_id, $allowed_fields ) ) {
582
-								$_POST[ $input_name ] = $entry[ $input['id'] ];
582
+								$_POST[ $input_name ] = $entry[ $input[ 'id' ] ];
583 583
 							}
584 584
 						}
585 585
 
586
-						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] );
586
+						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] );
587 587
 				    }
588 588
 				} else {
589 589
 					// Set to what it previously was if it's not editable
@@ -623,19 +623,19 @@  discard block
 block discarded – undo
623 623
 
624 624
 		$input_name = 'input_' . $field_id;
625 625
 
626
-		if ( !empty( $_FILES[ $input_name ]['name'] ) ) {
626
+		if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
627 627
 
628 628
 			// We have a new image
629 629
 
630
-			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
630
+			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] );
631 631
 
632 632
 			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
633 633
 	        $ary = stripslashes_deep( $ary );
634 634
 			$img_url = \GV\Utils::get( $ary, 0 );
635 635
 
636
-			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
637
-			$img_caption     = count( $ary ) > 2 ? $ary[2] : '';
638
-			$img_description = count( $ary ) > 3 ? $ary[3] : '';
636
+			$img_title       = count( $ary ) > 1 ? $ary[ 1 ] : '';
637
+			$img_caption     = count( $ary ) > 2 ? $ary[ 2 ] : '';
638
+			$img_description = count( $ary ) > 3 ? $ary[ 3 ] : '';
639 639
 
640 640
 			$image_meta = array(
641 641
 				'post_excerpt' => $img_caption,
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 
645 645
 			//adding title only if it is not empty. It will default to the file name if it is not in the array
646 646
 			if ( ! empty( $img_title ) ) {
647
-				$image_meta['post_title'] = $img_title;
647
+				$image_meta[ 'post_title' ] = $img_title;
648 648
 			}
649 649
 
650 650
 			/**
@@ -702,15 +702,15 @@  discard block
 block discarded – undo
702 702
 	 */
703 703
 	private function maybe_update_post_fields( $form ) {
704 704
 
705
-		if( empty( $this->entry['post_id'] ) ) {
705
+		if ( empty( $this->entry[ 'post_id' ] ) ) {
706 706
 	        gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
707 707
 			return;
708 708
 		}
709 709
 
710
-		$post_id = $this->entry['post_id'];
710
+		$post_id = $this->entry[ 'post_id' ];
711 711
 
712 712
 		// Security check
713
-		if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
713
+		if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
714 714
 			gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) );
715 715
 			return;
716 716
 		}
@@ -723,25 +723,25 @@  discard block
 block discarded – undo
723 723
 
724 724
 			$field = RGFormsModel::get_field( $form, $field_id );
725 725
 
726
-			if( ! $field ) {
726
+			if ( ! $field ) {
727 727
 				continue;
728 728
 			}
729 729
 
730
-			if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
730
+			if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
731 731
 
732 732
 				// Get the value of the field, including $_POSTed value
733 733
 				$value = RGFormsModel::get_field_value( $field );
734 734
 
735 735
 				// Use temporary entry variable, to make values available to fill_post_template() and update_post_image()
736 736
 				$entry_tmp = $this->entry;
737
-				$entry_tmp["{$field_id}"] = $value;
737
+				$entry_tmp[ "{$field_id}" ] = $value;
738 738
 
739
-				switch( $field->type ) {
739
+				switch ( $field->type ) {
740 740
 
741 741
 				    case 'post_title':
742 742
 				        $post_title = $value;
743 743
 				        if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
744
-				            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
744
+				            $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp );
745 745
 				        }
746 746
 				        $updated_post->post_title = $post_title;
747 747
 				        $updated_post->post_name  = $post_title;
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
 				    case 'post_content':
752 752
 				        $post_content = $value;
753 753
 				        if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
754
-				            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
754
+				            $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true );
755 755
 				        }
756 756
 				        $updated_post->post_content = $post_content;
757 757
 				        unset( $post_content );
@@ -769,11 +769,11 @@  discard block
 block discarded – undo
769 769
 							$value = $value[ $field_id ];
770 770
 						}
771 771
 
772
-				        if( ! empty( $field->customFieldTemplateEnabled ) ) {
772
+				        if ( ! empty( $field->customFieldTemplateEnabled ) ) {
773 773
 				            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
774 774
 				        }
775 775
 
776
-						$value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry );
776
+						$value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry );
777 777
 
778 778
 				        update_post_meta( $post_id, $field->postCustomFieldName, $value );
779 779
 				        break;
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 				}
786 786
 
787 787
 				// update entry after
788
-				$this->entry["{$field_id}"] = $value;
788
+				$this->entry[ "{$field_id}" ] = $value;
789 789
 
790 790
 				$update_entry = true;
791 791
 
@@ -794,11 +794,11 @@  discard block
 block discarded – undo
794 794
 
795 795
 		}
796 796
 
797
-		if( $update_entry ) {
797
+		if ( $update_entry ) {
798 798
 
799 799
 			$return_entry = GFAPI::update_entry( $this->entry );
800 800
 
801
-			if( is_wp_error( $return_entry ) ) {
801
+			if ( is_wp_error( $return_entry ) ) {
802 802
 				gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) );
803 803
 			} else {
804 804
 				gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) );
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
 
809 809
 		$return_post = wp_update_post( $updated_post, true );
810 810
 
811
-		if( is_wp_error( $return_post ) ) {
811
+		if ( is_wp_error( $return_post ) ) {
812 812
 			$return_post->add_data( $updated_post, '$updated_post' );
813 813
 			gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) );
814 814
 		} else {
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 		$output = GFCommon::replace_variables( $output, $form, $entry, false, false, false );
843 843
 
844 844
 		// replace conditional shortcodes
845
-		if( $do_shortcode ) {
845
+		if ( $do_shortcode ) {
846 846
 			$output = do_shortcode( $output );
847 847
 		}
848 848
 
@@ -861,19 +861,19 @@  discard block
 block discarded – undo
861 861
 	 */
862 862
 	private function after_update() {
863 863
 
864
-		do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry );
865
-		do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry );
864
+		do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry );
865
+		do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry );
866 866
 
867 867
 		// Re-define the entry now that we've updated it.
868
-		$entry = RGFormsModel::get_lead( $this->entry['id'] );
868
+		$entry = RGFormsModel::get_lead( $this->entry[ 'id' ] );
869 869
 
870 870
 		$entry = GFFormsModel::set_entry_meta( $entry, self::$original_form );
871 871
 
872 872
 		if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) {
873 873
 			// We need to clear the cache because Gravity Forms caches the field values, which
874 874
 			// we have just updated.
875
-			foreach ($this->form['fields'] as $key => $field) {
876
-				GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );
875
+			foreach ( $this->form[ 'fields' ] as $key => $field ) {
876
+				GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id );
877 877
 			}
878 878
 		}
879 879
 
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 
893 893
 		<div class="gv-edit-entry-wrapper"><?php
894 894
 
895
-			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );
895
+			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this );
896 896
 
897 897
 			/**
898 898
 			 * Fixes weird wpautop() issue
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 				     * @param string $edit_entry_title Modify the "Edit Entry" title
909 909
 				     * @param GravityView_Edit_Entry_Render $this This object
910 910
 				     */
911
-				    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
911
+				    $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this );
912 912
 
913 913
 				    echo esc_attr( $edit_entry_title );
914 914
 			?></span>
@@ -958,13 +958,13 @@  discard block
 block discarded – undo
958 958
 
959 959
 			$back_link = remove_query_arg( array( 'page', 'view', 'edit' ) );
960 960
 
961
-			if( ! $this->is_valid ){
961
+			if ( ! $this->is_valid ) {
962 962
 
963 963
 				// Keeping this compatible with Gravity Forms.
964
-				$validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
965
-				$message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form);
964
+				$validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>";
965
+				$message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form );
966 966
 
967
-				echo GVCommon::generate_notice( $message , 'gv-error' );
967
+				echo GVCommon::generate_notice( $message, 'gv-error' );
968 968
 
969 969
 			} else {
970 970
 				$view = \GV\View::by_id( $this->view_id );
@@ -975,23 +975,23 @@  discard block
 block discarded – undo
975 975
 
976 976
                     case '0':
977 977
 	                    $redirect_url = $back_link;
978
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
978
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' );
979 979
                         break;
980 980
 
981 981
                     case '1':
982 982
 	                    $redirect_url = $directory_link = GravityView_API::directory_link();
983
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
983
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
984 984
 	                    break;
985 985
 
986 986
                     case '2':
987 987
 	                    $redirect_url = $edit_redirect_url;
988 988
 	                    $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
989
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
989
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
990 990
                         break;
991 991
 
992 992
                     case '':
993 993
                     default:
994
-					    $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
994
+					    $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' );
995 995
                         break;
996 996
 				}
997 997
 
@@ -1007,7 +1007,7 @@  discard block
 block discarded – undo
1007 1007
 				 * @param array $entry Gravity Forms entry array
1008 1008
 				 * @param string $back_link URL to return to the original entry. @since 1.6
1009 1009
 				 */
1010
-				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );
1010
+				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link );
1011 1011
 
1012 1012
 				echo GVCommon::generate_notice( $message );
1013 1013
 			}
@@ -1031,21 +1031,21 @@  discard block
 block discarded – undo
1031 1031
 		 */
1032 1032
 		do_action( 'gravityview/edit-entry/render/before', $this );
1033 1033
 
1034
-		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );
1035
-		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );
1034
+		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 );
1035
+		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
1036 1036
 		add_filter( 'gform_disable_view_counter', '__return_true' );
1037 1037
 
1038 1038
 		add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 );
1039 1039
 		add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );
1040 1040
 
1041 1041
 		// We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.
1042
-		unset( $_GET['page'] );
1042
+		unset( $_GET[ 'page' ] );
1043 1043
 
1044 1044
 		// TODO: Verify multiple-page forms
1045 1045
 
1046 1046
 		ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic
1047 1047
 
1048
-		$html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );
1048
+		$html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry );
1049 1049
 
1050 1050
 		ob_get_clean();
1051 1051
 
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 	 * @return string
1072 1072
 	 */
1073 1073
 	public function render_form_buttons() {
1074
-		return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );
1074
+		return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this );
1075 1075
 	}
1076 1076
 
1077 1077
 
@@ -1091,10 +1091,10 @@  discard block
 block discarded – undo
1091 1091
 	public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) {
1092 1092
 
1093 1093
 		// In case we have validated the form, use it to inject the validation results into the form render
1094
-		if( isset( $this->form_after_validation ) ) {
1094
+		if ( isset( $this->form_after_validation ) ) {
1095 1095
 			$form = $this->form_after_validation;
1096 1096
 		} else {
1097
-			$form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );
1097
+			$form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id );
1098 1098
 		}
1099 1099
 
1100 1100
 		$form = $this->filter_conditional_logic( $form );
@@ -1102,8 +1102,8 @@  discard block
 block discarded – undo
1102 1102
 		$form = $this->prefill_conditional_logic( $form );
1103 1103
 
1104 1104
 		// for now we don't support Save and Continue feature.
1105
-		if( ! self::$supports_save_and_continue ) {
1106
-	        unset( $form['save'] );
1105
+		if ( ! self::$supports_save_and_continue ) {
1106
+	        unset( $form[ 'save' ] );
1107 1107
 		}
1108 1108
 
1109 1109
 		$form = $this->unselect_default_values( $form );
@@ -1126,31 +1126,31 @@  discard block
 block discarded – undo
1126 1126
 	 */
1127 1127
 	public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) {
1128 1128
 
1129
-		if( ! GFCommon::is_post_field( $field ) ) {
1129
+		if ( ! GFCommon::is_post_field( $field ) ) {
1130 1130
 			return $field_content;
1131 1131
 		}
1132 1132
 
1133 1133
         $message = null;
1134 1134
 
1135 1135
         // First, make sure they have the capability to edit the post.
1136
-        if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1136
+        if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) {
1137 1137
 
1138 1138
             /**
1139 1139
              * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1140 1140
              * @param string $message The existing "You don't have permission..." text
1141 1141
              */
1142
-            $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1142
+            $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don&rsquo;t have permission to edit this post.', 'gravityview' ) );
1143 1143
 
1144
-        } elseif( null === get_post( $this->entry['post_id'] ) ) {
1144
+        } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) {
1145 1145
             /**
1146 1146
              * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1147 1147
              * @param string $message The existing "This field is not editable; the post no longer exists." text
1148 1148
              */
1149
-            $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1149
+            $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) );
1150 1150
         }
1151 1151
 
1152
-        if( $message ) {
1153
-            $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1152
+        if ( $message ) {
1153
+            $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1154 1154
         }
1155 1155
 
1156 1156
         return $field_content;
@@ -1174,8 +1174,8 @@  discard block
 block discarded – undo
1174 1174
 
1175 1175
 		// If the form has been submitted, then we don't need to pre-fill the values,
1176 1176
 		// Except for fileupload type and when a field input is overridden- run always!!
1177
-		if(
1178
-			( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1177
+		if (
1178
+			( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1179 1179
 			&& false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) )
1180 1180
 			&& ! GFCommon::is_product_field( $field->type )
1181 1181
 			|| ! empty( $field_content )
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
 	    $return = null;
1196 1196
 
1197 1197
 		/** @var GravityView_Field $gv_field */
1198
-		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1198
+		if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1199 1199
 			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1200 1200
 		} else {
1201 1201
 	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
 	    // If there was output, it's an error
1205 1205
 	    $warnings = ob_get_clean();
1206 1206
 
1207
-	    if( !empty( $warnings ) ) {
1207
+	    if ( ! empty( $warnings ) ) {
1208 1208
 		    gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1209 1209
 	    }
1210 1210
 
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
 		$override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );
1230 1230
 
1231 1231
 		// We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)
1232
-		if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) {
1232
+		if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) {
1233 1233
 
1234 1234
 			$field_value = array();
1235 1235
 
@@ -1238,10 +1238,10 @@  discard block
 block discarded – undo
1238 1238
 
1239 1239
 			foreach ( (array)$field->inputs as $input ) {
1240 1240
 
1241
-				$input_id = strval( $input['id'] );
1241
+				$input_id = strval( $input[ 'id' ] );
1242 1242
 
1243 1243
 				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1244
-				    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1244
+				    $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1245 1245
 				    $allow_pre_populated = false;
1246 1246
 				}
1247 1247
 
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 
1250 1250
 			$pre_value = $field->get_value_submission( array(), false );
1251 1251
 
1252
-			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1252
+			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1253 1253
 
1254 1254
 		} else {
1255 1255
 
@@ -1260,13 +1260,13 @@  discard block
 block discarded – undo
1260 1260
 
1261 1261
 			// saved field entry value (if empty, fallback to the pre-populated value, if exists)
1262 1262
 			// or pre-populated value if not empty and set to override saved value
1263
-			$field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value;
1263
+			$field_value = isset( $this->entry[ $id ] ) && ! gv_empty( $this->entry[ $id ], false, false ) && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $this->entry[ $id ] : $pre_value;
1264 1264
 
1265 1265
 			// in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.
1266
-			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1266
+			if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) {
1267 1267
 				$categories = array();
1268 1268
 				foreach ( explode( ',', $field_value ) as $cat_string ) {
1269
-				    $categories[] = GFCommon::format_post_category( $cat_string, true );
1269
+				    $categories[ ] = GFCommon::format_post_category( $cat_string, true );
1270 1270
 				}
1271 1271
 				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1272 1272
 			}
@@ -1294,7 +1294,7 @@  discard block
 block discarded – undo
1294 1294
 	     * @param GF_Field $field Gravity Forms field object
1295 1295
 	     * @param GravityView_Edit_Entry_Render $this Current object
1296 1296
 	     */
1297
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1297
+	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this );
1298 1298
 
1299 1299
 		return $field_value;
1300 1300
 	}
@@ -1311,12 +1311,12 @@  discard block
 block discarded – undo
1311 1311
 	 */
1312 1312
 	public function gform_pre_validation( $form ) {
1313 1313
 
1314
-		if( ! $this->verify_nonce() ) {
1314
+		if ( ! $this->verify_nonce() ) {
1315 1315
 			return $form;
1316 1316
 		}
1317 1317
 
1318 1318
 		// Fix PHP warning regarding undefined index.
1319
-		foreach ( $form['fields'] as &$field) {
1319
+		foreach ( $form[ 'fields' ] as &$field ) {
1320 1320
 
1321 1321
 			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1322 1322
 			// expects certain field array items to be set.
@@ -1324,7 +1324,7 @@  discard block
 block discarded – undo
1324 1324
 	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1325 1325
 			}
1326 1326
 
1327
-			switch( RGFormsModel::get_input_type( $field ) ) {
1327
+			switch ( RGFormsModel::get_input_type( $field ) ) {
1328 1328
 
1329 1329
 				/**
1330 1330
 				 * this whole fileupload hack is because in the admin, Gravity Forms simply doesn't update any fileupload field if it's empty, but it DOES in the frontend.
@@ -1338,26 +1338,26 @@  discard block
 block discarded – undo
1338 1338
 				    // Set the previous value
1339 1339
 				    $entry = $this->get_entry();
1340 1340
 
1341
-				    $input_name = 'input_'.$field->id;
1342
-				    $form_id = $form['id'];
1341
+				    $input_name = 'input_' . $field->id;
1342
+				    $form_id = $form[ 'id' ];
1343 1343
 
1344 1344
 				    $value = NULL;
1345 1345
 
1346 1346
 				    // Use the previous entry value as the default.
1347
-				    if( isset( $entry[ $field->id ] ) ) {
1347
+				    if ( isset( $entry[ $field->id ] ) ) {
1348 1348
 				        $value = $entry[ $field->id ];
1349 1349
 				    }
1350 1350
 
1351 1351
 				    // If this is a single upload file
1352
-				    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1353
-				        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1354
-				        $value = $file_path['url'];
1352
+				    if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
1353
+				        $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] );
1354
+				        $value = $file_path[ 'url' ];
1355 1355
 
1356 1356
 				    } else {
1357 1357
 
1358 1358
 				        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1359 1359
 				        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1360
-				        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1360
+				        $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' );
1361 1361
 
1362 1362
 				    }
1363 1363
 
@@ -1365,10 +1365,10 @@  discard block
 block discarded – undo
1365 1365
 
1366 1366
 				        // If there are fresh uploads, process and merge them.
1367 1367
 				        // Otherwise, use the passed values, which should be json-encoded array of URLs
1368
-				        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1368
+				        if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) {
1369 1369
 				            $value = empty( $value ) ? '[]' : $value;
1370 1370
 				            $value = stripslashes_deep( $value );
1371
-				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1371
+				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() );
1372 1372
 				        }
1373 1373
 
1374 1374
 				    } else {
@@ -1386,8 +1386,8 @@  discard block
 block discarded – undo
1386 1386
 
1387 1387
 				case 'number':
1388 1388
 				    // Fix "undefined index" issue at line 1286 in form_display.php
1389
-				    if( !isset( $_POST['input_'.$field->id ] ) ) {
1390
-				        $_POST['input_'.$field->id ] = NULL;
1389
+				    if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) {
1390
+				        $_POST[ 'input_' . $field->id ] = NULL;
1391 1391
 				    }
1392 1392
 				    break;
1393 1393
 			}
@@ -1424,7 +1424,7 @@  discard block
 block discarded – undo
1424 1424
 		 * You can enter whatever you want!
1425 1425
 		 * We try validating, and customize the results using `self::custom_validation()`
1426 1426
 		 */
1427
-		add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);
1427
+		add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 );
1428 1428
 
1429 1429
 		// Needed by the validate funtion
1430 1430
 		$failed_validation_page = NULL;
@@ -1432,14 +1432,14 @@  discard block
 block discarded – undo
1432 1432
 
1433 1433
 		// Prevent entry limit from running when editing an entry, also
1434 1434
 		// prevent form scheduling from preventing editing
1435
-		unset( $this->form['limitEntries'], $this->form['scheduleForm'] );
1435
+		unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] );
1436 1436
 
1437 1437
 		// Hide fields depending on Edit Entry settings
1438
-		$this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1438
+		$this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1439 1439
 
1440 1440
 		$this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );
1441 1441
 
1442
-		remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 );
1442
+		remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 );
1443 1443
 	}
1444 1444
 
1445 1445
 
@@ -1462,7 +1462,7 @@  discard block
 block discarded – undo
1462 1462
 
1463 1463
 		$gv_valid = true;
1464 1464
 
1465
-		foreach ( $validation_results['form']['fields'] as $key => &$field ) {
1465
+		foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) {
1466 1466
 
1467 1467
 			$value = RGFormsModel::get_field_value( $field );
1468 1468
 			$field_type = RGFormsModel::get_input_type( $field );
@@ -1475,35 +1475,35 @@  discard block
 block discarded – undo
1475 1475
 				case 'post_image':
1476 1476
 
1477 1477
 				    // in case nothing is uploaded but there are already files saved
1478
-				    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1478
+				    if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) {
1479 1479
 				        $field->failed_validation = false;
1480 1480
 				        unset( $field->validation_message );
1481 1481
 				    }
1482 1482
 
1483 1483
 				    // validate if multi file upload reached max number of files [maxFiles] => 2
1484
-				    if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1484
+				    if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) {
1485 1485
 
1486 1486
 				        $input_name = 'input_' . $field->id;
1487 1487
 				        //uploaded
1488
-				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1488
+				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array();
1489 1489
 
1490 1490
 				        //existent
1491 1491
 				        $entry = $this->get_entry();
1492 1492
 				        $value = NULL;
1493
-				        if( isset( $entry[ $field->id ] ) ) {
1493
+				        if ( isset( $entry[ $field->id ] ) ) {
1494 1494
 				            $value = json_decode( $entry[ $field->id ], true );
1495 1495
 				        }
1496 1496
 
1497 1497
 				        // count uploaded files and existent entry files
1498 1498
 				        $count_files = count( $file_names ) + count( $value );
1499 1499
 
1500
-				        if( $count_files > $field->maxFiles ) {
1500
+				        if ( $count_files > $field->maxFiles ) {
1501 1501
 				            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1502 1502
 				            $field->failed_validation = 1;
1503 1503
 				            $gv_valid = false;
1504 1504
 
1505 1505
 				            // in case of error make sure the newest upload files are removed from the upload input
1506
-				            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1506
+				            GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null;
1507 1507
 				        }
1508 1508
 
1509 1509
 				    }
@@ -1514,7 +1514,7 @@  discard block
 block discarded – undo
1514 1514
 			}
1515 1515
 
1516 1516
 			// This field has failed validation.
1517
-			if( !empty( $field->failed_validation ) ) {
1517
+			if ( ! empty( $field->failed_validation ) ) {
1518 1518
 
1519 1519
 				gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) );
1520 1520
 
@@ -1532,19 +1532,19 @@  discard block
 block discarded – undo
1532 1532
 				}
1533 1533
 
1534 1534
 				// You can't continue inside a switch, so we do it after.
1535
-				if( empty( $field->failed_validation ) ) {
1535
+				if ( empty( $field->failed_validation ) ) {
1536 1536
 				    continue;
1537 1537
 				}
1538 1538
 
1539 1539
 				// checks if the No Duplicates option is not validating entry against itself, since
1540 1540
 				// we're editing a stored entry, it would also assume it's a duplicate.
1541
-				if( !empty( $field->noDuplicates ) ) {
1541
+				if ( ! empty( $field->noDuplicates ) ) {
1542 1542
 
1543 1543
 				    $entry = $this->get_entry();
1544 1544
 
1545 1545
 				    // If the value of the entry is the same as the stored value
1546 1546
 				    // Then we can assume it's not a duplicate, it's the same.
1547
-				    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1547
+				    if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) {
1548 1548
 				        //if value submitted was not changed, then don't validate
1549 1549
 				        $field->failed_validation = false;
1550 1550
 
@@ -1557,7 +1557,7 @@  discard block
 block discarded – undo
1557 1557
 				}
1558 1558
 
1559 1559
 				// if here then probably we are facing the validation 'At least one field must be filled out'
1560
-				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1560
+				if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) {
1561 1561
 				    unset( $field->validation_message );
1562 1562
 	                $field->validation_message = false;
1563 1563
 				    continue;
@@ -1569,12 +1569,12 @@  discard block
 block discarded – undo
1569 1569
 
1570 1570
 		}
1571 1571
 
1572
-		$validation_results['is_valid'] = $gv_valid;
1572
+		$validation_results[ 'is_valid' ] = $gv_valid;
1573 1573
 
1574 1574
 		gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) );
1575 1575
 
1576 1576
 		// We'll need this result when rendering the form ( on GFFormDisplay::get_form )
1577
-		$this->form_after_validation = $validation_results['form'];
1577
+		$this->form_after_validation = $validation_results[ 'form' ];
1578 1578
 
1579 1579
 		return $validation_results;
1580 1580
 	}
@@ -1587,7 +1587,7 @@  discard block
 block discarded – undo
1587 1587
 	 */
1588 1588
 	public function get_entry() {
1589 1589
 
1590
-		if( empty( $this->entry ) ) {
1590
+		if ( empty( $this->entry ) ) {
1591 1591
 			// Get the database value of the entry that's being edited
1592 1592
 			$this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );
1593 1593
 		}
@@ -1619,10 +1619,10 @@  discard block
 block discarded – undo
1619 1619
 		}
1620 1620
 
1621 1621
 		// If edit tab not yet configured, show all fields
1622
-		$edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;
1622
+		$edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL;
1623 1623
 
1624 1624
 		// Hide fields depending on admin settings
1625
-		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1625
+		$fields = $this->filter_fields( $form[ 'fields' ], $edit_fields );
1626 1626
 
1627 1627
 	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1628 1628
 	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
@@ -1654,7 +1654,7 @@  discard block
 block discarded – undo
1654 1654
 	 */
1655 1655
 	private function filter_fields( $fields, $configured_fields ) {
1656 1656
 
1657
-		if( empty( $fields ) || !is_array( $fields ) ) {
1657
+		if ( empty( $fields ) || ! is_array( $fields ) ) {
1658 1658
 			return $fields;
1659 1659
 		}
1660 1660
 
@@ -1667,18 +1667,18 @@  discard block
 block discarded – undo
1667 1667
 
1668 1668
 			// Remove the fields that have calculation properties and keep them to be used later
1669 1669
 			// @since 1.16.2
1670
-			if( $field->has_calculation() ) {
1671
-				$this->fields_with_calculation[] = $field;
1670
+			if ( $field->has_calculation() ) {
1671
+				$this->fields_with_calculation[ ] = $field;
1672 1672
 				// don't remove the calculation fields on form render.
1673 1673
 			}
1674 1674
 
1675
-			if( in_array( $field->type, $field_type_blacklist ) ) {
1675
+			if ( in_array( $field->type, $field_type_blacklist ) ) {
1676 1676
 				unset( $fields[ $key ] );
1677 1677
 			}
1678 1678
 		}
1679 1679
 
1680 1680
 		// The Edit tab has not been configured, so we return all fields by default.
1681
-		if( empty( $configured_fields ) ) {
1681
+		if ( empty( $configured_fields ) ) {
1682 1682
 			return array_values( $fields );
1683 1683
 		}
1684 1684
 
@@ -1687,8 +1687,8 @@  discard block
 block discarded – undo
1687 1687
 
1688 1688
 	        /** @var GF_Field $field */
1689 1689
 	        foreach ( $fields as $field ) {
1690
-				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1691
-				    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1690
+				if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1691
+				    $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field );
1692 1692
 				    break;
1693 1693
 				}
1694 1694
 
@@ -1711,14 +1711,14 @@  discard block
 block discarded – undo
1711 1711
 
1712 1712
 		$return_field = $field;
1713 1713
 
1714
-		if( empty( $field_setting['show_label'] ) ) {
1714
+		if ( empty( $field_setting[ 'show_label' ] ) ) {
1715 1715
 			$return_field->label = '';
1716
-		} elseif ( !empty( $field_setting['custom_label'] ) ) {
1717
-			$return_field->label = $field_setting['custom_label'];
1716
+		} elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) {
1717
+			$return_field->label = $field_setting[ 'custom_label' ];
1718 1718
 		}
1719 1719
 
1720
-		if( !empty( $field_setting['custom_class'] ) ) {
1721
-			$return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );
1720
+		if ( ! empty( $field_setting[ 'custom_class' ] ) ) {
1721
+			$return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] );
1722 1722
 		}
1723 1723
 
1724 1724
 		/**
@@ -1756,16 +1756,16 @@  discard block
 block discarded – undo
1756 1756
 	     */
1757 1757
 	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1758 1758
 
1759
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1760
-			foreach( $fields as $k => $field ) {
1761
-				if( $field->adminOnly ) {
1759
+	    if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) {
1760
+			foreach ( $fields as $k => $field ) {
1761
+				if ( $field->adminOnly ) {
1762 1762
 				    unset( $fields[ $k ] );
1763 1763
 				}
1764 1764
 			}
1765 1765
 			return array_values( $fields );
1766 1766
 		}
1767 1767
 
1768
-	    foreach( $fields as &$field ) {
1768
+	    foreach ( $fields as &$field ) {
1769 1769
 		    $field->adminOnly = false;
1770 1770
 		}
1771 1771
 
@@ -1786,7 +1786,7 @@  discard block
 block discarded – undo
1786 1786
 	 */
1787 1787
 	private function unselect_default_values( $form ) {
1788 1788
 
1789
-	    foreach ( $form['fields'] as &$field ) {
1789
+	    foreach ( $form[ 'fields' ] as &$field ) {
1790 1790
 
1791 1791
 			if ( empty( $field->choices ) ) {
1792 1792
                 continue;
@@ -1794,7 +1794,7 @@  discard block
 block discarded – undo
1794 1794
 
1795 1795
             foreach ( $field->choices as &$choice ) {
1796 1796
 				if ( \GV\Utils::get( $choice, 'isSelected' ) ) {
1797
-					$choice['isSelected'] = false;
1797
+					$choice[ 'isSelected' ] = false;
1798 1798
 				}
1799 1799
 			}
1800 1800
 		}
@@ -1819,22 +1819,22 @@  discard block
 block discarded – undo
1819 1819
 	 */
1820 1820
 	function prefill_conditional_logic( $form ) {
1821 1821
 
1822
-		if( ! GFFormDisplay::has_conditional_logic( $form ) ) {
1822
+		if ( ! GFFormDisplay::has_conditional_logic( $form ) ) {
1823 1823
 			return $form;
1824 1824
 		}
1825 1825
 
1826 1826
 		// Have Conditional Logic pre-fill fields as if the data were default values
1827 1827
 		/** @var GF_Field $field */
1828
-		foreach ( $form['fields'] as &$field ) {
1828
+		foreach ( $form[ 'fields' ] as &$field ) {
1829 1829
 
1830
-			if( 'checkbox' === $field->type ) {
1830
+			if ( 'checkbox' === $field->type ) {
1831 1831
 				foreach ( $field->get_entry_inputs() as $key => $input ) {
1832
-				    $input_id = $input['id'];
1832
+				    $input_id = $input[ 'id' ];
1833 1833
 				    $choice = $field->choices[ $key ];
1834 1834
 				    $value = \GV\Utils::get( $this->entry, $input_id );
1835 1835
 				    $match = RGFormsModel::choice_value_match( $field, $choice, $value );
1836
-				    if( $match ) {
1837
-				        $field->choices[ $key ]['isSelected'] = true;
1836
+				    if ( $match ) {
1837
+				        $field->choices[ $key ][ 'isSelected' ] = true;
1838 1838
 				    }
1839 1839
 				}
1840 1840
 			} else {
@@ -1842,15 +1842,15 @@  discard block
 block discarded – undo
1842 1842
 				// We need to run through each field to set the default values
1843 1843
 				foreach ( $this->entry as $field_id => $field_value ) {
1844 1844
 
1845
-				    if( floatval( $field_id ) === floatval( $field->id ) ) {
1845
+				    if ( floatval( $field_id ) === floatval( $field->id ) ) {
1846 1846
 
1847
-				        if( 'list' === $field->type ) {
1847
+				        if ( 'list' === $field->type ) {
1848 1848
 				            $list_rows = maybe_unserialize( $field_value );
1849 1849
 
1850 1850
 				            $list_field_value = array();
1851
-				            foreach ( (array) $list_rows as $row ) {
1852
-				                foreach ( (array) $row as $column ) {
1853
-				                    $list_field_value[] = $column;
1851
+				            foreach ( (array)$list_rows as $row ) {
1852
+				                foreach ( (array)$row as $column ) {
1853
+				                    $list_field_value[ ] = $column;
1854 1854
 				                }
1855 1855
 				            }
1856 1856
 
@@ -1885,16 +1885,16 @@  discard block
 block discarded – undo
1885 1885
 		 */
1886 1886
 		$use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );
1887 1887
 
1888
-		if( $use_conditional_logic ) {
1888
+		if ( $use_conditional_logic ) {
1889 1889
 			return $form;
1890 1890
 		}
1891 1891
 
1892
-		foreach( $form['fields'] as &$field ) {
1892
+		foreach ( $form[ 'fields' ] as &$field ) {
1893 1893
 			/* @var GF_Field $field */
1894 1894
 			$field->conditionalLogic = null;
1895 1895
 		}
1896 1896
 
1897
-		unset( $form['button']['conditionalLogic'] );
1897
+		unset( $form[ 'button' ][ 'conditionalLogic' ] );
1898 1898
 
1899 1899
 		return $form;
1900 1900
 
@@ -1911,7 +1911,7 @@  discard block
 block discarded – undo
1911 1911
 	 */
1912 1912
 	public function manage_conditional_logic( $has_conditional_logic, $form ) {
1913 1913
 
1914
-		if( ! $this->is_edit_entry() ) {
1914
+		if ( ! $this->is_edit_entry() ) {
1915 1915
 			return $has_conditional_logic;
1916 1916
 		}
1917 1917
 
@@ -1943,44 +1943,44 @@  discard block
 block discarded – undo
1943 1943
 		 *  2. There are two entries embedded using oEmbed
1944 1944
 		 *  3. One of the entries has just been saved
1945 1945
 		 */
1946
-		if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) {
1946
+		if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) {
1947 1947
 
1948 1948
 			$error = true;
1949 1949
 
1950 1950
 		}
1951 1951
 
1952
-		if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) {
1952
+		if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) {
1953 1953
 
1954 1954
 			$error = true;
1955 1955
 
1956
-		} elseif( ! $this->verify_nonce() ) {
1956
+		} elseif ( ! $this->verify_nonce() ) {
1957 1957
 
1958 1958
 			/**
1959 1959
 			 * If the Entry is embedded, there may be two entries on the same page.
1960 1960
 			 * If that's the case, and one is being edited, the other should fail gracefully and not display an error.
1961 1961
 			 */
1962
-			if( GravityView_oEmbed::getInstance()->get_entry_id() ) {
1962
+			if ( GravityView_oEmbed::getInstance()->get_entry_id() ) {
1963 1963
 				$error = true;
1964 1964
 			} else {
1965
-				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');
1965
+				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' );
1966 1966
 			}
1967 1967
 
1968 1968
 		}
1969 1969
 
1970
-		if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
1971
-			$error = __( 'You do not have permission to edit this entry.', 'gravityview');
1970
+		if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
1971
+			$error = __( 'You do not have permission to edit this entry.', 'gravityview' );
1972 1972
 		}
1973 1973
 
1974
-		if( $this->entry['status'] === 'trash' ) {
1975
-			$error = __('You cannot edit the entry; it is in the trash.', 'gravityview' );
1974
+		if ( $this->entry[ 'status' ] === 'trash' ) {
1975
+			$error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' );
1976 1976
 		}
1977 1977
 
1978 1978
 		// No errors; everything's fine here!
1979
-		if( empty( $error ) ) {
1979
+		if ( empty( $error ) ) {
1980 1980
 			return true;
1981 1981
 		}
1982 1982
 
1983
-		if( $echo && $error !== true ) {
1983
+		if ( $echo && $error !== true ) {
1984 1984
 
1985 1985
 	        $error = esc_html( $error );
1986 1986
 
@@ -1988,10 +1988,10 @@  discard block
 block discarded – undo
1988 1988
 	         * @since 1.9
1989 1989
 	         */
1990 1990
 	        if ( ! empty( $this->entry ) ) {
1991
-		        $error .= ' ' . gravityview_get_link( '#', _x('Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) );
1991
+		        $error .= ' ' . gravityview_get_link( '#', _x( 'Go back.', 'Link shown when invalid Edit Entry link is clicked', 'gravityview' ), array( 'onclick' => "window.history.go(-1); return false;" ) );
1992 1992
 	        }
1993 1993
 
1994
-			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
1994
+			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' );
1995 1995
 		}
1996 1996
 
1997 1997
 		gravityview()->log->error( '{error}', array( 'error' => $error ) );
@@ -2011,17 +2011,17 @@  discard block
 block discarded – undo
2011 2011
 
2012 2012
 		$error = NULL;
2013 2013
 
2014
-		if( ! $this->check_user_cap_edit_field( $field ) ) {
2015
-			$error = __( 'You do not have permission to edit this field.', 'gravityview');
2014
+		if ( ! $this->check_user_cap_edit_field( $field ) ) {
2015
+			$error = __( 'You do not have permission to edit this field.', 'gravityview' );
2016 2016
 		}
2017 2017
 
2018 2018
 		// No errors; everything's fine here!
2019
-		if( empty( $error ) ) {
2019
+		if ( empty( $error ) ) {
2020 2020
 			return true;
2021 2021
 		}
2022 2022
 
2023
-		if( $echo ) {
2024
-			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');
2023
+		if ( $echo ) {
2024
+			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' );
2025 2025
 		}
2026 2026
 
2027 2027
 		gravityview()->log->error( '{error}', array( 'error' => $error ) );
@@ -2042,14 +2042,14 @@  discard block
 block discarded – undo
2042 2042
 	private function check_user_cap_edit_field( $field ) {
2043 2043
 
2044 2044
 		// If they can edit any entries (as defined in Gravity Forms), we're good.
2045
-		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
2045
+		if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
2046 2046
 			return true;
2047 2047
 		}
2048 2048
 
2049
-		$field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;
2049
+		$field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false;
2050 2050
 
2051
-		if( $field_cap ) {
2052
-			return GVCommon::has_cap( $field['allow_edit_cap'] );
2051
+		if ( $field_cap ) {
2052
+			return GVCommon::has_cap( $field[ 'allow_edit_cap' ] );
2053 2053
 		}
2054 2054
 
2055 2055
 		return false;
@@ -2063,17 +2063,17 @@  discard block
 block discarded – undo
2063 2063
 	public function verify_nonce() {
2064 2064
 
2065 2065
 		// Verify form submitted for editing single
2066
-		if( $this->is_edit_entry_submission() ) {
2066
+		if ( $this->is_edit_entry_submission() ) {
2067 2067
 			$valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );
2068 2068
 		}
2069 2069
 
2070 2070
 		// Verify
2071
-		else if( ! $this->is_edit_entry() ) {
2071
+		else if ( ! $this->is_edit_entry() ) {
2072 2072
 			$valid = false;
2073 2073
 		}
2074 2074
 
2075 2075
 		else {
2076
-			$valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
2076
+			$valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key );
2077 2077
 		}
2078 2078
 
2079 2079
 		/**
Please login to merge, or discard this patch.
Braces   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -573,7 +573,8 @@  discard block
 block discarded – undo
573 573
 
574 574
 							// Only allow quantity to be set if it's allowed to be edited
575 575
 							if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) {
576
-							} else { // otherwise set to what it previously was
576
+							} else {
577
+// otherwise set to what it previously was
577 578
 								$_POST[ $input_name ] = $entry[ $input['id'] ];
578 579
 							}
579 580
 						} else {
@@ -958,7 +959,7 @@  discard block
 block discarded – undo
958 959
 
959 960
 			$back_link = remove_query_arg( array( 'page', 'view', 'edit' ) );
960 961
 
961
-			if( ! $this->is_valid ){
962
+			if( ! $this->is_valid ) {
962 963
 
963 964
 				// Keeping this compatible with Gravity Forms.
964 965
 				$validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
@@ -2070,9 +2071,7 @@  discard block
 block discarded – undo
2070 2071
 		// Verify
2071 2072
 		else if( ! $this->is_edit_entry() ) {
2072 2073
 			$valid = false;
2073
-		}
2074
-
2075
-		else {
2074
+		} else {
2076 2075
 			$valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
2077 2076
 		}
2078 2077
 
Please login to merge, or discard this patch.