Completed
Pull Request — master (#1197)
by Zack
22:52 queued 18:53
created
includes/widgets/search-widget/class-search-widget.php 1 patch
Spacing   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 				'type' => 'radio',
65 65
 				'full_width' => true,
66 66
 				'label' => esc_html__( 'Search Mode', 'gravityview' ),
67
-				'desc' => __('Should search results match all search fields, or any?', 'gravityview'),
67
+				'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ),
68 68
 				'value' => 'any',
69 69
 				'class' => 'hide-if-js',
70 70
 				'options' => array(
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
 			// admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999
88 88
 			add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 );
89
-			add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') );
89
+			add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) );
90 90
 			add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) );
91 91
 
92 92
 			// ajax - get the searchable fields
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 		$script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
228 228
 		$script_source = empty( $script_min ) ? '/source' : '';
229 229
 
230
-		wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version );
230
+		wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version );
231 231
 
232 232
 		wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array(
233 233
 			'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ),
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	 * @return array Scripts allowed in no-conflict mode, plus the search widget script
250 250
 	 */
251 251
 	public function register_no_conflict( $allowed ) {
252
-		$allowed[] = 'gravityview_searchwidget_admin';
252
+		$allowed[ ] = 'gravityview_searchwidget_admin';
253 253
 		return $allowed;
254 254
 	}
255 255
 
@@ -262,24 +262,24 @@  discard block
 block discarded – undo
262 262
 	 */
263 263
 	public static function get_searchable_fields() {
264 264
 
265
-		if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) {
265
+		if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) {
266 266
 			exit( '0' );
267 267
 		}
268 268
 
269 269
 		$form = '';
270 270
 
271 271
 		// Fetch the form for the current View
272
-		if ( ! empty( $_POST['view_id'] ) ) {
272
+		if ( ! empty( $_POST[ 'view_id' ] ) ) {
273 273
 
274
-			$form = gravityview_get_form_id( $_POST['view_id'] );
274
+			$form = gravityview_get_form_id( $_POST[ 'view_id' ] );
275 275
 
276
-		} elseif ( ! empty( $_POST['formid'] ) ) {
276
+		} elseif ( ! empty( $_POST[ 'formid' ] ) ) {
277 277
 
278
-			$form = (int) $_POST['formid'];
278
+			$form = (int)$_POST[ 'formid' ];
279 279
 
280
-		} elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) {
280
+		} elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) {
281 281
 
282
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
282
+			$form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] );
283 283
 
284 284
 		}
285 285
 
@@ -329,14 +329,14 @@  discard block
 block discarded – undo
329 329
 		);
330 330
 
331 331
 		if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) {
332
-			$custom_fields['is_approved'] = array(
332
+			$custom_fields[ 'is_approved' ] = array(
333 333
 				'text' => esc_html__( 'Approval Status', 'gravityview' ),
334 334
 				'type' => 'multi',
335 335
 			);
336 336
 		}
337 337
 
338
-		foreach( $custom_fields as $custom_field_key => $custom_field ) {
339
-			$output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] );
338
+		foreach ( $custom_fields as $custom_field_key => $custom_field ) {
339
+			$output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field[ 'type' ], self::get_field_label( array( 'field' => $custom_field_key ) ), $custom_field[ 'text' ] );
340 340
 		}
341 341
 
342 342
 		// Get fields with sub-inputs and no parent
@@ -358,13 +358,13 @@  discard block
 block discarded – undo
358 358
 
359 359
 			foreach ( $fields as $id => $field ) {
360 360
 
361
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
361
+				if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
362 362
 					continue;
363 363
 				}
364 364
 
365
-				$types = self::get_search_input_types( $id, $field['type'] );
365
+				$types = self::get_search_input_types( $id, $field[ 'type' ] );
366 366
 
367
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>';
367
+				$output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>';
368 368
 			}
369 369
 		}
370 370
 
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	public static function get_search_input_types( $field_id = '', $field_type = null ) {
388 388
 
389 389
 		// @todo - This needs to be improved - many fields have . including products and addresses
390
-		if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) {
390
+		if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) {
391 391
 			$input_type = 'boolean'; // on/off checkbox
392 392
 		} elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) {
393 393
 			$input_type = 'multi'; //multiselect
@@ -431,19 +431,19 @@  discard block
 block discarded – undo
431 431
 			$post_id = 0;
432 432
 
433 433
 			// We're in the WordPress Widget context, and an overriding post ID has been set.
434
-			if ( ! empty( $widget_args['post_id'] ) ) {
435
-				$post_id = absint( $widget_args['post_id'] );
434
+			if ( ! empty( $widget_args[ 'post_id' ] ) ) {
435
+				$post_id = absint( $widget_args[ 'post_id' ] );
436 436
 			}
437 437
 			// We're in the WordPress Widget context, and the base View ID should be used
438
-			else if ( ! empty( $widget_args['view_id'] ) ) {
439
-				$post_id = absint( $widget_args['view_id'] );
438
+			else if ( ! empty( $widget_args[ 'view_id' ] ) ) {
439
+				$post_id = absint( $widget_args[ 'view_id' ] );
440 440
 			}
441 441
 
442 442
 			$args = gravityview_get_permalink_query_args( $post_id );
443 443
 
444 444
 			// Add hidden fields to the search form
445 445
 			foreach ( $args as $key => $value ) {
446
-				$search_fields[] = array(
446
+				$search_fields[ ] = array(
447 447
 					'name'  => $key,
448 448
 					'input' => 'hidden',
449 449
 					'value' => $value,
@@ -482,22 +482,22 @@  discard block
 block discarded – undo
482 482
 		/**
483 483
 		 * Include the sidebar Widgets.
484 484
 		 */
485
-		$widgets = (array) get_option( 'widget_gravityview_search', array() );
485
+		$widgets = (array)get_option( 'widget_gravityview_search', array() );
486 486
 
487 487
 		foreach ( $widgets as $widget ) {
488
-			if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) {
489
-				if( $_fields = json_decode( $widget['search_fields'], true ) ) {
488
+			if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) {
489
+				if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) {
490 490
 					foreach ( $_fields as $field ) {
491
-						$searchable_fields [] = $with_full_field ? $field : $field['field'];
491
+						$searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ];
492 492
 					}
493 493
 				}
494 494
 			}
495 495
 		}
496 496
 
497 497
 		foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) {
498
-			if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) {
498
+			if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) {
499 499
 				foreach ( $_fields as $field ) {
500
-					$searchable_fields [] = $with_full_field ? $field : $field['field'];
500
+					$searchable_fields [ ] = $with_full_field ? $field : $field[ 'field' ];
501 501
 				}
502 502
 			}
503 503
 		}
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 			return $search_criteria; // Return the original criteria, GF_Query modification kicks in later
528 528
 		}
529 529
 
530
-		if( 'post' === $this->search_method ) {
530
+		if ( 'post' === $this->search_method ) {
531 531
 			$get = $_POST;
532 532
 		} else {
533 533
 			$get = $_GET;
@@ -546,14 +546,14 @@  discard block
 block discarded – undo
546 546
 		$get = gv_map_deep( $get, 'rawurldecode' );
547 547
 
548 548
 		// Make sure array key is set up
549
-		$search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() );
549
+		$search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() );
550 550
 
551 551
 		$searchable_fields = $this->get_view_searchable_fields( $view );
552 552
 
553 553
 		// add free search
554
-		if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) {
554
+		if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) {
555 555
 
556
-			$search_all_value = trim( $get['gv_search'] );
556
+			$search_all_value = trim( $get[ 'gv_search' ] );
557 557
 
558 558
 			/**
559 559
 			 * @filter `gravityview/search-all-split-words` Search for each word separately or the whole phrase?
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 			}
579 579
 
580 580
 			foreach ( $words as $word ) {
581
-				$search_criteria['field_filters'][] = array(
581
+				$search_criteria[ 'field_filters' ][ ] = array(
582 582
 					'key' => null, // The field ID to search
583 583
 					'value' => $word, // The value to search
584 584
 					'operator' => 'contains', // What to search in. Options: `is` or `contains`
@@ -591,14 +591,14 @@  discard block
 block discarded – undo
591 591
 			/**
592 592
 			 * Get and normalize the dates according to the input format.
593 593
 			 */
594
-			if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) {
595
-				if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) {
594
+			if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) {
595
+				if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) {
596 596
 					$curr_start = $curr_start_date->format( 'Y-m-d' );
597 597
 				}
598 598
 			}
599 599
 
600
-			if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) {
601
-				if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) {
600
+			if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) {
601
+				if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) {
602 602
 					$curr_end = $curr_end_date->format( 'Y-m-d' );
603 603
 				}
604 604
 			}
@@ -633,22 +633,22 @@  discard block
 block discarded – undo
633 633
 			 */
634 634
 			if ( ! empty( $curr_start ) ) {
635 635
 				$curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) );
636
-				$search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
636
+				$search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
637 637
 			}
638 638
 
639 639
 			if ( ! empty( $curr_end ) ) {
640 640
 				// Fast-forward 24 hour on the end time
641 641
 				$curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS );
642
-				$search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
643
-				if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056
644
-					$search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 );
642
+				$search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
643
+				if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056
644
+					$search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 );
645 645
 				}
646 646
 			}
647 647
 		}
648 648
 
649 649
 		// search for a specific entry ID
650 650
 		if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) {
651
-			$search_criteria['field_filters'][] = array(
651
+			$search_criteria[ 'field_filters' ][ ] = array(
652 652
 				'key' => 'id',
653 653
 				'value' => absint( $get[ 'gv_id' ] ),
654 654
 				'operator' => '=',
@@ -657,41 +657,41 @@  discard block
 block discarded – undo
657 657
 
658 658
 		// search for a specific Created_by ID
659 659
 		if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) {
660
-			$search_criteria['field_filters'][] = array(
660
+			$search_criteria[ 'field_filters' ][ ] = array(
661 661
 				'key' => 'created_by',
662
-				'value' => $get['gv_by'],
662
+				'value' => $get[ 'gv_by' ],
663 663
 				'operator' => '=',
664 664
 			);
665 665
 		}
666 666
 
667 667
 		// Get search mode passed in URL
668
-		$mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ?  $get['mode'] : 'any';
668
+		$mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any';
669 669
 
670 670
 		// get the other search filters
671 671
 		foreach ( $get as $key => $value ) {
672 672
 
673
-			if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) {
673
+			if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) {
674 674
 				continue;
675 675
 			}
676 676
 
677 677
 			$filter_key = $this->convert_request_key_to_filter_key( $key );
678 678
 
679 679
 			// could return simple filter or multiple filters
680
-			if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key , $searchable_fields ) ) {
680
+			if ( ! in_array( 'search_all', $searchable_fields ) && ! in_array( $filter_key, $searchable_fields ) ) {
681 681
 				continue;
682 682
 			}
683 683
 
684 684
 			$filter = $this->prepare_field_filter( $filter_key, $value, $view );
685 685
 
686
-			if ( isset( $filter[0]['value'] ) ) {
687
-				$search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter );
686
+			if ( isset( $filter[ 0 ][ 'value' ] ) ) {
687
+				$search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter );
688 688
 
689 689
 				// if date range type, set search mode to ALL
690
-				if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) {
690
+				if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) {
691 691
 					$mode = 'all';
692 692
 				}
693
-			} elseif( !empty( $filter ) ) {
694
-				$search_criteria['field_filters'][] = $filter;
693
+			} elseif ( ! empty( $filter ) ) {
694
+				$search_criteria[ 'field_filters' ][ ] = $filter;
695 695
 			}
696 696
 		}
697 697
 
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 		 * @since 1.5.1
701 701
 		 * @param[out,in] string $mode Search mode (`any` vs `all`)
702 702
 		 */
703
-		$search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode );
703
+		$search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode );
704 704
 
705 705
 		gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) );
706 706
 
@@ -725,16 +725,16 @@  discard block
 block discarded – undo
725 725
 		 */
726 726
 		$search_criteria = $this->filter_entries( array(), null, array( 'id' => $view->ID ), true /** force search_criteria */ );
727 727
 
728
-		if ( empty( $search_criteria['field_filters'] ) ) {
728
+		if ( empty( $search_criteria[ 'field_filters' ] ) ) {
729 729
 			return;
730 730
 		}
731 731
 
732 732
 		$widgets = $view->widgets->by_id( $this->widget_id );
733 733
 		if ( $widgets->count() ) {
734 734
 			$widgets = $widgets->all();
735
-			$widget  = $widgets[0];
735
+			$widget  = $widgets[ 0 ];
736 736
 			foreach ( $search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) as $search_field ) {
737
-				if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) {
737
+				if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) {
738 738
 					$created_by_text_mode = true;
739 739
 				}
740 740
 			}
@@ -742,19 +742,19 @@  discard block
 block discarded – undo
742 742
 
743 743
 		$extra_conditions = array();
744 744
 
745
-		foreach ( $search_criteria['field_filters'] as &$filter ) {
745
+		foreach ( $search_criteria[ 'field_filters' ] as &$filter ) {
746 746
 			if ( ! is_array( $filter ) ) {
747 747
 				continue;
748 748
 			}
749 749
 
750 750
 			// Construct a manual query for unapproved statuses
751
-			if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'], true ) ) {
752
-				$_tmp_query       = new GF_Query( $view->form->ID, array(
751
+			if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array)$filter[ 'value' ], true ) ) {
752
+				$_tmp_query = new GF_Query( $view->form->ID, array(
753 753
 					'field_filters' => array(
754 754
 						array(
755 755
 							'operator' => 'in',
756 756
 							'key'      => 'is_approved',
757
-							'value'    => $filter['value'],
757
+							'value'    => $filter[ 'value' ],
758 758
 						),
759 759
 						array(
760 760
 							'operator' => 'is',
@@ -766,25 +766,25 @@  discard block
 block discarded – undo
766 766
 				) );
767 767
 				$_tmp_query_parts = $_tmp_query->_introspect();
768 768
 
769
-				$extra_conditions[] = $_tmp_query_parts['where'];
769
+				$extra_conditions[ ] = $_tmp_query_parts[ 'where' ];
770 770
 
771 771
 				$filter = false;
772 772
 				continue;
773 773
 			}
774 774
 
775 775
 			// Construct manual query for text mode creator search
776
-			if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) {
777
-				$extra_conditions[] = new GravityView_Widget_Search_GF_Query_Condition( $filter, $view );
776
+			if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) {
777
+				$extra_conditions[ ] = new GravityView_Widget_Search_GF_Query_Condition( $filter, $view );
778 778
 				$filter = false;
779 779
 				continue;
780 780
 			}
781 781
 
782 782
 			// By default, we want searches to be wildcard for each field.
783
-			$filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator'];
783
+			$filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ];
784 784
 
785 785
 			// For multichoice, let's have an in (OR) search.
786
-			if ( is_array( $filter['value'] ) ) {
787
-				$filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)?
786
+			if ( is_array( $filter[ 'value' ] ) ) {
787
+				$filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)?
788 788
 			}
789 789
 
790 790
 			/**
@@ -792,10 +792,10 @@  discard block
 block discarded – undo
792 792
 			 * @param string $operator Existing search operator
793 793
 			 * @param array $filter array with `key`, `value`, `operator`, `type` keys
794 794
 			 */
795
-			$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter );
795
+			$filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter );
796 796
 		}
797 797
 
798
-		$search_criteria['field_filters'] = array_filter( $search_criteria['field_filters'] );
798
+		$search_criteria[ 'field_filters' ] = array_filter( $search_criteria[ 'field_filters' ] );
799 799
 
800 800
 		/**
801 801
 		 * Parse the filter criteria to generate the needed
@@ -808,12 +808,12 @@  discard block
 block discarded – undo
808 808
 		/**
809 809
 		 * Grab the current clauses. We'll be combining them shortly.
810 810
 		 */
811
-		$query_parts      = $query->_introspect();
811
+		$query_parts = $query->_introspect();
812 812
 
813 813
 		/**
814 814
 		 * Combine the parts as a new WHERE clause.
815 815
 		 */
816
-		$where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'], $_tmp_query_parts['where'] ), $extra_conditions ) );
816
+		$where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ], $_tmp_query_parts[ 'where' ] ), $extra_conditions ) );
817 817
 		$query->where( $where );
818 818
 	}
819 819
 
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 		$field_id = str_replace( 'filter_', '', $key );
837 837
 
838 838
 		// calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox )
839
-		if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) {
839
+		if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) {
840 840
 			$field_id = str_replace( '_', '.', $field_id );
841 841
 		}
842 842
 
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 
872 872
 			case 'select':
873 873
 			case 'radio':
874
-				$filter['operator'] = 'is';
874
+				$filter[ 'operator' ] = 'is';
875 875
 				break;
876 876
 
877 877
 			case 'post_category':
@@ -885,7 +885,7 @@  discard block
 block discarded – undo
885 885
 
886 886
 				foreach ( $value as $val ) {
887 887
 					$cat = get_term( $val, 'category' );
888
-					$filter[] = array(
888
+					$filter[ ] = array(
889 889
 						'key'      => $filter_key,
890 890
 						'value'    => esc_attr( $cat->name ) . ':' . $val,
891 891
 						'operator' => 'is',
@@ -904,7 +904,7 @@  discard block
 block discarded – undo
904 904
 				$filter = array();
905 905
 
906 906
 				foreach ( $value as $val ) {
907
-					$filter[] = array( 'key' => $filter_key, 'value' => $val );
907
+					$filter[ ] = array( 'key' => $filter_key, 'value' => $val );
908 908
 				}
909 909
 
910 910
 				break;
@@ -913,9 +913,9 @@  discard block
 block discarded – undo
913 913
 				// convert checkbox on/off into the correct search filter
914 914
 				if ( false !== strpos( $filter_key, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) {
915 915
 					foreach ( $form_field->inputs as $k => $input ) {
916
-						if ( $input['id'] == $filter_key ) {
917
-							$filter['value'] = $form_field->choices[ $k ]['value'];
918
-							$filter['operator'] = 'is';
916
+						if ( $input[ 'id' ] == $filter_key ) {
917
+							$filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ];
918
+							$filter[ 'operator' ] = 'is';
919 919
 							break;
920 920
 						}
921 921
 					}
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
 					$filter = array();
926 926
 
927 927
 					foreach ( $value as $val ) {
928
-						$filter[] = array(
928
+						$filter[ ] = array(
929 929
 							'key'      => $filter_key,
930 930
 							'value'    => $val,
931 931
 							'operator' => 'is',
@@ -946,9 +946,9 @@  discard block
 block discarded – undo
946 946
 					foreach ( $words as $word ) {
947 947
 						if ( ! empty( $word ) && strlen( $word ) > 1 ) {
948 948
 							// Keep the same key for each filter
949
-							$filter['value'] = $word;
949
+							$filter[ 'value' ] = $word;
950 950
 							// Add a search for the value
951
-							$filters[] = $filter;
951
+							$filters[ ] = $filter;
952 952
 						}
953 953
 					}
954 954
 
@@ -962,19 +962,19 @@  discard block
 block discarded – undo
962 962
 
963 963
 					foreach ( $searchable_fields as $searchable_field ) {
964 964
 
965
-						if( $form_field->ID !== $searchable_field['field'] ) {
965
+						if ( $form_field->ID !== $searchable_field[ 'field' ] ) {
966 966
 							continue;
967 967
 						}
968 968
 
969 969
 						// Only exact-match dropdowns, not text search
970
-						if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) {
970
+						if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) {
971 971
 							continue;
972 972
 						}
973 973
 
974 974
 						$input_id = gravityview_get_input_id_from_id( $form_field->ID );
975 975
 
976 976
 						if ( 4 === $input_id ) {
977
-							$filter['operator'] = 'is';
977
+							$filter[ 'operator' ] = 'is';
978 978
 						};
979 979
 					}
980 980
 				}
@@ -1001,12 +1001,12 @@  discard block
 block discarded – undo
1001 1001
 						 * @since 1.16.3
1002 1002
 						 * Safeguard until GF implements '<=' operator
1003 1003
 						 */
1004
-						if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
1004
+						if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
1005 1005
 							$operator = '<';
1006 1006
 							$date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) );
1007 1007
 						}
1008 1008
 
1009
-						$filter[] = array(
1009
+						$filter[ ] = array(
1010 1010
 							'key'      => $filter_key,
1011 1011
 							'value'    => self::get_formatted_date( $date, 'Y-m-d', $date_format ),
1012 1012
 							'operator' => $operator,
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
 					}
1015 1015
 				} else {
1016 1016
 					$date = $value;
1017
-					$filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format );
1017
+					$filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format );
1018 1018
 				}
1019 1019
 
1020 1020
 				break;
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
 			'ymd_dot' => 'Y.m.d',
1046 1046
 		);
1047 1047
 
1048
-		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){
1048
+		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) {
1049 1049
 			$format = $datepicker[ $field->dateFormat ];
1050 1050
 		}
1051 1051
 
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
 	public function add_template_path( $file_paths ) {
1083 1083
 
1084 1084
 		// Index 100 is the default GravityView template path.
1085
-		$file_paths[102] = self::$file . 'templates/';
1085
+		$file_paths[ 102 ] = self::$file . 'templates/';
1086 1086
 
1087 1087
 		return $file_paths;
1088 1088
 	}
@@ -1101,7 +1101,7 @@  discard block
 block discarded – undo
1101 1101
 		$has_date = false;
1102 1102
 
1103 1103
 		foreach ( $search_fields as $k => $field ) {
1104
-			if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) {
1104
+			if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) {
1105 1105
 				$has_date = true;
1106 1106
 				break;
1107 1107
 			}
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 		}
1129 1129
 
1130 1130
 		// get configured search fields
1131
-		$search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : '';
1131
+		$search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : '';
1132 1132
 
1133 1133
 		if ( empty( $search_fields ) || ! is_array( $search_fields ) ) {
1134 1134
 			gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) );
@@ -1143,40 +1143,40 @@  discard block
 block discarded – undo
1143 1143
 
1144 1144
 			$updated_field = $this->get_search_filter_details( $updated_field );
1145 1145
 
1146
-			switch ( $field['field'] ) {
1146
+			switch ( $field[ 'field' ] ) {
1147 1147
 
1148 1148
 				case 'search_all':
1149
-					$updated_field['key'] = 'search_all';
1150
-					$updated_field['input'] = 'search_all';
1151
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' );
1149
+					$updated_field[ 'key' ] = 'search_all';
1150
+					$updated_field[ 'input' ] = 'search_all';
1151
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' );
1152 1152
 					break;
1153 1153
 
1154 1154
 				case 'entry_date':
1155
-					$updated_field['key'] = 'entry_date';
1156
-					$updated_field['input'] = 'entry_date';
1157
-					$updated_field['value'] = array(
1155
+					$updated_field[ 'key' ] = 'entry_date';
1156
+					$updated_field[ 'input' ] = 'entry_date';
1157
+					$updated_field[ 'value' ] = array(
1158 1158
 						'start' => $this->rgget_or_rgpost( 'gv_start' ),
1159 1159
 						'end' => $this->rgget_or_rgpost( 'gv_end' ),
1160 1160
 					);
1161 1161
 					break;
1162 1162
 
1163 1163
 				case 'entry_id':
1164
-					$updated_field['key'] = 'entry_id';
1165
-					$updated_field['input'] = 'entry_id';
1166
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' );
1164
+					$updated_field[ 'key' ] = 'entry_id';
1165
+					$updated_field[ 'input' ] = 'entry_id';
1166
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' );
1167 1167
 					break;
1168 1168
 
1169 1169
 				case 'created_by':
1170
-					$updated_field['key'] = 'created_by';
1171
-					$updated_field['name'] = 'gv_by';
1172
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' );
1173
-					$updated_field['choices'] = self::get_created_by_choices();
1170
+					$updated_field[ 'key' ] = 'created_by';
1171
+					$updated_field[ 'name' ] = 'gv_by';
1172
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' );
1173
+					$updated_field[ 'choices' ] = self::get_created_by_choices();
1174 1174
 					break;
1175 1175
 				
1176 1176
 				case 'is_approved':
1177
-					$updated_field['key'] = 'is_approved';
1178
-					$updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' );
1179
-					$updated_field['choices'] = self::get_is_approved_choices();
1177
+					$updated_field[ 'key' ] = 'is_approved';
1178
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' );
1179
+					$updated_field[ 'choices' ] = self::get_is_approved_choices();
1180 1180
 					break;
1181 1181
 			}
1182 1182
 
@@ -1195,16 +1195,16 @@  discard block
 block discarded – undo
1195 1195
 		 */
1196 1196
 		$gravityview_view->search_fields = apply_filters( 'gravityview_widget_search_filters', $search_fields, $this, $widget_args, $context );
1197 1197
 
1198
-		$gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal';
1198
+		$gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal';
1199 1199
 
1200 1200
 		/** @since 1.14 */
1201
-		$gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any';
1201
+		$gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any';
1202 1202
 
1203
-		$custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : '';
1203
+		$custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : '';
1204 1204
 
1205 1205
 		$gravityview_view->search_class = self::get_search_class( $custom_class );
1206 1206
 
1207
-		$gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false;
1207
+		$gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false;
1208 1208
 
1209 1209
 		if ( $this->has_date_field( $search_fields ) ) {
1210 1210
 			// enqueue datepicker stuff only if needed!
@@ -1226,10 +1226,10 @@  discard block
 block discarded – undo
1226 1226
 	public static function get_search_class( $custom_class = '' ) {
1227 1227
 		$gravityview_view = GravityView_View::getInstance();
1228 1228
 
1229
-		$search_class = 'gv-search-'.$gravityview_view->search_layout;
1229
+		$search_class = 'gv-search-' . $gravityview_view->search_layout;
1230 1230
 
1231
-		if ( ! empty( $custom_class )  ) {
1232
-			$search_class .= ' '.$custom_class;
1231
+		if ( ! empty( $custom_class ) ) {
1232
+			$search_class .= ' ' . $custom_class;
1233 1233
 		}
1234 1234
 
1235 1235
 		/**
@@ -1273,9 +1273,9 @@  discard block
 block discarded – undo
1273 1273
 
1274 1274
 		if ( ! $label ) {
1275 1275
 
1276
-			$label = isset( $form_field['label'] ) ? $form_field['label'] : '';
1276
+			$label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : '';
1277 1277
 
1278
-			switch( $field['field'] ) {
1278
+			switch ( $field[ 'field' ] ) {
1279 1279
 				case 'search_all':
1280 1280
 					$label = __( 'Search Entries:', 'gravityview' );
1281 1281
 					break;
@@ -1287,10 +1287,10 @@  discard block
 block discarded – undo
1287 1287
 					break;
1288 1288
 				default:
1289 1289
 					// If this is a field input, not a field
1290
-					if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) {
1290
+					if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) {
1291 1291
 
1292 1292
 						// Get the label for the field in question, which returns an array
1293
-						$items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) );
1293
+						$items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) );
1294 1294
 
1295 1295
 						// Get the item with the `label` key
1296 1296
 						$values = wp_list_pluck( $items, 'label' );
@@ -1329,32 +1329,32 @@  discard block
 block discarded – undo
1329 1329
 		$form = $gravityview_view->getForm();
1330 1330
 
1331 1331
 		// for advanced field ids (eg, first name / last name )
1332
-		$name = 'filter_' . str_replace( '.', '_', $field['field'] );
1332
+		$name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] );
1333 1333
 
1334 1334
 		// get searched value from $_GET/$_POST (string or array)
1335 1335
 		$value = $this->rgget_or_rgpost( $name );
1336 1336
 
1337 1337
 		// get form field details
1338
-		$form_field = gravityview_get_field( $form, $field['field'] );
1338
+		$form_field = gravityview_get_field( $form, $field[ 'field' ] );
1339 1339
 
1340 1340
 		$filter = array(
1341
-			'key' => $field['field'],
1341
+			'key' => $field[ 'field' ],
1342 1342
 			'name' => $name,
1343 1343
 			'label' => self::get_field_label( $field, $form_field ),
1344
-			'input' => $field['input'],
1344
+			'input' => $field[ 'input' ],
1345 1345
 			'value' => $value,
1346
-			'type' => $form_field['type'],
1346
+			'type' => $form_field[ 'type' ],
1347 1347
 		);
1348 1348
 
1349 1349
 		// collect choices
1350
-		if ( 'post_category' === $form_field['type'] && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) {
1351
-			$filter['choices'] = gravityview_get_terms_choices();
1352
-		} elseif ( ! empty( $form_field['choices'] ) ) {
1353
-			$filter['choices'] = $form_field['choices'];
1350
+		if ( 'post_category' === $form_field[ 'type' ] && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) {
1351
+			$filter[ 'choices' ] = gravityview_get_terms_choices();
1352
+		} elseif ( ! empty( $form_field[ 'choices' ] ) ) {
1353
+			$filter[ 'choices' ] = $form_field[ 'choices' ];
1354 1354
 		}
1355 1355
 
1356
-		if ( 'date_range' === $field['input'] && empty( $value ) ) {
1357
-			$filter['value'] = array( 'start' => '', 'end' => '' );
1356
+		if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) {
1357
+			$filter[ 'value' ] = array( 'start' => '', 'end' => '' );
1358 1358
 		}
1359 1359
 
1360 1360
 		return $filter;
@@ -1378,7 +1378,7 @@  discard block
 block discarded – undo
1378 1378
 
1379 1379
 		$choices = array();
1380 1380
 		foreach ( $users as $user ) {
1381
-			$choices[] = array(
1381
+			$choices[ ] = array(
1382 1382
 				'value' => $user->ID,
1383 1383
 				'text' => $user->display_name,
1384 1384
 			);
@@ -1398,9 +1398,9 @@  discard block
 block discarded – undo
1398 1398
 
1399 1399
 		$choices = array();
1400 1400
 		foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) {
1401
-			$choices[] = array(
1402
-				'value' => $status['value'],
1403
-				'text' => $status['label'],
1401
+			$choices[ ] = array(
1402
+				'value' => $status[ 'value' ],
1403
+				'text' => $status[ 'label' ],
1404 1404
 			);
1405 1405
 		}
1406 1406
 
@@ -1452,7 +1452,7 @@  discard block
 block discarded – undo
1452 1452
 	 */
1453 1453
 	public function add_datepicker_js_dependency( $js_dependencies ) {
1454 1454
 
1455
-		$js_dependencies[] = 'jquery-ui-datepicker';
1455
+		$js_dependencies[ ] = 'jquery-ui-datepicker';
1456 1456
 
1457 1457
 		return $js_dependencies;
1458 1458
 	}
@@ -1496,7 +1496,7 @@  discard block
 block discarded – undo
1496 1496
 			'isRTL'             => is_rtl(),
1497 1497
 		), $view_data );
1498 1498
 
1499
-		$localizations['datepicker'] = $datepicker_settings;
1499
+		$localizations[ 'datepicker' ] = $datepicker_settings;
1500 1500
 
1501 1501
 		return $localizations;
1502 1502
 
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
 	 * @return void
1524 1524
 	 */
1525 1525
 	private function maybe_enqueue_flexibility() {
1526
-		if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) {
1526
+		if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
1527 1527
 			wp_enqueue_script( 'gv-flexibility' );
1528 1528
 		}
1529 1529
 	}
@@ -1545,7 +1545,7 @@  discard block
 block discarded – undo
1545 1545
 		add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 );
1546 1546
 
1547 1547
 		$scheme = is_ssl() ? 'https://' : 'http://';
1548
-		wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1548
+		wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1549 1549
 
1550 1550
 		/**
1551 1551
 		 * @filter `gravityview_search_datepicker_class`
@@ -1628,7 +1628,7 @@  discard block
 block discarded – undo
1628 1628
  */
1629 1629
 class GravityView_Widget_Search_GF_Query_Condition extends \GF_Query_Condition {
1630 1630
 	public function __construct( $filter, $view ) {
1631
-		$this->value = $filter['value'];
1631
+		$this->value = $filter[ 'value' ];
1632 1632
 		$this->view = $view;
1633 1633
 	}
1634 1634
 
@@ -1662,11 +1662,11 @@  discard block
 block discarded – undo
1662 1662
 		$conditions = array();
1663 1663
 
1664 1664
 		foreach ( $user_fields as $user_field ) {
1665
-			$conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) .  '%' );
1665
+			$conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' );
1666 1666
 		}
1667 1667
 
1668 1668
 		foreach ( $user_meta_fields as $meta_field ) {
1669
-			$conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) .  '%' );
1669
+			$conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' );
1670 1670
 		}
1671 1671
 
1672 1672
 		$conditions = '(' . implode( ' OR ', $conditions ) . ')';
Please login to merge, or discard this patch.
includes/widgets/search-widget/templates/search-field-select.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,14 +10,14 @@  discard block
 block discarded – undo
10 10
 $search_field = $gravityview_view->search_field;
11 11
 
12 12
 // Make sure that there are choices to display
13
-if( empty( $search_field['choices'] ) ) {
13
+if ( empty( $search_field[ 'choices' ] ) ) {
14 14
 	gravityview()->log->debug( 'search-field-select.php - No choices for field' );
15 15
 	return;
16 16
 }
17 17
 
18
-if( is_array( $search_field['value'] ) ) {
18
+if ( is_array( $search_field[ 'value' ] ) ) {
19 19
     gravityview()->log->debug( 'search-field-select.php - Array values passed; using first value.' );
20
-	$search_field['value'] = reset( $search_field['value'] );
20
+	$search_field[ 'value' ] = reset( $search_field[ 'value' ] );
21 21
 }
22 22
 
23 23
 /**
@@ -26,19 +26,19 @@  discard block
 block discarded – undo
26 26
  * @param string $default_option Default: `&mdash;` (—)
27 27
  * @param string $field_type Field type: "select" or "multiselect"
28 28
  */
29
-$default_option = apply_filters('gravityview/extension/search/select_default', '&mdash;', 'select' );
29
+$default_option = apply_filters( 'gravityview/extension/search/select_default', '&mdash;', 'select' );
30 30
 
31 31
 ?>
32 32
 <div class="gv-search-box gv-search-field-select">
33
-	<?php if( ! gv_empty( $search_field['label'], false, false ) ) { ?>
34
-		<label for="search-box-<?php echo esc_attr( $search_field['name'] ); ?>"><?php echo esc_html( $search_field['label'] ); ?></label>
33
+	<?php if ( ! gv_empty( $search_field[ 'label' ], false, false ) ) { ?>
34
+		<label for="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>"><?php echo esc_html( $search_field[ 'label' ] ); ?></label>
35 35
 	<?php } ?>
36 36
 	<p>
37
-		<select name="<?php echo esc_attr( $search_field['name'] ); ?>" id="search-box-<?php echo esc_attr( $search_field['name'] ); ?>">
38
-			<option value="" <?php gv_selected( '', $search_field['value'], true ); ?>><?php echo esc_html( $default_option ); ?></option>
37
+		<select name="<?php echo esc_attr( $search_field[ 'name' ] ); ?>" id="search-box-<?php echo esc_attr( $search_field[ 'name' ] ); ?>">
38
+			<option value="" <?php gv_selected( '', $search_field[ 'value' ], true ); ?>><?php echo esc_html( $default_option ); ?></option>
39 39
 			<?php
40
-			foreach( $search_field['choices'] as $choice ) : ?>
41
-				<option value="<?php echo esc_attr( $choice['value'] ); ?>" <?php gv_selected( esc_attr( $choice['value'] ), esc_attr( $search_field['value'] ), true ); ?>><?php echo esc_html( $choice['text'] ); ?></option>
40
+			foreach ( $search_field[ 'choices' ] as $choice ) : ?>
41
+				<option value="<?php echo esc_attr( $choice[ 'value' ] ); ?>" <?php gv_selected( esc_attr( $choice[ 'value' ] ), esc_attr( $search_field[ 'value' ] ), true ); ?>><?php echo esc_html( $choice[ 'text' ] ); ?></option>
42 42
 			<?php endforeach; ?>
43 43
 		</select>
44 44
 	</p>
Please login to merge, or discard this patch.
includes/extensions/edit-entry/class-edit-entry-render.php 1 patch
Spacing   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -115,16 +115,16 @@  discard block
 block discarded – undo
115 115
 	function load() {
116 116
 
117 117
 		/** @define "GRAVITYVIEW_DIR" "../../../" */
118
-		include_once( GRAVITYVIEW_DIR .'includes/class-admin-approve-entries.php' );
118
+		include_once( GRAVITYVIEW_DIR . 'includes/class-admin-approve-entries.php' );
119 119
 
120 120
 		// Don't display an embedded form when editing an entry
121 121
 		add_action( 'wp_head', array( $this, 'prevent_render_form' ) );
122 122
 		add_action( 'wp_footer', array( $this, 'prevent_render_form' ) );
123 123
 
124 124
 		// Stop Gravity Forms processing what is ours!
125
-		add_filter( 'wp', array( $this, 'prevent_maybe_process_form'), 8 );
125
+		add_filter( 'wp', array( $this, 'prevent_maybe_process_form' ), 8 );
126 126
 
127
-		add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry') );
127
+		add_filter( 'gravityview_is_edit_entry', array( $this, 'is_edit_entry' ) );
128 128
 
129 129
 		add_action( 'gravityview_edit_entry', array( $this, 'init' ) );
130 130
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		add_filter( 'gform_plupload_settings', array( $this, 'modify_fileupload_settings' ), 10, 3 );
136 136
 
137 137
 		// Add fields expected by GFFormDisplay::validate()
138
-		add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation') );
138
+		add_filter( 'gform_pre_validation', array( $this, 'gform_pre_validation' ) );
139 139
 
140 140
 		// Fix multiselect value for GF 2.2
141 141
 		add_filter( 'gravityview/edit_entry/field_value_multiselect', array( $this, 'fix_multiselect_value_serialization' ), 10, 3 );
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 	 * @return void
153 153
 	 */
154 154
 	public function prevent_render_form() {
155
-		if( $this->is_edit_entry() ) {
156
-			if( 'wp_head' === current_filter() ) {
155
+		if ( $this->is_edit_entry() ) {
156
+			if ( 'wp_head' === current_filter() ) {
157 157
 				add_filter( 'gform_shortcode_form', '__return_empty_string' );
158 158
 			} else {
159 159
 				remove_filter( 'gform_shortcode_form', '__return_empty_string' );
@@ -168,13 +168,13 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	public function prevent_maybe_process_form() {
170 170
 
171
-		if( ! empty( $_POST ) ) {
171
+		if ( ! empty( $_POST ) ) {
172 172
 	        gravityview()->log->debug( 'GravityView_Edit_Entry[prevent_maybe_process_form] $_POSTed data (sanitized): ', array( 'data' => esc_html( print_r( $_POST, true ) ) ) );
173 173
 		}
174 174
 
175
-		if( $this->is_edit_entry_submission() ) {
176
-			remove_action( 'wp',  array( 'RGForms', 'maybe_process_form'), 9 );
177
-	        remove_action( 'wp',  array( 'GFForms', 'maybe_process_form'), 9 );
175
+		if ( $this->is_edit_entry_submission() ) {
176
+			remove_action( 'wp', array( 'RGForms', 'maybe_process_form' ), 9 );
177
+	        remove_action( 'wp', array( 'GFForms', 'maybe_process_form' ), 9 );
178 178
 		}
179 179
 	}
180 180
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	 */
185 185
 	public function is_edit_entry() {
186 186
 
187
-		$is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET['edit'] );
187
+		$is_edit_entry = GravityView_frontend::is_single_entry() && ! empty( $_GET[ 'edit' ] );
188 188
 
189 189
 		return ( $is_edit_entry || $this->is_edit_entry_submission() );
190 190
 	}
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * @return boolean
196 196
 	 */
197 197
 	public function is_edit_entry_submission() {
198
-		return !empty( $_POST[ self::$nonce_field ] );
198
+		return ! empty( $_POST[ self::$nonce_field ] );
199 199
 	}
200 200
 
201 201
 	/**
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 
209 209
 
210 210
 		$entries = $gravityview_view->getEntries();
211
-	    self::$original_entry = $entries[0];
212
-	    $this->entry = $entries[0];
211
+	    self::$original_entry = $entries[ 0 ];
212
+	    $this->entry = $entries[ 0 ];
213 213
 
214 214
 		self::$original_form = $gravityview_view->getForm();
215 215
 		$this->form = $gravityview_view->getForm();
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		$this->view_id = $gravityview_view->getViewId();
218 218
 		$this->post_id = \GV\Utils::get( $post, 'ID', null );
219 219
 
220
-		self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry['id'] );
220
+		self::$nonce_key = GravityView_Edit_Entry::get_nonce_key( $this->view_id, $this->form_id, $this->entry[ 'id' ] );
221 221
 	}
222 222
 
223 223
 
@@ -268,9 +268,9 @@  discard block
 block discarded – undo
268 268
 	private function print_scripts() {
269 269
 		$gravityview_view = GravityView_View::getInstance();
270 270
 
271
-		wp_register_script( 'gform_gravityforms', GFCommon::get_base_url().'/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
271
+		wp_register_script( 'gform_gravityforms', GFCommon::get_base_url() . '/js/gravityforms.js', array( 'jquery', 'gform_json', 'gform_placeholder', 'sack', 'plupload-all', 'gravityview-fe-view' ) );
272 272
 
273
-		GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false);
273
+		GFFormDisplay::enqueue_form_scripts( $gravityview_view->getForm(), false );
274 274
 
275 275
 		wp_localize_script( 'gravityview-fe-view', 'gvGlobals', array( 'cookiepath' => COOKIEPATH ) );
276 276
 
@@ -286,19 +286,19 @@  discard block
 block discarded – undo
286 286
 	 */
287 287
 	private function process_save( $gv_data ) {
288 288
 
289
-		if ( empty( $_POST ) || ! isset( $_POST['lid'] ) ) {
289
+		if ( empty( $_POST ) || ! isset( $_POST[ 'lid' ] ) ) {
290 290
 			return;
291 291
 		}
292 292
 
293 293
 		// Make sure the entry, view, and form IDs are all correct
294 294
 		$valid = $this->verify_nonce();
295 295
 
296
-		if ( !$valid ) {
296
+		if ( ! $valid ) {
297 297
 			gravityview()->log->error( 'Nonce validation failed.' );
298 298
 			return;
299 299
 		}
300 300
 
301
-		if ( $this->entry['id'] !== $_POST['lid'] ) {
301
+		if ( $this->entry[ 'id' ] !== $_POST[ 'lid' ] ) {
302 302
 			gravityview()->log->error( 'Entry ID did not match posted entry ID.' );
303 303
 			return;
304 304
 		}
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 
310 310
 		$this->validate();
311 311
 
312
-		if( $this->is_valid ) {
312
+		if ( $this->is_valid ) {
313 313
 
314 314
 			gravityview()->log->debug( 'Submission is valid.' );
315 315
 
@@ -321,22 +321,22 @@  discard block
 block discarded – undo
321 321
 			/**
322 322
 			 * @hack to avoid the capability validation of the method save_lead for GF 1.9+
323 323
 			 */
324
-			unset( $_GET['page'] );
324
+			unset( $_GET[ 'page' ] );
325 325
 
326
-			$date_created = $this->entry['date_created'];
326
+			$date_created = $this->entry[ 'date_created' ];
327 327
 
328 328
 			/**
329 329
 			 * @hack to force Gravity Forms to use $read_value_from_post in GFFormsModel::save_lead()
330 330
 			 * @since 1.17.2
331 331
 			 */
332
-			unset( $this->entry['date_created'] );
332
+			unset( $this->entry[ 'date_created' ] );
333 333
 
334 334
 			GFFormsModel::save_lead( $form, $this->entry );
335 335
 
336 336
 	        // Delete the values for hidden inputs
337 337
 	        $this->unset_hidden_field_values();
338 338
 			
339
-			$this->entry['date_created'] = $date_created;
339
+			$this->entry[ 'date_created' ] = $date_created;
340 340
 
341 341
 			// Process calculation fields
342 342
 			$this->update_calculation_fields();
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 			 * @param GravityView_Edit_Entry_Render $this This object
359 359
 			 * @param GravityView_View_Data $gv_data The View data
360 360
 			 */
361
-			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry['id'], $this, $gv_data );
361
+			do_action( 'gravityview/edit_entry/after_update', $this->form, $this->entry[ 'id' ], $this, $gv_data );
362 362
 
363 363
 		} else {
364 364
 			gravityview()->log->error( 'Submission is NOT valid.', array( 'entry' => $this->entry ) );
@@ -386,16 +386,16 @@  discard block
 block discarded – undo
386 386
 		 */
387 387
 		$unset_hidden_field_values = apply_filters( 'gravityview/edit_entry/unset_hidden_field_values', true, $this );
388 388
 
389
-		if( ! $unset_hidden_field_values ) {
389
+		if ( ! $unset_hidden_field_values ) {
390 390
 			return;
391 391
 		}
392 392
 
393 393
 		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
394 394
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
395
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry['id'] ) );
395
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $entry_meta_table WHERE entry_id=%d", $this->entry[ 'id' ] ) );
396 396
 		} else {
397 397
 			$lead_detail_table = GFFormsModel::get_lead_details_table_name();
398
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry['id'] ) );
398
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT id, field_number FROM $lead_detail_table WHERE lead_id=%d", $this->entry[ 'id' ] ) );
399 399
 		}
400 400
 
401 401
 	    foreach ( $this->entry as $input_id => $field_value ) {
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 		}
477 477
 
478 478
 		/** No file is being uploaded. */
479
-		if ( empty( $_FILES[ $input_name ]['name'] ) ) {
479
+		if ( empty( $_FILES[ $input_name ][ 'name' ] ) ) {
480 480
 			/** So return the original upload */
481 481
 			return $entry[ $input_id ];
482 482
 		}
@@ -494,11 +494,11 @@  discard block
 block discarded – undo
494 494
 	 * @return mixed
495 495
 	 */
496 496
 	public function modify_fileupload_settings( $plupload_init, $form_id, $instance ) {
497
-		if( ! $this->is_edit_entry() ) {
497
+		if ( ! $this->is_edit_entry() ) {
498 498
 			return $plupload_init;
499 499
 		}
500 500
 
501
-		$plupload_init['gf_vars']['max_files'] = 0;
501
+		$plupload_init[ 'gf_vars' ][ 'max_files' ] = 0;
502 502
 
503 503
 		return $plupload_init;
504 504
 	}
@@ -513,27 +513,27 @@  discard block
 block discarded – undo
513 513
 		$form = $this->form;
514 514
 
515 515
 	    /** @var GF_Field $field */
516
-		foreach( $form['fields'] as $k => &$field ) {
516
+		foreach ( $form[ 'fields' ] as $k => &$field ) {
517 517
 
518 518
 			/**
519 519
 			 * Remove the fields with calculation formulas before save to avoid conflicts with GF logic
520 520
 			 * @since 1.16.3
521 521
 			 * @var GF_Field $field
522 522
 			 */
523
-			if( $field->has_calculation() ) {
524
-				unset( $form['fields'][ $k ] );
523
+			if ( $field->has_calculation() ) {
524
+				unset( $form[ 'fields' ][ $k ] );
525 525
 			}
526 526
 
527 527
 			$field->adminOnly = false;
528 528
 
529
-			if( isset( $field->inputs ) && is_array( $field->inputs ) ) {
530
-				foreach( $field->inputs as $key => $input ) {
531
-				    $field->inputs[ $key ][ 'id' ] = (string)$input['id'];
529
+			if ( isset( $field->inputs ) && is_array( $field->inputs ) ) {
530
+				foreach ( $field->inputs as $key => $input ) {
531
+				    $field->inputs[ $key ][ 'id' ] = (string)$input[ 'id' ];
532 532
 				}
533 533
 			}
534 534
 		}
535 535
 
536
-		$form['fields'] = array_values( $form['fields'] );
536
+		$form[ 'fields' ] = array_values( $form[ 'fields' ] );
537 537
 
538 538
 		return $form;
539 539
 	}
@@ -545,14 +545,14 @@  discard block
 block discarded – undo
545 545
 		$update = false;
546 546
 
547 547
 		// get the most up to date entry values
548
-		$entry = GFAPI::get_entry( $this->entry['id'] );
548
+		$entry = GFAPI::get_entry( $this->entry[ 'id' ] );
549 549
 
550 550
 		if ( version_compare( GravityView_GFFormsModel::get_database_version(), '2.3-dev-1', '>=' ) && method_exists( 'GFFormsModel', 'get_entry_meta_table_name' ) ) {
551 551
 			$entry_meta_table = GFFormsModel::get_entry_meta_table_name();
552
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry['id'] ) );
552
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $entry_meta_table WHERE entry_id=%d", $entry[ 'id' ] ) );
553 553
 		} else {
554 554
 			$lead_detail_table = GFFormsModel::get_lead_details_table_name();
555
-			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry['id'] ) );
555
+			$current_fields = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $lead_detail_table WHERE lead_id=%d", $entry[ 'id' ] ) );
556 556
 		}
557 557
 
558 558
 
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 				$inputs = $field->get_entry_inputs();
563 563
 				if ( is_array( $inputs ) ) {
564 564
 				    foreach ( $inputs as $input ) {
565
-						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input['id'] );
565
+						GFFormsModel::save_input( $form, $field, $entry, $current_fields, $input[ 'id' ] );
566 566
 				    }
567 567
 				} else {
568 568
 					GFFormsModel::save_input( $form, $field, $entry, $current_fields, $field->id );
@@ -598,19 +598,19 @@  discard block
 block discarded – undo
598 598
 
599 599
 		$input_name = 'input_' . $field_id;
600 600
 
601
-		if ( !empty( $_FILES[ $input_name ]['name'] ) ) {
601
+		if ( ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
602 602
 
603 603
 			// We have a new image
604 604
 
605
-			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'] );
605
+			$value = RGFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ] );
606 606
 
607 607
 			$ary = ! empty( $value ) ? explode( '|:|', $value ) : array();
608 608
 	        $ary = stripslashes_deep( $ary );
609 609
 			$img_url = \GV\Utils::get( $ary, 0 );
610 610
 
611
-			$img_title       = count( $ary ) > 1 ? $ary[1] : '';
612
-			$img_caption     = count( $ary ) > 2 ? $ary[2] : '';
613
-			$img_description = count( $ary ) > 3 ? $ary[3] : '';
611
+			$img_title       = count( $ary ) > 1 ? $ary[ 1 ] : '';
612
+			$img_caption     = count( $ary ) > 2 ? $ary[ 2 ] : '';
613
+			$img_description = count( $ary ) > 3 ? $ary[ 3 ] : '';
614 614
 
615 615
 			$image_meta = array(
616 616
 				'post_excerpt' => $img_caption,
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 
620 620
 			//adding title only if it is not empty. It will default to the file name if it is not in the array
621 621
 			if ( ! empty( $img_title ) ) {
622
-				$image_meta['post_title'] = $img_title;
622
+				$image_meta[ 'post_title' ] = $img_title;
623 623
 			}
624 624
 
625 625
 			/**
@@ -677,15 +677,15 @@  discard block
 block discarded – undo
677 677
 	 */
678 678
 	private function maybe_update_post_fields( $form ) {
679 679
 
680
-		if( empty( $this->entry['post_id'] ) ) {
680
+		if ( empty( $this->entry[ 'post_id' ] ) ) {
681 681
 	        gravityview()->log->debug( 'This entry has no post fields. Continuing...' );
682 682
 			return;
683 683
 		}
684 684
 
685
-		$post_id = $this->entry['post_id'];
685
+		$post_id = $this->entry[ 'post_id' ];
686 686
 
687 687
 		// Security check
688
-		if( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
688
+		if ( false === GVCommon::has_cap( 'edit_post', $post_id ) ) {
689 689
 			gravityview()->log->error( 'The current user does not have the ability to edit Post #{post_id}', array( 'post_id' => $post_id ) );
690 690
 			return;
691 691
 		}
@@ -698,25 +698,25 @@  discard block
 block discarded – undo
698 698
 
699 699
 			$field = RGFormsModel::get_field( $form, $field_id );
700 700
 
701
-			if( ! $field ) {
701
+			if ( ! $field ) {
702 702
 				continue;
703 703
 			}
704 704
 
705
-			if( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
705
+			if ( GFCommon::is_post_field( $field ) && 'post_category' !== $field->type ) {
706 706
 
707 707
 				// Get the value of the field, including $_POSTed value
708 708
 				$value = RGFormsModel::get_field_value( $field );
709 709
 
710 710
 				// Use temporary entry variable, to make values available to fill_post_template() and update_post_image()
711 711
 				$entry_tmp = $this->entry;
712
-				$entry_tmp["{$field_id}"] = $value;
712
+				$entry_tmp[ "{$field_id}" ] = $value;
713 713
 
714
-				switch( $field->type ) {
714
+				switch ( $field->type ) {
715 715
 
716 716
 				    case 'post_title':
717 717
 				        $post_title = $value;
718 718
 				        if ( \GV\Utils::get( $form, 'postTitleTemplateEnabled' ) ) {
719
-				            $post_title = $this->fill_post_template( $form['postTitleTemplate'], $form, $entry_tmp );
719
+				            $post_title = $this->fill_post_template( $form[ 'postTitleTemplate' ], $form, $entry_tmp );
720 720
 				        }
721 721
 				        $updated_post->post_title = $post_title;
722 722
 				        $updated_post->post_name  = $post_title;
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 				    case 'post_content':
727 727
 				        $post_content = $value;
728 728
 				        if ( \GV\Utils::get( $form, 'postContentTemplateEnabled' ) ) {
729
-				            $post_content = $this->fill_post_template( $form['postContentTemplate'], $form, $entry_tmp, true );
729
+				            $post_content = $this->fill_post_template( $form[ 'postContentTemplate' ], $form, $entry_tmp, true );
730 730
 				        }
731 731
 				        $updated_post->post_content = $post_content;
732 732
 				        unset( $post_content );
@@ -744,7 +744,7 @@  discard block
 block discarded – undo
744 744
 							$value = $value[ $field_id ];
745 745
 						}
746 746
 
747
-				        if( ! empty( $field->customFieldTemplateEnabled ) ) {
747
+				        if ( ! empty( $field->customFieldTemplateEnabled ) ) {
748 748
 				            $value = $this->fill_post_template( $field->customFieldTemplate, $form, $entry_tmp, true );
749 749
 				        }
750 750
 
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 				}
763 763
 
764 764
 				// update entry after
765
-				$this->entry["{$field_id}"] = $value;
765
+				$this->entry[ "{$field_id}" ] = $value;
766 766
 
767 767
 				$update_entry = true;
768 768
 
@@ -771,11 +771,11 @@  discard block
 block discarded – undo
771 771
 
772 772
 		}
773 773
 
774
-		if( $update_entry ) {
774
+		if ( $update_entry ) {
775 775
 
776 776
 			$return_entry = GFAPI::update_entry( $this->entry );
777 777
 
778
-			if( is_wp_error( $return_entry ) ) {
778
+			if ( is_wp_error( $return_entry ) ) {
779 779
 				gravityview()->log->error( 'Updating the entry post fields failed', array( 'data' => array( '$this->entry' => $this->entry, '$return_entry' => $return_entry ) ) );
780 780
 			} else {
781 781
 				gravityview()->log->debug( 'Updating the entry post fields for post #{post_id} succeeded', array( 'post_id' => $post_id ) );
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 
786 786
 		$return_post = wp_update_post( $updated_post, true );
787 787
 
788
-		if( is_wp_error( $return_post ) ) {
788
+		if ( is_wp_error( $return_post ) ) {
789 789
 			$return_post->add_data( $updated_post, '$updated_post' );
790 790
 			gravityview()->log->error( 'Updating the post content failed', array( 'data' => compact( 'updated_post', 'return_post' ) ) );
791 791
 		} else {
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
 		$input_type = RGFormsModel::get_input_type( $field );
808 808
 
809 809
 	    // Only certain custom field types are supported
810
-	    switch( $input_type ) {
810
+	    switch ( $input_type ) {
811 811
 		    case 'fileupload':
812 812
 		    case 'list':
813 813
 		    case 'multiselect':
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
 		$output = GFCommon::replace_variables( $output, $form, $entry, false, false, false );
845 845
 
846 846
 		// replace conditional shortcodes
847
-		if( $do_shortcode ) {
847
+		if ( $do_shortcode ) {
848 848
 			$output = do_shortcode( $output );
849 849
 		}
850 850
 
@@ -863,19 +863,19 @@  discard block
 block discarded – undo
863 863
 	 */
864 864
 	private function after_update() {
865 865
 
866
-		do_action( 'gform_after_update_entry', $this->form, $this->entry['id'], self::$original_entry );
867
-		do_action( "gform_after_update_entry_{$this->form['id']}", $this->form, $this->entry['id'], self::$original_entry );
866
+		do_action( 'gform_after_update_entry', $this->form, $this->entry[ 'id' ], self::$original_entry );
867
+		do_action( "gform_after_update_entry_{$this->form[ 'id' ]}", $this->form, $this->entry[ 'id' ], self::$original_entry );
868 868
 
869 869
 		// Re-define the entry now that we've updated it.
870
-		$entry = RGFormsModel::get_lead( $this->entry['id'] );
870
+		$entry = RGFormsModel::get_lead( $this->entry[ 'id' ] );
871 871
 
872 872
 		$entry = GFFormsModel::set_entry_meta( $entry, self::$original_form );
873 873
 
874 874
 		if ( version_compare( GFFormsModel::get_database_version(), '2.3-dev-1', '<' ) ) {
875 875
 			// We need to clear the cache because Gravity Forms caches the field values, which
876 876
 			// we have just updated.
877
-			foreach ($this->form['fields'] as $key => $field) {
878
-				GFFormsModel::refresh_lead_field_value( $entry['id'], $field->id );
877
+			foreach ( $this->form[ 'fields' ] as $key => $field ) {
878
+				GFFormsModel::refresh_lead_field_value( $entry[ 'id' ], $field->id );
879 879
 			}
880 880
 		}
881 881
 
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
 
895 895
 		<div class="gv-edit-entry-wrapper"><?php
896 896
 
897
-			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/inline-javascript.php', $this );
897
+			$javascript = gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this );
898 898
 
899 899
 			/**
900 900
 			 * Fixes weird wpautop() issue
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 				     * @param string $edit_entry_title Modify the "Edit Entry" title
911 911
 				     * @param GravityView_Edit_Entry_Render $this This object
912 912
 				     */
913
-				    $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this );
913
+				    $edit_entry_title = apply_filters( 'gravityview_edit_entry_title', __( 'Edit Entry', 'gravityview' ), $this );
914 914
 
915 915
 				    echo esc_attr( $edit_entry_title );
916 916
 			?></span>
@@ -960,13 +960,13 @@  discard block
 block discarded – undo
960 960
 
961 961
 			$back_link = remove_query_arg( array( 'page', 'view', 'edit' ) );
962 962
 
963
-			if( ! $this->is_valid ){
963
+			if ( ! $this->is_valid ) {
964 964
 
965 965
 				// Keeping this compatible with Gravity Forms.
966
-				$validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>";
967
-				$message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form);
966
+				$validation_message = "<div class='validation_error'>" . __( 'There was a problem with your submission.', 'gravityview' ) . " " . __( 'Errors have been highlighted below.', 'gravityview' ) . "</div>";
967
+				$message = apply_filters( "gform_validation_message_{$this->form[ 'id' ]}", apply_filters( "gform_validation_message", $validation_message, $this->form ), $this->form );
968 968
 
969
-				echo GVCommon::generate_notice( $message , 'gv-error' );
969
+				echo GVCommon::generate_notice( $message, 'gv-error' );
970 970
 
971 971
 			} else {
972 972
 				$view = \GV\View::by_id( $this->view_id );
@@ -977,23 +977,23 @@  discard block
 block discarded – undo
977 977
 
978 978
                     case '0':
979 979
 	                    $redirect_url = $back_link;
980
-	                    $entry_updated_message = sprintf( esc_attr_x('Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview'), '<a href="'. esc_url( $redirect_url ) .'">', '</a>' );
980
+	                    $entry_updated_message = sprintf( esc_attr_x( 'Entry Updated. %sReturning to Entry%s', 'Replacements are HTML', 'gravityview' ), '<a href="' . esc_url( $redirect_url ) . '">', '</a>' );
981 981
                         break;
982 982
 
983 983
                     case '1':
984 984
 	                    $redirect_url = $directory_link = GravityView_API::directory_link();
985
-	                    $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>' );
985
+	                    $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>' );
986 986
 	                    break;
987 987
 
988 988
                     case '2':
989 989
 	                    $redirect_url = $edit_redirect_url;
990 990
 	                    $redirect_url = GFCommon::replace_variables( $redirect_url, $this->form, $this->entry, false, false, false, 'text' );
991
-	                    $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>' );
991
+	                    $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>' );
992 992
                         break;
993 993
 
994 994
                     case '':
995 995
                     default:
996
-					    $entry_updated_message = sprintf( esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="'. esc_url( $back_link ) .'">', '</a>' );
996
+					    $entry_updated_message = sprintf( esc_attr__( 'Entry Updated. %sReturn to Entry%s', 'gravityview' ), '<a href="' . esc_url( $back_link ) . '">', '</a>' );
997 997
                         break;
998 998
 				}
999 999
 
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
 				 * @param array $entry Gravity Forms entry array
1010 1010
 				 * @param string $back_link URL to return to the original entry. @since 1.6
1011 1011
 				 */
1012
-				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message , $this->view_id, $this->entry, $back_link );
1012
+				$message = apply_filters( 'gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link );
1013 1013
 
1014 1014
 				echo GVCommon::generate_notice( $message );
1015 1015
 			}
@@ -1033,21 +1033,21 @@  discard block
 block discarded – undo
1033 1033
 		 */
1034 1034
 		do_action( 'gravityview/edit-entry/render/before', $this );
1035 1035
 
1036
-		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields'), 5000, 3 );
1037
-		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons') );
1036
+		add_filter( 'gform_pre_render', array( $this, 'filter_modify_form_fields' ), 5000, 3 );
1037
+		add_filter( 'gform_submit_button', array( $this, 'render_form_buttons' ) );
1038 1038
 		add_filter( 'gform_disable_view_counter', '__return_true' );
1039 1039
 
1040 1040
 		add_filter( 'gform_field_input', array( $this, 'verify_user_can_edit_post' ), 5, 5 );
1041 1041
 		add_filter( 'gform_field_input', array( $this, 'modify_edit_field_input' ), 10, 5 );
1042 1042
 
1043 1043
 		// We need to remove the fake $_GET['page'] arg to avoid rendering form as if in admin.
1044
-		unset( $_GET['page'] );
1044
+		unset( $_GET[ 'page' ] );
1045 1045
 
1046 1046
 		// TODO: Verify multiple-page forms
1047 1047
 
1048 1048
 		ob_start(); // Prevent PHP warnings possibly caused by prefilling list fields for conditional logic
1049 1049
 
1050
-		$html = GFFormDisplay::get_form( $this->form['id'], false, false, true, $this->entry );
1050
+		$html = GFFormDisplay::get_form( $this->form[ 'id' ], false, false, true, $this->entry );
1051 1051
 
1052 1052
 		ob_get_clean();
1053 1053
 
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
 	 * @return string
1074 1074
 	 */
1075 1075
 	public function render_form_buttons() {
1076
-		return gravityview_ob_include( GravityView_Edit_Entry::$file .'/partials/form-buttons.php', $this );
1076
+		return gravityview_ob_include( GravityView_Edit_Entry::$file . '/partials/form-buttons.php', $this );
1077 1077
 	}
1078 1078
 
1079 1079
 
@@ -1093,10 +1093,10 @@  discard block
 block discarded – undo
1093 1093
 	public function filter_modify_form_fields( $form, $ajax = false, $field_values = '' ) {
1094 1094
 
1095 1095
 		// In case we have validated the form, use it to inject the validation results into the form render
1096
-		if( isset( $this->form_after_validation ) ) {
1096
+		if ( isset( $this->form_after_validation ) ) {
1097 1097
 			$form = $this->form_after_validation;
1098 1098
 		} else {
1099
-			$form['fields'] = $this->get_configured_edit_fields( $form, $this->view_id );
1099
+			$form[ 'fields' ] = $this->get_configured_edit_fields( $form, $this->view_id );
1100 1100
 		}
1101 1101
 
1102 1102
 		$form = $this->filter_conditional_logic( $form );
@@ -1104,8 +1104,8 @@  discard block
 block discarded – undo
1104 1104
 		$form = $this->prefill_conditional_logic( $form );
1105 1105
 
1106 1106
 		// for now we don't support Save and Continue feature.
1107
-		if( ! self::$supports_save_and_continue ) {
1108
-	        unset( $form['save'] );
1107
+		if ( ! self::$supports_save_and_continue ) {
1108
+	        unset( $form[ 'save' ] );
1109 1109
 		}
1110 1110
 
1111 1111
 		$form = $this->unselect_default_values( $form );
@@ -1128,31 +1128,31 @@  discard block
 block discarded – undo
1128 1128
 	 */
1129 1129
 	public function verify_user_can_edit_post( $field_content = '', $field, $value, $lead_id = 0, $form_id ) {
1130 1130
 
1131
-		if( ! GFCommon::is_post_field( $field ) ) {
1131
+		if ( ! GFCommon::is_post_field( $field ) ) {
1132 1132
 			return $field_content;
1133 1133
 		}
1134 1134
 
1135 1135
         $message = null;
1136 1136
 
1137 1137
         // First, make sure they have the capability to edit the post.
1138
-        if( false === current_user_can( 'edit_post', $this->entry['post_id'] ) ) {
1138
+        if ( false === current_user_can( 'edit_post', $this->entry[ 'post_id' ] ) ) {
1139 1139
 
1140 1140
             /**
1141 1141
              * @filter `gravityview/edit_entry/unsupported_post_field_text` Modify the message when someone isn't able to edit a post
1142 1142
              * @param string $message The existing "You don't have permission..." text
1143 1143
              */
1144
-            $message = apply_filters('gravityview/edit_entry/unsupported_post_field_text', __('You don&rsquo;t have permission to edit this post.', 'gravityview') );
1144
+            $message = apply_filters( 'gravityview/edit_entry/unsupported_post_field_text', __( 'You don&rsquo;t have permission to edit this post.', 'gravityview' ) );
1145 1145
 
1146
-        } elseif( null === get_post( $this->entry['post_id'] ) ) {
1146
+        } elseif ( null === get_post( $this->entry[ 'post_id' ] ) ) {
1147 1147
             /**
1148 1148
              * @filter `gravityview/edit_entry/no_post_text` Modify the message when someone is editing an entry attached to a post that no longer exists
1149 1149
              * @param string $message The existing "This field is not editable; the post no longer exists." text
1150 1150
              */
1151
-            $message = apply_filters('gravityview/edit_entry/no_post_text', __('This field is not editable; the post no longer exists.', 'gravityview' ) );
1151
+            $message = apply_filters( 'gravityview/edit_entry/no_post_text', __( 'This field is not editable; the post no longer exists.', 'gravityview' ) );
1152 1152
         }
1153 1153
 
1154
-        if( $message ) {
1155
-            $field_content = sprintf('<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1154
+        if ( $message ) {
1155
+            $field_content = sprintf( '<div class="ginput_container ginput_container_' . $field->type . '">%s</div>', wpautop( $message ) );
1156 1156
         }
1157 1157
 
1158 1158
         return $field_content;
@@ -1176,8 +1176,8 @@  discard block
 block discarded – undo
1176 1176
 
1177 1177
 		// If the form has been submitted, then we don't need to pre-fill the values,
1178 1178
 		// Except for fileupload type and when a field input is overridden- run always!!
1179
-		if(
1180
-			( $this->is_edit_entry_submission() && !in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1179
+		if (
1180
+			( $this->is_edit_entry_submission() && ! in_array( $field->type, array( 'fileupload', 'post_image' ) ) )
1181 1181
 			&& false === ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) )
1182 1182
 			&& ! GFCommon::is_product_field( $field->type )
1183 1183
 			|| ! empty( $field_content )
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 	    $return = null;
1198 1198
 
1199 1199
 		/** @var GravityView_Field $gv_field */
1200
-		if( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1200
+		if ( $gv_field && is_callable( array( $gv_field, 'get_field_input' ) ) ) {
1201 1201
 			$return = $gv_field->get_field_input( $this->form, $field_value, $this->entry, $field );
1202 1202
 		} else {
1203 1203
 	        $return = $field->get_field_input( $this->form, $field_value, $this->entry );
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
 	    // If there was output, it's an error
1207 1207
 	    $warnings = ob_get_clean();
1208 1208
 
1209
-	    if( !empty( $warnings ) ) {
1209
+	    if ( ! empty( $warnings ) ) {
1210 1210
 		    gravityview()->log->error( '{warning}', array( 'warning' => $warnings, 'data' => $field_value ) );
1211 1211
 	    }
1212 1212
 
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
 		$override_saved_value = apply_filters( 'gravityview/edit_entry/pre_populate/override', false, $field );
1232 1232
 
1233 1233
 		// We're dealing with multiple inputs (e.g. checkbox) but not time or date (as it doesn't store data in input IDs)
1234
-		if( isset( $field->inputs ) && is_array( $field->inputs ) && !in_array( $field->type, array( 'time', 'date' ) ) ) {
1234
+		if ( isset( $field->inputs ) && is_array( $field->inputs ) && ! in_array( $field->type, array( 'time', 'date' ) ) ) {
1235 1235
 
1236 1236
 			$field_value = array();
1237 1237
 
@@ -1240,10 +1240,10 @@  discard block
 block discarded – undo
1240 1240
 
1241 1241
 			foreach ( (array)$field->inputs as $input ) {
1242 1242
 
1243
-				$input_id = strval( $input['id'] );
1243
+				$input_id = strval( $input[ 'id' ] );
1244 1244
 
1245 1245
 				if ( isset( $this->entry[ $input_id ] ) && ! gv_empty( $this->entry[ $input_id ], false, false ) ) {
1246
-				    $field_value[ $input_id ] =  'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1246
+				    $field_value[ $input_id ] = 'post_category' === $field->type ? GFCommon::format_post_category( $this->entry[ $input_id ], true ) : $this->entry[ $input_id ];
1247 1247
 				    $allow_pre_populated = false;
1248 1248
 				}
1249 1249
 
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
 
1252 1252
 			$pre_value = $field->get_value_submission( array(), false );
1253 1253
 
1254
-			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && !gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1254
+			$field_value = ! $allow_pre_populated && ! ( $override_saved_value && ! gv_empty( $pre_value, false, false ) ) ? $field_value : $pre_value;
1255 1255
 
1256 1256
 		} else {
1257 1257
 
@@ -1262,13 +1262,13 @@  discard block
 block discarded – undo
1262 1262
 
1263 1263
 			// saved field entry value (if empty, fallback to the pre-populated value, if exists)
1264 1264
 			// or pre-populated value if not empty and set to override saved value
1265
-			$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;
1265
+			$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;
1266 1266
 
1267 1267
 			// in case field is post_category but inputType is select, multi-select or radio, convert value into array of category IDs.
1268
-			if ( 'post_category' === $field->type && !gv_empty( $field_value, false, false ) ) {
1268
+			if ( 'post_category' === $field->type && ! gv_empty( $field_value, false, false ) ) {
1269 1269
 				$categories = array();
1270 1270
 				foreach ( explode( ',', $field_value ) as $cat_string ) {
1271
-				    $categories[] = GFCommon::format_post_category( $cat_string, true );
1271
+				    $categories[ ] = GFCommon::format_post_category( $cat_string, true );
1272 1272
 				}
1273 1273
 				$field_value = 'multiselect' === $field->get_input_type() ? $categories : implode( '', $categories );
1274 1274
 			}
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
 	     * @param GF_Field $field Gravity Forms field object
1297 1297
 	     * @param GravityView_Edit_Entry_Render $this Current object
1298 1298
 	     */
1299
-	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type , $field_value, $field, $this );
1299
+	    $field_value = apply_filters( 'gravityview/edit_entry/field_value_' . $field->type, $field_value, $field, $this );
1300 1300
 
1301 1301
 		return $field_value;
1302 1302
 	}
@@ -1313,12 +1313,12 @@  discard block
 block discarded – undo
1313 1313
 	 */
1314 1314
 	public function gform_pre_validation( $form ) {
1315 1315
 
1316
-		if( ! $this->verify_nonce() ) {
1316
+		if ( ! $this->verify_nonce() ) {
1317 1317
 			return $form;
1318 1318
 		}
1319 1319
 
1320 1320
 		// Fix PHP warning regarding undefined index.
1321
-		foreach ( $form['fields'] as &$field) {
1321
+		foreach ( $form[ 'fields' ] as &$field ) {
1322 1322
 
1323 1323
 			// This is because we're doing admin form pretending to be front-end, so Gravity Forms
1324 1324
 			// expects certain field array items to be set.
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
 	            $field->{$key} = isset( $field->{$key} ) ? $field->{$key} : NULL;
1327 1327
 			}
1328 1328
 
1329
-			switch( RGFormsModel::get_input_type( $field ) ) {
1329
+			switch ( RGFormsModel::get_input_type( $field ) ) {
1330 1330
 
1331 1331
 				/**
1332 1332
 				 * 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.
@@ -1340,26 +1340,26 @@  discard block
 block discarded – undo
1340 1340
 				    // Set the previous value
1341 1341
 				    $entry = $this->get_entry();
1342 1342
 
1343
-				    $input_name = 'input_'.$field->id;
1344
-				    $form_id = $form['id'];
1343
+				    $input_name = 'input_' . $field->id;
1344
+				    $form_id = $form[ 'id' ];
1345 1345
 
1346 1346
 				    $value = NULL;
1347 1347
 
1348 1348
 				    // Use the previous entry value as the default.
1349
-				    if( isset( $entry[ $field->id ] ) ) {
1349
+				    if ( isset( $entry[ $field->id ] ) ) {
1350 1350
 				        $value = $entry[ $field->id ];
1351 1351
 				    }
1352 1352
 
1353 1353
 				    // If this is a single upload file
1354
-				    if( !empty( $_FILES[ $input_name ] ) && !empty( $_FILES[ $input_name ]['name'] ) ) {
1355
-				        $file_path = GFFormsModel::get_file_upload_path( $form['id'], $_FILES[ $input_name ]['name'] );
1356
-				        $value = $file_path['url'];
1354
+				    if ( ! empty( $_FILES[ $input_name ] ) && ! empty( $_FILES[ $input_name ][ 'name' ] ) ) {
1355
+				        $file_path = GFFormsModel::get_file_upload_path( $form[ 'id' ], $_FILES[ $input_name ][ 'name' ] );
1356
+				        $value = $file_path[ 'url' ];
1357 1357
 
1358 1358
 				    } else {
1359 1359
 
1360 1360
 				        // Fix PHP warning on line 1498 of form_display.php for post_image fields
1361 1361
 				        // Fix PHP Notice:  Undefined index:  size in form_display.php on line 1511
1362
-				        $_FILES[ $input_name ] = array('name' => '', 'size' => '' );
1362
+				        $_FILES[ $input_name ] = array( 'name' => '', 'size' => '' );
1363 1363
 
1364 1364
 				    }
1365 1365
 
@@ -1367,10 +1367,10 @@  discard block
 block discarded – undo
1367 1367
 
1368 1368
 				        // If there are fresh uploads, process and merge them.
1369 1369
 				        // Otherwise, use the passed values, which should be json-encoded array of URLs
1370
-				        if( isset( GFFormsModel::$uploaded_files[$form_id][$input_name] ) ) {
1370
+				        if ( isset( GFFormsModel::$uploaded_files[ $form_id ][ $input_name ] ) ) {
1371 1371
 				            $value = empty( $value ) ? '[]' : $value;
1372 1372
 				            $value = stripslashes_deep( $value );
1373
-				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry['id'], array());
1373
+				            $value = GFFormsModel::prepare_value( $form, $field, $value, $input_name, $entry[ 'id' ], array() );
1374 1374
 				        }
1375 1375
 
1376 1376
 				    } else {
@@ -1388,8 +1388,8 @@  discard block
 block discarded – undo
1388 1388
 
1389 1389
 				case 'number':
1390 1390
 				    // Fix "undefined index" issue at line 1286 in form_display.php
1391
-				    if( !isset( $_POST['input_'.$field->id ] ) ) {
1392
-				        $_POST['input_'.$field->id ] = NULL;
1391
+				    if ( ! isset( $_POST[ 'input_' . $field->id ] ) ) {
1392
+				        $_POST[ 'input_' . $field->id ] = NULL;
1393 1393
 				    }
1394 1394
 				    break;
1395 1395
 			}
@@ -1426,7 +1426,7 @@  discard block
 block discarded – undo
1426 1426
 		 * You can enter whatever you want!
1427 1427
 		 * We try validating, and customize the results using `self::custom_validation()`
1428 1428
 		 */
1429
-		add_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10, 4);
1429
+		add_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10, 4 );
1430 1430
 
1431 1431
 		// Needed by the validate funtion
1432 1432
 		$failed_validation_page = NULL;
@@ -1434,14 +1434,14 @@  discard block
 block discarded – undo
1434 1434
 
1435 1435
 		// Prevent entry limit from running when editing an entry, also
1436 1436
 		// prevent form scheduling from preventing editing
1437
-		unset( $this->form['limitEntries'], $this->form['scheduleForm'] );
1437
+		unset( $this->form[ 'limitEntries' ], $this->form[ 'scheduleForm' ] );
1438 1438
 
1439 1439
 		// Hide fields depending on Edit Entry settings
1440
-		$this->form['fields'] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1440
+		$this->form[ 'fields' ] = $this->get_configured_edit_fields( $this->form, $this->view_id );
1441 1441
 
1442 1442
 		$this->is_valid = GFFormDisplay::validate( $this->form, $field_values, 1, $failed_validation_page );
1443 1443
 
1444
-		remove_filter( 'gform_validation_'. $this->form_id, array( $this, 'custom_validation' ), 10 );
1444
+		remove_filter( 'gform_validation_' . $this->form_id, array( $this, 'custom_validation' ), 10 );
1445 1445
 	}
1446 1446
 
1447 1447
 
@@ -1464,7 +1464,7 @@  discard block
 block discarded – undo
1464 1464
 
1465 1465
 		$gv_valid = true;
1466 1466
 
1467
-		foreach ( $validation_results['form']['fields'] as $key => &$field ) {
1467
+		foreach ( $validation_results[ 'form' ][ 'fields' ] as $key => &$field ) {
1468 1468
 
1469 1469
 			$value = RGFormsModel::get_field_value( $field );
1470 1470
 			$field_type = RGFormsModel::get_input_type( $field );
@@ -1477,35 +1477,35 @@  discard block
 block discarded – undo
1477 1477
 				case 'post_image':
1478 1478
 
1479 1479
 				    // in case nothing is uploaded but there are already files saved
1480
-				    if( !empty( $field->failed_validation ) && !empty( $field->isRequired ) && !empty( $value ) ) {
1480
+				    if ( ! empty( $field->failed_validation ) && ! empty( $field->isRequired ) && ! empty( $value ) ) {
1481 1481
 				        $field->failed_validation = false;
1482 1482
 				        unset( $field->validation_message );
1483 1483
 				    }
1484 1484
 
1485 1485
 				    // validate if multi file upload reached max number of files [maxFiles] => 2
1486
-				    if( \GV\Utils::get( $field, 'maxFiles') && \GV\Utils::get( $field, 'multipleFiles') ) {
1486
+				    if ( \GV\Utils::get( $field, 'maxFiles' ) && \GV\Utils::get( $field, 'multipleFiles' ) ) {
1487 1487
 
1488 1488
 				        $input_name = 'input_' . $field->id;
1489 1489
 				        //uploaded
1490
-				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ][ $input_name ] : array();
1490
+				        $file_names = isset( GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] ) ? GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ][ $input_name ] : array();
1491 1491
 
1492 1492
 				        //existent
1493 1493
 				        $entry = $this->get_entry();
1494 1494
 				        $value = NULL;
1495
-				        if( isset( $entry[ $field->id ] ) ) {
1495
+				        if ( isset( $entry[ $field->id ] ) ) {
1496 1496
 				            $value = json_decode( $entry[ $field->id ], true );
1497 1497
 				        }
1498 1498
 
1499 1499
 				        // count uploaded files and existent entry files
1500 1500
 				        $count_files = count( $file_names ) + count( $value );
1501 1501
 
1502
-				        if( $count_files > $field->maxFiles ) {
1502
+				        if ( $count_files > $field->maxFiles ) {
1503 1503
 				            $field->validation_message = __( 'Maximum number of files reached', 'gravityview' );
1504 1504
 				            $field->failed_validation = 1;
1505 1505
 				            $gv_valid = false;
1506 1506
 
1507 1507
 				            // in case of error make sure the newest upload files are removed from the upload input
1508
-				            GFFormsModel::$uploaded_files[ $validation_results['form']['id'] ] = null;
1508
+				            GFFormsModel::$uploaded_files[ $validation_results[ 'form' ][ 'id' ] ] = null;
1509 1509
 				        }
1510 1510
 
1511 1511
 				    }
@@ -1516,7 +1516,7 @@  discard block
 block discarded – undo
1516 1516
 			}
1517 1517
 
1518 1518
 			// This field has failed validation.
1519
-			if( !empty( $field->failed_validation ) ) {
1519
+			if ( ! empty( $field->failed_validation ) ) {
1520 1520
 
1521 1521
 				gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Field is invalid.', array( 'data' => array( 'field' => $field, 'value' => $value ) ) );
1522 1522
 
@@ -1534,19 +1534,19 @@  discard block
 block discarded – undo
1534 1534
 				}
1535 1535
 
1536 1536
 				// You can't continue inside a switch, so we do it after.
1537
-				if( empty( $field->failed_validation ) ) {
1537
+				if ( empty( $field->failed_validation ) ) {
1538 1538
 				    continue;
1539 1539
 				}
1540 1540
 
1541 1541
 				// checks if the No Duplicates option is not validating entry against itself, since
1542 1542
 				// we're editing a stored entry, it would also assume it's a duplicate.
1543
-				if( !empty( $field->noDuplicates ) ) {
1543
+				if ( ! empty( $field->noDuplicates ) ) {
1544 1544
 
1545 1545
 				    $entry = $this->get_entry();
1546 1546
 
1547 1547
 				    // If the value of the entry is the same as the stored value
1548 1548
 				    // Then we can assume it's not a duplicate, it's the same.
1549
-				    if( !empty( $entry ) && $value == $entry[ $field->id ] ) {
1549
+				    if ( ! empty( $entry ) && $value == $entry[ $field->id ] ) {
1550 1550
 				        //if value submitted was not changed, then don't validate
1551 1551
 				        $field->failed_validation = false;
1552 1552
 
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
 				}
1560 1560
 
1561 1561
 				// if here then probably we are facing the validation 'At least one field must be filled out'
1562
-				if( GFFormDisplay::is_empty( $field, $this->form_id  ) && empty( $field->isRequired ) ) {
1562
+				if ( GFFormDisplay::is_empty( $field, $this->form_id ) && empty( $field->isRequired ) ) {
1563 1563
 				    unset( $field->validation_message );
1564 1564
 	                $field->validation_message = false;
1565 1565
 				    continue;
@@ -1571,12 +1571,12 @@  discard block
 block discarded – undo
1571 1571
 
1572 1572
 		}
1573 1573
 
1574
-		$validation_results['is_valid'] = $gv_valid;
1574
+		$validation_results[ 'is_valid' ] = $gv_valid;
1575 1575
 
1576 1576
 		gravityview()->log->debug( 'GravityView_Edit_Entry[custom_validation] Validation results.', array( 'data' => $validation_results ) );
1577 1577
 
1578 1578
 		// We'll need this result when rendering the form ( on GFFormDisplay::get_form )
1579
-		$this->form_after_validation = $validation_results['form'];
1579
+		$this->form_after_validation = $validation_results[ 'form' ];
1580 1580
 
1581 1581
 		return $validation_results;
1582 1582
 	}
@@ -1589,7 +1589,7 @@  discard block
 block discarded – undo
1589 1589
 	 */
1590 1590
 	public function get_entry() {
1591 1591
 
1592
-		if( empty( $this->entry ) ) {
1592
+		if ( empty( $this->entry ) ) {
1593 1593
 			// Get the database value of the entry that's being edited
1594 1594
 			$this->entry = gravityview_get_entry( GravityView_frontend::is_single_entry() );
1595 1595
 		}
@@ -1621,10 +1621,10 @@  discard block
 block discarded – undo
1621 1621
 		}
1622 1622
 
1623 1623
 		// If edit tab not yet configured, show all fields
1624
-		$edit_fields = !empty( $properties['edit_edit-fields'] ) ? $properties['edit_edit-fields'] : NULL;
1624
+		$edit_fields = ! empty( $properties[ 'edit_edit-fields' ] ) ? $properties[ 'edit_edit-fields' ] : NULL;
1625 1625
 
1626 1626
 		// Hide fields depending on admin settings
1627
-		$fields = $this->filter_fields( $form['fields'], $edit_fields );
1627
+		$fields = $this->filter_fields( $form[ 'fields' ], $edit_fields );
1628 1628
 
1629 1629
 	    // If Edit Entry fields are configured, remove adminOnly field settings. Otherwise, don't.
1630 1630
 	    $fields = $this->filter_admin_only_fields( $fields, $edit_fields, $form, $view_id );
@@ -1656,7 +1656,7 @@  discard block
 block discarded – undo
1656 1656
 	 */
1657 1657
 	private function filter_fields( $fields, $configured_fields ) {
1658 1658
 
1659
-		if( empty( $fields ) || !is_array( $fields ) ) {
1659
+		if ( empty( $fields ) || ! is_array( $fields ) ) {
1660 1660
 			return $fields;
1661 1661
 		}
1662 1662
 
@@ -1669,18 +1669,18 @@  discard block
 block discarded – undo
1669 1669
 
1670 1670
 			// Remove the fields that have calculation properties and keep them to be used later
1671 1671
 			// @since 1.16.2
1672
-			if( $field->has_calculation() ) {
1673
-				$this->fields_with_calculation[] = $field;
1672
+			if ( $field->has_calculation() ) {
1673
+				$this->fields_with_calculation[ ] = $field;
1674 1674
 				// don't remove the calculation fields on form render.
1675 1675
 			}
1676 1676
 
1677
-			if( in_array( $field->type, $field_type_blacklist ) ) {
1677
+			if ( in_array( $field->type, $field_type_blacklist ) ) {
1678 1678
 				unset( $fields[ $key ] );
1679 1679
 			}
1680 1680
 		}
1681 1681
 
1682 1682
 		// The Edit tab has not been configured, so we return all fields by default.
1683
-		if( empty( $configured_fields ) ) {
1683
+		if ( empty( $configured_fields ) ) {
1684 1684
 			return array_values( $fields );
1685 1685
 		}
1686 1686
 
@@ -1689,8 +1689,8 @@  discard block
 block discarded – undo
1689 1689
 
1690 1690
 	        /** @var GF_Field $field */
1691 1691
 	        foreach ( $fields as $field ) {
1692
-				if( intval( $configured_field['id'] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1693
-				    $edit_fields[] = $this->merge_field_properties( $field, $configured_field );
1692
+				if ( intval( $configured_field[ 'id' ] ) === intval( $field->id ) && $this->user_can_edit_field( $configured_field, false ) ) {
1693
+				    $edit_fields[ ] = $this->merge_field_properties( $field, $configured_field );
1694 1694
 				    break;
1695 1695
 				}
1696 1696
 
@@ -1713,14 +1713,14 @@  discard block
 block discarded – undo
1713 1713
 
1714 1714
 		$return_field = $field;
1715 1715
 
1716
-		if( empty( $field_setting['show_label'] ) ) {
1716
+		if ( empty( $field_setting[ 'show_label' ] ) ) {
1717 1717
 			$return_field->label = '';
1718
-		} elseif ( !empty( $field_setting['custom_label'] ) ) {
1719
-			$return_field->label = $field_setting['custom_label'];
1718
+		} elseif ( ! empty( $field_setting[ 'custom_label' ] ) ) {
1719
+			$return_field->label = $field_setting[ 'custom_label' ];
1720 1720
 		}
1721 1721
 
1722
-		if( !empty( $field_setting['custom_class'] ) ) {
1723
-			$return_field->cssClass .= ' '. gravityview_sanitize_html_class( $field_setting['custom_class'] );
1722
+		if ( ! empty( $field_setting[ 'custom_class' ] ) ) {
1723
+			$return_field->cssClass .= ' ' . gravityview_sanitize_html_class( $field_setting[ 'custom_class' ] );
1724 1724
 		}
1725 1725
 
1726 1726
 		/**
@@ -1758,16 +1758,16 @@  discard block
 block discarded – undo
1758 1758
 	     */
1759 1759
 	    $use_gf_adminonly_setting = apply_filters( 'gravityview/edit_entry/use_gf_admin_only_setting', empty( $edit_fields ), $form, $view_id );
1760 1760
 
1761
-	    if( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry['id'] ) ) {
1762
-			foreach( $fields as $k => $field ) {
1763
-				if( $field->adminOnly ) {
1761
+	    if ( $use_gf_adminonly_setting && false === GVCommon::has_cap( 'gravityforms_edit_entries', $this->entry[ 'id' ] ) ) {
1762
+			foreach ( $fields as $k => $field ) {
1763
+				if ( $field->adminOnly ) {
1764 1764
 				    unset( $fields[ $k ] );
1765 1765
 				}
1766 1766
 			}
1767 1767
 			return array_values( $fields );
1768 1768
 		}
1769 1769
 
1770
-	    foreach( $fields as &$field ) {
1770
+	    foreach ( $fields as &$field ) {
1771 1771
 		    $field->adminOnly = false;
1772 1772
 		}
1773 1773
 
@@ -1788,7 +1788,7 @@  discard block
 block discarded – undo
1788 1788
 	 */
1789 1789
 	private function unselect_default_values( $form ) {
1790 1790
 
1791
-	    foreach ( $form['fields'] as &$field ) {
1791
+	    foreach ( $form[ 'fields' ] as &$field ) {
1792 1792
 
1793 1793
 			if ( empty( $field->choices ) ) {
1794 1794
                 continue;
@@ -1796,7 +1796,7 @@  discard block
 block discarded – undo
1796 1796
 
1797 1797
             foreach ( $field->choices as &$choice ) {
1798 1798
 				if ( \GV\Utils::get( $choice, 'isSelected' ) ) {
1799
-					$choice['isSelected'] = false;
1799
+					$choice[ 'isSelected' ] = false;
1800 1800
 				}
1801 1801
 			}
1802 1802
 		}
@@ -1821,22 +1821,22 @@  discard block
 block discarded – undo
1821 1821
 	 */
1822 1822
 	function prefill_conditional_logic( $form ) {
1823 1823
 
1824
-		if( ! GFFormDisplay::has_conditional_logic( $form ) ) {
1824
+		if ( ! GFFormDisplay::has_conditional_logic( $form ) ) {
1825 1825
 			return $form;
1826 1826
 		}
1827 1827
 
1828 1828
 		// Have Conditional Logic pre-fill fields as if the data were default values
1829 1829
 		/** @var GF_Field $field */
1830
-		foreach ( $form['fields'] as &$field ) {
1830
+		foreach ( $form[ 'fields' ] as &$field ) {
1831 1831
 
1832
-			if( 'checkbox' === $field->type ) {
1832
+			if ( 'checkbox' === $field->type ) {
1833 1833
 				foreach ( $field->get_entry_inputs() as $key => $input ) {
1834
-				    $input_id = $input['id'];
1834
+				    $input_id = $input[ 'id' ];
1835 1835
 				    $choice = $field->choices[ $key ];
1836 1836
 				    $value = \GV\Utils::get( $this->entry, $input_id );
1837 1837
 				    $match = RGFormsModel::choice_value_match( $field, $choice, $value );
1838
-				    if( $match ) {
1839
-				        $field->choices[ $key ]['isSelected'] = true;
1838
+				    if ( $match ) {
1839
+				        $field->choices[ $key ][ 'isSelected' ] = true;
1840 1840
 				    }
1841 1841
 				}
1842 1842
 			} else {
@@ -1844,15 +1844,15 @@  discard block
 block discarded – undo
1844 1844
 				// We need to run through each field to set the default values
1845 1845
 				foreach ( $this->entry as $field_id => $field_value ) {
1846 1846
 
1847
-				    if( floatval( $field_id ) === floatval( $field->id ) ) {
1847
+				    if ( floatval( $field_id ) === floatval( $field->id ) ) {
1848 1848
 
1849
-				        if( 'list' === $field->type ) {
1849
+				        if ( 'list' === $field->type ) {
1850 1850
 				            $list_rows = maybe_unserialize( $field_value );
1851 1851
 
1852 1852
 				            $list_field_value = array();
1853
-				            foreach ( (array) $list_rows as $row ) {
1854
-				                foreach ( (array) $row as $column ) {
1855
-				                    $list_field_value[] = $column;
1853
+				            foreach ( (array)$list_rows as $row ) {
1854
+				                foreach ( (array)$row as $column ) {
1855
+				                    $list_field_value[ ] = $column;
1856 1856
 				                }
1857 1857
 				            }
1858 1858
 
@@ -1887,16 +1887,16 @@  discard block
 block discarded – undo
1887 1887
 		 */
1888 1888
 		$use_conditional_logic = apply_filters( 'gravityview/edit_entry/conditional_logic', true, $form );
1889 1889
 
1890
-		if( $use_conditional_logic ) {
1890
+		if ( $use_conditional_logic ) {
1891 1891
 			return $form;
1892 1892
 		}
1893 1893
 
1894
-		foreach( $form['fields'] as &$field ) {
1894
+		foreach ( $form[ 'fields' ] as &$field ) {
1895 1895
 			/* @var GF_Field $field */
1896 1896
 			$field->conditionalLogic = null;
1897 1897
 		}
1898 1898
 
1899
-		unset( $form['button']['conditionalLogic'] );
1899
+		unset( $form[ 'button' ][ 'conditionalLogic' ] );
1900 1900
 
1901 1901
 		return $form;
1902 1902
 
@@ -1913,7 +1913,7 @@  discard block
 block discarded – undo
1913 1913
 	 */
1914 1914
 	public function manage_conditional_logic( $has_conditional_logic, $form ) {
1915 1915
 
1916
-		if( ! $this->is_edit_entry() ) {
1916
+		if ( ! $this->is_edit_entry() ) {
1917 1917
 			return $has_conditional_logic;
1918 1918
 		}
1919 1919
 
@@ -1945,44 +1945,44 @@  discard block
 block discarded – undo
1945 1945
 		 *  2. There are two entries embedded using oEmbed
1946 1946
 		 *  3. One of the entries has just been saved
1947 1947
 		 */
1948
-		if( !empty( $_POST['lid'] ) && !empty( $_GET['entry'] ) && ( $_POST['lid'] !== $_GET['entry'] ) ) {
1948
+		if ( ! empty( $_POST[ 'lid' ] ) && ! empty( $_GET[ 'entry' ] ) && ( $_POST[ 'lid' ] !== $_GET[ 'entry' ] ) ) {
1949 1949
 
1950 1950
 			$error = true;
1951 1951
 
1952 1952
 		}
1953 1953
 
1954
-		if( !empty( $_GET['entry'] ) && (string)$this->entry['id'] !== $_GET['entry'] ) {
1954
+		if ( ! empty( $_GET[ 'entry' ] ) && (string)$this->entry[ 'id' ] !== $_GET[ 'entry' ] ) {
1955 1955
 
1956 1956
 			$error = true;
1957 1957
 
1958
-		} elseif( ! $this->verify_nonce() ) {
1958
+		} elseif ( ! $this->verify_nonce() ) {
1959 1959
 
1960 1960
 			/**
1961 1961
 			 * If the Entry is embedded, there may be two entries on the same page.
1962 1962
 			 * If that's the case, and one is being edited, the other should fail gracefully and not display an error.
1963 1963
 			 */
1964
-			if( GravityView_oEmbed::getInstance()->get_entry_id() ) {
1964
+			if ( GravityView_oEmbed::getInstance()->get_entry_id() ) {
1965 1965
 				$error = true;
1966 1966
 			} else {
1967
-				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview');
1967
+				$error = __( 'The link to edit this entry is not valid; it may have expired.', 'gravityview' );
1968 1968
 			}
1969 1969
 
1970 1970
 		}
1971 1971
 
1972
-		if( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
1973
-			$error = __( 'You do not have permission to edit this entry.', 'gravityview');
1972
+		if ( ! GravityView_Edit_Entry::check_user_cap_edit_entry( $this->entry ) ) {
1973
+			$error = __( 'You do not have permission to edit this entry.', 'gravityview' );
1974 1974
 		}
1975 1975
 
1976
-		if( $this->entry['status'] === 'trash' ) {
1977
-			$error = __('You cannot edit the entry; it is in the trash.', 'gravityview' );
1976
+		if ( $this->entry[ 'status' ] === 'trash' ) {
1977
+			$error = __( 'You cannot edit the entry; it is in the trash.', 'gravityview' );
1978 1978
 		}
1979 1979
 
1980 1980
 		// No errors; everything's fine here!
1981
-		if( empty( $error ) ) {
1981
+		if ( empty( $error ) ) {
1982 1982
 			return true;
1983 1983
 		}
1984 1984
 
1985
-		if( $echo && $error !== true ) {
1985
+		if ( $echo && $error !== true ) {
1986 1986
 
1987 1987
 	        $error = esc_html( $error );
1988 1988
 
@@ -1990,10 +1990,10 @@  discard block
 block discarded – undo
1990 1990
 	         * @since 1.9
1991 1991
 	         */
1992 1992
 	        if ( ! empty( $this->entry ) ) {
1993
-		        $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;" ) );
1993
+		        $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;" ) );
1994 1994
 	        }
1995 1995
 
1996
-			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error');
1996
+			echo GVCommon::generate_notice( wpautop( $error ), 'gv-error error' );
1997 1997
 		}
1998 1998
 
1999 1999
 		gravityview()->log->error( '{error}', array( 'error' => $error ) );
@@ -2013,17 +2013,17 @@  discard block
 block discarded – undo
2013 2013
 
2014 2014
 		$error = NULL;
2015 2015
 
2016
-		if( ! $this->check_user_cap_edit_field( $field ) ) {
2017
-			$error = __( 'You do not have permission to edit this field.', 'gravityview');
2016
+		if ( ! $this->check_user_cap_edit_field( $field ) ) {
2017
+			$error = __( 'You do not have permission to edit this field.', 'gravityview' );
2018 2018
 		}
2019 2019
 
2020 2020
 		// No errors; everything's fine here!
2021
-		if( empty( $error ) ) {
2021
+		if ( empty( $error ) ) {
2022 2022
 			return true;
2023 2023
 		}
2024 2024
 
2025
-		if( $echo ) {
2026
-			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error');
2025
+		if ( $echo ) {
2026
+			echo GVCommon::generate_notice( wpautop( esc_html( $error ) ), 'gv-error error' );
2027 2027
 		}
2028 2028
 
2029 2029
 		gravityview()->log->error( '{error}', array( 'error' => $error ) );
@@ -2044,14 +2044,14 @@  discard block
 block discarded – undo
2044 2044
 	private function check_user_cap_edit_field( $field ) {
2045 2045
 
2046 2046
 		// If they can edit any entries (as defined in Gravity Forms), we're good.
2047
-		if( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
2047
+		if ( GVCommon::has_cap( array( 'gravityforms_edit_entries', 'gravityview_edit_others_entries' ) ) ) {
2048 2048
 			return true;
2049 2049
 		}
2050 2050
 
2051
-		$field_cap = isset( $field['allow_edit_cap'] ) ? $field['allow_edit_cap'] : false;
2051
+		$field_cap = isset( $field[ 'allow_edit_cap' ] ) ? $field[ 'allow_edit_cap' ] : false;
2052 2052
 
2053
-		if( $field_cap ) {
2054
-			return GVCommon::has_cap( $field['allow_edit_cap'] );
2053
+		if ( $field_cap ) {
2054
+			return GVCommon::has_cap( $field[ 'allow_edit_cap' ] );
2055 2055
 		}
2056 2056
 
2057 2057
 		return false;
@@ -2065,17 +2065,17 @@  discard block
 block discarded – undo
2065 2065
 	public function verify_nonce() {
2066 2066
 
2067 2067
 		// Verify form submitted for editing single
2068
-		if( $this->is_edit_entry_submission() ) {
2068
+		if ( $this->is_edit_entry_submission() ) {
2069 2069
 			$valid = wp_verify_nonce( $_POST[ self::$nonce_field ], self::$nonce_field );
2070 2070
 		}
2071 2071
 
2072 2072
 		// Verify
2073
-		else if( ! $this->is_edit_entry() ) {
2073
+		else if ( ! $this->is_edit_entry() ) {
2074 2074
 			$valid = false;
2075 2075
 		}
2076 2076
 
2077 2077
 		else {
2078
-			$valid = wp_verify_nonce( $_GET['edit'], self::$nonce_key );
2078
+			$valid = wp_verify_nonce( $_GET[ 'edit' ], self::$nonce_key );
2079 2079
 		}
2080 2080
 
2081 2081
 		/**
Please login to merge, or discard this patch.