Completed
Pull Request — develop (#1366)
by
unknown
15:22
created
includes/extensions/edit-entry/class-edit-entry-render.php 1 patch
Spacing   +236 added lines, -236 removed lines patch added patch discarded remove patch
@@ -134,16 +134,16 @@  discard block
 block discarded – undo
134 134
 	function load() {
135 135
 
136 136
 		/** @define "GRAVITYVIEW_DIR" "../../../" */
137
-		include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' );
137
+		include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' );
138 138
 
139 139
 		// Don't display an embedded form when editing an entry
140 140
 		add_action( 'wp_head', array( $this, 'prevent_render_form' ) );
141 141
 		add_action( 'wp_footer', array( $this, 'prevent_render_form' ) );
142 142
 
143 143
 		// Stop Gravity Forms processing what is ours!
144
-		add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 );
144
+		add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 );
145 145
 
146
-		add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') );
146
+		add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) );
147 147
 
148 148
 		add_action( 'gravityview_edit_entry', array( $this, 'init' ), 10, 4 );
149 149
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 		add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 );
155 155
 
156 156
 		// Add fields expected by GFFormDisplay::validate()
157
-		add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') );
157
+		add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) );
158 158
 
159 159
 		// Fix multiselect value for GF 2.2
160 160
 		add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 );
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 * @return void
172 172
 	 */
173 173
 	public function prevent_render_form() {
174
-		if( $this->is_edit_entry() ) {
175
-			if( 'wp_head' === current_filter() ) {
174
+		if ( $this->is_edit_entry() ) {
175
+			if ( 'wp_head' === current_filter() ) {
176 176
 				add_filter( 'gform_shortcode_form', '__return_empty_string' );
177 177
 			} else {
178 178
 				remove_filter( 'gform_shortcode_form', '__return_empty_string' );
@@ -187,14 +187,14 @@  discard block
 block discarded – undo
187 187
 	 */
188 188
 	public function prevent_maybe_process_form() {
189 189
 
190
-	    if( ! $this->is_edit_entry_submission() ) {
190
+	    if ( ! $this->is_edit_entry_submission() ) {
191 191
 			return;
192 192
 		}
193 193
 
194 194
 		gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] Removing GFForms::maybe_process_form() action.' );
195 195
 
196
-		remove_action( 'wp',  array( 'RGForms', 'maybe_process_form'), 9 );
197
-		remove_action( 'wp',  array( 'GFForms', 'maybe_process_form'), 9 );
196
+		remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 );
197
+		remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 );
198 198
 	}
199 199
 
200 200
 	/**
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 */
204 204
 	public function is_edit_entry() {
205 205
 
206
-		$is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] );
206
+		$is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] );
207 207
 
208 208
 		return ( $is_edit_entry || $this->is_edit_entry_submission() );
209 209
 	}
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 * @return boolean
215 215
 	 */
216 216
 	public function is_edit_entry_submission() {
217
-		return !empty( $_POST[ self::$nonce_field ] );
217
+		return ! empty( $_POST[ self::$nonce_field ] );
218 218
 	}
219 219
 
220 220
 	/**
@@ -227,16 +227,16 @@  discard block
 block discarded – undo
227 227
 
228 228
 
229 229
 		$entries = $gravityview_view->getEntries();
230
-	    self::$original_entry = $entries[0];
231
-	    $this->entry = $entries[0];
230
+	    self::$original_entry = $entries[ 0 ];
231
+	    $this->entry = $entries[ 0 ];
232 232
 
233 233
 		self::$original_form = $gravityview_view->getForm();
234 234
 		$this->form = $gravityview_view->getForm();
235
-		$this->form_id = $this->entry['form_id'];
235
+		$this->form_id = $this->entry[ 'form_id' ];
236 236
 		$this->view_id = $gravityview_view->getViewId();
237 237
 		$this->post_id = \GV\Utils::get( $post, 'ID', null );
238 238
 
239
-		self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] );
239
+		self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] );
240 240
 	}
241 241
 
242 242
 
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
 	private function print_scripts() {
296 296
 		$gravityview_view = GravityView_View::getInstance();
297 297
 
298
-		wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
298
+		wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
299 299
 
300
-		GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false);
300
+		GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false );
301 301
 
302 302
 		wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) );
303 303
 
@@ -313,19 +313,19 @@  discard block
 block discarded – undo
313 313
 	 */
314 314
 	private function process_save( $gv_data ) {
315 315
 
316
-		if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) {
316
+		if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) {
317 317
 			return;
318 318
 		}
319 319
 
320 320
 		// Make sure the entry, view, and form IDs are all correct
321 321
 		$valid = $this->verify_nonce();
322 322
 
323
-		if ( !$valid ) {
323
+		if ( ! $valid ) {
324 324
 			gravityview()->log->error( 'Nonce validation failed.' );
325 325
 			return;
326 326
 		}
327 327
 
328
-		if ( $this->entry['id'] !== $_POST['lid'] ) {
328
+		if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) {
329 329
 			gravityview()->log->error( 'Entry ID did not match posted entry ID.' );
330 330
 			return;
331 331
 		}
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
 		$this->validate();
338 338
 
339
-		if( $this->is_valid ) {
339
+		if ( $this->is_valid ) {
340 340
 
341 341
 			gravityview()->log->debug( 'Submission is valid.' );
342 342
 
@@ -348,15 +348,15 @@  discard block
 block discarded – undo
348 348
 			/**
349 349
 			 * @hack to avoid the capability validation of the method save_lead for GF 1.9+
350 350
 			 */
351
-			unset( $_GET['page'] );
351
+			unset( $_GET[ 'page' ] );
352 352
 
353
-			$date_created = $this->entry['date_created'];
353
+			$date_created = $this->entry[ 'date_created' ];
354 354
 
355 355
 			/**
356 356
 			 * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead()
357 357
 			 * @since 1.17.2
358 358
 			 */
359
-			unset( $this->entry['date_created'] );
359
+			unset( $this->entry[ 'date_created' ] );
360 360
 
361 361
 			/**
362 362
 			 * @action `gravityview/edit_entry/before_update` Perform an action after the entry has been updated using Edit Entry
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
 			 * @param GravityView_Edit_Entry_Render $this This object
367 367
 			 * @param GravityView_View_Data $gv_data The View data
368 368
 			 */
369
-			do_action( 'gravityview/edit_entry/before_update', $form, $this->entry['id'], $this, $gv_data );
369
+			do_action( 'gravityview/edit_entry/before_update', $form, $this->entry[ 'id' ], $this, $gv_data );
370 370
 
371 371
 			GFFormsModel::save_lead( $form, $this->entry );
372 372
 
373 373
 	        // Delete the values for hidden inputs
374 374
 	        $this->unset_hidden_field_values();
375 375
 			
376
-			$this->entry['date_created'] = $date_created;
376
+			$this->entry[ 'date_created' ] = $date_created;
377 377
 
378 378
 			// Process calculation fields
379 379
 			$this->update_calculation_fields();
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 			 * @param GravityView_Edit_Entry_Render $this This object
396 396
 			 * @param GravityView_View_Data $gv_data The View data
397 397
 			 */
398
-			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data );
398
+			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data );
399 399
 
400 400
 		} else {
401 401
 			gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) );
@@ -425,16 +425,16 @@  discard block
 block discarded – undo
425 425
 
426 426
 		$this->unset_hidden_calculations = array();
427 427
 
428
-		if( ! $unset_hidden_field_values ) {
428
+		if ( ! $unset_hidden_field_values ) {
429 429
 			return;
430 430
 		}
431 431
 
432 432
 		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
433 433
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
434
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) );
434
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) );
435 435
 		} else {
436 436
 			$lead_detail_table = GFFormsModel::get_lead_details_table_name();
437
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );
437
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) );
438 438
 		}
439 439
 
440 440
 	    foreach ( $this->entry as $input_id => $field_value ) {
@@ -451,11 +451,11 @@  discard block
 block discarded – undo
451 451
 
452 452
 				$empty_value = $field->get_value_save_entry(
453 453
 					is_array( $field->get_entry_inputs() ) ? array() : '',
454
-					$this->form, '', $this->entry['id'], $this->entry
454
+					$this->form, '', $this->entry[ 'id' ], $this->entry
455 455
 				);
456 456
 
457 457
 				if ( $field->has_calculation() ) {
458
-					$this->unset_hidden_calculations[] = $field->id; // Unset
458
+					$this->unset_hidden_calculations[ ] = $field->id; // Unset
459 459
 					$empty_value = '';
460 460
 				}
461 461
 
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 		}
527 527
 
528 528
 		/** No file is being uploaded. */
529
-		if ( empty( $_FILES[ $input_name ]['name'] ) ) {
529
+		if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) {
530 530
 			/** So return the original upload */
531 531
 			return $entry[ $input_id ];
532 532
 		}
@@ -544,11 +544,11 @@  discard block
 block discarded – undo
544 544
 	 * @return mixed
545 545
 	 */
546 546
 	public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) {
547
-		if( ! $this->is_edit_entry() ) {
547
+		if ( ! $this->is_edit_entry() ) {
548 548
 			return $plupload_init;
549 549
 		}
550 550
 
551
-		$plupload_init['gf_vars']['max_files'] = 0;
551
+		$plupload_init[ 'gf_vars' ][ 'max_files' ] = 0;
552 552
 
553 553
 		return $plupload_init;
554 554
 	}
@@ -563,27 +563,27 @@  discard block
 block discarded – undo
563 563
 		$form = $this->filter_conditional_logic( $this->form );
564 564
 
565 565
 	    /** @var GF_Field $field */
566
-		foreach( $form['fields'] as $k => &$field ) {
566
+		foreach ( $form[ 'fields' ] as $k => &$field ) {
567 567
 
568 568
 			/**
569 569
 			 * Remove the fields with calculation formulas before save to avoid conflicts with GF logic
570 570
 			 * @since 1.16.3
571 571
 			 * @var GF_Field $field
572 572
 			 */
573
-			if( $field->has_calculation() ) {
574
-				unset( $form['fields'][ $k ] );
573
+			if ( $field->has_calculation() ) {
574
+				unset( $form[ 'fields' ][ $k ] );
575 575
 			}
576 576
 
577 577
 			$field->adminOnly = false;
578 578
 
579
-			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
580
-				foreach( $field->inputs as $key => $input ) {
581
-				    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
579
+			if ( isset( $field->inputs ) && is_array( $field->inputs ) ) {
580
+				foreach ( $field->inputs as $key => $input ) {
581
+				    $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ];
582 582
 				}
583 583
 			}
584 584
 		}
585 585
 
586
-		$form['fields'] = array_values( $form['fields'] );
586
+		$form[ 'fields' ] = array_values( $form[ 'fields' ] );
587 587
 
588 588
 		return $form;
589 589
 	}
@@ -595,14 +595,14 @@  discard block
 block discarded – undo
595 595
 		$update = false;
596 596
 
597 597
 		// get the most up to date entry values
598
-		$entry = GFAPI::get_entry( $this->entry['id'] );
598
+		$entry = GFAPI::get_entry( $this->entry[ 'id' ] );
599 599
 
600 600
 		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
601 601
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
602
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) );
602
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) );
603 603
 		} else {
604 604
 			$lead_detail_table = GFFormsModel::get_lead_details_table_name();
605
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) );
605
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) );
606 606
 		}
607 607
 
608 608
 
@@ -619,24 +619,24 @@  discard block
 block discarded – undo
619 619
 				$inputs = $field->get_entry_inputs();
620 620
 				if ( is_array( $inputs ) ) {
621 621
 				    foreach ( $inputs as $input ) {
622
-						list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 );
622
+						list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 );
623 623
 
624 624
 						if ( 'product' === $field->type ) {
625
-							$input_name = 'input_' . str_replace( '.', '_', $input['id'] );
625
+							$input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] );
626 626
 
627 627
 							// Only allow quantity to be set if it's allowed to be edited
628 628
 							if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) {
629 629
 							} else { // otherwise set to what it previously was
630
-								$_POST[ $input_name ] = $entry[ $input['id'] ];
630
+								$_POST[ $input_name ] = $entry[ $input[ 'id' ] ];
631 631
 							}
632 632
 						} else {
633 633
 							// Set to what it previously was if it's not editable
634 634
 							if ( ! in_array( $field_id, $allowed_fields ) ) {
635
-								$_POST[ $input_name ] = $entry[ $input['id'] ];
635
+								$_POST[ $input_name ] = $entry[ $input[ 'id' ] ];
636 636
 							}
637 637
 						}
638 638
 
639
-						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] );
639
+						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] );
640 640
 				    }
641 641
 				} else {
642 642
 					// Set to what it previously was if it's not editable
@@ -676,19 +676,19 @@  discard block
 block discarded – undo
676 676
 
677 677
 		$input_name = 'input_' . $field_id;
678 678
 
679
-		if ( !empty( $_FILES[ $input_name ]['name'] ) ) {
679
+		if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
680 680
 
681 681
 			// We have a new image
682 682
 
683
-			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
683
+			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] );
684 684
 
685 685
 			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
686 686
 	        $ary = stripslashes_deep( $ary );
687 687
 			$img_url = \GV\Utils::get( $ary, 0 );
688 688
 
689
-			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
690
-			$img_caption     = count( $ary ) > 2 ? $ary[2] : '';
691
-			$img_description = count( $ary ) > 3 ? $ary[3] : '';
689
+			$img_title       = count( $ary ) > 1 ? $ary[ 1 ] : '';
690
+			$img_caption     = count( $ary ) > 2 ? $ary[ 2 ] : '';
691
+			$img_description = count( $ary ) > 3 ? $ary[ 3 ] : '';
692 692
 
693 693
 			$image_meta = array(
694 694
 				'post_excerpt' => $img_caption,
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 
698 698
 			//adding title only if it is not empty. It will default to the file name if it is not in the array
699 699
 			if ( ! empty( $img_title ) ) {
700
-				$image_meta['post_title'] = $img_title;
700
+				$image_meta[ 'post_title' ] = $img_title;
701 701
 			}
702 702
 
703 703
 			/**
@@ -755,15 +755,15 @@  discard block
 block discarded – undo
755 755
 	 */
756 756
 	private function maybe_update_post_fields( $form ) {
757 757
 
758
-		if( empty( $this->entry['post_id'] ) ) {
758
+		if ( empty( $this->entry[ 'post_id' ] ) ) {
759 759
 	        gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
760 760
 			return;
761 761
 		}
762 762
 
763
-		$post_id = $this->entry['post_id'];
763
+		$post_id = $this->entry[ 'post_id' ];
764 764
 
765 765
 		// Security check
766
-		if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
766
+		if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
767 767
 			gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) );
768 768
 			return;
769 769
 		}
@@ -776,25 +776,25 @@  discard block
 block discarded – undo
776 776
 
777 777
 			$field = RGFormsModel::get_field( $form, $field_id );
778 778
 
779
-			if( ! $field ) {
779
+			if ( ! $field ) {
780 780
 				continue;
781 781
 			}
782 782
 
783
-			if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
783
+			if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
784 784
 
785 785
 				// Get the value of the field, including $_POSTed value
786 786
 				$value = RGFormsModel::get_field_value( $field );
787 787
 
788 788
 				// Use temporary entry variable, to make values available to fill_post_template() and update_post_image()
789 789
 				$entry_tmp = $this->entry;
790
-				$entry_tmp["{$field_id}"] = $value;
790
+				$entry_tmp[ "{$field_id}" ] = $value;
791 791
 
792
-				switch( $field->type ) {
792
+				switch ( $field->type ) {
793 793
 
794 794
 				    case 'post_title':
795 795
 				        $post_title = $value;
796 796
 				        if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
797
-				            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
797
+				            $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp );
798 798
 				        }
799 799
 				        $updated_post->post_title = $post_title;
800 800
 				        $updated_post->post_name  = $post_title;
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 				    case 'post_content':
805 805
 				        $post_content = $value;
806 806
 				        if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
807
-				            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
807
+				            $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true );
808 808
 				        }
809 809
 				        $updated_post->post_content = $post_content;
810 810
 				        unset( $post_content );
@@ -822,11 +822,11 @@  discard block
 block discarded – undo
822 822
 							$value = $value[ $field_id ];
823 823
 						}
824 824
 
825
-				        if( ! empty( $field->customFieldTemplateEnabled ) ) {
825
+				        if ( ! empty( $field->customFieldTemplateEnabled ) ) {
826 826
 				            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
827 827
 				        }
828 828
 
829
-						$value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry );
829
+						$value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry );
830 830
 
831 831
 				        update_post_meta( $post_id, $field->postCustomFieldName, $value );
832 832
 				        break;
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 				}
839 839
 
840 840
 				// update entry after
841
-				$this->entry["{$field_id}"] = $value;
841
+				$this->entry[ "{$field_id}" ] = $value;
842 842
 
843 843
 				$update_entry = true;
844 844
 
@@ -847,11 +847,11 @@  discard block
 block discarded – undo
847 847
 
848 848
 		}
849 849
 
850
-		if( $update_entry ) {
850
+		if ( $update_entry ) {
851 851
 
852 852
 			$return_entry = GFAPI::update_entry( $this->entry );
853 853
 
854
-			if( is_wp_error( $return_entry ) ) {
854
+			if ( is_wp_error( $return_entry ) ) {
855 855
 				gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) );
856 856
 			} else {
857 857
 				gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) );
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 
862 862
 		$return_post = wp_update_post( $updated_post, true );
863 863
 
864
-		if( is_wp_error( $return_post ) ) {
864
+		if ( is_wp_error( $return_post ) ) {
865 865
 			$return_post->add_data( $updated_post, '$updated_post' );
866 866
 			gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) );
867 867
 		} else {
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 		$output = GFCommon::replace_variables( $output, $form, $entry, false, false, false );
896 896
 
897 897
 		// replace conditional shortcodes
898
-		if( $do_shortcode ) {
898
+		if ( $do_shortcode ) {
899 899
 			$output = do_shortcode( $output );
900 900
 		}
901 901
 
@@ -914,19 +914,19 @@  discard block
 block discarded – undo
914 914
 	 */
915 915
 	private function after_update() {
916 916
 
917
-		do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry );
918
-		do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry );
917
+		do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry );
918
+		do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry );
919 919
 
920 920
 		// Re-define the entry now that we've updated it.
921
-		$entry = RGFormsModel::get_lead( $this->entry['id'] );
921
+		$entry = RGFormsModel::get_lead( $this->entry[ 'id' ] );
922 922
 
923 923
 		$entry = GFFormsModel::set_entry_meta( $entry, self::$original_form );
924 924
 
925 925
 		if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) {
926 926
 			// We need to clear the cache because Gravity Forms caches the field values, which
927 927
 			// we have just updated.
928
-			foreach ($this->form['fields'] as $key => $field) {
929
-				GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );
928
+			foreach ( $this->form[ 'fields' ] as $key => $field ) {
929
+				GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id );
930 930
 			}
931 931
 		}
932 932
 
@@ -936,11 +936,11 @@  discard block
 block discarded – undo
936 936
 		 * @since develop
937 937
 		 */
938 938
 		if ( $allowed_feeds = $this->view->settings->get( 'edit_feeds', array() ) ) {
939
-			$feeds = GFAPI::get_feeds( null, $entry['form_id'] );
939
+			$feeds = GFAPI::get_feeds( null, $entry[ 'form_id' ] );
940 940
 			if ( ! is_wp_error( $feeds ) ) {
941 941
 				$registered_feeds = array();
942 942
 				foreach ( GFAddOn::get_registered_addons() as $registered_feed ) {
943
-					if ( is_subclass_of( $registered_feed,  'GFFeedAddOn' ) ) {
943
+					if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) {
944 944
 						if ( method_exists( $registered_feed, 'get_instance' ) ) {
945 945
 							$registered_feed = call_user_func( array( $registered_feed, 'get_instance' ) );
946 946
 							$registered_feeds[ $registered_feed->get_slug() ] = $registered_feed;
@@ -948,8 +948,8 @@  discard block
 block discarded – undo
948 948
 					}
949 949
 				}
950 950
 				foreach ( $feeds as $feed ) {
951
-					if ( in_array( $feed['id'], $allowed_feeds ) ) {
952
-						if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed['addon_slug'] ) ) {
951
+					if ( in_array( $feed[ 'id' ], $allowed_feeds ) ) {
952
+						if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed[ 'addon_slug' ] ) ) {
953 953
 							$returned_entry = $feed_object->process_feed( $feed, $entry, self::$original_form );
954 954
 							if ( is_array( $returned_entry ) && rgar( $returned_entry, 'id' ) ) {
955 955
 								$entry = $returned_entry;
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
 
980 980
 		<div class="gv-edit-entry-wrapper"><?php
981 981
 
982
-			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );
982
+			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this );
983 983
 
984 984
 			/**
985 985
 			 * Fixes weird wpautop() issue
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 				     * @param string $edit_entry_title Modify the "Edit Entry" title
996 996
 				     * @param GravityView_Edit_Entry_Render $this This object
997 997
 				     */
998
-				    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
998
+				    $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this );
999 999
 
1000 1000
 				    echo esc_attr( $edit_entry_title );
1001 1001
 			?></span>
@@ -1045,13 +1045,13 @@  discard block
 block discarded – undo
1045 1045
 
1046 1046
 			$back_link = remove_query_arg( array( 'page', 'view', 'edit' ) );
1047 1047
 
1048
-			if( ! $this->is_valid ){
1048
+			if ( ! $this->is_valid ) {
1049 1049
 
1050 1050
 				// Keeping this compatible with Gravity Forms.
1051
-				$validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
1052
-				$message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form);
1051
+				$validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>";
1052
+				$message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form );
1053 1053
 
1054
-				echo GVCommon::generate_notice( $message , 'gv-error' );
1054
+				echo GVCommon::generate_notice( $message, 'gv-error' );
1055 1055
 
1056 1056
 			} else {
1057 1057
 				$view = \GV\View::by_id( $this->view_id );
@@ -1062,23 +1062,23 @@  discard block
 block discarded – undo
1062 1062
 
1063 1063
                     case '0':
1064 1064
 	                    $redirect_url = $back_link;
1065
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
1065
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' );
1066 1066
                         break;
1067 1067
 
1068 1068
                     case '1':
1069 1069
 	                    $redirect_url = $directory_link = GravityView_API::directory_link();
1070
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
1070
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
1071 1071
 	                    break;
1072 1072
 
1073 1073
                     case '2':
1074 1074
 	                    $redirect_url = $edit_redirect_url;
1075 1075
 	                    $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
1076
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
1076
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
1077 1077
                         break;
1078 1078
 
1079 1079
                     case '':
1080 1080
                     default:
1081
-					    $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
1081
+					    $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' );
1082 1082
                         break;
1083 1083
 				}
1084 1084
 
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
 				 * @param array $entry Gravity Forms entry array
1095 1095
 				 * @param string $back_link URL to return to the original entry. @since 1.6
1096 1096
 				 */
1097
-				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );
1097
+				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link );
1098 1098
 
1099 1099
 				echo GVCommon::generate_notice( $message );
1100 1100
 			}
@@ -1118,8 +1118,8 @@  discard block
 block discarded – undo
1118 1118
 		 */
1119 1119
 		do_action( 'gravityview/edit-entry/render/before', $this );
1120 1120
 
1121
-		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );
1122
-		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );
1121
+		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 );
1122
+		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
1123 1123
 		add_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) );
1124 1124
 		add_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) );
1125 1125
 		add_filter( 'gform_disable_view_counter', '__return_true' );
@@ -1128,17 +1128,17 @@  discard block
 block discarded – undo
1128 1128
 		add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );
1129 1129
 
1130 1130
 		// We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.
1131
-		unset( $_GET['page'] );
1131
+		unset( $_GET[ 'page' ] );
1132 1132
 
1133 1133
 		$this->show_next_button = false;
1134 1134
 		$this->show_previous_button = false;
1135 1135
 
1136 1136
 		// TODO: Verify multiple-page forms
1137 1137
 		if ( GFCommon::has_pages( $this->form ) && apply_filters( 'gravityview/features/paged-edit', false ) ) {
1138
-			if ( intval( $page_number = \GV\Utils::_POST( 'gform_target_page_number_' . $this->form['id'], 1 ) ) > 1 ) {
1139
-				GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form;
1140
-				GFFormDisplay::$submission[ $this->form['id'] ][ 'is_valid' ] = true;
1141
-				GFFormDisplay::$submission[ $this->form['id'] ][ 'page_number' ] = $page_number;
1138
+			if ( intval( $page_number = \GV\Utils::_POST( 'gform_target_page_number_' . $this->form[ 'id' ], 1 ) ) > 1 ) {
1139
+				GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'form' ] = $this->form;
1140
+				GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'is_valid' ] = true;
1141
+				GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'page_number' ] = $page_number;
1142 1142
 			}
1143 1143
 
1144 1144
 			if ( ( $page_number = intval( $page_number ) ) < 2 ) {
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
 
1165 1165
 		ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic
1166 1166
 
1167
-		$html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );
1167
+		$html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry );
1168 1168
 
1169 1169
 		ob_get_clean();
1170 1170
 
@@ -1192,7 +1192,7 @@  discard block
 block discarded – undo
1192 1192
 	 * @return string
1193 1193
 	 */
1194 1194
 	public function render_form_buttons() {
1195
-		return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );
1195
+		return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this );
1196 1196
 	}
1197 1197
 
1198 1198
 
@@ -1211,15 +1211,15 @@  discard block
 block discarded – undo
1211 1211
 	 */
1212 1212
 	public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) {
1213 1213
 
1214
-		if( $form['id'] != $this->form_id ) {
1214
+		if ( $form[ 'id' ] != $this->form_id ) {
1215 1215
 			return $form;
1216 1216
 		}
1217 1217
 
1218 1218
 		// In case we have validated the form, use it to inject the validation results into the form render
1219
-		if( isset( $this->form_after_validation ) && $this->form_after_validation['id'] === $form['id'] ) {
1219
+		if ( isset( $this->form_after_validation ) && $this->form_after_validation[ 'id' ] === $form[ 'id' ] ) {
1220 1220
 			$form = $this->form_after_validation;
1221 1221
 		} else {
1222
-			$form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );
1222
+			$form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id );
1223 1223
 		}
1224 1224
 
1225 1225
 		$form = $this->filter_conditional_logic( $form );
@@ -1227,8 +1227,8 @@  discard block
 block discarded – undo
1227 1227
 		$form = $this->prefill_conditional_logic( $form );
1228 1228
 
1229 1229
 		// for now we don't support Save and Continue feature.
1230
-		if( ! self::$supports_save_and_continue ) {
1231
-	        unset( $form['save'] );
1230
+		if ( ! self::$supports_save_and_continue ) {
1231
+	        unset( $form[ 'save' ] );
1232 1232
 		}
1233 1233
 
1234 1234
 		$form = $this->unselect_default_values( $form );
@@ -1251,31 +1251,31 @@  discard block
 block discarded – undo
1251 1251
 	 */
1252 1252
 	public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) {
1253 1253
 
1254
-		if( ! GFCommon::is_post_field( $field ) ) {
1254
+		if ( ! GFCommon::is_post_field( $field ) ) {
1255 1255
 			return $field_content;
1256 1256
 		}
1257 1257
 
1258 1258
         $message = null;
1259 1259
 
1260 1260
         // First, make sure they have the capability to edit the post.
1261
-        if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1261
+        if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) {
1262 1262
 
1263 1263
             /**
1264 1264
              * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1265 1265
              * @param string $message The existing "You don't have permission..." text
1266 1266
              */
1267
-            $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1267
+            $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don&rsquo;t have permission to edit this post.', 'gravityview' ) );
1268 1268
 
1269
-        } elseif( null === get_post( $this->entry['post_id'] ) ) {
1269
+        } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) {
1270 1270
             /**
1271 1271
              * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1272 1272
              * @param string $message The existing "This field is not editable; the post no longer exists." text
1273 1273
              */
1274
-            $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1274
+            $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) );
1275 1275
         }
1276 1276
 
1277
-        if( $message ) {
1278
-            $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1277
+        if ( $message ) {
1278
+            $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1279 1279
         }
1280 1280
 
1281 1281
         return $field_content;
@@ -1299,8 +1299,8 @@  discard block
 block discarded – undo
1299 1299
 
1300 1300
 		// If the form has been submitted, then we don't need to pre-fill the values,
1301 1301
 		// Except for fileupload type and when a field input is overridden- run always!!
1302
-		if(
1303
-			( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1302
+		if (
1303
+			( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1304 1304
 			&& false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) )
1305 1305
 			&& ! GFCommon::is_product_field( $field->type )
1306 1306
 			|| ! empty( $field_content )
@@ -1320,7 +1320,7 @@  discard block
 block discarded – undo
1320 1320
 	    $return = null;
1321 1321
 
1322 1322
 		/** @var GravityView_Field $gv_field */
1323
-		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1323
+		if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1324 1324
 			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1325 1325
 		} else {
1326 1326
 	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
@@ -1329,7 +1329,7 @@  discard block
 block discarded – undo
1329 1329
 	    // If there was output, it's an error
1330 1330
 	    $warnings = ob_get_clean();
1331 1331
 
1332
-	    if( !empty( $warnings ) ) {
1332
+	    if ( ! empty( $warnings ) ) {
1333 1333
 		    gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1334 1334
 	    }
1335 1335
 
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
 		$override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );
1355 1355
 
1356 1356
 		// We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)
1357
-		if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) {
1357
+		if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) {
1358 1358
 
1359 1359
 			$field_value = array();
1360 1360
 
@@ -1363,10 +1363,10 @@  discard block
 block discarded – undo
1363 1363
 
1364 1364
 			foreach ( (array)$field->inputs as $input ) {
1365 1365
 
1366
-				$input_id = strval( $input['id'] );
1366
+				$input_id = strval( $input[ 'id' ] );
1367 1367
 
1368 1368
 				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1369
-				    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1369
+				    $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1370 1370
 				    $allow_pre_populated = false;
1371 1371
 				}
1372 1372
 
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
 
1375 1375
 			$pre_value = $field->get_value_submission( array(), false );
1376 1376
 
1377
-			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1377
+			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1378 1378
 
1379 1379
 		} else {
1380 1380
 
@@ -1385,13 +1385,13 @@  discard block
 block discarded – undo
1385 1385
 
1386 1386
 			// saved field entry value (if empty, fallback to the pre-populated value, if exists)
1387 1387
 			// or pre-populated value if not empty and set to override saved value
1388
-			$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;
1388
+			$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;
1389 1389
 
1390 1390
 			// in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.
1391
-			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1391
+			if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) {
1392 1392
 				$categories = array();
1393 1393
 				foreach ( explode( ',', $field_value ) as $cat_string ) {
1394
-				    $categories[] = GFCommon::format_post_category( $cat_string, true );
1394
+				    $categories[ ] = GFCommon::format_post_category( $cat_string, true );
1395 1395
 				}
1396 1396
 				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1397 1397
 			}
@@ -1419,7 +1419,7 @@  discard block
 block discarded – undo
1419 1419
 	     * @param GF_Field $field Gravity Forms field object
1420 1420
 	     * @param GravityView_Edit_Entry_Render $this Current object
1421 1421
 	     */
1422
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1422
+	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this );
1423 1423
 
1424 1424
 		return $field_value;
1425 1425
 	}
@@ -1436,12 +1436,12 @@  discard block
 block discarded – undo
1436 1436
 	 */
1437 1437
 	public function gform_pre_validation( $form ) {
1438 1438
 
1439
-		if( ! $this->verify_nonce() ) {
1439
+		if ( ! $this->verify_nonce() ) {
1440 1440
 			return $form;
1441 1441
 		}
1442 1442
 
1443 1443
 		// Fix PHP warning regarding undefined index.
1444
-		foreach ( $form['fields'] as &$field) {
1444
+		foreach ( $form[ 'fields' ] as &$field ) {
1445 1445
 
1446 1446
 			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1447 1447
 			// expects certain field array items to be set.
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1450 1450
 			}
1451 1451
 
1452
-			switch( RGFormsModel::get_input_type( $field ) ) {
1452
+			switch ( RGFormsModel::get_input_type( $field ) ) {
1453 1453
 
1454 1454
 				/**
1455 1455
 				 * 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.
@@ -1463,26 +1463,26 @@  discard block
 block discarded – undo
1463 1463
 				    // Set the previous value
1464 1464
 				    $entry = $this->get_entry();
1465 1465
 
1466
-				    $input_name = 'input_'.$field->id;
1467
-				    $form_id = $form['id'];
1466
+				    $input_name = 'input_' . $field->id;
1467
+				    $form_id = $form[ 'id' ];
1468 1468
 
1469 1469
 				    $value = NULL;
1470 1470
 
1471 1471
 				    // Use the previous entry value as the default.
1472
-				    if( isset( $entry[ $field->id ] ) ) {
1472
+				    if ( isset( $entry[ $field->id ] ) ) {
1473 1473
 				        $value = $entry[ $field->id ];
1474 1474
 				    }
1475 1475
 
1476 1476
 				    // If this is a single upload file
1477
-				    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1478
-				        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1479
-				        $value = $file_path['url'];
1477
+				    if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
1478
+				        $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] );
1479
+				        $value = $file_path[ 'url' ];
1480 1480
 
1481 1481
 				    } else {
1482 1482
 
1483 1483
 				        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1484 1484
 				        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1485
-				        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1485
+				        $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' );
1486 1486
 
1487 1487
 				    }
1488 1488
 
@@ -1490,10 +1490,10 @@  discard block
 block discarded – undo
1490 1490
 
1491 1491
 				        // If there are fresh uploads, process and merge them.
1492 1492
 				        // Otherwise, use the passed values, which should be json-encoded array of URLs
1493
-				        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1493
+				        if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) {
1494 1494
 				            $value = empty( $value ) ? '[]' : $value;
1495 1495
 				            $value = stripslashes_deep( $value );
1496
-				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1496
+				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() );
1497 1497
 				        }
1498 1498
 
1499 1499
 				    } else {
@@ -1511,8 +1511,8 @@  discard block
 block discarded – undo
1511 1511
 
1512 1512
 				case 'number':
1513 1513
 				    // Fix "undefined index" issue at line 1286 in form_display.php
1514
-				    if( !isset( $_POST['input_'.$field->id ] ) ) {
1515
-				        $_POST['input_'.$field->id ] = NULL;
1514
+				    if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) {
1515
+				        $_POST[ 'input_' . $field->id ] = NULL;
1516 1516
 				    }
1517 1517
 				    break;
1518 1518
 			}
@@ -1549,7 +1549,7 @@  discard block
 block discarded – undo
1549 1549
 		 * You can enter whatever you want!
1550 1550
 		 * We try validating, and customize the results using `self::custom_validation()`
1551 1551
 		 */
1552
-		add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);
1552
+		add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 );
1553 1553
 
1554 1554
 		// Needed by the validate funtion
1555 1555
 		$failed_validation_page = NULL;
@@ -1557,14 +1557,14 @@  discard block
 block discarded – undo
1557 1557
 
1558 1558
 		// Prevent entry limit from running when editing an entry, also
1559 1559
 		// prevent form scheduling from preventing editing
1560
-		unset( $this->form['limitEntries'], $this->form['scheduleForm'] );
1560
+		unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] );
1561 1561
 
1562 1562
 		// Hide fields depending on Edit Entry settings
1563
-		$this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1563
+		$this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1564 1564
 
1565 1565
 		$this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );
1566 1566
 
1567
-		remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 );
1567
+		remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 );
1568 1568
 	}
1569 1569
 
1570 1570
 
@@ -1587,7 +1587,7 @@  discard block
 block discarded – undo
1587 1587
 
1588 1588
 		$gv_valid = true;
1589 1589
 
1590
-		foreach ( $validation_results['form']['fields'] as $key => &$field ) {
1590
+		foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) {
1591 1591
 
1592 1592
 			$value = RGFormsModel::get_field_value( $field );
1593 1593
 			$field_type = RGFormsModel::get_input_type( $field );
@@ -1600,22 +1600,22 @@  discard block
 block discarded – undo
1600 1600
 				case 'post_image':
1601 1601
 
1602 1602
 				    // in case nothing is uploaded but there are already files saved
1603
-				    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1603
+				    if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) {
1604 1604
 				        $field->failed_validation = false;
1605 1605
 				        unset( $field->validation_message );
1606 1606
 				    }
1607 1607
 
1608 1608
 				    // validate if multi file upload reached max number of files [maxFiles] => 2
1609
-				    if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1609
+				    if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) {
1610 1610
 
1611 1611
 				        $input_name = 'input_' . $field->id;
1612 1612
 				        //uploaded
1613
-				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1613
+				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array();
1614 1614
 
1615 1615
 				        //existent
1616 1616
 				        $entry = $this->get_entry();
1617 1617
 				        $value = NULL;
1618
-				        if( isset( $entry[ $field->id ] ) ) {
1618
+				        if ( isset( $entry[ $field->id ] ) ) {
1619 1619
 				            $value = json_decode( $entry[ $field->id ], true );
1620 1620
 				        }
1621 1621
 
@@ -1623,13 +1623,13 @@  discard block
 block discarded – undo
1623 1623
 				        $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) +
1624 1624
 						               ( is_array( $value ) ? count( $value ) : 0 );
1625 1625
 
1626
-				        if( $count_files > $field->maxFiles ) {
1626
+				        if ( $count_files > $field->maxFiles ) {
1627 1627
 				            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1628 1628
 				            $field->failed_validation = 1;
1629 1629
 				            $gv_valid = false;
1630 1630
 
1631 1631
 				            // in case of error make sure the newest upload files are removed from the upload input
1632
-				            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1632
+				            GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null;
1633 1633
 				        }
1634 1634
 
1635 1635
 				    }
@@ -1640,7 +1640,7 @@  discard block
 block discarded – undo
1640 1640
 			}
1641 1641
 
1642 1642
 			// This field has failed validation.
1643
-			if( !empty( $field->failed_validation ) ) {
1643
+			if ( ! empty( $field->failed_validation ) ) {
1644 1644
 
1645 1645
 				gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) );
1646 1646
 
@@ -1658,19 +1658,19 @@  discard block
 block discarded – undo
1658 1658
 				}
1659 1659
 
1660 1660
 				// You can't continue inside a switch, so we do it after.
1661
-				if( empty( $field->failed_validation ) ) {
1661
+				if ( empty( $field->failed_validation ) ) {
1662 1662
 				    continue;
1663 1663
 				}
1664 1664
 
1665 1665
 				// checks if the No Duplicates option is not validating entry against itself, since
1666 1666
 				// we're editing a stored entry, it would also assume it's a duplicate.
1667
-				if( !empty( $field->noDuplicates ) ) {
1667
+				if ( ! empty( $field->noDuplicates ) ) {
1668 1668
 
1669 1669
 				    $entry = $this->get_entry();
1670 1670
 
1671 1671
 				    // If the value of the entry is the same as the stored value
1672 1672
 				    // Then we can assume it's not a duplicate, it's the same.
1673
-				    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1673
+				    if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) {
1674 1674
 				        //if value submitted was not changed, then don't validate
1675 1675
 				        $field->failed_validation = false;
1676 1676
 
@@ -1683,7 +1683,7 @@  discard block
 block discarded – undo
1683 1683
 				}
1684 1684
 
1685 1685
 				// if here then probably we are facing the validation 'At least one field must be filled out'
1686
-				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1686
+				if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) {
1687 1687
 				    unset( $field->validation_message );
1688 1688
 	                $field->validation_message = false;
1689 1689
 				    continue;
@@ -1695,12 +1695,12 @@  discard block
 block discarded – undo
1695 1695
 
1696 1696
 		}
1697 1697
 
1698
-		$validation_results['is_valid'] = $gv_valid;
1698
+		$validation_results[ 'is_valid' ] = $gv_valid;
1699 1699
 
1700 1700
 		gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) );
1701 1701
 
1702 1702
 		// We'll need this result when rendering the form ( on GFFormDisplay::get_form )
1703
-		$this->form_after_validation = $validation_results['form'];
1703
+		$this->form_after_validation = $validation_results[ 'form' ];
1704 1704
 
1705 1705
 		return $validation_results;
1706 1706
 	}
@@ -1713,7 +1713,7 @@  discard block
 block discarded – undo
1713 1713
 	 */
1714 1714
 	public function get_entry() {
1715 1715
 
1716
-		if( empty( $this->entry ) ) {
1716
+		if ( empty( $this->entry ) ) {
1717 1717
 			// Get the database value of the entry that's being edited
1718 1718
 			$this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );
1719 1719
 		}
@@ -1745,10 +1745,10 @@  discard block
 block discarded – undo
1745 1745
 		}
1746 1746
 
1747 1747
 		// If edit tab not yet configured, show all fields
1748
-		$edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;
1748
+		$edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL;
1749 1749
 
1750 1750
 		// Hide fields depending on admin settings
1751
-		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1751
+		$fields = $this->filter_fields( $form[ 'fields' ], $edit_fields );
1752 1752
 
1753 1753
 	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1754 1754
 	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
@@ -1781,7 +1781,7 @@  discard block
 block discarded – undo
1781 1781
 	 */
1782 1782
 	private function filter_fields( $fields, $configured_fields ) {
1783 1783
 
1784
-		if( empty( $fields ) || !is_array( $fields ) ) {
1784
+		if ( empty( $fields ) || ! is_array( $fields ) ) {
1785 1785
 			return $fields;
1786 1786
 		}
1787 1787
 
@@ -1798,12 +1798,12 @@  discard block
 block discarded – undo
1798 1798
 
1799 1799
 			// Remove the fields that have calculation properties and keep them to be used later
1800 1800
 			// @since 1.16.2
1801
-			if( $field->has_calculation() ) {
1802
-				$this->fields_with_calculation[] = $field;
1801
+			if ( $field->has_calculation() ) {
1802
+				$this->fields_with_calculation[ ] = $field;
1803 1803
 				// don't remove the calculation fields on form render.
1804 1804
 			}
1805 1805
 
1806
-			if( in_array( $field->type, $field_type_blacklist ) ) {
1806
+			if ( in_array( $field->type, $field_type_blacklist ) ) {
1807 1807
 				unset( $fields[ $key ] );
1808 1808
 			}
1809 1809
 		}
@@ -1821,7 +1821,7 @@  discard block
 block discarded – undo
1821 1821
 					continue; // Same
1822 1822
 				}
1823 1823
 
1824
-				$out_fields[] = $field;
1824
+				$out_fields[ ] = $field;
1825 1825
 			}
1826 1826
 
1827 1827
 			return array_values( $out_fields );
@@ -1832,8 +1832,8 @@  discard block
 block discarded – undo
1832 1832
 
1833 1833
 	        /** @var GF_Field $field */
1834 1834
 	        foreach ( $fields as $field ) {
1835
-				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1836
-				    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1835
+				if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1836
+				    $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field );
1837 1837
 				    break;
1838 1838
 				}
1839 1839
 
@@ -1856,14 +1856,14 @@  discard block
 block discarded – undo
1856 1856
 
1857 1857
 		$return_field = $field;
1858 1858
 
1859
-		if( empty( $field_setting['show_label'] ) ) {
1859
+		if ( empty( $field_setting[ 'show_label' ] ) ) {
1860 1860
 			$return_field->label = '';
1861
-		} elseif ( !empty( $field_setting['custom_label'] ) ) {
1862
-			$return_field->label = $field_setting['custom_label'];
1861
+		} elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) {
1862
+			$return_field->label = $field_setting[ 'custom_label' ];
1863 1863
 		}
1864 1864
 
1865
-		if( !empty( $field_setting['custom_class'] ) ) {
1866
-			$return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );
1865
+		if ( ! empty( $field_setting[ 'custom_class' ] ) ) {
1866
+			$return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] );
1867 1867
 		}
1868 1868
 
1869 1869
 		/**
@@ -1901,16 +1901,16 @@  discard block
 block discarded – undo
1901 1901
 	     */
1902 1902
 	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1903 1903
 
1904
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1905
-			foreach( $fields as $k => $field ) {
1906
-				if( $field->adminOnly ) {
1904
+	    if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) {
1905
+			foreach ( $fields as $k => $field ) {
1906
+				if ( $field->adminOnly ) {
1907 1907
 				    unset( $fields[ $k ] );
1908 1908
 				}
1909 1909
 			}
1910 1910
 			return array_values( $fields );
1911 1911
 		}
1912 1912
 
1913
-	    foreach( $fields as &$field ) {
1913
+	    foreach ( $fields as &$field ) {
1914 1914
 		    $field->adminOnly = false;
1915 1915
 		}
1916 1916
 
@@ -1931,7 +1931,7 @@  discard block
 block discarded – undo
1931 1931
 	 */
1932 1932
 	private function unselect_default_values( $form ) {
1933 1933
 
1934
-	    foreach ( $form['fields'] as &$field ) {
1934
+	    foreach ( $form[ 'fields' ] as &$field ) {
1935 1935
 
1936 1936
 			if ( empty( $field->choices ) ) {
1937 1937
                 continue;
@@ -1939,7 +1939,7 @@  discard block
 block discarded – undo
1939 1939
 
1940 1940
             foreach ( $field->choices as &$choice ) {
1941 1941
 				if ( \GV\Utils::get( $choice, 'isSelected' ) ) {
1942
-					$choice['isSelected'] = false;
1942
+					$choice[ 'isSelected' ] = false;
1943 1943
 				}
1944 1944
 			}
1945 1945
 		}
@@ -1964,22 +1964,22 @@  discard block
 block discarded – undo
1964 1964
 	 */
1965 1965
 	function prefill_conditional_logic( $form ) {
1966 1966
 
1967
-		if( ! GFFormDisplay::has_conditional_logic( $form ) ) {
1967
+		if ( ! GFFormDisplay::has_conditional_logic( $form ) ) {
1968 1968
 			return $form;
1969 1969
 		}
1970 1970
 
1971 1971
 		// Have Conditional Logic pre-fill fields as if the data were default values
1972 1972
 		/** @var GF_Field $field */
1973
-		foreach ( $form['fields'] as &$field ) {
1973
+		foreach ( $form[ 'fields' ] as &$field ) {
1974 1974
 
1975
-			if( 'checkbox' === $field->type ) {
1975
+			if ( 'checkbox' === $field->type ) {
1976 1976
 				foreach ( $field->get_entry_inputs() as $key => $input ) {
1977
-				    $input_id = $input['id'];
1977
+				    $input_id = $input[ 'id' ];
1978 1978
 				    $choice = $field->choices[ $key ];
1979 1979
 				    $value = \GV\Utils::get( $this->entry, $input_id );
1980 1980
 				    $match = RGFormsModel::choice_value_match( $field, $choice, $value );
1981
-				    if( $match ) {
1982
-				        $field->choices[ $key ]['isSelected'] = true;
1981
+				    if ( $match ) {
1982
+				        $field->choices[ $key ][ 'isSelected' ] = true;
1983 1983
 				    }
1984 1984
 				}
1985 1985
 			} else {
@@ -1987,15 +1987,15 @@  discard block
 block discarded – undo
1987 1987
 				// We need to run through each field to set the default values
1988 1988
 				foreach ( $this->entry as $field_id => $field_value ) {
1989 1989
 
1990
-				    if( floatval( $field_id ) === floatval( $field->id ) ) {
1990
+				    if ( floatval( $field_id ) === floatval( $field->id ) ) {
1991 1991
 
1992
-				        if( 'list' === $field->type ) {
1992
+				        if ( 'list' === $field->type ) {
1993 1993
 				            $list_rows = maybe_unserialize( $field_value );
1994 1994
 
1995 1995
 				            $list_field_value = array();
1996
-				            foreach ( (array) $list_rows as $row ) {
1997
-				                foreach ( (array) $row as $column ) {
1998
-				                    $list_field_value[] = $column;
1996
+				            foreach ( (array)$list_rows as $row ) {
1997
+				                foreach ( (array)$row as $column ) {
1998
+				                    $list_field_value[ ] = $column;
1999 1999
 				                }
2000 2000
 				            }
2001 2001
 
@@ -2028,32 +2028,32 @@  discard block
 block discarded – undo
2028 2028
 		 * @see https://github.com/gravityview/GravityView/issues/840
2029 2029
 		 * @since develop
2030 2030
 		 */
2031
-		$the_form = GFAPI::get_form( $form['id'] );
2031
+		$the_form = GFAPI::get_form( $form[ 'id' ] );
2032 2032
 		$editable_ids = array();
2033
-		foreach ( $form['fields'] as $field ) {
2034
-			$editable_ids[] = $field['id']; // wp_list_pluck is destructive in this context
2033
+		foreach ( $form[ 'fields' ] as $field ) {
2034
+			$editable_ids[ ] = $field[ 'id' ]; // wp_list_pluck is destructive in this context
2035 2035
 		}
2036 2036
 		$remove_conditions_rule = array();
2037
-		foreach ( $the_form['fields'] as $field ) {
2038
-			if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic['rules'] ) ) {
2039
-				foreach ( $field->conditionalLogic['rules'] as $i => $rule ) {
2040
-					if ( ! in_array( $rule['fieldId'], $editable_ids ) ) {
2037
+		foreach ( $the_form[ 'fields' ] as $field ) {
2038
+			if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic[ 'rules' ] ) ) {
2039
+				foreach ( $field->conditionalLogic[ 'rules' ] as $i => $rule ) {
2040
+					if ( ! in_array( $rule[ 'fieldId' ], $editable_ids ) ) {
2041 2041
 						/**
2042 2042
 						 * This conditional field is not editable in this View.
2043 2043
 						 * We need to remove the rule, but only if it matches.
2044 2044
 						 */
2045
-						if ( $_field = GFAPI::get_field( $the_form, $rule['fieldId'] ) ) {
2045
+						if ( $_field = GFAPI::get_field( $the_form, $rule[ 'fieldId' ] ) ) {
2046 2046
 							$value = $_field->get_value_export( $this->entry );
2047
-						} elseif ( isset( $this->entry[ $rule['fieldId'] ] ) ) {
2048
-							$value = $this->entry[ $rule['fieldId'] ];
2047
+						} elseif ( isset( $this->entry[ $rule[ 'fieldId' ] ] ) ) {
2048
+							$value = $this->entry[ $rule[ 'fieldId' ] ];
2049 2049
 						} else {
2050
-							$value = gform_get_meta( $this->entry['id'], $rule['fieldId'] );
2050
+							$value = gform_get_meta( $this->entry[ 'id' ], $rule[ 'fieldId' ] );
2051 2051
 						}
2052 2052
 
2053
-						$match = GFFormsModel::matches_operation( $value, $rule['value'], $rule['operator'] );
2053
+						$match = GFFormsModel::matches_operation( $value, $rule[ 'value' ], $rule[ 'operator' ] );
2054 2054
 						
2055 2055
 						if ( $match ) {
2056
-							$remove_conditions_rule[] = array( $field['id'], $i );
2056
+							$remove_conditions_rule[ ] = array( $field[ 'id' ], $i );
2057 2057
 						}
2058 2058
 					}
2059 2059
 				}
@@ -2061,21 +2061,21 @@  discard block
 block discarded – undo
2061 2061
 		}
2062 2062
 
2063 2063
 		if ( $remove_conditions_rule ) {
2064
-			foreach ( $form['fields'] as &$field ) {
2064
+			foreach ( $form[ 'fields' ] as &$field ) {
2065 2065
 				foreach ( $remove_conditions_rule as $_remove_conditions_r ) {
2066 2066
 
2067 2067
 				    list( $rule_field_id, $rule_i ) = $_remove_conditions_r;
2068 2068
 
2069
-					if ( $field['id'] == $rule_field_id ) {
2070
-						unset( $field->conditionalLogic['rules'][ $rule_i ] );
2071
-						gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field['id'] ) );
2069
+					if ( $field[ 'id' ] == $rule_field_id ) {
2070
+						unset( $field->conditionalLogic[ 'rules' ][ $rule_i ] );
2071
+						gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field[ 'id' ] ) );
2072 2072
 					}
2073 2073
 				}
2074 2074
 			}
2075 2075
 		}
2076 2076
 
2077 2077
 		/** Normalize the indices... */
2078
-		$form['fields'] = array_values( $form['fields'] );
2078
+		$form[ 'fields' ] = array_values( $form[ 'fields' ] );
2079 2079
 
2080 2080
 		/**
2081 2081
 		 * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields?
@@ -2085,16 +2085,16 @@  discard block
 block discarded – undo
2085 2085
 		 */
2086 2086
 		$use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );
2087 2087
 
2088
-		if( $use_conditional_logic ) {
2088
+		if ( $use_conditional_logic ) {
2089 2089
 			return $form;
2090 2090
 		}
2091 2091
 
2092
-		foreach( $form['fields'] as &$field ) {
2092
+		foreach ( $form[ 'fields' ] as &$field ) {
2093 2093
 			/* @var GF_Field $field */
2094 2094
 			$field->conditionalLogic = null;
2095 2095
 		}
2096 2096
 
2097
-		unset( $form['button']['conditionalLogic'] );
2097
+		unset( $form[ 'button' ][ 'conditionalLogic' ] );
2098 2098
 
2099 2099
 		return $form;
2100 2100
 
@@ -2111,7 +2111,7 @@  discard block
 block discarded – undo
2111 2111
 	 */
2112 2112
 	public function manage_conditional_logic( $has_conditional_logic, $form ) {
2113 2113
 
2114
-		if( ! $this->is_edit_entry() ) {
2114
+		if ( ! $this->is_edit_entry() ) {
2115 2115
 			return $has_conditional_logic;
2116 2116
 		}
2117 2117
 
@@ -2143,44 +2143,44 @@  discard block
 block discarded – undo
2143 2143
 		 *  2. There are two entries embedded using oEmbed
2144 2144
 		 *  3. One of the entries has just been saved
2145 2145
 		 */
2146
-		if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) {
2146
+		if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) {
2147 2147
 
2148 2148
 			$error = true;
2149 2149
 
2150 2150
 		}
2151 2151
 
2152
-		if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) {
2152
+		if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) {
2153 2153
 
2154 2154
 			$error = true;
2155 2155
 
2156
-		} elseif( ! $this->verify_nonce() ) {
2156
+		} elseif ( ! $this->verify_nonce() ) {
2157 2157
 
2158 2158
 			/**
2159 2159
 			 * If the Entry is embedded, there may be two entries on the same page.
2160 2160
 			 * If that's the case, and one is being edited, the other should fail gracefully and not display an error.
2161 2161
 			 */
2162
-			if( GravityView_oEmbed::getInstance()->get_entry_id() ) {
2162
+			if ( GravityView_oEmbed::getInstance()->get_entry_id() ) {
2163 2163
 				$error = true;
2164 2164
 			} else {
2165
-				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');
2165
+				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' );
2166 2166
 			}
2167 2167
 
2168 2168
 		}
2169 2169
 
2170
-		if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
2171
-			$error = __( 'You do not have permission to edit this entry.', 'gravityview');
2170
+		if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
2171
+			$error = __( 'You do not have permission to edit this entry.', 'gravityview' );
2172 2172
 		}
2173 2173
 
2174
-		if( $this->entry['status'] === 'trash' ) {
2175
-			$error = __('You cannot edit the entry; it is in the trash.', 'gravityview' );
2174
+		if ( $this->entry[ 'status' ] === 'trash' ) {
2175
+			$error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' );
2176 2176
 		}
2177 2177
 
2178 2178
 		// No errors; everything's fine here!
2179
-		if( empty( $error ) ) {
2179
+		if ( empty( $error ) ) {
2180 2180
 			return true;
2181 2181
 		}
2182 2182
 
2183
-		if( $echo && $error !== true ) {
2183
+		if ( $echo && $error !== true ) {
2184 2184
 
2185 2185
 	        $error = esc_html( $error );
2186 2186
 
@@ -2188,10 +2188,10 @@  discard block
 block discarded – undo
2188 2188
 	         * @since 1.9
2189 2189
 	         */
2190 2190
 	        if ( ! empty( $this->entry ) ) {
2191
-		        $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;" ) );
2191
+		        $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;" ) );
2192 2192
 	        }
2193 2193
 
2194
-			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
2194
+			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' );
2195 2195
 		}
2196 2196
 
2197 2197
 		gravityview()->log->error( '{error}', array( 'error' => $error ) );
@@ -2211,17 +2211,17 @@  discard block
 block discarded – undo
2211 2211
 
2212 2212
 		$error = NULL;
2213 2213
 
2214
-		if( ! $this->check_user_cap_edit_field( $field ) ) {
2215
-			$error = __( 'You do not have permission to edit this field.', 'gravityview');
2214
+		if ( ! $this->check_user_cap_edit_field( $field ) ) {
2215
+			$error = __( 'You do not have permission to edit this field.', 'gravityview' );
2216 2216
 		}
2217 2217
 
2218 2218
 		// No errors; everything's fine here!
2219
-		if( empty( $error ) ) {
2219
+		if ( empty( $error ) ) {
2220 2220
 			return true;
2221 2221
 		}
2222 2222
 
2223
-		if( $echo ) {
2224
-			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');
2223
+		if ( $echo ) {
2224
+			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' );
2225 2225
 		}
2226 2226
 
2227 2227
 		gravityview()->log->error( '{error}', array( 'error' => $error ) );
@@ -2242,14 +2242,14 @@  discard block
 block discarded – undo
2242 2242
 	private function check_user_cap_edit_field( $field ) {
2243 2243
 
2244 2244
 		// If they can edit any entries (as defined in Gravity Forms), we're good.
2245
-		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
2245
+		if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
2246 2246
 			return true;
2247 2247
 		}
2248 2248
 
2249
-		$field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;
2249
+		$field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false;
2250 2250
 
2251
-		if( $field_cap ) {
2252
-			return GVCommon::has_cap( $field['allow_edit_cap'] );
2251
+		if ( $field_cap ) {
2252
+			return GVCommon::has_cap( $field[ 'allow_edit_cap' ] );
2253 2253
 		}
2254 2254
 
2255 2255
 		return false;
@@ -2263,17 +2263,17 @@  discard block
 block discarded – undo
2263 2263
 	public function verify_nonce() {
2264 2264
 
2265 2265
 		// Verify form submitted for editing single
2266
-		if( $this->is_edit_entry_submission() ) {
2266
+		if ( $this->is_edit_entry_submission() ) {
2267 2267
 			$valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );
2268 2268
 		}
2269 2269
 
2270 2270
 		// Verify
2271
-		else if( ! $this->is_edit_entry() ) {
2271
+		else if ( ! $this->is_edit_entry() ) {
2272 2272
 			$valid = false;
2273 2273
 		}
2274 2274
 
2275 2275
 		else {
2276
-			$valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
2276
+			$valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key );
2277 2277
 		}
2278 2278
 
2279 2279
 		/**
Please login to merge, or discard this patch.