Completed
Pull Request — develop (#1487)
by Zack
14:14 queued 02:44
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.
includes/fields/class-gravityview-field-custom.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) {
54 54
 
55
-		unset ( $field_options['search_filter'], $field_options['show_as_link'] );
55
+		unset ( $field_options[ 'search_filter' ], $field_options[ 'show_as_link' ] );
56 56
 
57 57
 		$new_fields = array(
58 58
 			'content' => array(
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		$this->add_field_support( 'is_numeric', $new_fields );
90 90
 
91 91
 		if ( 'edit' === $context ) {
92
-			unset( $field_options['custom_label'], $field_options['show_label'], $field_options['allow_edit_cap'], $new_fields['wpautop'], $new_fields['oembed'] );
92
+			unset( $field_options[ 'custom_label' ], $field_options[ 'show_label' ], $field_options[ 'allow_edit_cap' ], $new_fields[ 'wpautop' ], $new_fields[ 'oembed' ] );
93 93
 		}
94 94
 
95 95
 		return $new_fields + $field_options;
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 
124 124
 		// Loop through the configured Edit Entry fields and add Custom Content fields if there are any
125 125
 		// TODO: Make this available to other custom GV field types
126
-		foreach ( (array) $edit_fields as $edit_field ) {
126
+		foreach ( (array)$edit_fields as $edit_field ) {
127 127
 
128
-			if( 'custom' === \GV\Utils::get( $edit_field, 'id') ) {
128
+			if ( 'custom' === \GV\Utils::get( $edit_field, 'id' ) ) {
129 129
 
130 130
 				$field_data = array(
131 131
 					'label' => \GV\Utils::get( $edit_field, 'custom_label' ),
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 					$field_data[ $key ] = GravityView_Merge_Tags::replace_variables( $field_datum, $form, $entry->as_entry(), false, false );
139 139
 				}
140 140
 
141
-				$field_data['cssClass'] = \GV\Utils::get( $edit_field, 'custom_class' );
141
+				$field_data[ 'cssClass' ] = \GV\Utils::get( $edit_field, 'custom_class' );
142 142
 
143
-				$new_fields[] = new GF_Field_HTML( $field_data );
143
+				$new_fields[ ] = new GF_Field_HTML( $field_data );
144 144
 
145 145
 			} else {
146
-				if( isset( $fields[ $i ] ) ) {
147
-					$new_fields[] =  $fields[ $i ];
146
+				if ( isset( $fields[ $i ] ) ) {
147
+					$new_fields[ ] = $fields[ $i ];
148 148
 				}
149 149
 				$i++;
150 150
 			}
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 				return; // Default sorting may be empty string
178 178
 			}
179 179
 
180
-			$sorts = array_combine( (array) $view->settings->get( 'sort_field' ), (array) $view->settings->get( 'sort_direction' ) );
180
+			$sorts = array_combine( (array)$view->settings->get( 'sort_field' ), (array)$view->settings->get( 'sort_direction' ) );
181 181
 		}
182 182
 
183 183
 		if ( empty( $sorts ) || ! is_array( $sorts ) ) {
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 				if ( strpos( $key, 'custom_' ) === 0 ) {
200 200
 					$field = $view->fields->get( str_replace( 'custom_', '', $key ) );
201 201
 				} else {
202
-					$field  = is_numeric( $key ) ? \GV\GF_Field::by_id( $view->form, $key ) : \GV\Internal_Field::by_id( $key );
202
+					$field = is_numeric( $key ) ? \GV\GF_Field::by_id( $view->form, $key ) : \GV\Internal_Field::by_id( $key );
203 203
 				}
204 204
 
205 205
 				$source = is_numeric( $key ) ? $view->form : new \GV\Internal_Source();
Please login to merge, or discard this patch.
future/includes/class-gv-view.php 1 patch
Spacing   +82 added lines, -83 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
 		/**
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
 		$rule = array( sprintf( '%s/([^/]+)/csv/?', $slug ), 'index.php?gravityview=$matches[1]&csv=1', 'top' );
228 228
 
229 229
 		add_filter( 'query_vars', function( $query_vars ) {
230
-			$query_vars[] = 'csv';
230
+			$query_vars[ ] = 'csv';
231 231
 			return $query_vars;
232 232
 		} );
233 233
 
234
-		if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[0] ] ) ) {
234
+		if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[ 0 ] ] ) ) {
235 235
 			call_user_func_array( 'add_rewrite_rule', $rule );
236 236
 		}
237 237
 	}
@@ -308,13 +308,13 @@  discard block
 block discarded – undo
308 308
 			return $content;
309 309
 		}
310 310
 
311
-		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID );
311
+		$is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID );
312 312
 
313 313
 		/**
314 314
 		 * Editing a single entry.
315 315
 		 */
316 316
 		if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) {
317
-			if ( $entry['status'] != 'active' ) {
317
+			if ( $entry[ 'status' ] != 'active' ) {
318 318
 				gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
319 319
 				return __( 'You are not allowed to view this content.', 'gravityview' );
320 320
 			}
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 			}
326 326
 
327 327
 			if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
328
-				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
328
+				if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
329 329
 					gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
330 330
 					return __( 'You are not allowed to view this content.', 'gravityview' );
331 331
 				}
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 
349 349
 			foreach ( $entryset as $e ) {
350 350
 
351
-				if ( 'active' !== $e['status'] ) {
351
+				if ( 'active' !== $e[ 'status' ] ) {
352 352
 					gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $e->ID ) );
353 353
 					return __( 'You are not allowed to view this content.', 'gravityview' );
354 354
 				}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 				}
360 360
 
361 361
 				if ( $show_only_approved && ! $is_admin_and_can_view ) {
362
-					if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
362
+					if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
363 363
 						gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $e->ID ) );
364 364
 						return __( 'You are not allowed to view this content.', 'gravityview' );
365 365
 					}
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 			$join_column    = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field::by_id( $join_column );
535 535
 			$join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field::by_id( $join_on_column );
536 536
 
537
-			$joins [] = new Join( $join, $join_column, $join_on, $join_on_column );
537
+			$joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column );
538 538
 		}
539 539
 
540 540
 		return $joins;
@@ -624,13 +624,13 @@  discard block
 block discarded – undo
624 624
 			}
625 625
 
626 626
 			foreach ( $_fields as $field ) {
627
-				if ( ! empty( $field['unions'] ) ) {
628
-					foreach ( $field['unions'] as $form_id => $field_id ) {
627
+				if ( ! empty( $field[ 'unions' ] ) ) {
628
+					foreach ( $field[ 'unions' ] as $form_id => $field_id ) {
629 629
 						if ( ! isset( $unions[ $form_id ] ) ) {
630 630
 							$unions[ $form_id ] = array();
631 631
 						}
632 632
 
633
-						$unions[ $form_id ][ $field['id'] ] =
633
+						$unions[ $form_id ][ $field[ 'id' ] ] =
634 634
 							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 );
635 635
 					}
636 636
 				}
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
 		if ( ! $view->form ) {
686 686
 			gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array(
687 687
 				'view_id' => $view->ID,
688
-				'form_id' => $view->_gravityview_form_id ? : 0,
688
+				'form_id' => $view->_gravityview_form_id ?: 0,
689 689
 			) );
690 690
 		}
691 691
 
@@ -925,11 +925,11 @@  discard block
 block discarded – undo
925 925
 			 * Remove multiple sorting before calling legacy filters.
926 926
 			 * This allows us to fake it till we make it.
927 927
 			 */
928
-			if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) {
928
+			if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) {
929 929
 				$has_multisort = true;
930
-				$parameters['sort_field'] = reset( $parameters['sort_field'] );
931
-				if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) {
932
-					$parameters['sort_direction'] = reset( $parameters['sort_direction'] );
930
+				$parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] );
931
+				if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) {
932
+					$parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] );
933 933
 				}
934 934
 			}
935 935
 
@@ -938,31 +938,30 @@  discard block
 block discarded – undo
938 938
 			 */
939 939
 			$parameters = \GravityView_frontend::get_view_entries_parameters( $parameters, $this->form->ID );
940 940
 
941
-			$parameters['context_view_id'] = $this->ID;
941
+			$parameters[ 'context_view_id' ] = $this->ID;
942 942
 			$parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID );
943 943
 
944 944
 			if ( ! is_array( $parameters ) ) {
945 945
 				$parameters = array();
946 946
 			}
947 947
 
948
-			if ( ! is_array( $parameters['search_criteria'] ) ) {
949
-				$parameters['search_criteria'] = array();
948
+			if ( ! is_array( $parameters[ 'search_criteria' ] ) ) {
949
+				$parameters[ 'search_criteria' ] = array();
950 950
 			}
951 951
 
952
-			if ( ( ! isset( $parameters['search_criteria']['field_filters'] ) ) || ( ! is_array( $parameters['search_criteria']['field_filters'] ) ) ) {
953
-				$parameters['search_criteria']['field_filters'] = array();
952
+			if ( ( ! isset( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) || ( ! is_array( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) ) {
953
+				$parameters[ 'search_criteria' ][ 'field_filters' ] = array();
954 954
 			}
955 955
 
956 956
 			if ( $request instanceof REST\Request ) {
957 957
 				$atts = $this->settings->as_atts();
958 958
 				$paging_parameters = wp_parse_args( $request->get_paging(), array(
959
-						'paging' => array( 'page_size' => $atts['page_size'] ),
959
+						'paging' => array( 'page_size' => $atts[ 'page_size' ] ),
960 960
 					) );
961
-				$parameters['paging'] = $paging_parameters['paging'];
961
+				$parameters[ 'paging' ] = $paging_parameters[ 'paging' ];
962 962
 			}
963 963
 
964
-			$page = Utils::get( $parameters['paging'], 'current_page' ) ?
965
-				: ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 );
964
+			$page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 );
966 965
 
967 966
 			/**
968 967
 			 * Cleanup duplicate field_filter parameters to simplify the query.
@@ -970,14 +969,14 @@  discard block
 block discarded – undo
970 969
 			$unique_field_filters = array();
971 970
 			foreach ( Utils::get( $parameters, 'search_criteria/field_filters', array() ) as $key => $filter ) {
972 971
 				if ( 'mode' === $key ) {
973
-					$unique_field_filters['mode'] = $filter;
972
+					$unique_field_filters[ 'mode' ] = $filter;
974 973
 				} else if ( ! in_array( $filter, $unique_field_filters ) ) {
975
-					$unique_field_filters[] = $filter;
974
+					$unique_field_filters[ ] = $filter;
976 975
 				}
977 976
 			}
978
-			$parameters['search_criteria']['field_filters'] = $unique_field_filters;
977
+			$parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters;
979 978
 
980
-			if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) {
979
+			if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) {
981 980
 				gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' );
982 981
 			}
983 982
 
@@ -986,7 +985,7 @@  discard block
 block discarded – undo
986 985
 				$query_class = $this->get_query_class();
987 986
 
988 987
 				/** @type \GF_Query $query */
989
-				$query = new $query_class( $this->form->ID, $parameters['search_criteria'], Utils::get( $parameters, 'sorting' ) );
988
+				$query = new $query_class( $this->form->ID, $parameters[ 'search_criteria' ], Utils::get( $parameters, 'sorting' ) );
990 989
 
991 990
 				/**
992 991
 				 * Apply multisort.
@@ -997,15 +996,15 @@  discard block
 block discarded – undo
997 996
 					$view_setting_sort_field_ids = \GV\Utils::get( $atts, 'sort_field', array() );
998 997
 					$view_setting_sort_directions = \GV\Utils::get( $atts, 'sort_direction', array() );
999 998
 
1000
-					$has_sort_query_param = ! empty( $_GET['sort'] ) && is_array( $_GET['sort'] );
999
+					$has_sort_query_param = ! empty( $_GET[ 'sort' ] ) && is_array( $_GET[ 'sort' ] );
1001 1000
 
1002
-					if( $has_sort_query_param ) {
1003
-						$has_sort_query_param = array_filter( array_values( $_GET['sort'] ) );
1001
+					if ( $has_sort_query_param ) {
1002
+						$has_sort_query_param = array_filter( array_values( $_GET[ 'sort' ] ) );
1004 1003
 					}
1005 1004
 
1006 1005
 					if ( $this->settings->get( 'sort_columns' ) && $has_sort_query_param ) {
1007
-						$sort_field_ids = array_keys( $_GET['sort'] );
1008
-						$sort_directions = array_values( $_GET['sort'] );
1006
+						$sort_field_ids = array_keys( $_GET[ 'sort' ] );
1007
+						$sort_directions = array_values( $_GET[ 'sort' ] );
1009 1008
 					} else {
1010 1009
 						$sort_field_ids = $view_setting_sort_field_ids;
1011 1010
 						$sort_directions = $view_setting_sort_directions;
@@ -1013,7 +1012,7 @@  discard block
 block discarded – undo
1013 1012
 
1014 1013
 					$skip_first = false;
1015 1014
 
1016
-					foreach ( (array) $sort_field_ids as $key => $sort_field_id ) {
1015
+					foreach ( (array)$sort_field_ids as $key => $sort_field_id ) {
1017 1016
 
1018 1017
 						if ( ! $skip_first && ! $has_sort_query_param ) {
1019 1018
 							$skip_first = true; // Skip the first one, it's already in the query
@@ -1043,15 +1042,15 @@  discard block
 block discarded – undo
1043 1042
 
1044 1043
 					$merged_time = false;
1045 1044
 
1046
-					foreach ( $q['order'] as $oid => $order ) {
1047
-						if ( $order[0] instanceof \GF_Query_Column ) {
1048
-							$column = $order[0];
1049
-						} else if ( $order[0] instanceof \GF_Query_Call ) {
1050
-							if ( count( $order[0]->columns ) != 1 || ! $order[0]->columns[0] instanceof \GF_Query_Column ) {
1045
+					foreach ( $q[ 'order' ] as $oid => $order ) {
1046
+						if ( $order[ 0 ] instanceof \GF_Query_Column ) {
1047
+							$column = $order[ 0 ];
1048
+						} else if ( $order[ 0 ] instanceof \GF_Query_Call ) {
1049
+							if ( count( $order[ 0 ]->columns ) != 1 || ! $order[ 0 ]->columns[ 0 ] instanceof \GF_Query_Column ) {
1051 1050
 								$orders[ $oid ] = $order;
1052 1051
 								continue; // Need something that resembles a single sort
1053 1052
 							}
1054
-							$column = $order[0]->columns[0];
1053
+							$column = $order[ 0 ]->columns[ 0 ];
1055 1054
 						}
1056 1055
 
1057 1056
 						if ( ( ! $field = \GFAPI::get_field( $column->source, $column->field_id ) ) || $field->type !== 'time' ) {
@@ -1065,7 +1064,7 @@  discard block
 block discarded – undo
1065 1064
 
1066 1065
 						$orders[ $oid ] = array(
1067 1066
 							new \GV\Mocks\GF_Query_Call_TIMESORT( 'timesort', array( $column, $sql ) ),
1068
-							$order[1] // Mock it!
1067
+							$order[ 1 ] // Mock it!
1069 1068
 						);
1070 1069
 
1071 1070
 						$merged_time = true;
@@ -1076,15 +1075,15 @@  discard block
 block discarded – undo
1076 1075
 						 * ORDER again.
1077 1076
 						 */
1078 1077
 						if ( ! empty( $orders ) && $_orders = $query->_order_generate( $orders ) ) {
1079
-							$sql['order'] = 'ORDER BY ' . implode( ', ', $_orders );
1078
+							$sql[ 'order' ] = 'ORDER BY ' . implode( ', ', $_orders );
1080 1079
 						}
1081 1080
 					}
1082 1081
 
1083 1082
 					return $sql;
1084 1083
 				} );
1085 1084
 
1086
-				$query->limit( $parameters['paging']['page_size'] )
1087
-					->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) );
1085
+				$query->limit( $parameters[ 'paging' ][ 'page_size' ] )
1086
+					->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) );
1088 1087
 
1089 1088
 				/**
1090 1089
 				 * Any joins?
@@ -1107,7 +1106,7 @@  discard block
 block discarded – undo
1107 1106
 
1108 1107
 							$query_parameters = $query->_introspect();
1109 1108
 
1110
-							$query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) );
1109
+							$query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) );
1111 1110
 						}
1112 1111
 
1113 1112
 						/**
@@ -1141,7 +1140,7 @@  discard block
 block discarded – undo
1141 1140
 						}
1142 1141
 
1143 1142
 						$q = $query->_introspect();
1144
-						$query->where( \GF_Query_Condition::_and( $q['where'], $condition ) );
1143
+						$query->where( \GF_Query_Condition::_and( $q[ 'where' ], $condition ) );
1145 1144
 
1146 1145
 						if ( $this->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
1147 1146
 
@@ -1166,7 +1165,7 @@  discard block
 block discarded – undo
1166 1165
 
1167 1166
 							$query_parameters = $query->_introspect();
1168 1167
 
1169
-							$query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) );
1168
+							$query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) );
1170 1169
 						}
1171 1170
 					}
1172 1171
 
@@ -1190,7 +1189,7 @@  discard block
 block discarded – undo
1190 1189
 							$conditions = array();
1191 1190
 
1192 1191
 							foreach ( $condition->expressions as $_condition ) {
1193
-								$conditions[] = $recurse( $_condition, $fields, $recurse );
1192
+								$conditions[ ] = $recurse( $_condition, $fields, $recurse );
1194 1193
 							}
1195 1194
 
1196 1195
 							return call_user_func_array(
@@ -1219,10 +1218,10 @@  discard block
 block discarded – undo
1219 1218
 						$q = new $query_class( $form_id );
1220 1219
 
1221 1220
 						// Copy the WHERE clauses but substitute the field_ids to the respective ones
1222
-						$q->where( $where_union_substitute( $query_parameters['where'], $fields, $where_union_substitute ) );
1221
+						$q->where( $where_union_substitute( $query_parameters[ 'where' ], $fields, $where_union_substitute ) );
1223 1222
 
1224 1223
 						// Copy the ORDER clause and substitute the field_ids to the respective ones
1225
-						foreach ( $query_parameters['order'] as $order ) {
1224
+						foreach ( $query_parameters[ 'order' ] as $order ) {
1226 1225
 							list( $column, $_order ) = $order;
1227 1226
 
1228 1227
 							if ( $column && $column instanceof \GF_Query_Column ) {
@@ -1236,15 +1235,15 @@  discard block
 block discarded – undo
1236 1235
 
1237 1236
 						add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( &$unions_sql ) {
1238 1237
 							// Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses
1239
-							$select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] );
1238
+							$select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] );
1240 1239
 
1241 1240
 							// Record the SQL
1242
-							$unions_sql[] = array(
1241
+							$unions_sql[ ] = array(
1243 1242
 								// Remove columns, we'll rebuild them
1244 1243
 								'select'  => preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $select ),
1245
-								'from'    => $sql['from'],
1246
-								'join'    => $sql['join'],
1247
-								'where'   => $sql['where'],
1244
+								'from'    => $sql[ 'from' ],
1245
+								'join'    => $sql[ 'join' ],
1246
+								'where'   => $sql[ 'where' ],
1248 1247
 								// Remove order and limit
1249 1248
 							);
1250 1249
 
@@ -1261,11 +1260,11 @@  discard block
 block discarded – undo
1261 1260
 
1262 1261
 					add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( $unions_sql ) {
1263 1262
 						// Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses
1264
-						$sql['select'] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] );
1263
+						$sql[ 'select' ] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] );
1265 1264
 
1266 1265
 						// Remove columns, we'll rebuild them
1267
-						preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql['select'], $select_match );
1268
-						$sql['select'] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql['select'] );
1266
+						preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql[ 'select' ], $select_match );
1267
+						$sql[ 'select' ] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql[ 'select' ] );
1269 1268
 
1270 1269
 						$unions = array();
1271 1270
 
@@ -1276,30 +1275,30 @@  discard block
 block discarded – undo
1276 1275
 						};
1277 1276
 
1278 1277
 						// Add all the order columns into the selects, so we can order by the whole union group
1279
-						preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql['order'], $order_matches );
1278
+						preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql[ 'order' ], $order_matches );
1280 1279
 
1281 1280
 						$columns = array(
1282
-							sprintf( '%s AS %s', $select_match[1], $column_to_alias( $select_match[1] ) )
1281
+							sprintf( '%s AS %s', $select_match[ 1 ], $column_to_alias( $select_match[ 1 ] ) )
1283 1282
 						);
1284 1283
 
1285 1284
 						foreach ( array_slice( $order_matches, 1 ) as $match ) {
1286
-							$columns[] = sprintf( '%s AS %s', $match[0], $column_to_alias( $match[0] ) );
1285
+							$columns[ ] = sprintf( '%s AS %s', $match[ 0 ], $column_to_alias( $match[ 0 ] ) );
1287 1286
 
1288 1287
 							// Rewrite the order columns to the shared aliases
1289
-							$sql['order'] = str_replace( $match[0], $column_to_alias( $match[0] ), $sql['order'] );
1288
+							$sql[ 'order' ] = str_replace( $match[ 0 ], $column_to_alias( $match[ 0 ] ), $sql[ 'order' ] );
1290 1289
 						}
1291 1290
 
1292 1291
 						$columns = array_unique( $columns );
1293 1292
 
1294 1293
 						// Add the columns to every UNION
1295 1294
 						foreach ( $unions_sql as $union_sql ) {
1296
-							$union_sql['select'] .= implode( ', ', $columns );
1297
-							$unions []= implode( ' ', $union_sql );
1295
+							$union_sql[ 'select' ] .= implode( ', ', $columns );
1296
+							$unions [ ] = implode( ' ', $union_sql );
1298 1297
 						}
1299 1298
 
1300 1299
 						// Add the columns to the main SELECT, but only grab the entry id column
1301
-						$sql['select'] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql['select'] . implode( ', ', $columns );
1302
-						$sql['order'] = implode( ' ', $unions ) . ') AS u ' . $sql['order'];
1300
+						$sql[ 'select' ] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql[ 'select' ] . implode( ', ', $columns );
1301
+						$sql[ 'order' ] = implode( ' ', $unions ) . ') AS u ' . $sql[ 'order' ];
1303 1302
 
1304 1303
 						return $sql;
1305 1304
 					} );
@@ -1398,10 +1397,10 @@  discard block
 block discarded – undo
1398 1397
 						} );
1399 1398
 					}
1400 1399
 
1401
-					array_map( array( $entries, 'add'), array_slice(
1400
+					array_map( array( $entries, 'add' ), array_slice(
1402 1401
 						$filtered,
1403
-						( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ), // Offset and page
1404
-						$parameters['paging']['page_size'] // Per page
1402
+						( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ), // Offset and page
1403
+						$parameters[ 'paging' ][ 'page_size' ] // Per page
1405 1404
 					) );
1406 1405
 
1407 1406
 					$entries->add_count_callback( function() use ( $filtered, $v ) {
@@ -1428,20 +1427,20 @@  discard block
 block discarded – undo
1428 1427
 				}
1429 1428
 			} else {
1430 1429
 				$entries = $this->form->entries
1431
-					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) )
1430
+					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) )
1432 1431
 					->offset( $this->settings->get( 'offset' ) )
1433
-					->limit( $parameters['paging']['page_size'] )
1432
+					->limit( $parameters[ 'paging' ][ 'page_size' ] )
1434 1433
 					->page( $page );
1435 1434
 
1436
-				if ( ! empty( $parameters['sorting'] ) && is_array( $parameters['sorting'] && ! isset( $parameters['sorting']['key'] ) ) ) {
1435
+				if ( ! empty( $parameters[ 'sorting' ] ) && is_array( $parameters[ 'sorting' ] && ! isset( $parameters[ 'sorting' ][ 'key' ] ) ) ) {
1437 1436
 					// Pluck off multisort arrays
1438
-					$parameters['sorting'] = $parameters['sorting'][0];
1437
+					$parameters[ 'sorting' ] = $parameters[ 'sorting' ][ 0 ];
1439 1438
 				}
1440 1439
 
1441
-				if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) {
1440
+				if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) {
1442 1441
 					$field = new \GV\Field();
1443
-					$field->ID = $parameters['sorting']['key'];
1444
-					$direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
1442
+					$field->ID = $parameters[ 'sorting' ][ 'key' ];
1443
+					$direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
1445 1444
 					$entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) );
1446 1445
 				}
1447 1446
 			}
@@ -1516,7 +1515,7 @@  discard block
 block discarded – undo
1516 1515
 		$allowed = $headers = array();
1517 1516
 
1518 1517
 		foreach ( $view->fields->by_position( "directory_*" )->by_visible( $view )->all() as $id => $field ) {
1519
-			$allowed[] = $field;
1518
+			$allowed[ ] = $field;
1520 1519
 		}
1521 1520
 
1522 1521
 		$renderer = new Field_Renderer();
@@ -1538,17 +1537,17 @@  discard block
 block discarded – undo
1538 1537
 			} );
1539 1538
 
1540 1539
 			foreach ( array_diff( $allowed_field_ids, wp_list_pluck( $allowed, 'ID' ) ) as $field_id ) {
1541
-				$allowed[] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id );
1540
+				$allowed[ ] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id );
1542 1541
 			}
1543 1542
 
1544 1543
 			foreach ( $allowed as $field ) {
1545 1544
 				$source = is_numeric( $field->ID ) ? $view->form : new \GV\Internal_Source();
1546 1545
 
1547
-				$return[] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' );
1546
+				$return[ ] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' );
1548 1547
 
1549 1548
 				if ( ! $headers_done ) {
1550 1549
 					$label = $field->get_label( $view, $source, $entry );
1551
-					$headers[] = $label ? $label : $field->ID;
1550
+					$headers[ ] = $label ? $label : $field->ID;
1552 1551
 				}
1553 1552
 			}
1554 1553
 
Please login to merge, or discard this patch.