Completed
Pull Request — develop (#1487)
by Zack
15:49
created
future/includes/class-gv-template-view-table.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -75,22 +75,22 @@  discard block
 block discarded – undo
75 75
 			if ( is_array( $sorts ) ) {
76 76
 				foreach ( (array)$sorts as $key => $direction ) {
77 77
 					if ( $key == $field_id ) {
78
-						$sorting['key'] = $field_id;
79
-						$sorting['direction'] = strtolower( $direction );
78
+						$sorting[ 'key' ] = $field_id;
79
+						$sorting[ 'direction' ] = strtolower( $direction );
80 80
 						break;
81 81
 					}
82 82
 				}
83 83
 			} else {
84 84
 				if ( $sorts == $field_id ) {
85
-					$sorting['key'] = $context_id;
86
-					$sorting['direction'] = strtolower( Utils::_GET( 'dir', '' ) );
85
+					$sorting[ 'key' ] = $context_id;
86
+					$sorting[ 'direction' ] = strtolower( Utils::_GET( 'dir', '' ) );
87 87
 				}
88 88
 			}
89 89
 		} else {
90 90
 			foreach ( (array)$context->view->settings->get( 'sort_field', array() ) as $i => $sort_field ) {
91 91
 				if ( $sort_field == $field_id ) {
92
-					$sorting['key'] = $sort_field;
93
-					$sorting['direction'] = strtolower( Utils::get( $directions, $i, '' ) );
92
+					$sorting[ 'key' ] = $sort_field;
93
+					$sorting[ 'direction' ] = strtolower( Utils::get( $directions, $i, '' ) );
94 94
 					break; // Only get the first sort
95 95
 				}
96 96
 			}
@@ -109,21 +109,21 @@  discard block
 block discarded – undo
109 109
 		);
110 110
 
111 111
 		// If we are already sorting by the current field...
112
-		if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) {
112
+		if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) {
113 113
 
114
-		    switch( $sorting['direction'] ) {
114
+		    switch ( $sorting[ 'direction' ] ) {
115 115
 		        // No sort
116 116
                 case '':
117
-	                $sort_args[1] = 'asc';
117
+	                $sort_args[ 1 ] = 'asc';
118 118
 	                $class .= ' gv-icon-caret-up-down';
119 119
                     break;
120 120
                 case 'desc':
121
-	                $sort_args[1] = '';
121
+	                $sort_args[ 1 ] = '';
122 122
 	                $class .= ' gv-icon-sort-asc';
123 123
 	                break;
124 124
                 case 'asc':
125 125
                 default:
126
-                    $sort_args[1] = 'desc';
126
+                    $sort_args[ 1 ] = 'desc';
127 127
                     $class .= ' gv-icon-sort-desc';
128 128
                     break;
129 129
             }
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
 		$url = remove_query_arg( 'sort', $url );
137 137
 		$multisort_url = self::_get_multisort_url( $url, $sort_args, $context->field );
138 138
 
139
-    	$url = add_query_arg( $sort_args[0], $sort_args[1], $url );
139
+    	$url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $url );
140 140
 
141
-		$return = '<a href="'. esc_url_raw( $url ) .'"';
141
+		$return = '<a href="' . esc_url_raw( $url ) . '"';
142 142
 
143 143
 		if ( ! empty( $multisort_url ) ) {
144
-			$return .= ' data-multisort-href="'. esc_url_raw( $multisort_url ) . '"';
144
+			$return .= ' data-multisort-href="' . esc_url_raw( $multisort_url ) . '"';
145 145
 		}
146 146
 
147
-		$return .= ' class="'. $class .'" ></a>&nbsp;'. $column_label;
147
+		$return .= ' class="' . $class . '" ></a>&nbsp;' . $column_label;
148 148
 
149 149
 		return $return;
150 150
 	}
@@ -183,19 +183,19 @@  discard block
 block discarded – undo
183 183
         if ( ! in_array( $field_id, $keys = array_keys( $sorts ) ) ) {
184 184
             if ( count( $keys ) ) {
185 185
                 $multisort_url = add_query_arg( sprintf( 'sort[%s]', end( $keys ) ), $sorts[ end( $keys ) ], $multisort_url );
186
-                $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url );
186
+                $multisort_url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $multisort_url );
187 187
             } else {
188
-                $multisort_url = add_query_arg( $sort_args[0], $sort_args[1], $multisort_url );
188
+                $multisort_url = add_query_arg( $sort_args[ 0 ], $sort_args[ 1 ], $multisort_url );
189 189
             }
190 190
         }
191 191
         // Otherwise, we are just updating the sort order
192 192
         else {
193 193
 
194 194
             // Pass empty value to unset
195
-            if( '' === $sort_args[1] ) {
195
+            if ( '' === $sort_args[ 1 ] ) {
196 196
 	            unset( $sorts[ $field_id ] );
197 197
             } else {
198
-	            $sorts[ $field_id ] = $sort_args[1];
198
+	            $sorts[ $field_id ] = $sort_args[ 1 ];
199 199
             }
200 200
 
201 201
             $multisort_url = add_query_arg( array( 'sort' => $sorts ), $multisort_url );
@@ -333,9 +333,9 @@  discard block
 block discarded – undo
333 333
                 do_action( 'gravityview_table_cells_before', \GravityView_View::getInstance() );
334 334
 
335 335
                 foreach ( $fields->all() as $field ) {
336
-					if ( isset( $this->view->unions[ $entry['form_id'] ] ) ) {
337
-						if ( isset( $this->view->unions[ $entry['form_id'] ][ $field->ID ] ) ) {
338
-							$field = $this->view->unions[ $entry['form_id'] ][ $field->ID ];
336
+					if ( isset( $this->view->unions[ $entry[ 'form_id' ] ] ) ) {
337
+						if ( isset( $this->view->unions[ $entry[ 'form_id' ] ][ $field->ID ] ) ) {
338
+							$field = $this->view->unions[ $entry[ 'form_id' ] ][ $field->ID ];
339 339
 						} else {
340 340
 							if ( ! $field instanceof Internal_Field ) {
341 341
 								$field = Internal_Field::from_configuration( array( 'id' => 'custom' ) );
Please login to merge, or discard this patch.
future/includes/class-gv-view.php 1 patch
Spacing   +84 added lines, -85 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 		$supports = array( 'title', 'revisions' );
126 126
 
127 127
 		if ( $is_hierarchical ) {
128
-			$supports[] = 'page-attributes';
128
+			$supports[ ] = 'page-attributes';
129 129
 		}
130 130
 
131 131
 		/**
@@ -229,12 +229,12 @@  discard block
 block discarded – undo
229 229
 		$tsv_rule = array( sprintf( '%s/([^/]+)/tsv/?', $slug ), 'index.php?gravityview=$matches[1]&tsv=1', 'top' );
230 230
 
231 231
 		add_filter( 'query_vars', function( $query_vars ) {
232
-			$query_vars[] = 'csv';
233
-			$query_vars[] = 'tsv';
232
+			$query_vars[ ] = 'csv';
233
+			$query_vars[ ] = 'tsv';
234 234
 			return $query_vars;
235 235
 		} );
236 236
 
237
-		if ( ! isset( $wp_rewrite->extra_rules_top[ $csv_rule[0] ] ) ) {
237
+		if ( ! isset( $wp_rewrite->extra_rules_top[ $csv_rule[ 0 ] ] ) ) {
238 238
 			call_user_func_array( 'add_rewrite_rule', $csv_rule );
239 239
 			call_user_func_array( 'add_rewrite_rule', $tsv_rule );
240 240
 		}
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 
296 296
 						$message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' );
297 297
 
298
-						$image =  sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', esc_attr__( 'Data Source', 'gravityview' ), esc_url( plugins_url( 'assets/images/screenshots/data-source.png', GRAVITYVIEW_FILE ) ) );
298
+						$image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', esc_attr__( 'Data Source', 'gravityview' ), esc_url( plugins_url( 'assets/images/screenshots/data-source.png', GRAVITYVIEW_FILE ) ) );
299 299
 
300 300
 						return \GVCommon::generate_notice( '<h3>' . $title . '</h3>' . wpautop( $message . $image ), 'notice' );
301 301
 					}
@@ -321,13 +321,13 @@  discard block
 block discarded – undo
321 321
 			return $content;
322 322
 		}
323 323
 
324
-		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID );
324
+		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID );
325 325
 
326 326
 		/**
327 327
 		 * Editing a single entry.
328 328
 		 */
329 329
 		if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) {
330
-			if ( $entry['status'] != 'active' ) {
330
+			if ( $entry[ 'status' ] != 'active' ) {
331 331
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
332 332
 				return __( 'You are not allowed to view this content.', 'gravityview' );
333 333
 			}
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 			}
339 339
 
340 340
 			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
341
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
341
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
342 342
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
343 343
 					return __( 'You are not allowed to view this content.', 'gravityview' );
344 344
 				}
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 
362 362
 			foreach ( $entryset as $e ) {
363 363
 
364
-				if ( 'active' !== $e['status'] ) {
364
+				if ( 'active' !== $e[ 'status' ] ) {
365 365
 					gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $e->ID ) );
366 366
 					return __( 'You are not allowed to view this content.', 'gravityview' );
367 367
 				}
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 				}
373 373
 
374 374
 				if ( $show_only_approved && ! $is_admin_and_can_view ) {
375
-					if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
375
+					if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
376 376
 						gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $e->ID ) );
377 377
 						return __( 'You are not allowed to view this content.', 'gravityview' );
378 378
 					}
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 			$join_column    = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field::by_id( $join_column );
548 548
 			$join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field::by_id( $join_on_column );
549 549
 
550
-			$joins [] = new Join( $join, $join_column, $join_on, $join_on_column );
550
+			$joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column );
551 551
 		}
552 552
 
553 553
 		return $joins;
@@ -637,13 +637,13 @@  discard block
 block discarded – undo
637 637
 			}
638 638
 
639 639
 			foreach ( $_fields as $field ) {
640
-				if ( ! empty( $field['unions'] ) ) {
641
-					foreach ( $field['unions'] as $form_id => $field_id ) {
640
+				if ( ! empty( $field[ 'unions' ] ) ) {
641
+					foreach ( $field[ 'unions' ] as $form_id => $field_id ) {
642 642
 						if ( ! isset( $unions[ $form_id ] ) ) {
643 643
 							$unions[ $form_id ] = array();
644 644
 						}
645 645
 
646
-						$unions[ $form_id ][ $field['id'] ] =
646
+						$unions[ $form_id ][ $field[ 'id' ] ] =
647 647
 							is_numeric( $field_id ) ? \GV\GF_Field::by_id( \GV\GF_Form::by_id( $form_id ), $field_id ) : \GV\Internal_Field::by_id( $field_id );
648 648
 					}
649 649
 				}
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 		if ( ! $view->form ) {
699 699
 			gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array(
700 700
 				'view_id' => $view->ID,
701
-				'form_id' => $view->_gravityview_form_id ? : 0,
701
+				'form_id' => $view->_gravityview_form_id ?: 0,
702 702
 			) );
703 703
 		}
704 704
 
@@ -938,11 +938,11 @@  discard block
 block discarded – undo
938 938
 			 * Remove multiple sorting before calling legacy filters.
939 939
 			 * This allows us to fake it till we make it.
940 940
 			 */
941
-			if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) {
941
+			if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) {
942 942
 				$has_multisort = true;
943
-				$parameters['sort_field'] = reset( $parameters['sort_field'] );
944
-				if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) {
945
-					$parameters['sort_direction'] = reset( $parameters['sort_direction'] );
943
+				$parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] );
944
+				if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) {
945
+					$parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] );
946 946
 				}
947 947
 			}
948 948
 
@@ -951,31 +951,30 @@  discard block
 block discarded – undo
951 951
 			 */
952 952
 			$parameters = \GravityView_frontend::get_view_entries_parameters( $parameters, $this->form->ID );
953 953
 
954
-			$parameters['context_view_id'] = $this->ID;
954
+			$parameters[ 'context_view_id' ] = $this->ID;
955 955
 			$parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID );
956 956
 
957 957
 			if ( ! is_array( $parameters ) ) {
958 958
 				$parameters = array();
959 959
 			}
960 960
 
961
-			if ( ! is_array( $parameters['search_criteria'] ) ) {
962
-				$parameters['search_criteria'] = array();
961
+			if ( ! is_array( $parameters[ 'search_criteria' ] ) ) {
962
+				$parameters[ 'search_criteria' ] = array();
963 963
 			}
964 964
 
965
-			if ( ( ! isset( $parameters['search_criteria']['field_filters'] ) ) || ( ! is_array( $parameters['search_criteria']['field_filters'] ) ) ) {
966
-				$parameters['search_criteria']['field_filters'] = array();
965
+			if ( ( ! isset( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) || ( ! is_array( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) ) {
966
+				$parameters[ 'search_criteria' ][ 'field_filters' ] = array();
967 967
 			}
968 968
 
969 969
 			if ( $request instanceof REST\Request ) {
970 970
 				$atts = $this->settings->as_atts();
971 971
 				$paging_parameters = wp_parse_args( $request->get_paging(), array(
972
-						'paging' => array( 'page_size' => $atts['page_size'] ),
972
+						'paging' => array( 'page_size' => $atts[ 'page_size' ] ),
973 973
 					) );
974
-				$parameters['paging'] = $paging_parameters['paging'];
974
+				$parameters[ 'paging' ] = $paging_parameters[ 'paging' ];
975 975
 			}
976 976
 
977
-			$page = Utils::get( $parameters['paging'], 'current_page' ) ?
978
-				: ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 );
977
+			$page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 );
979 978
 
980 979
 			/**
981 980
 			 * Cleanup duplicate field_filter parameters to simplify the query.
@@ -983,14 +982,14 @@  discard block
 block discarded – undo
983 982
 			$unique_field_filters = array();
984 983
 			foreach ( Utils::get( $parameters, 'search_criteria/field_filters', array() ) as $key => $filter ) {
985 984
 				if ( 'mode' === $key ) {
986
-					$unique_field_filters['mode'] = $filter;
985
+					$unique_field_filters[ 'mode' ] = $filter;
987 986
 				} else if ( ! in_array( $filter, $unique_field_filters ) ) {
988
-					$unique_field_filters[] = $filter;
987
+					$unique_field_filters[ ] = $filter;
989 988
 				}
990 989
 			}
991
-			$parameters['search_criteria']['field_filters'] = $unique_field_filters;
990
+			$parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters;
992 991
 
993
-			if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) {
992
+			if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) {
994 993
 				gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' );
995 994
 			}
996 995
 
@@ -999,7 +998,7 @@  discard block
 block discarded – undo
999 998
 				$query_class = $this->get_query_class();
1000 999
 
1001 1000
 				/** @type \GF_Query $query */
1002
-				$query = new $query_class( $this->form->ID, $parameters['search_criteria'], Utils::get( $parameters, 'sorting' ) );
1001
+				$query = new $query_class( $this->form->ID, $parameters[ 'search_criteria' ], Utils::get( $parameters, 'sorting' ) );
1003 1002
 
1004 1003
 				/**
1005 1004
 				 * Apply multisort.
@@ -1010,15 +1009,15 @@  discard block
 block discarded – undo
1010 1009
 					$view_setting_sort_field_ids = \GV\Utils::get( $atts, 'sort_field', array() );
1011 1010
 					$view_setting_sort_directions = \GV\Utils::get( $atts, 'sort_direction', array() );
1012 1011
 
1013
-					$has_sort_query_param = ! empty( $_GET['sort'] ) && is_array( $_GET['sort'] );
1012
+					$has_sort_query_param = ! empty( $_GET[ 'sort' ] ) && is_array( $_GET[ 'sort' ] );
1014 1013
 
1015
-					if( $has_sort_query_param ) {
1016
-						$has_sort_query_param = array_filter( array_values( $_GET['sort'] ) );
1014
+					if ( $has_sort_query_param ) {
1015
+						$has_sort_query_param = array_filter( array_values( $_GET[ 'sort' ] ) );
1017 1016
 					}
1018 1017
 
1019 1018
 					if ( $this->settings->get( 'sort_columns' ) && $has_sort_query_param ) {
1020
-						$sort_field_ids = array_keys( $_GET['sort'] );
1021
-						$sort_directions = array_values( $_GET['sort'] );
1019
+						$sort_field_ids = array_keys( $_GET[ 'sort' ] );
1020
+						$sort_directions = array_values( $_GET[ 'sort' ] );
1022 1021
 					} else {
1023 1022
 						$sort_field_ids = $view_setting_sort_field_ids;
1024 1023
 						$sort_directions = $view_setting_sort_directions;
@@ -1026,7 +1025,7 @@  discard block
 block discarded – undo
1026 1025
 
1027 1026
 					$skip_first = false;
1028 1027
 
1029
-					foreach ( (array) $sort_field_ids as $key => $sort_field_id ) {
1028
+					foreach ( (array)$sort_field_ids as $key => $sort_field_id ) {
1030 1029
 
1031 1030
 						if ( ! $skip_first && ! $has_sort_query_param ) {
1032 1031
 							$skip_first = true; // Skip the first one, it's already in the query
@@ -1056,15 +1055,15 @@  discard block
 block discarded – undo
1056 1055
 
1057 1056
 					$merged_time = false;
1058 1057
 
1059
-					foreach ( $q['order'] as $oid => $order ) {
1060
-						if ( $order[0] instanceof \GF_Query_Column ) {
1061
-							$column = $order[0];
1062
-						} else if ( $order[0] instanceof \GF_Query_Call ) {
1063
-							if ( count( $order[0]->columns ) != 1 || ! $order[0]->columns[0] instanceof \GF_Query_Column ) {
1058
+					foreach ( $q[ 'order' ] as $oid => $order ) {
1059
+						if ( $order[ 0 ] instanceof \GF_Query_Column ) {
1060
+							$column = $order[ 0 ];
1061
+						} else if ( $order[ 0 ] instanceof \GF_Query_Call ) {
1062
+							if ( count( $order[ 0 ]->columns ) != 1 || ! $order[ 0 ]->columns[ 0 ] instanceof \GF_Query_Column ) {
1064 1063
 								$orders[ $oid ] = $order;
1065 1064
 								continue; // Need something that resembles a single sort
1066 1065
 							}
1067
-							$column = $order[0]->columns[0];
1066
+							$column = $order[ 0 ]->columns[ 0 ];
1068 1067
 						}
1069 1068
 
1070 1069
 						if ( ( ! $field = \GFAPI::get_field( $column->source, $column->field_id ) ) || $field->type !== 'time' ) {
@@ -1078,7 +1077,7 @@  discard block
 block discarded – undo
1078 1077
 
1079 1078
 						$orders[ $oid ] = array(
1080 1079
 							new \GV\Mocks\GF_Query_Call_TIMESORT( 'timesort', array( $column, $sql ) ),
1081
-							$order[1] // Mock it!
1080
+							$order[ 1 ] // Mock it!
1082 1081
 						);
1083 1082
 
1084 1083
 						$merged_time = true;
@@ -1089,15 +1088,15 @@  discard block
 block discarded – undo
1089 1088
 						 * ORDER again.
1090 1089
 						 */
1091 1090
 						if ( ! empty( $orders ) && $_orders = $query->_order_generate( $orders ) ) {
1092
-							$sql['order'] = 'ORDER BY ' . implode( ', ', $_orders );
1091
+							$sql[ 'order' ] = 'ORDER BY ' . implode( ', ', $_orders );
1093 1092
 						}
1094 1093
 					}
1095 1094
 
1096 1095
 					return $sql;
1097 1096
 				} );
1098 1097
 
1099
-				$query->limit( $parameters['paging']['page_size'] )
1100
-					->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) );
1098
+				$query->limit( $parameters[ 'paging' ][ 'page_size' ] )
1099
+					->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) );
1101 1100
 
1102 1101
 				/**
1103 1102
 				 * Any joins?
@@ -1120,7 +1119,7 @@  discard block
 block discarded – undo
1120 1119
 
1121 1120
 							$query_parameters = $query->_introspect();
1122 1121
 
1123
-							$query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) );
1122
+							$query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) );
1124 1123
 						}
1125 1124
 
1126 1125
 						/**
@@ -1154,7 +1153,7 @@  discard block
 block discarded – undo
1154 1153
 						}
1155 1154
 
1156 1155
 						$q = $query->_introspect();
1157
-						$query->where( \GF_Query_Condition::_and( $q['where'], $condition ) );
1156
+						$query->where( \GF_Query_Condition::_and( $q[ 'where' ], $condition ) );
1158 1157
 
1159 1158
 						if ( $this->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
1160 1159
 
@@ -1179,7 +1178,7 @@  discard block
 block discarded – undo
1179 1178
 
1180 1179
 							$query_parameters = $query->_introspect();
1181 1180
 
1182
-							$query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) );
1181
+							$query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) );
1183 1182
 						}
1184 1183
 					}
1185 1184
 
@@ -1203,7 +1202,7 @@  discard block
 block discarded – undo
1203 1202
 							$conditions = array();
1204 1203
 
1205 1204
 							foreach ( $condition->expressions as $_condition ) {
1206
-								$conditions[] = $recurse( $_condition, $fields, $recurse );
1205
+								$conditions[ ] = $recurse( $_condition, $fields, $recurse );
1207 1206
 							}
1208 1207
 
1209 1208
 							return call_user_func_array(
@@ -1232,10 +1231,10 @@  discard block
 block discarded – undo
1232 1231
 						$q = new $query_class( $form_id );
1233 1232
 
1234 1233
 						// Copy the WHERE clauses but substitute the field_ids to the respective ones
1235
-						$q->where( $where_union_substitute( $query_parameters['where'], $fields, $where_union_substitute ) );
1234
+						$q->where( $where_union_substitute( $query_parameters[ 'where' ], $fields, $where_union_substitute ) );
1236 1235
 
1237 1236
 						// Copy the ORDER clause and substitute the field_ids to the respective ones
1238
-						foreach ( $query_parameters['order'] as $order ) {
1237
+						foreach ( $query_parameters[ 'order' ] as $order ) {
1239 1238
 							list( $column, $_order ) = $order;
1240 1239
 
1241 1240
 							if ( $column && $column instanceof \GF_Query_Column ) {
@@ -1249,15 +1248,15 @@  discard block
 block discarded – undo
1249 1248
 
1250 1249
 						add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( &$unions_sql ) {
1251 1250
 							// Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses
1252
-							$select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] );
1251
+							$select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] );
1253 1252
 
1254 1253
 							// Record the SQL
1255
-							$unions_sql[] = array(
1254
+							$unions_sql[ ] = array(
1256 1255
 								// Remove columns, we'll rebuild them
1257 1256
 								'select'  => preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $select ),
1258
-								'from'    => $sql['from'],
1259
-								'join'    => $sql['join'],
1260
-								'where'   => $sql['where'],
1257
+								'from'    => $sql[ 'from' ],
1258
+								'join'    => $sql[ 'join' ],
1259
+								'where'   => $sql[ 'where' ],
1261 1260
 								// Remove order and limit
1262 1261
 							);
1263 1262
 
@@ -1274,11 +1273,11 @@  discard block
 block discarded – undo
1274 1273
 
1275 1274
 					add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( $unions_sql ) {
1276 1275
 						// Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses
1277
-						$sql['select'] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] );
1276
+						$sql[ 'select' ] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] );
1278 1277
 
1279 1278
 						// Remove columns, we'll rebuild them
1280
-						preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql['select'], $select_match );
1281
-						$sql['select'] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql['select'] );
1279
+						preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql[ 'select' ], $select_match );
1280
+						$sql[ 'select' ] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql[ 'select' ] );
1282 1281
 
1283 1282
 						$unions = array();
1284 1283
 
@@ -1289,30 +1288,30 @@  discard block
 block discarded – undo
1289 1288
 						};
1290 1289
 
1291 1290
 						// Add all the order columns into the selects, so we can order by the whole union group
1292
-						preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql['order'], $order_matches );
1291
+						preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql[ 'order' ], $order_matches );
1293 1292
 
1294 1293
 						$columns = array(
1295
-							sprintf( '%s AS %s', $select_match[1], $column_to_alias( $select_match[1] ) )
1294
+							sprintf( '%s AS %s', $select_match[ 1 ], $column_to_alias( $select_match[ 1 ] ) )
1296 1295
 						);
1297 1296
 
1298 1297
 						foreach ( array_slice( $order_matches, 1 ) as $match ) {
1299
-							$columns[] = sprintf( '%s AS %s', $match[0], $column_to_alias( $match[0] ) );
1298
+							$columns[ ] = sprintf( '%s AS %s', $match[ 0 ], $column_to_alias( $match[ 0 ] ) );
1300 1299
 
1301 1300
 							// Rewrite the order columns to the shared aliases
1302
-							$sql['order'] = str_replace( $match[0], $column_to_alias( $match[0] ), $sql['order'] );
1301
+							$sql[ 'order' ] = str_replace( $match[ 0 ], $column_to_alias( $match[ 0 ] ), $sql[ 'order' ] );
1303 1302
 						}
1304 1303
 
1305 1304
 						$columns = array_unique( $columns );
1306 1305
 
1307 1306
 						// Add the columns to every UNION
1308 1307
 						foreach ( $unions_sql as $union_sql ) {
1309
-							$union_sql['select'] .= implode( ', ', $columns );
1310
-							$unions []= implode( ' ', $union_sql );
1308
+							$union_sql[ 'select' ] .= implode( ', ', $columns );
1309
+							$unions [ ] = implode( ' ', $union_sql );
1311 1310
 						}
1312 1311
 
1313 1312
 						// Add the columns to the main SELECT, but only grab the entry id column
1314
-						$sql['select'] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql['select'] . implode( ', ', $columns );
1315
-						$sql['order'] = implode( ' ', $unions ) . ') AS u ' . $sql['order'];
1313
+						$sql[ 'select' ] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql[ 'select' ] . implode( ', ', $columns );
1314
+						$sql[ 'order' ] = implode( ' ', $unions ) . ') AS u ' . $sql[ 'order' ];
1316 1315
 
1317 1316
 						return $sql;
1318 1317
 					} );
@@ -1411,10 +1410,10 @@  discard block
 block discarded – undo
1411 1410
 						} );
1412 1411
 					}
1413 1412
 
1414
-					array_map( array( $entries, 'add'), array_slice(
1413
+					array_map( array( $entries, 'add' ), array_slice(
1415 1414
 						$filtered,
1416
-						( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ), // Offset and page
1417
-						$parameters['paging']['page_size'] // Per page
1415
+						( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ), // Offset and page
1416
+						$parameters[ 'paging' ][ 'page_size' ] // Per page
1418 1417
 					) );
1419 1418
 
1420 1419
 					$entries->add_count_callback( function() use ( $filtered, $v ) {
@@ -1441,20 +1440,20 @@  discard block
 block discarded – undo
1441 1440
 				}
1442 1441
 			} else {
1443 1442
 				$entries = $this->form->entries
1444
-					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) )
1443
+					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) )
1445 1444
 					->offset( $this->settings->get( 'offset' ) )
1446
-					->limit( $parameters['paging']['page_size'] )
1445
+					->limit( $parameters[ 'paging' ][ 'page_size' ] )
1447 1446
 					->page( $page );
1448 1447
 
1449
-				if ( ! empty( $parameters['sorting'] ) && is_array( $parameters['sorting'] && ! isset( $parameters['sorting']['key'] ) ) ) {
1448
+				if ( ! empty( $parameters[ 'sorting' ] ) && is_array( $parameters[ 'sorting' ] && ! isset( $parameters[ 'sorting' ][ 'key' ] ) ) ) {
1450 1449
 					// Pluck off multisort arrays
1451
-					$parameters['sorting'] = $parameters['sorting'][0];
1450
+					$parameters[ 'sorting' ] = $parameters[ 'sorting' ][ 0 ];
1452 1451
 				}
1453 1452
 
1454
-				if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) {
1453
+				if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) {
1455 1454
 					$field = new \GV\Field();
1456
-					$field->ID = $parameters['sorting']['key'];
1457
-					$direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
1455
+					$field->ID = $parameters[ 'sorting' ][ 'key' ];
1456
+					$direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
1458 1457
 					$entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) );
1459 1458
 				}
1460 1459
 			}
@@ -1539,7 +1538,7 @@  discard block
 block discarded – undo
1539 1538
 		$allowed = $headers = array();
1540 1539
 
1541 1540
 		foreach ( $view->fields->by_position( "directory_*" )->by_visible( $view )->all() as $id => $field ) {
1542
-			$allowed[] = $field;
1541
+			$allowed[ ] = $field;
1543 1542
 		}
1544 1543
 
1545 1544
 		$renderer = new Field_Renderer();
@@ -1561,17 +1560,17 @@  discard block
 block discarded – undo
1561 1560
 			} );
1562 1561
 
1563 1562
 			foreach ( array_diff( $allowed_field_ids, wp_list_pluck( $allowed, 'ID' ) ) as $field_id ) {
1564
-				$allowed[] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id );
1563
+				$allowed[ ] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id );
1565 1564
 			}
1566 1565
 
1567 1566
 			foreach ( $allowed as $field ) {
1568 1567
 				$source = is_numeric( $field->ID ) ? $view->form : new \GV\Internal_Source();
1569 1568
 
1570
-				$return[] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' );
1569
+				$return[ ] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' );
1571 1570
 
1572 1571
 				if ( ! $headers_done ) {
1573 1572
 					$label = $field->get_label( $view, $source, $entry );
1574
-					$headers[] = $label ? $label : $field->ID;
1573
+					$headers[ ] = $label ? $label : $field->ID;
1575 1574
 				}
1576 1575
 			}
1577 1576
 
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-custom.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 */
55 55
 	public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) {
56 56
 
57
-		unset ( $field_options['search_filter'], $field_options['show_as_link'], $field_options['new_window'] );
57
+		unset ( $field_options[ 'search_filter' ], $field_options[ 'show_as_link' ], $field_options[ 'new_window' ] );
58 58
 
59 59
 		$new_fields = array(
60 60
 			'content' => array(
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 		$this->add_field_support( 'is_numeric', $new_fields );
92 92
 
93 93
 		if ( 'edit' === $context ) {
94
-			unset( $field_options['custom_label'], $field_options['show_label'], $field_options['allow_edit_cap'], $new_fields['wpautop'], $new_fields['oembed'] );
94
+			unset( $field_options[ 'custom_label' ], $field_options[ 'show_label' ], $field_options[ 'allow_edit_cap' ], $new_fields[ 'wpautop' ], $new_fields[ 'oembed' ] );
95 95
 		}
96 96
 
97 97
 		return $new_fields + $field_options;
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 
126 126
 		// Loop through the configured Edit Entry fields and add Custom Content fields if there are any
127 127
 		// TODO: Make this available to other custom GV field types
128
-		foreach ( (array) $edit_fields as $edit_field ) {
128
+		foreach ( (array)$edit_fields as $edit_field ) {
129 129
 
130
-			if( 'custom' === \GV\Utils::get( $edit_field, 'id') ) {
130
+			if ( 'custom' === \GV\Utils::get( $edit_field, 'id' ) ) {
131 131
 
132 132
 				$field_data = array(
133 133
 					'label' => \GV\Utils::get( $edit_field, 'custom_label' ),
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
 					$field_data[ $key ] = GravityView_Merge_Tags::replace_variables( $field_datum, $form, $entry->as_entry(), false, false );
141 141
 				}
142 142
 
143
-				$field_data['cssClass'] = \GV\Utils::get( $edit_field, 'custom_class' );
143
+				$field_data[ 'cssClass' ] = \GV\Utils::get( $edit_field, 'custom_class' );
144 144
 
145
-				$new_fields[] = new GF_Field_HTML( $field_data );
145
+				$new_fields[ ] = new GF_Field_HTML( $field_data );
146 146
 
147 147
 			} else {
148
-				if( isset( $fields[ $i ] ) ) {
149
-					$new_fields[] =  $fields[ $i ];
148
+				if ( isset( $fields[ $i ] ) ) {
149
+					$new_fields[ ] = $fields[ $i ];
150 150
 				}
151 151
 				$i++;
152 152
 			}
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 				return; // Default sorting may be empty string
180 180
 			}
181 181
 
182
-			$sorts = array_combine( (array) $view->settings->get( 'sort_field' ), (array) $view->settings->get( 'sort_direction' ) );
182
+			$sorts = array_combine( (array)$view->settings->get( 'sort_field' ), (array)$view->settings->get( 'sort_direction' ) );
183 183
 		}
184 184
 
185 185
 		if ( empty( $sorts ) || ! is_array( $sorts ) ) {
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 				if ( strpos( $key, 'custom_' ) === 0 ) {
202 202
 					$field = $view->fields->get( str_replace( 'custom_', '', $key ) );
203 203
 				} else {
204
-					$field  = is_numeric( $key ) ? \GV\GF_Field::by_id( $view->form, $key ) : \GV\Internal_Field::by_id( $key );
204
+					$field = is_numeric( $key ) ? \GV\GF_Field::by_id( $view->form, $key ) : \GV\Internal_Field::by_id( $key );
205 205
 				}
206 206
 
207 207
 				$source = is_numeric( $key ) ? $view->form : new \GV\Internal_Source();
Please login to merge, or discard this patch.