Completed
Push — develop ( 75c287...89334a )
by Gennady
17:03 queued 11s
created
includes/extensions/edit-entry/class-edit-entry-render.php 1 patch
Spacing   +240 added lines, -240 removed lines patch added patch discarded remove patch
@@ -135,16 +135,16 @@  discard block
 block discarded – undo
135 135
 	function load() {
136 136
 
137 137
 		/** @define "GRAVITYVIEW_DIR" "../../../" */
138
-		include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' );
138
+		include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' );
139 139
 
140 140
 		// Don't display an embedded form when editing an entry
141 141
 		add_action( 'wp_head', array( $this, 'prevent_render_form' ) );
142 142
 		add_action( 'wp_footer', array( $this, 'prevent_render_form' ) );
143 143
 
144 144
 		// Stop Gravity Forms processing what is ours!
145
-		add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 );
145
+		add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 );
146 146
 
147
-		add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') );
147
+		add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) );
148 148
 
149 149
 		add_action( 'gravityview_edit_entry', array( $this, 'init' ), 10, 4 );
150 150
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 		add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 );
156 156
 
157 157
 		// Add fields expected by GFFormDisplay::validate()
158
-		add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') );
158
+		add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) );
159 159
 
160 160
 		// Fix multiselect value for GF 2.2
161 161
 		add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 );
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	 * @return void
173 173
 	 */
174 174
 	public function prevent_render_form() {
175
-		if( $this->is_edit_entry() ) {
176
-			if( 'wp_head' === current_filter() ) {
175
+		if ( $this->is_edit_entry() ) {
176
+			if ( 'wp_head' === current_filter() ) {
177 177
 				add_filter( 'gform_shortcode_form', '__return_empty_string' );
178 178
 			} else {
179 179
 				remove_filter( 'gform_shortcode_form', '__return_empty_string' );
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
 	 */
189 189
 	public function prevent_maybe_process_form() {
190 190
 
191
-	    if( ! $this->is_edit_entry_submission() ) {
191
+	    if ( ! $this->is_edit_entry_submission() ) {
192 192
 			return;
193 193
 		}
194 194
 
195 195
 		gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] Removing GFForms::maybe_process_form() action.' );
196 196
 
197
-		remove_action( 'wp',  array( 'RGForms', 'maybe_process_form'), 9 );
198
-		remove_action( 'wp',  array( 'GFForms', 'maybe_process_form'), 9 );
197
+		remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 );
198
+		remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 );
199 199
 	}
200 200
 
201 201
 	/**
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 */
205 205
 	public function is_edit_entry() {
206 206
 
207
-		$is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] );
207
+		$is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] );
208 208
 
209 209
 		return ( $is_edit_entry || $this->is_edit_entry_submission() );
210 210
 	}
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 * @return boolean
216 216
 	 */
217 217
 	public function is_edit_entry_submission() {
218
-		return !empty( $_POST[ self::$nonce_field ] );
218
+		return ! empty( $_POST[ self::$nonce_field ] );
219 219
 	}
220 220
 
221 221
 	/**
@@ -228,16 +228,16 @@  discard block
 block discarded – undo
228 228
 
229 229
 
230 230
 		$entries = $gravityview_view->getEntries();
231
-	    self::$original_entry = $entries[0];
232
-	    $this->entry = $entries[0];
231
+	    self::$original_entry = $entries[ 0 ];
232
+	    $this->entry = $entries[ 0 ];
233 233
 
234 234
 		self::$original_form = $gravityview_view->getForm();
235 235
 		$this->form = $gravityview_view->getForm();
236
-		$this->form_id = $this->entry['form_id'];
236
+		$this->form_id = $this->entry[ 'form_id' ];
237 237
 		$this->view_id = $gravityview_view->getViewId();
238 238
 		$this->post_id = \GV\Utils::get( $post, 'ID', null );
239 239
 
240
-		self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] );
240
+		self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] );
241 241
 	}
242 242
 
243 243
 
@@ -296,9 +296,9 @@  discard block
 block discarded – undo
296 296
 	private function print_scripts() {
297 297
 		$gravityview_view = GravityView_View::getInstance();
298 298
 
299
-		wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
299
+		wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
300 300
 
301
-		GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false);
301
+		GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false );
302 302
 
303 303
 		wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) );
304 304
 
@@ -314,19 +314,19 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	private function process_save( $gv_data ) {
316 316
 
317
-		if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) {
317
+		if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) {
318 318
 			return;
319 319
 		}
320 320
 
321 321
 		// Make sure the entry, view, and form IDs are all correct
322 322
 		$valid = $this->verify_nonce();
323 323
 
324
-		if ( !$valid ) {
324
+		if ( ! $valid ) {
325 325
 			gravityview()->log->error( 'Nonce validation failed.' );
326 326
 			return;
327 327
 		}
328 328
 
329
-		if ( $this->entry['id'] !== $_POST['lid'] ) {
329
+		if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) {
330 330
 			gravityview()->log->error( 'Entry ID did not match posted entry ID.' );
331 331
 			return;
332 332
 		}
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 
338 338
 		$this->validate();
339 339
 
340
-		if( $this->is_valid ) {
340
+		if ( $this->is_valid ) {
341 341
 
342 342
 			gravityview()->log->debug( 'Submission is valid.' );
343 343
 
@@ -349,15 +349,15 @@  discard block
 block discarded – undo
349 349
 			/**
350 350
 			 * @hack to avoid the capability validation of the method save_lead for GF 1.9+
351 351
 			 */
352
-			unset( $_GET['page'] );
352
+			unset( $_GET[ 'page' ] );
353 353
 
354
-			$date_created = $this->entry['date_created'];
354
+			$date_created = $this->entry[ 'date_created' ];
355 355
 
356 356
 			/**
357 357
 			 * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead()
358 358
 			 * @since 1.17.2
359 359
 			 */
360
-			unset( $this->entry['date_created'] );
360
+			unset( $this->entry[ 'date_created' ] );
361 361
 
362 362
 			/**
363 363
 			 * @action `gravityview/edit_entry/before_update` Perform an action after the entry has been updated using Edit Entry
@@ -367,14 +367,14 @@  discard block
 block discarded – undo
367 367
 			 * @param GravityView_Edit_Entry_Render $this This object
368 368
 			 * @param GravityView_View_Data $gv_data The View data
369 369
 			 */
370
-			do_action( 'gravityview/edit_entry/before_update', $form, $this->entry['id'], $this, $gv_data );
370
+			do_action( 'gravityview/edit_entry/before_update', $form, $this->entry[ 'id' ], $this, $gv_data );
371 371
 
372 372
 			GFFormsModel::save_lead( $form, $this->entry );
373 373
 
374 374
 	        // Delete the values for hidden inputs
375 375
 	        $this->unset_hidden_field_values();
376 376
 			
377
-			$this->entry['date_created'] = $date_created;
377
+			$this->entry[ 'date_created' ] = $date_created;
378 378
 
379 379
 			// Process calculation fields
380 380
 			$this->update_calculation_fields();
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 			 * @param GravityView_Edit_Entry_Render $this This object
397 397
 			 * @param GravityView_View_Data $gv_data The View data
398 398
 			 */
399
-			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data );
399
+			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data );
400 400
 
401 401
 		} else {
402 402
 			gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) );
@@ -426,16 +426,16 @@  discard block
 block discarded – undo
426 426
 
427 427
 		$this->unset_hidden_calculations = array();
428 428
 
429
-		if( ! $unset_hidden_field_values ) {
429
+		if ( ! $unset_hidden_field_values ) {
430 430
 			return;
431 431
 		}
432 432
 
433 433
 		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
434 434
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
435
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) );
435
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) );
436 436
 		} else {
437 437
 			$lead_detail_table = GFFormsModel::get_lead_details_table_name();
438
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );
438
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) );
439 439
 		}
440 440
 
441 441
 	    foreach ( $this->entry as $input_id => $field_value ) {
@@ -452,11 +452,11 @@  discard block
 block discarded – undo
452 452
 
453 453
 				$empty_value = $field->get_value_save_entry(
454 454
 					is_array( $field->get_entry_inputs() ) ? array() : '',
455
-					$this->form, '', $this->entry['id'], $this->entry
455
+					$this->form, '', $this->entry[ 'id' ], $this->entry
456 456
 				);
457 457
 
458 458
 				if ( $field->has_calculation() ) {
459
-					$this->unset_hidden_calculations[] = $field->id; // Unset
459
+					$this->unset_hidden_calculations[ ] = $field->id; // Unset
460 460
 					$empty_value = '';
461 461
 				}
462 462
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 		}
528 528
 
529 529
 		/** No file is being uploaded. */
530
-		if ( empty( $_FILES[ $input_name ]['name'] ) ) {
530
+		if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) {
531 531
 			/** So return the original upload */
532 532
 			return $entry[ $input_id ];
533 533
 		}
@@ -545,11 +545,11 @@  discard block
 block discarded – undo
545 545
 	 * @return mixed
546 546
 	 */
547 547
 	public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) {
548
-		if( ! $this->is_edit_entry() ) {
548
+		if ( ! $this->is_edit_entry() ) {
549 549
 			return $plupload_init;
550 550
 		}
551 551
 
552
-		$plupload_init['gf_vars']['max_files'] = 0;
552
+		$plupload_init[ 'gf_vars' ][ 'max_files' ] = 0;
553 553
 
554 554
 		return $plupload_init;
555 555
 	}
@@ -564,27 +564,27 @@  discard block
 block discarded – undo
564 564
 		$form = $this->filter_conditional_logic( $this->form );
565 565
 
566 566
 	    /** @var GF_Field $field */
567
-		foreach( $form['fields'] as $k => &$field ) {
567
+		foreach ( $form[ 'fields' ] as $k => &$field ) {
568 568
 
569 569
 			/**
570 570
 			 * Remove the fields with calculation formulas before save to avoid conflicts with GF logic
571 571
 			 * @since 1.16.3
572 572
 			 * @var GF_Field $field
573 573
 			 */
574
-			if( $field->has_calculation() ) {
575
-				unset( $form['fields'][ $k ] );
574
+			if ( $field->has_calculation() ) {
575
+				unset( $form[ 'fields' ][ $k ] );
576 576
 			}
577 577
 
578 578
 			$field->adminOnly = false;
579 579
 
580
-			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
581
-				foreach( $field->inputs as $key => $input ) {
582
-				    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
580
+			if ( isset( $field->inputs ) && is_array( $field->inputs ) ) {
581
+				foreach ( $field->inputs as $key => $input ) {
582
+				    $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ];
583 583
 				}
584 584
 			}
585 585
 		}
586 586
 
587
-		$form['fields'] = array_values( $form['fields'] );
587
+		$form[ 'fields' ] = array_values( $form[ 'fields' ] );
588 588
 
589 589
 		return $form;
590 590
 	}
@@ -596,14 +596,14 @@  discard block
 block discarded – undo
596 596
 		$update = false;
597 597
 
598 598
 		// get the most up to date entry values
599
-		$entry = GFAPI::get_entry( $this->entry['id'] );
599
+		$entry = GFAPI::get_entry( $this->entry[ 'id' ] );
600 600
 
601 601
 		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
602 602
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
603
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) );
603
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) );
604 604
 		} else {
605 605
 			$lead_detail_table = GFFormsModel::get_lead_details_table_name();
606
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) );
606
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) );
607 607
 		}
608 608
 
609 609
 
@@ -620,24 +620,24 @@  discard block
 block discarded – undo
620 620
 				$inputs = $field->get_entry_inputs();
621 621
 				if ( is_array( $inputs ) ) {
622 622
 				    foreach ( $inputs as $input ) {
623
-						list( $field_id, $input_id ) = rgexplode( '.', $input['id'], 2 );
623
+						list( $field_id, $input_id ) = rgexplode( '.', $input[ 'id' ], 2 );
624 624
 
625 625
 						if ( 'product' === $field->type ) {
626
-							$input_name = 'input_' . str_replace( '.', '_', $input['id'] );
626
+							$input_name = 'input_' . str_replace( '.', '_', $input[ 'id' ] );
627 627
 
628 628
 							// Only allow quantity to be set if it's allowed to be edited
629 629
 							if ( in_array( $field_id, $allowed_fields ) && $input_id == 3 ) {
630 630
 							} else { // otherwise set to what it previously was
631
-								$_POST[ $input_name ] = $entry[ $input['id'] ];
631
+								$_POST[ $input_name ] = $entry[ $input[ 'id' ] ];
632 632
 							}
633 633
 						} else {
634 634
 							// Set to what it previously was if it's not editable
635 635
 							if ( ! in_array( $field_id, $allowed_fields ) ) {
636
-								$_POST[ $input_name ] = $entry[ $input['id'] ];
636
+								$_POST[ $input_name ] = $entry[ $input[ 'id' ] ];
637 637
 							}
638 638
 						}
639 639
 
640
-						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] );
640
+						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] );
641 641
 				    }
642 642
 				} else {
643 643
 					// Set to what it previously was if it's not editable
@@ -677,19 +677,19 @@  discard block
 block discarded – undo
677 677
 
678 678
 		$input_name = 'input_' . $field_id;
679 679
 
680
-		if ( !empty( $_FILES[ $input_name ]['name'] ) ) {
680
+		if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
681 681
 
682 682
 			// We have a new image
683 683
 
684
-			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
684
+			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] );
685 685
 
686 686
 			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
687 687
 	        $ary = stripslashes_deep( $ary );
688 688
 			$img_url = \GV\Utils::get( $ary, 0 );
689 689
 
690
-			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
691
-			$img_caption     = count( $ary ) > 2 ? $ary[2] : '';
692
-			$img_description = count( $ary ) > 3 ? $ary[3] : '';
690
+			$img_title       = count( $ary ) > 1 ? $ary[ 1 ] : '';
691
+			$img_caption     = count( $ary ) > 2 ? $ary[ 2 ] : '';
692
+			$img_description = count( $ary ) > 3 ? $ary[ 3 ] : '';
693 693
 
694 694
 			$image_meta = array(
695 695
 				'post_excerpt' => $img_caption,
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 
699 699
 			//adding title only if it is not empty. It will default to the file name if it is not in the array
700 700
 			if ( ! empty( $img_title ) ) {
701
-				$image_meta['post_title'] = $img_title;
701
+				$image_meta[ 'post_title' ] = $img_title;
702 702
 			}
703 703
 
704 704
 			/**
@@ -756,15 +756,15 @@  discard block
 block discarded – undo
756 756
 	 */
757 757
 	private function maybe_update_post_fields( $form ) {
758 758
 
759
-		if( empty( $this->entry['post_id'] ) ) {
759
+		if ( empty( $this->entry[ 'post_id' ] ) ) {
760 760
 	        gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
761 761
 			return;
762 762
 		}
763 763
 
764
-		$post_id = $this->entry['post_id'];
764
+		$post_id = $this->entry[ 'post_id' ];
765 765
 
766 766
 		// Security check
767
-		if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
767
+		if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
768 768
 			gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) );
769 769
 			return;
770 770
 		}
@@ -777,25 +777,25 @@  discard block
 block discarded – undo
777 777
 
778 778
 			$field = RGFormsModel::get_field( $form, $field_id );
779 779
 
780
-			if( ! $field ) {
780
+			if ( ! $field ) {
781 781
 				continue;
782 782
 			}
783 783
 
784
-			if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
784
+			if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
785 785
 
786 786
 				// Get the value of the field, including $_POSTed value
787 787
 				$value = RGFormsModel::get_field_value( $field );
788 788
 
789 789
 				// Use temporary entry variable, to make values available to fill_post_template() and update_post_image()
790 790
 				$entry_tmp = $this->entry;
791
-				$entry_tmp["{$field_id}"] = $value;
791
+				$entry_tmp[ "{$field_id}" ] = $value;
792 792
 
793
-				switch( $field->type ) {
793
+				switch ( $field->type ) {
794 794
 
795 795
 				    case 'post_title':
796 796
 				        $post_title = $value;
797 797
 				        if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
798
-				            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
798
+				            $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp );
799 799
 				        }
800 800
 				        $updated_post->post_title = $post_title;
801 801
 				        $updated_post->post_name  = $post_title;
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 				    case 'post_content':
806 806
 				        $post_content = $value;
807 807
 				        if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
808
-				            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
808
+				            $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true );
809 809
 				        }
810 810
 				        $updated_post->post_content = $post_content;
811 811
 				        unset( $post_content );
@@ -823,11 +823,11 @@  discard block
 block discarded – undo
823 823
 							$value = $value[ $field_id ];
824 824
 						}
825 825
 
826
-				        if( ! empty( $field->customFieldTemplateEnabled ) ) {
826
+				        if ( ! empty( $field->customFieldTemplateEnabled ) ) {
827 827
 				            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
828 828
 				        }
829 829
 
830
-						$value = $field->get_value_save_entry( $value, $form, '', $this->entry['id'], $this->entry );
830
+						$value = $field->get_value_save_entry( $value, $form, '', $this->entry[ 'id' ], $this->entry );
831 831
 
832 832
 				        update_post_meta( $post_id, $field->postCustomFieldName, $value );
833 833
 				        break;
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
 				}
840 840
 
841 841
 				// update entry after
842
-				$this->entry["{$field_id}"] = $value;
842
+				$this->entry[ "{$field_id}" ] = $value;
843 843
 
844 844
 				$update_entry = true;
845 845
 
@@ -848,11 +848,11 @@  discard block
 block discarded – undo
848 848
 
849 849
 		}
850 850
 
851
-		if( $update_entry ) {
851
+		if ( $update_entry ) {
852 852
 
853 853
 			$return_entry = GFAPI::update_entry( $this->entry );
854 854
 
855
-			if( is_wp_error( $return_entry ) ) {
855
+			if ( is_wp_error( $return_entry ) ) {
856 856
 				gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) );
857 857
 			} else {
858 858
 				gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) );
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
 
863 863
 		$return_post = wp_update_post( $updated_post, true );
864 864
 
865
-		if( is_wp_error( $return_post ) ) {
865
+		if ( is_wp_error( $return_post ) ) {
866 866
 			$return_post->add_data( $updated_post, '$updated_post' );
867 867
 			gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) );
868 868
 		} else {
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 		$output = GFCommon::replace_variables( $output, $form, $entry, false, false, false );
897 897
 
898 898
 		// replace conditional shortcodes
899
-		if( $do_shortcode ) {
899
+		if ( $do_shortcode ) {
900 900
 			$output = do_shortcode( $output );
901 901
 		}
902 902
 
@@ -915,19 +915,19 @@  discard block
 block discarded – undo
915 915
 	 */
916 916
 	private function after_update() {
917 917
 
918
-		do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry );
919
-		do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry );
918
+		do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry );
919
+		do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry );
920 920
 
921 921
 		// Re-define the entry now that we've updated it.
922
-		$entry = RGFormsModel::get_lead( $this->entry['id'] );
922
+		$entry = RGFormsModel::get_lead( $this->entry[ 'id' ] );
923 923
 
924 924
 		$entry = GFFormsModel::set_entry_meta( $entry, self::$original_form );
925 925
 
926 926
 		if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) {
927 927
 			// We need to clear the cache because Gravity Forms caches the field values, which
928 928
 			// we have just updated.
929
-			foreach ($this->form['fields'] as $key => $field) {
930
-				GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );
929
+			foreach ( $this->form[ 'fields' ] as $key => $field ) {
930
+				GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id );
931 931
 			}
932 932
 		}
933 933
 
@@ -937,11 +937,11 @@  discard block
 block discarded – undo
937 937
 		 * @since develop
938 938
 		 */
939 939
 		if ( $allowed_feeds = $this->view->settings->get( 'edit_feeds', array() ) ) {
940
-			$feeds = GFAPI::get_feeds( null, $entry['form_id'] );
940
+			$feeds = GFAPI::get_feeds( null, $entry[ 'form_id' ] );
941 941
 			if ( ! is_wp_error( $feeds ) ) {
942 942
 				$registered_feeds = array();
943 943
 				foreach ( GFAddOn::get_registered_addons() as $registered_feed ) {
944
-					if ( is_subclass_of( $registered_feed,  'GFFeedAddOn' ) ) {
944
+					if ( is_subclass_of( $registered_feed, 'GFFeedAddOn' ) ) {
945 945
 						if ( method_exists( $registered_feed, 'get_instance' ) ) {
946 946
 							$registered_feed = call_user_func( array( $registered_feed, 'get_instance' ) );
947 947
 							$registered_feeds[ $registered_feed->get_slug() ] = $registered_feed;
@@ -949,8 +949,8 @@  discard block
 block discarded – undo
949 949
 					}
950 950
 				}
951 951
 				foreach ( $feeds as $feed ) {
952
-					if ( in_array( $feed['id'], $allowed_feeds ) ) {
953
-						if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed['addon_slug'] ) ) {
952
+					if ( in_array( $feed[ 'id' ], $allowed_feeds ) ) {
953
+						if ( $feed_object = \GV\Utils::get( $registered_feeds, $feed[ 'addon_slug' ] ) ) {
954 954
 							$returned_entry = $feed_object->process_feed( $feed, $entry, self::$original_form );
955 955
 							if ( is_array( $returned_entry ) && rgar( $returned_entry, 'id' ) ) {
956 956
 								$entry = $returned_entry;
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
 
981 981
 		<div class="gv-edit-entry-wrapper"><?php
982 982
 
983
-			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );
983
+			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this );
984 984
 
985 985
 			/**
986 986
 			 * Fixes weird wpautop() issue
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
 				     * @param string $edit_entry_title Modify the "Edit Entry" title
997 997
 				     * @param GravityView_Edit_Entry_Render $this This object
998 998
 				     */
999
-				    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
999
+				    $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this );
1000 1000
 
1001 1001
 				    echo esc_attr( $edit_entry_title );
1002 1002
 			?></span>
@@ -1062,18 +1062,18 @@  discard block
 block discarded – undo
1062 1062
 				*/
1063 1063
 				$labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id );
1064 1064
 
1065
-				$this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels['submit'];
1065
+				$this->is_paged_submitted = \GV\Utils::_POST( 'save' ) === $labels[ 'submit' ];
1066 1066
 			}
1067 1067
 
1068 1068
 			$back_link = remove_query_arg( array( 'page', 'view', 'edit' ) );
1069 1069
 
1070
-			if( ! $this->is_valid ){
1070
+			if ( ! $this->is_valid ) {
1071 1071
 
1072 1072
 				// Keeping this compatible with Gravity Forms.
1073
-				$validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
1074
-				$message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form);
1073
+				$validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>";
1074
+				$message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form );
1075 1075
 
1076
-				echo GVCommon::generate_notice( $message , 'gv-error' );
1076
+				echo GVCommon::generate_notice( $message, 'gv-error' );
1077 1077
 
1078 1078
 			} elseif ( false === $this->is_paged_submitted ) {
1079 1079
 				// Paged form that hasn't been submitted on the last page yet
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
 				 * @param int $view_id View ID
1087 1087
 				 * @param array $entry Gravity Forms entry array
1088 1088
 				 */
1089
-				$message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message , $this->view_id, $this->entry );
1089
+				$message = apply_filters( 'gravityview/edit_entry/page/success', $entry_updated_message, $this->view_id, $this->entry );
1090 1090
 
1091 1091
 				echo GVCommon::generate_notice( $message );
1092 1092
 			} else {
@@ -1098,23 +1098,23 @@  discard block
 block discarded – undo
1098 1098
 
1099 1099
                     case '0':
1100 1100
 	                    $redirect_url = $back_link;
1101
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
1101
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' );
1102 1102
                         break;
1103 1103
 
1104 1104
                     case '1':
1105 1105
 	                    $redirect_url = $directory_link = GravityView_API::directory_link();
1106
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
1106
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to %s%s', 'Replacement 1 is HTML. Replacement 2 is the title of the page where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $view->post_title ), '</a>' );
1107 1107
 	                    break;
1108 1108
 
1109 1109
                     case '2':
1110 1110
 	                    $redirect_url = $edit_redirect_url;
1111 1111
 	                    $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
1112
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.','gravityview'), '<a href="'. esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
1112
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sRedirecting to %s%s', 'Replacement 1 is HTML. Replacement 2 is the URL where the user will be taken. Replacement 3 is HTML.', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', esc_html( $edit_redirect_url ), '</a>' );
1113 1113
                         break;
1114 1114
 
1115 1115
                     case '':
1116 1116
                     default:
1117
-					    $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
1117
+					    $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' );
1118 1118
                         break;
1119 1119
 				}
1120 1120
 
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 				 * @param array $entry Gravity Forms entry array
1131 1131
 				 * @param string $back_link URL to return to the original entry. @since 1.6
1132 1132
 				 */
1133
-				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );
1133
+				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link );
1134 1134
 
1135 1135
 				echo GVCommon::generate_notice( $message );
1136 1136
 			}
@@ -1154,8 +1154,8 @@  discard block
 block discarded – undo
1154 1154
 		 */
1155 1155
 		do_action( 'gravityview/edit-entry/render/before', $this );
1156 1156
 
1157
-		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );
1158
-		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );
1157
+		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 );
1158
+		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
1159 1159
 		add_filter( 'gform_next_button', array( $this, 'render_form_buttons' ) );
1160 1160
 		add_filter( 'gform_previous_button', array( $this, 'render_form_buttons' ) );
1161 1161
 		add_filter( 'gform_disable_view_counter', '__return_true' );
@@ -1164,14 +1164,14 @@  discard block
 block discarded – undo
1164 1164
 		add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );
1165 1165
 
1166 1166
 		// We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.
1167
-		unset( $_GET['page'] );
1167
+		unset( $_GET[ 'page' ] );
1168 1168
 
1169 1169
 		$this->show_next_button = false;
1170 1170
 		$this->show_previous_button = false;
1171 1171
 
1172 1172
 		// TODO: Verify multiple-page forms
1173 1173
 		if ( GFCommon::has_pages( $this->form ) && apply_filters( 'gravityview/features/paged-edit', false ) ) {
1174
-			if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form['id'], 0 ) ) ) {
1174
+			if ( intval( $page_number = \GV\Utils::_POST( 'gform_source_page_number_' . $this->form[ 'id' ], 0 ) ) ) {
1175 1175
 
1176 1176
 				$labels = array(
1177 1177
 					'cancel'   => __( 'Cancel', 'gravityview' ),
@@ -1190,16 +1190,16 @@  discard block
 block discarded – undo
1190 1190
 				*/
1191 1191
 				$labels = apply_filters( 'gravityview/edit_entry/button_labels', $labels, $this->form, $this->entry, $this->view_id );
1192 1192
 
1193
-				GFFormDisplay::$submission[ $this->form['id'] ][ 'form' ] = $this->form;
1194
-				GFFormDisplay::$submission[ $this->form['id'] ][ 'is_valid' ] = true;
1193
+				GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'form' ] = $this->form;
1194
+				GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'is_valid' ] = true;
1195 1195
 
1196
-				if ( \GV\Utils::_POST( 'save' ) === $labels['next'] ) {
1196
+				if ( \GV\Utils::_POST( 'save' ) === $labels[ 'next' ] ) {
1197 1197
 					$page_number++;
1198
-				} elseif ( \GV\Utils::_POST( 'save' ) === $labels['previous'] ) {
1198
+				} elseif ( \GV\Utils::_POST( 'save' ) === $labels[ 'previous' ] ) {
1199 1199
 					$page_number--;
1200 1200
 				}
1201 1201
 
1202
-				GFFormDisplay::$submission[ $this->form['id'] ][ 'page_number' ] = $page_number;
1202
+				GFFormDisplay::$submission[ $this->form[ 'id' ] ][ 'page_number' ] = $page_number;
1203 1203
 			}
1204 1204
 
1205 1205
 			if ( ( $page_number = intval( $page_number ) ) < 2 ) {
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
 
1226 1226
 		ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic
1227 1227
 
1228
-		$html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );
1228
+		$html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry );
1229 1229
 
1230 1230
 		ob_get_clean();
1231 1231
 
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 	 * @return string
1254 1254
 	 */
1255 1255
 	public function render_form_buttons() {
1256
-		return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );
1256
+		return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this );
1257 1257
 	}
1258 1258
 
1259 1259
 
@@ -1272,15 +1272,15 @@  discard block
 block discarded – undo
1272 1272
 	 */
1273 1273
 	public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) {
1274 1274
 
1275
-		if( $form['id'] != $this->form_id ) {
1275
+		if ( $form[ 'id' ] != $this->form_id ) {
1276 1276
 			return $form;
1277 1277
 		}
1278 1278
 
1279 1279
 		// In case we have validated the form, use it to inject the validation results into the form render
1280
-		if( isset( $this->form_after_validation ) && $this->form_after_validation['id'] === $form['id'] ) {
1280
+		if ( isset( $this->form_after_validation ) && $this->form_after_validation[ 'id' ] === $form[ 'id' ] ) {
1281 1281
 			$form = $this->form_after_validation;
1282 1282
 		} else {
1283
-			$form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );
1283
+			$form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id );
1284 1284
 		}
1285 1285
 
1286 1286
 		$form = $this->filter_conditional_logic( $form );
@@ -1288,8 +1288,8 @@  discard block
 block discarded – undo
1288 1288
 		$form = $this->prefill_conditional_logic( $form );
1289 1289
 
1290 1290
 		// for now we don't support Save and Continue feature.
1291
-		if( ! self::$supports_save_and_continue ) {
1292
-	        unset( $form['save'] );
1291
+		if ( ! self::$supports_save_and_continue ) {
1292
+	        unset( $form[ 'save' ] );
1293 1293
 		}
1294 1294
 
1295 1295
 		$form = $this->unselect_default_values( $form );
@@ -1312,31 +1312,31 @@  discard block
 block discarded – undo
1312 1312
 	 */
1313 1313
 	public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) {
1314 1314
 
1315
-		if( ! GFCommon::is_post_field( $field ) ) {
1315
+		if ( ! GFCommon::is_post_field( $field ) ) {
1316 1316
 			return $field_content;
1317 1317
 		}
1318 1318
 
1319 1319
         $message = null;
1320 1320
 
1321 1321
         // First, make sure they have the capability to edit the post.
1322
-        if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1322
+        if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) {
1323 1323
 
1324 1324
             /**
1325 1325
              * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1326 1326
              * @param string $message The existing "You don't have permission..." text
1327 1327
              */
1328
-            $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1328
+            $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don&rsquo;t have permission to edit this post.', 'gravityview' ) );
1329 1329
 
1330
-        } elseif( null === get_post( $this->entry['post_id'] ) ) {
1330
+        } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) {
1331 1331
             /**
1332 1332
              * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1333 1333
              * @param string $message The existing "This field is not editable; the post no longer exists." text
1334 1334
              */
1335
-            $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1335
+            $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) );
1336 1336
         }
1337 1337
 
1338
-        if( $message ) {
1339
-            $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1338
+        if ( $message ) {
1339
+            $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1340 1340
         }
1341 1341
 
1342 1342
         return $field_content;
@@ -1360,8 +1360,8 @@  discard block
 block discarded – undo
1360 1360
 
1361 1361
 		// If the form has been submitted, then we don't need to pre-fill the values,
1362 1362
 		// Except for fileupload type and when a field input is overridden- run always!!
1363
-		if(
1364
-			( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1363
+		if (
1364
+			( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1365 1365
 			&& false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) )
1366 1366
 			&& ! GFCommon::is_product_field( $field->type )
1367 1367
 			|| ! empty( $field_content )
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
 	    $return = null;
1382 1382
 
1383 1383
 		/** @var GravityView_Field $gv_field */
1384
-		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1384
+		if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1385 1385
 			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1386 1386
 		} else {
1387 1387
 	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
 	    // If there was output, it's an error
1391 1391
 	    $warnings = ob_get_clean();
1392 1392
 
1393
-	    if( !empty( $warnings ) ) {
1393
+	    if ( ! empty( $warnings ) ) {
1394 1394
 		    gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1395 1395
 	    }
1396 1396
 
@@ -1415,7 +1415,7 @@  discard block
 block discarded – undo
1415 1415
 		$override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );
1416 1416
 
1417 1417
 		// We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)
1418
-		if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) {
1418
+		if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) {
1419 1419
 
1420 1420
 			$field_value = array();
1421 1421
 
@@ -1424,10 +1424,10 @@  discard block
 block discarded – undo
1424 1424
 
1425 1425
 			foreach ( (array)$field->inputs as $input ) {
1426 1426
 
1427
-				$input_id = strval( $input['id'] );
1427
+				$input_id = strval( $input[ 'id' ] );
1428 1428
 
1429 1429
 				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1430
-				    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1430
+				    $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1431 1431
 				    $allow_pre_populated = false;
1432 1432
 				}
1433 1433
 
@@ -1435,7 +1435,7 @@  discard block
 block discarded – undo
1435 1435
 
1436 1436
 			$pre_value = $field->get_value_submission( array(), false );
1437 1437
 
1438
-			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1438
+			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1439 1439
 
1440 1440
 		} else {
1441 1441
 
@@ -1446,13 +1446,13 @@  discard block
 block discarded – undo
1446 1446
 
1447 1447
 			// saved field entry value (if empty, fallback to the pre-populated value, if exists)
1448 1448
 			// or pre-populated value if not empty and set to override saved value
1449
-			$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;
1449
+			$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;
1450 1450
 
1451 1451
 			// in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.
1452
-			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1452
+			if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) {
1453 1453
 				$categories = array();
1454 1454
 				foreach ( explode( ',', $field_value ) as $cat_string ) {
1455
-				    $categories[] = GFCommon::format_post_category( $cat_string, true );
1455
+				    $categories[ ] = GFCommon::format_post_category( $cat_string, true );
1456 1456
 				}
1457 1457
 				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1458 1458
 			}
@@ -1480,7 +1480,7 @@  discard block
 block discarded – undo
1480 1480
 	     * @param GF_Field $field Gravity Forms field object
1481 1481
 	     * @param GravityView_Edit_Entry_Render $this Current object
1482 1482
 	     */
1483
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1483
+	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this );
1484 1484
 
1485 1485
 		return $field_value;
1486 1486
 	}
@@ -1497,12 +1497,12 @@  discard block
 block discarded – undo
1497 1497
 	 */
1498 1498
 	public function gform_pre_validation( $form ) {
1499 1499
 
1500
-		if( ! $this->verify_nonce() ) {
1500
+		if ( ! $this->verify_nonce() ) {
1501 1501
 			return $form;
1502 1502
 		}
1503 1503
 
1504 1504
 		// Fix PHP warning regarding undefined index.
1505
-		foreach ( $form['fields'] as &$field) {
1505
+		foreach ( $form[ 'fields' ] as &$field ) {
1506 1506
 
1507 1507
 			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1508 1508
 			// expects certain field array items to be set.
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
 	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1511 1511
 			}
1512 1512
 
1513
-			switch( RGFormsModel::get_input_type( $field ) ) {
1513
+			switch ( RGFormsModel::get_input_type( $field ) ) {
1514 1514
 
1515 1515
 				/**
1516 1516
 				 * 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.
@@ -1524,26 +1524,26 @@  discard block
 block discarded – undo
1524 1524
 				    // Set the previous value
1525 1525
 				    $entry = $this->get_entry();
1526 1526
 
1527
-				    $input_name = 'input_'.$field->id;
1528
-				    $form_id = $form['id'];
1527
+				    $input_name = 'input_' . $field->id;
1528
+				    $form_id = $form[ 'id' ];
1529 1529
 
1530 1530
 				    $value = NULL;
1531 1531
 
1532 1532
 				    // Use the previous entry value as the default.
1533
-				    if( isset( $entry[ $field->id ] ) ) {
1533
+				    if ( isset( $entry[ $field->id ] ) ) {
1534 1534
 				        $value = $entry[ $field->id ];
1535 1535
 				    }
1536 1536
 
1537 1537
 				    // If this is a single upload file
1538
-				    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1539
-				        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1540
-				        $value = $file_path['url'];
1538
+				    if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
1539
+				        $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] );
1540
+				        $value = $file_path[ 'url' ];
1541 1541
 
1542 1542
 				    } else {
1543 1543
 
1544 1544
 				        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1545 1545
 				        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1546
-				        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1546
+				        $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' );
1547 1547
 
1548 1548
 				    }
1549 1549
 
@@ -1551,10 +1551,10 @@  discard block
 block discarded – undo
1551 1551
 
1552 1552
 				        // If there are fresh uploads, process and merge them.
1553 1553
 				        // Otherwise, use the passed values, which should be json-encoded array of URLs
1554
-				        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1554
+				        if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) {
1555 1555
 				            $value = empty( $value ) ? '[]' : $value;
1556 1556
 				            $value = stripslashes_deep( $value );
1557
-				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1557
+				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() );
1558 1558
 				        }
1559 1559
 
1560 1560
 				    } else {
@@ -1572,8 +1572,8 @@  discard block
 block discarded – undo
1572 1572
 
1573 1573
 				case 'number':
1574 1574
 				    // Fix "undefined index" issue at line 1286 in form_display.php
1575
-				    if( !isset( $_POST['input_'.$field->id ] ) ) {
1576
-				        $_POST['input_'.$field->id ] = NULL;
1575
+				    if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) {
1576
+				        $_POST[ 'input_' . $field->id ] = NULL;
1577 1577
 				    }
1578 1578
 				    break;
1579 1579
 			}
@@ -1610,7 +1610,7 @@  discard block
 block discarded – undo
1610 1610
 		 * You can enter whatever you want!
1611 1611
 		 * We try validating, and customize the results using `self::custom_validation()`
1612 1612
 		 */
1613
-		add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);
1613
+		add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 );
1614 1614
 
1615 1615
 		// Needed by the validate funtion
1616 1616
 		$failed_validation_page = NULL;
@@ -1618,14 +1618,14 @@  discard block
 block discarded – undo
1618 1618
 
1619 1619
 		// Prevent entry limit from running when editing an entry, also
1620 1620
 		// prevent form scheduling from preventing editing
1621
-		unset( $this->form['limitEntries'], $this->form['scheduleForm'] );
1621
+		unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] );
1622 1622
 
1623 1623
 		// Hide fields depending on Edit Entry settings
1624
-		$this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1624
+		$this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1625 1625
 
1626 1626
 		$this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );
1627 1627
 
1628
-		remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 );
1628
+		remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 );
1629 1629
 	}
1630 1630
 
1631 1631
 
@@ -1648,7 +1648,7 @@  discard block
 block discarded – undo
1648 1648
 
1649 1649
 		$gv_valid = true;
1650 1650
 
1651
-		foreach ( $validation_results['form']['fields'] as $key => &$field ) {
1651
+		foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) {
1652 1652
 
1653 1653
 			$value = RGFormsModel::get_field_value( $field );
1654 1654
 			$field_type = RGFormsModel::get_input_type( $field );
@@ -1661,22 +1661,22 @@  discard block
 block discarded – undo
1661 1661
 				case 'post_image':
1662 1662
 
1663 1663
 				    // in case nothing is uploaded but there are already files saved
1664
-				    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1664
+				    if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) {
1665 1665
 				        $field->failed_validation = false;
1666 1666
 				        unset( $field->validation_message );
1667 1667
 				    }
1668 1668
 
1669 1669
 				    // validate if multi file upload reached max number of files [maxFiles] => 2
1670
-				    if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1670
+				    if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) {
1671 1671
 
1672 1672
 				        $input_name = 'input_' . $field->id;
1673 1673
 				        //uploaded
1674
-				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1674
+				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array();
1675 1675
 
1676 1676
 				        //existent
1677 1677
 				        $entry = $this->get_entry();
1678 1678
 				        $value = NULL;
1679
-				        if( isset( $entry[ $field->id ] ) ) {
1679
+				        if ( isset( $entry[ $field->id ] ) ) {
1680 1680
 				            $value = json_decode( $entry[ $field->id ], true );
1681 1681
 				        }
1682 1682
 
@@ -1684,13 +1684,13 @@  discard block
 block discarded – undo
1684 1684
 				        $count_files = ( is_array( $file_names ) ? count( $file_names ) : 0 ) +
1685 1685
 						               ( is_array( $value ) ? count( $value ) : 0 );
1686 1686
 
1687
-				        if( $count_files > $field->maxFiles ) {
1687
+				        if ( $count_files > $field->maxFiles ) {
1688 1688
 				            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1689 1689
 				            $field->failed_validation = 1;
1690 1690
 				            $gv_valid = false;
1691 1691
 
1692 1692
 				            // in case of error make sure the newest upload files are removed from the upload input
1693
-				            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1693
+				            GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null;
1694 1694
 				        }
1695 1695
 
1696 1696
 				    }
@@ -1701,7 +1701,7 @@  discard block
 block discarded – undo
1701 1701
 			}
1702 1702
 
1703 1703
 			// This field has failed validation.
1704
-			if( !empty( $field->failed_validation ) ) {
1704
+			if ( ! empty( $field->failed_validation ) ) {
1705 1705
 
1706 1706
 				gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) );
1707 1707
 
@@ -1719,19 +1719,19 @@  discard block
 block discarded – undo
1719 1719
 				}
1720 1720
 
1721 1721
 				// You can't continue inside a switch, so we do it after.
1722
-				if( empty( $field->failed_validation ) ) {
1722
+				if ( empty( $field->failed_validation ) ) {
1723 1723
 				    continue;
1724 1724
 				}
1725 1725
 
1726 1726
 				// checks if the No Duplicates option is not validating entry against itself, since
1727 1727
 				// we're editing a stored entry, it would also assume it's a duplicate.
1728
-				if( !empty( $field->noDuplicates ) ) {
1728
+				if ( ! empty( $field->noDuplicates ) ) {
1729 1729
 
1730 1730
 				    $entry = $this->get_entry();
1731 1731
 
1732 1732
 				    // If the value of the entry is the same as the stored value
1733 1733
 				    // Then we can assume it's not a duplicate, it's the same.
1734
-				    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1734
+				    if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) {
1735 1735
 				        //if value submitted was not changed, then don't validate
1736 1736
 				        $field->failed_validation = false;
1737 1737
 
@@ -1744,7 +1744,7 @@  discard block
 block discarded – undo
1744 1744
 				}
1745 1745
 
1746 1746
 				// if here then probably we are facing the validation 'At least one field must be filled out'
1747
-				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1747
+				if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) {
1748 1748
 				    unset( $field->validation_message );
1749 1749
 	                $field->validation_message = false;
1750 1750
 				    continue;
@@ -1756,12 +1756,12 @@  discard block
 block discarded – undo
1756 1756
 
1757 1757
 		}
1758 1758
 
1759
-		$validation_results['is_valid'] = $gv_valid;
1759
+		$validation_results[ 'is_valid' ] = $gv_valid;
1760 1760
 
1761 1761
 		gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) );
1762 1762
 
1763 1763
 		// We'll need this result when rendering the form ( on GFFormDisplay::get_form )
1764
-		$this->form_after_validation = $validation_results['form'];
1764
+		$this->form_after_validation = $validation_results[ 'form' ];
1765 1765
 
1766 1766
 		return $validation_results;
1767 1767
 	}
@@ -1774,7 +1774,7 @@  discard block
 block discarded – undo
1774 1774
 	 */
1775 1775
 	public function get_entry() {
1776 1776
 
1777
-		if( empty( $this->entry ) ) {
1777
+		if ( empty( $this->entry ) ) {
1778 1778
 			// Get the database value of the entry that's being edited
1779 1779
 			$this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );
1780 1780
 		}
@@ -1806,10 +1806,10 @@  discard block
 block discarded – undo
1806 1806
 		}
1807 1807
 
1808 1808
 		// If edit tab not yet configured, show all fields
1809
-		$edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;
1809
+		$edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL;
1810 1810
 
1811 1811
 		// Hide fields depending on admin settings
1812
-		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1812
+		$fields = $this->filter_fields( $form[ 'fields' ], $edit_fields );
1813 1813
 
1814 1814
 	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1815 1815
 	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
@@ -1842,7 +1842,7 @@  discard block
 block discarded – undo
1842 1842
 	 */
1843 1843
 	private function filter_fields( $fields, $configured_fields ) {
1844 1844
 
1845
-		if( empty( $fields ) || !is_array( $fields ) ) {
1845
+		if ( empty( $fields ) || ! is_array( $fields ) ) {
1846 1846
 			return $fields;
1847 1847
 		}
1848 1848
 
@@ -1859,12 +1859,12 @@  discard block
 block discarded – undo
1859 1859
 
1860 1860
 			// Remove the fields that have calculation properties and keep them to be used later
1861 1861
 			// @since 1.16.2
1862
-			if( $field->has_calculation() ) {
1863
-				$this->fields_with_calculation[] = $field;
1862
+			if ( $field->has_calculation() ) {
1863
+				$this->fields_with_calculation[ ] = $field;
1864 1864
 				// don't remove the calculation fields on form render.
1865 1865
 			}
1866 1866
 
1867
-			if( in_array( $field->type, $field_type_blacklist ) ) {
1867
+			if ( in_array( $field->type, $field_type_blacklist ) ) {
1868 1868
 				unset( $fields[ $key ] );
1869 1869
 			}
1870 1870
 		}
@@ -1882,7 +1882,7 @@  discard block
 block discarded – undo
1882 1882
 					continue; // Same
1883 1883
 				}
1884 1884
 
1885
-				$out_fields[] = $field;
1885
+				$out_fields[ ] = $field;
1886 1886
 			}
1887 1887
 
1888 1888
 			return array_values( $out_fields );
@@ -1893,8 +1893,8 @@  discard block
 block discarded – undo
1893 1893
 
1894 1894
 	        /** @var GF_Field $field */
1895 1895
 	        foreach ( $fields as $field ) {
1896
-				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1897
-				    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1896
+				if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1897
+				    $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field );
1898 1898
 				    break;
1899 1899
 				}
1900 1900
 
@@ -1917,14 +1917,14 @@  discard block
 block discarded – undo
1917 1917
 
1918 1918
 		$return_field = $field;
1919 1919
 
1920
-		if( empty( $field_setting['show_label'] ) ) {
1920
+		if ( empty( $field_setting[ 'show_label' ] ) ) {
1921 1921
 			$return_field->label = '';
1922
-		} elseif ( !empty( $field_setting['custom_label'] ) ) {
1923
-			$return_field->label = $field_setting['custom_label'];
1922
+		} elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) {
1923
+			$return_field->label = $field_setting[ 'custom_label' ];
1924 1924
 		}
1925 1925
 
1926
-		if( !empty( $field_setting['custom_class'] ) ) {
1927
-			$return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );
1926
+		if ( ! empty( $field_setting[ 'custom_class' ] ) ) {
1927
+			$return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] );
1928 1928
 		}
1929 1929
 
1930 1930
 		/**
@@ -1962,16 +1962,16 @@  discard block
 block discarded – undo
1962 1962
 	     */
1963 1963
 	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1964 1964
 
1965
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1966
-			foreach( $fields as $k => $field ) {
1967
-				if( $field->adminOnly ) {
1965
+	    if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) {
1966
+			foreach ( $fields as $k => $field ) {
1967
+				if ( $field->adminOnly ) {
1968 1968
 				    unset( $fields[ $k ] );
1969 1969
 				}
1970 1970
 			}
1971 1971
 			return array_values( $fields );
1972 1972
 		}
1973 1973
 
1974
-	    foreach( $fields as &$field ) {
1974
+	    foreach ( $fields as &$field ) {
1975 1975
 		    $field->adminOnly = false;
1976 1976
 		}
1977 1977
 
@@ -1992,7 +1992,7 @@  discard block
 block discarded – undo
1992 1992
 	 */
1993 1993
 	private function unselect_default_values( $form ) {
1994 1994
 
1995
-	    foreach ( $form['fields'] as &$field ) {
1995
+	    foreach ( $form[ 'fields' ] as &$field ) {
1996 1996
 
1997 1997
 			if ( empty( $field->choices ) ) {
1998 1998
                 continue;
@@ -2000,7 +2000,7 @@  discard block
 block discarded – undo
2000 2000
 
2001 2001
             foreach ( $field->choices as &$choice ) {
2002 2002
 				if ( \GV\Utils::get( $choice, 'isSelected' ) ) {
2003
-					$choice['isSelected'] = false;
2003
+					$choice[ 'isSelected' ] = false;
2004 2004
 				}
2005 2005
 			}
2006 2006
 		}
@@ -2025,22 +2025,22 @@  discard block
 block discarded – undo
2025 2025
 	 */
2026 2026
 	function prefill_conditional_logic( $form ) {
2027 2027
 
2028
-		if( ! GFFormDisplay::has_conditional_logic( $form ) ) {
2028
+		if ( ! GFFormDisplay::has_conditional_logic( $form ) ) {
2029 2029
 			return $form;
2030 2030
 		}
2031 2031
 
2032 2032
 		// Have Conditional Logic pre-fill fields as if the data were default values
2033 2033
 		/** @var GF_Field $field */
2034
-		foreach ( $form['fields'] as &$field ) {
2034
+		foreach ( $form[ 'fields' ] as &$field ) {
2035 2035
 
2036
-			if( 'checkbox' === $field->type ) {
2036
+			if ( 'checkbox' === $field->type ) {
2037 2037
 				foreach ( $field->get_entry_inputs() as $key => $input ) {
2038
-				    $input_id = $input['id'];
2038
+				    $input_id = $input[ 'id' ];
2039 2039
 				    $choice = $field->choices[ $key ];
2040 2040
 				    $value = \GV\Utils::get( $this->entry, $input_id );
2041 2041
 				    $match = RGFormsModel::choice_value_match( $field, $choice, $value );
2042
-				    if( $match ) {
2043
-				        $field->choices[ $key ]['isSelected'] = true;
2042
+				    if ( $match ) {
2043
+				        $field->choices[ $key ][ 'isSelected' ] = true;
2044 2044
 				    }
2045 2045
 				}
2046 2046
 			} else {
@@ -2048,15 +2048,15 @@  discard block
 block discarded – undo
2048 2048
 				// We need to run through each field to set the default values
2049 2049
 				foreach ( $this->entry as $field_id => $field_value ) {
2050 2050
 
2051
-				    if( floatval( $field_id ) === floatval( $field->id ) ) {
2051
+				    if ( floatval( $field_id ) === floatval( $field->id ) ) {
2052 2052
 
2053
-				        if( 'list' === $field->type ) {
2053
+				        if ( 'list' === $field->type ) {
2054 2054
 				            $list_rows = maybe_unserialize( $field_value );
2055 2055
 
2056 2056
 				            $list_field_value = array();
2057
-				            foreach ( (array) $list_rows as $row ) {
2058
-				                foreach ( (array) $row as $column ) {
2059
-				                    $list_field_value[] = $column;
2057
+				            foreach ( (array)$list_rows as $row ) {
2058
+				                foreach ( (array)$row as $column ) {
2059
+				                    $list_field_value[ ] = $column;
2060 2060
 				                }
2061 2061
 				            }
2062 2062
 
@@ -2089,32 +2089,32 @@  discard block
 block discarded – undo
2089 2089
 		 * @see https://github.com/gravityview/GravityView/issues/840
2090 2090
 		 * @since develop
2091 2091
 		 */
2092
-		$the_form = GFAPI::get_form( $form['id'] );
2092
+		$the_form = GFAPI::get_form( $form[ 'id' ] );
2093 2093
 		$editable_ids = array();
2094
-		foreach ( $form['fields'] as $field ) {
2095
-			$editable_ids[] = $field['id']; // wp_list_pluck is destructive in this context
2094
+		foreach ( $form[ 'fields' ] as $field ) {
2095
+			$editable_ids[ ] = $field[ 'id' ]; // wp_list_pluck is destructive in this context
2096 2096
 		}
2097 2097
 		$remove_conditions_rule = array();
2098
-		foreach ( $the_form['fields'] as $field ) {
2099
-			if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic['rules'] ) ) {
2100
-				foreach ( $field->conditionalLogic['rules'] as $i => $rule ) {
2101
-					if ( ! in_array( $rule['fieldId'], $editable_ids ) ) {
2098
+		foreach ( $the_form[ 'fields' ] as $field ) {
2099
+			if ( ! empty( $field->conditionalLogic ) && ! empty( $field->conditionalLogic[ 'rules' ] ) ) {
2100
+				foreach ( $field->conditionalLogic[ 'rules' ] as $i => $rule ) {
2101
+					if ( ! in_array( $rule[ 'fieldId' ], $editable_ids ) ) {
2102 2102
 						/**
2103 2103
 						 * This conditional field is not editable in this View.
2104 2104
 						 * We need to remove the rule, but only if it matches.
2105 2105
 						 */
2106
-						if ( $_field = GFAPI::get_field( $the_form, $rule['fieldId'] ) ) {
2106
+						if ( $_field = GFAPI::get_field( $the_form, $rule[ 'fieldId' ] ) ) {
2107 2107
 							$value = $_field->get_value_export( $this->entry );
2108
-						} elseif ( isset( $this->entry[ $rule['fieldId'] ] ) ) {
2109
-							$value = $this->entry[ $rule['fieldId'] ];
2108
+						} elseif ( isset( $this->entry[ $rule[ 'fieldId' ] ] ) ) {
2109
+							$value = $this->entry[ $rule[ 'fieldId' ] ];
2110 2110
 						} else {
2111
-							$value = gform_get_meta( $this->entry['id'], $rule['fieldId'] );
2111
+							$value = gform_get_meta( $this->entry[ 'id' ], $rule[ 'fieldId' ] );
2112 2112
 						}
2113 2113
 
2114
-						$match = GFFormsModel::matches_operation( $value, $rule['value'], $rule['operator'] );
2114
+						$match = GFFormsModel::matches_operation( $value, $rule[ 'value' ], $rule[ 'operator' ] );
2115 2115
 						
2116 2116
 						if ( $match ) {
2117
-							$remove_conditions_rule[] = array( $field['id'], $i );
2117
+							$remove_conditions_rule[ ] = array( $field[ 'id' ], $i );
2118 2118
 						}
2119 2119
 					}
2120 2120
 				}
@@ -2122,21 +2122,21 @@  discard block
 block discarded – undo
2122 2122
 		}
2123 2123
 
2124 2124
 		if ( $remove_conditions_rule ) {
2125
-			foreach ( $form['fields'] as &$field ) {
2125
+			foreach ( $form[ 'fields' ] as &$field ) {
2126 2126
 				foreach ( $remove_conditions_rule as $_remove_conditions_r ) {
2127 2127
 
2128 2128
 				    list( $rule_field_id, $rule_i ) = $_remove_conditions_r;
2129 2129
 
2130
-					if ( $field['id'] == $rule_field_id ) {
2131
-						unset( $field->conditionalLogic['rules'][ $rule_i ] );
2132
-						gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field['id'] ) );
2130
+					if ( $field[ 'id' ] == $rule_field_id ) {
2131
+						unset( $field->conditionalLogic[ 'rules' ][ $rule_i ] );
2132
+						gravityview()->log->debug( 'Removed conditional rule #{rule} for field {field_id}', array( 'rule' => $rule_i, 'field_id' => $field[ 'id' ] ) );
2133 2133
 					}
2134 2134
 				}
2135 2135
 			}
2136 2136
 		}
2137 2137
 
2138 2138
 		/** Normalize the indices... */
2139
-		$form['fields'] = array_values( $form['fields'] );
2139
+		$form[ 'fields' ] = array_values( $form[ 'fields' ] );
2140 2140
 
2141 2141
 		/**
2142 2142
 		 * @filter `gravityview/edit_entry/conditional_logic` Should the Edit Entry form use Gravity Forms conditional logic showing/hiding of fields?
@@ -2146,16 +2146,16 @@  discard block
 block discarded – undo
2146 2146
 		 */
2147 2147
 		$use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );
2148 2148
 
2149
-		if( $use_conditional_logic ) {
2149
+		if ( $use_conditional_logic ) {
2150 2150
 			return $form;
2151 2151
 		}
2152 2152
 
2153
-		foreach( $form['fields'] as &$field ) {
2153
+		foreach ( $form[ 'fields' ] as &$field ) {
2154 2154
 			/* @var GF_Field $field */
2155 2155
 			$field->conditionalLogic = null;
2156 2156
 		}
2157 2157
 
2158
-		unset( $form['button']['conditionalLogic'] );
2158
+		unset( $form[ 'button' ][ 'conditionalLogic' ] );
2159 2159
 
2160 2160
 		return $form;
2161 2161
 
@@ -2172,7 +2172,7 @@  discard block
 block discarded – undo
2172 2172
 	 */
2173 2173
 	public function manage_conditional_logic( $has_conditional_logic, $form ) {
2174 2174
 
2175
-		if( ! $this->is_edit_entry() ) {
2175
+		if ( ! $this->is_edit_entry() ) {
2176 2176
 			return $has_conditional_logic;
2177 2177
 		}
2178 2178
 
@@ -2204,44 +2204,44 @@  discard block
 block discarded – undo
2204 2204
 		 *  2. There are two entries embedded using oEmbed
2205 2205
 		 *  3. One of the entries has just been saved
2206 2206
 		 */
2207
-		if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) {
2207
+		if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) {
2208 2208
 
2209 2209
 			$error = true;
2210 2210
 
2211 2211
 		}
2212 2212
 
2213
-		if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) {
2213
+		if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) {
2214 2214
 
2215 2215
 			$error = true;
2216 2216
 
2217
-		} elseif( ! $this->verify_nonce() ) {
2217
+		} elseif ( ! $this->verify_nonce() ) {
2218 2218
 
2219 2219
 			/**
2220 2220
 			 * If the Entry is embedded, there may be two entries on the same page.
2221 2221
 			 * If that's the case, and one is being edited, the other should fail gracefully and not display an error.
2222 2222
 			 */
2223
-			if( GravityView_oEmbed::getInstance()->get_entry_id() ) {
2223
+			if ( GravityView_oEmbed::getInstance()->get_entry_id() ) {
2224 2224
 				$error = true;
2225 2225
 			} else {
2226
-				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');
2226
+				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' );
2227 2227
 			}
2228 2228
 
2229 2229
 		}
2230 2230
 
2231
-		if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
2232
-			$error = __( 'You do not have permission to edit this entry.', 'gravityview');
2231
+		if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
2232
+			$error = __( 'You do not have permission to edit this entry.', 'gravityview' );
2233 2233
 		}
2234 2234
 
2235
-		if( $this->entry['status'] === 'trash' ) {
2236
-			$error = __('You cannot edit the entry; it is in the trash.', 'gravityview' );
2235
+		if ( $this->entry[ 'status' ] === 'trash' ) {
2236
+			$error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' );
2237 2237
 		}
2238 2238
 
2239 2239
 		// No errors; everything's fine here!
2240
-		if( empty( $error ) ) {
2240
+		if ( empty( $error ) ) {
2241 2241
 			return true;
2242 2242
 		}
2243 2243
 
2244
-		if( $echo && $error !== true ) {
2244
+		if ( $echo && $error !== true ) {
2245 2245
 
2246 2246
 	        $error = esc_html( $error );
2247 2247
 
@@ -2249,10 +2249,10 @@  discard block
 block discarded – undo
2249 2249
 	         * @since 1.9
2250 2250
 	         */
2251 2251
 	        if ( ! empty( $this->entry ) ) {
2252
-		        $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;" ) );
2252
+		        $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;" ) );
2253 2253
 	        }
2254 2254
 
2255
-			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
2255
+			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' );
2256 2256
 		}
2257 2257
 
2258 2258
 		gravityview()->log->error( '{error}', array( 'error' => $error ) );
@@ -2272,17 +2272,17 @@  discard block
 block discarded – undo
2272 2272
 
2273 2273
 		$error = NULL;
2274 2274
 
2275
-		if( ! $this->check_user_cap_edit_field( $field ) ) {
2276
-			$error = __( 'You do not have permission to edit this field.', 'gravityview');
2275
+		if ( ! $this->check_user_cap_edit_field( $field ) ) {
2276
+			$error = __( 'You do not have permission to edit this field.', 'gravityview' );
2277 2277
 		}
2278 2278
 
2279 2279
 		// No errors; everything's fine here!
2280
-		if( empty( $error ) ) {
2280
+		if ( empty( $error ) ) {
2281 2281
 			return true;
2282 2282
 		}
2283 2283
 
2284
-		if( $echo ) {
2285
-			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');
2284
+		if ( $echo ) {
2285
+			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' );
2286 2286
 		}
2287 2287
 
2288 2288
 		gravityview()->log->error( '{error}', array( 'error' => $error ) );
@@ -2303,14 +2303,14 @@  discard block
 block discarded – undo
2303 2303
 	private function check_user_cap_edit_field( $field ) {
2304 2304
 
2305 2305
 		// If they can edit any entries (as defined in Gravity Forms), we're good.
2306
-		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
2306
+		if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
2307 2307
 			return true;
2308 2308
 		}
2309 2309
 
2310
-		$field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;
2310
+		$field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false;
2311 2311
 
2312
-		if( $field_cap ) {
2313
-			return GVCommon::has_cap( $field['allow_edit_cap'] );
2312
+		if ( $field_cap ) {
2313
+			return GVCommon::has_cap( $field[ 'allow_edit_cap' ] );
2314 2314
 		}
2315 2315
 
2316 2316
 		return false;
@@ -2324,17 +2324,17 @@  discard block
 block discarded – undo
2324 2324
 	public function verify_nonce() {
2325 2325
 
2326 2326
 		// Verify form submitted for editing single
2327
-		if( $this->is_edit_entry_submission() ) {
2327
+		if ( $this->is_edit_entry_submission() ) {
2328 2328
 			$valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );
2329 2329
 		}
2330 2330
 
2331 2331
 		// Verify
2332
-		else if( ! $this->is_edit_entry() ) {
2332
+		else if ( ! $this->is_edit_entry() ) {
2333 2333
 			$valid = false;
2334 2334
 		}
2335 2335
 
2336 2336
 		else {
2337
-			$valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
2337
+			$valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key );
2338 2338
 		}
2339 2339
 
2340 2340
 		/**
Please login to merge, or discard this patch.