Completed
Pull Request — develop (#1577)
by Zack
15:52
created
future/includes/class-gv-view.php 4 patches
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,6 @@
 block discarded – undo
62 62
 	 *
63 63
 	 * Internal static cache for gets, and whatnot.
64 64
 	 * This is not persistent, resets across requests.
65
-
66 65
 	 * @internal
67 66
 	 */
68 67
 	private static $cache = array();
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -230,8 +230,9 @@
 block discarded – undo
230 230
 		 * Check permissions.
231 231
 		 */
232 232
 		while ( $error = $view->can_render( null, $request ) ) {
233
-			if ( ! is_wp_error( $error ) )
234
-				break;
233
+			if ( ! is_wp_error( $error ) ) {
234
+							break;
235
+			}
235 236
 
236 237
 			switch ( str_replace( 'gravityview/', '', $error->get_error_code() ) ) {
237 238
 				case 'post_password_required':
Please login to merge, or discard this patch.
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -795,6 +795,7 @@
 block discarded – undo
795 795
 	 * Retrieve the entries for the current view and request.
796 796
 	 *
797 797
 	 * @param \GV\Request The request. Unused for now.
798
+	 * @param Request $request
798 799
 	 *
799 800
 	 * @return \GV\Entry_Collection The entries.
800 801
 	 */
Please login to merge, or discard this patch.
Spacing   +81 added lines, -82 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
 
@@ -937,11 +937,11 @@  discard block
 block discarded – undo
937 937
 			 * Remove multiple sorting before calling legacy filters.
938 938
 			 * This allows us to fake it till we make it.
939 939
 			 */
940
-			if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) {
940
+			if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) {
941 941
 				$has_multisort = true;
942
-				$parameters['sort_field'] = reset( $parameters['sort_field'] );
943
-				if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) {
944
-					$parameters['sort_direction'] = reset( $parameters['sort_direction'] );
942
+				$parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] );
943
+				if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) {
944
+					$parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] );
945 945
 				}
946 946
 			}
947 947
 
@@ -950,31 +950,30 @@  discard block
 block discarded – undo
950 950
 			 */
951 951
 			$parameters = \GravityView_frontend::get_view_entries_parameters( $parameters, $this->form->ID );
952 952
 
953
-			$parameters['context_view_id'] = $this->ID;
953
+			$parameters[ 'context_view_id' ] = $this->ID;
954 954
 			$parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID );
955 955
 
956 956
 			if ( ! is_array( $parameters ) ) {
957 957
 				$parameters = array();
958 958
 			}
959 959
 
960
-			if ( ! is_array( $parameters['search_criteria'] ) ) {
961
-				$parameters['search_criteria'] = array();
960
+			if ( ! is_array( $parameters[ 'search_criteria' ] ) ) {
961
+				$parameters[ 'search_criteria' ] = array();
962 962
 			}
963 963
 
964
-			if ( ( ! isset( $parameters['search_criteria']['field_filters'] ) ) || ( ! is_array( $parameters['search_criteria']['field_filters'] ) ) ) {
965
-				$parameters['search_criteria']['field_filters'] = array();
964
+			if ( ( ! isset( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) || ( ! is_array( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) ) {
965
+				$parameters[ 'search_criteria' ][ 'field_filters' ] = array();
966 966
 			}
967 967
 
968 968
 			if ( $request instanceof REST\Request ) {
969 969
 				$atts = $this->settings->as_atts();
970 970
 				$paging_parameters = wp_parse_args( $request->get_paging(), array(
971
-						'paging' => array( 'page_size' => $atts['page_size'] ),
971
+						'paging' => array( 'page_size' => $atts[ 'page_size' ] ),
972 972
 					) );
973
-				$parameters['paging'] = $paging_parameters['paging'];
973
+				$parameters[ 'paging' ] = $paging_parameters[ 'paging' ];
974 974
 			}
975 975
 
976
-			$page = Utils::get( $parameters['paging'], 'current_page' ) ?
977
-				: ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 );
976
+			$page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 );
978 977
 
979 978
 			/**
980 979
 			 * Cleanup duplicate field_filter parameters to simplify the query.
@@ -982,14 +981,14 @@  discard block
 block discarded – undo
982 981
 			$unique_field_filters = array();
983 982
 			foreach ( Utils::get( $parameters, 'search_criteria/field_filters', array() ) as $key => $filter ) {
984 983
 				if ( 'mode' === $key ) {
985
-					$unique_field_filters['mode'] = $filter;
984
+					$unique_field_filters[ 'mode' ] = $filter;
986 985
 				} else if ( ! in_array( $filter, $unique_field_filters ) ) {
987
-					$unique_field_filters[] = $filter;
986
+					$unique_field_filters[ ] = $filter;
988 987
 				}
989 988
 			}
990
-			$parameters['search_criteria']['field_filters'] = $unique_field_filters;
989
+			$parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters;
991 990
 
992
-			if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) {
991
+			if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) {
993 992
 				gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' );
994 993
 			}
995 994
 
@@ -998,7 +997,7 @@  discard block
 block discarded – undo
998 997
 				$query_class = $this->get_query_class();
999 998
 
1000 999
 				/** @type \GF_Query $query */
1001
-				$query = new $query_class( $this->form->ID, $parameters['search_criteria'], Utils::get( $parameters, 'sorting' ) );
1000
+				$query = new $query_class( $this->form->ID, $parameters[ 'search_criteria' ], Utils::get( $parameters, 'sorting' ) );
1002 1001
 
1003 1002
 				/**
1004 1003
 				 * Apply multisort.
@@ -1009,15 +1008,15 @@  discard block
 block discarded – undo
1009 1008
 					$view_setting_sort_field_ids = \GV\Utils::get( $atts, 'sort_field', array() );
1010 1009
 					$view_setting_sort_directions = \GV\Utils::get( $atts, 'sort_direction', array() );
1011 1010
 
1012
-					$has_sort_query_param = ! empty( $_GET['sort'] ) && is_array( $_GET['sort'] );
1011
+					$has_sort_query_param = ! empty( $_GET[ 'sort' ] ) && is_array( $_GET[ 'sort' ] );
1013 1012
 
1014
-					if( $has_sort_query_param ) {
1015
-						$has_sort_query_param = array_filter( array_values( $_GET['sort'] ) );
1013
+					if ( $has_sort_query_param ) {
1014
+						$has_sort_query_param = array_filter( array_values( $_GET[ 'sort' ] ) );
1016 1015
 					}
1017 1016
 
1018 1017
 					if ( $this->settings->get( 'sort_columns' ) && $has_sort_query_param ) {
1019
-						$sort_field_ids = array_keys( $_GET['sort'] );
1020
-						$sort_directions = array_values( $_GET['sort'] );
1018
+						$sort_field_ids = array_keys( $_GET[ 'sort' ] );
1019
+						$sort_directions = array_values( $_GET[ 'sort' ] );
1021 1020
 					} else {
1022 1021
 						$sort_field_ids = $view_setting_sort_field_ids;
1023 1022
 						$sort_directions = $view_setting_sort_directions;
@@ -1025,7 +1024,7 @@  discard block
 block discarded – undo
1025 1024
 
1026 1025
 					$skip_first = false;
1027 1026
 
1028
-					foreach ( (array) $sort_field_ids as $key => $sort_field_id ) {
1027
+					foreach ( (array)$sort_field_ids as $key => $sort_field_id ) {
1029 1028
 
1030 1029
 						if ( ! $skip_first && ! $has_sort_query_param ) {
1031 1030
 							$skip_first = true; // Skip the first one, it's already in the query
@@ -1055,15 +1054,15 @@  discard block
 block discarded – undo
1055 1054
 
1056 1055
 					$merged_time = false;
1057 1056
 
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 ) {
1057
+					foreach ( $q[ 'order' ] as $oid => $order ) {
1058
+						if ( $order[ 0 ] instanceof \GF_Query_Column ) {
1059
+							$column = $order[ 0 ];
1060
+						} else if ( $order[ 0 ] instanceof \GF_Query_Call ) {
1061
+							if ( count( $order[ 0 ]->columns ) != 1 || ! $order[ 0 ]->columns[ 0 ] instanceof \GF_Query_Column ) {
1063 1062
 								$orders[ $oid ] = $order;
1064 1063
 								continue; // Need something that resembles a single sort
1065 1064
 							}
1066
-							$column = $order[0]->columns[0];
1065
+							$column = $order[ 0 ]->columns[ 0 ];
1067 1066
 						}
1068 1067
 
1069 1068
 						if ( ( ! $field = \GFAPI::get_field( $column->source, $column->field_id ) ) || $field->type !== 'time' ) {
@@ -1077,7 +1076,7 @@  discard block
 block discarded – undo
1077 1076
 
1078 1077
 						$orders[ $oid ] = array(
1079 1078
 							new \GV\Mocks\GF_Query_Call_TIMESORT( 'timesort', array( $column, $sql ) ),
1080
-							$order[1] // Mock it!
1079
+							$order[ 1 ] // Mock it!
1081 1080
 						);
1082 1081
 
1083 1082
 						$merged_time = true;
@@ -1088,15 +1087,15 @@  discard block
 block discarded – undo
1088 1087
 						 * ORDER again.
1089 1088
 						 */
1090 1089
 						if ( ! empty( $orders ) && $_orders = $query->_order_generate( $orders ) ) {
1091
-							$sql['order'] = 'ORDER BY ' . implode( ', ', $_orders );
1090
+							$sql[ 'order' ] = 'ORDER BY ' . implode( ', ', $_orders );
1092 1091
 						}
1093 1092
 					}
1094 1093
 
1095 1094
 					return $sql;
1096 1095
 				} );
1097 1096
 
1098
-				$query->limit( $parameters['paging']['page_size'] )
1099
-					->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) );
1097
+				$query->limit( $parameters[ 'paging' ][ 'page_size' ] )
1098
+					->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) );
1100 1099
 
1101 1100
 				/**
1102 1101
 				 * Any joins?
@@ -1119,7 +1118,7 @@  discard block
 block discarded – undo
1119 1118
 
1120 1119
 							$query_parameters = $query->_introspect();
1121 1120
 
1122
-							$query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) );
1121
+							$query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) );
1123 1122
 						}
1124 1123
 
1125 1124
 						/**
@@ -1153,7 +1152,7 @@  discard block
 block discarded – undo
1153 1152
 						}
1154 1153
 
1155 1154
 						$q = $query->_introspect();
1156
-						$query->where( \GF_Query_Condition::_and( $q['where'], $condition ) );
1155
+						$query->where( \GF_Query_Condition::_and( $q[ 'where' ], $condition ) );
1157 1156
 
1158 1157
 						if ( $this->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) {
1159 1158
 
@@ -1178,7 +1177,7 @@  discard block
 block discarded – undo
1178 1177
 
1179 1178
 							$query_parameters = $query->_introspect();
1180 1179
 
1181
-							$query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) );
1180
+							$query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) );
1182 1181
 						}
1183 1182
 					}
1184 1183
 
@@ -1202,7 +1201,7 @@  discard block
 block discarded – undo
1202 1201
 							$conditions = array();
1203 1202
 
1204 1203
 							foreach ( $condition->expressions as $_condition ) {
1205
-								$conditions[] = $recurse( $_condition, $fields, $recurse );
1204
+								$conditions[ ] = $recurse( $_condition, $fields, $recurse );
1206 1205
 							}
1207 1206
 
1208 1207
 							return call_user_func_array(
@@ -1231,10 +1230,10 @@  discard block
 block discarded – undo
1231 1230
 						$q = new $query_class( $form_id );
1232 1231
 
1233 1232
 						// Copy the WHERE clauses but substitute the field_ids to the respective ones
1234
-						$q->where( $where_union_substitute( $query_parameters['where'], $fields, $where_union_substitute ) );
1233
+						$q->where( $where_union_substitute( $query_parameters[ 'where' ], $fields, $where_union_substitute ) );
1235 1234
 
1236 1235
 						// Copy the ORDER clause and substitute the field_ids to the respective ones
1237
-						foreach ( $query_parameters['order'] as $order ) {
1236
+						foreach ( $query_parameters[ 'order' ] as $order ) {
1238 1237
 							list( $column, $_order ) = $order;
1239 1238
 
1240 1239
 							if ( $column && $column instanceof \GF_Query_Column ) {
@@ -1248,15 +1247,15 @@  discard block
 block discarded – undo
1248 1247
 
1249 1248
 						add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( &$unions_sql ) {
1250 1249
 							// Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses
1251
-							$select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] );
1250
+							$select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] );
1252 1251
 
1253 1252
 							// Record the SQL
1254
-							$unions_sql[] = array(
1253
+							$unions_sql[ ] = array(
1255 1254
 								// Remove columns, we'll rebuild them
1256 1255
 								'select'  => preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $select ),
1257
-								'from'    => $sql['from'],
1258
-								'join'    => $sql['join'],
1259
-								'where'   => $sql['where'],
1256
+								'from'    => $sql[ 'from' ],
1257
+								'join'    => $sql[ 'join' ],
1258
+								'where'   => $sql[ 'where' ],
1260 1259
 								// Remove order and limit
1261 1260
 							);
1262 1261
 
@@ -1273,11 +1272,11 @@  discard block
 block discarded – undo
1273 1272
 
1274 1273
 					add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( $unions_sql ) {
1275 1274
 						// Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses
1276
-						$sql['select'] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] );
1275
+						$sql[ 'select' ] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] );
1277 1276
 
1278 1277
 						// Remove columns, we'll rebuild them
1279
-						preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql['select'], $select_match );
1280
-						$sql['select'] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql['select'] );
1278
+						preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql[ 'select' ], $select_match );
1279
+						$sql[ 'select' ] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql[ 'select' ] );
1281 1280
 
1282 1281
 						$unions = array();
1283 1282
 
@@ -1288,30 +1287,30 @@  discard block
 block discarded – undo
1288 1287
 						};
1289 1288
 
1290 1289
 						// Add all the order columns into the selects, so we can order by the whole union group
1291
-						preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql['order'], $order_matches );
1290
+						preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql[ 'order' ], $order_matches );
1292 1291
 
1293 1292
 						$columns = array(
1294
-							sprintf( '%s AS %s', $select_match[1], $column_to_alias( $select_match[1] ) )
1293
+							sprintf( '%s AS %s', $select_match[ 1 ], $column_to_alias( $select_match[ 1 ] ) )
1295 1294
 						);
1296 1295
 
1297 1296
 						foreach ( array_slice( $order_matches, 1 ) as $match ) {
1298
-							$columns[] = sprintf( '%s AS %s', $match[0], $column_to_alias( $match[0] ) );
1297
+							$columns[ ] = sprintf( '%s AS %s', $match[ 0 ], $column_to_alias( $match[ 0 ] ) );
1299 1298
 
1300 1299
 							// Rewrite the order columns to the shared aliases
1301
-							$sql['order'] = str_replace( $match[0], $column_to_alias( $match[0] ), $sql['order'] );
1300
+							$sql[ 'order' ] = str_replace( $match[ 0 ], $column_to_alias( $match[ 0 ] ), $sql[ 'order' ] );
1302 1301
 						}
1303 1302
 
1304 1303
 						$columns = array_unique( $columns );
1305 1304
 
1306 1305
 						// Add the columns to every UNION
1307 1306
 						foreach ( $unions_sql as $union_sql ) {
1308
-							$union_sql['select'] .= implode( ', ', $columns );
1309
-							$unions []= implode( ' ', $union_sql );
1307
+							$union_sql[ 'select' ] .= implode( ', ', $columns );
1308
+							$unions [ ] = implode( ' ', $union_sql );
1310 1309
 						}
1311 1310
 
1312 1311
 						// Add the columns to the main SELECT, but only grab the entry id column
1313
-						$sql['select'] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql['select'] . implode( ', ', $columns );
1314
-						$sql['order'] = implode( ' ', $unions ) . ') AS u ' . $sql['order'];
1312
+						$sql[ 'select' ] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql[ 'select' ] . implode( ', ', $columns );
1313
+						$sql[ 'order' ] = implode( ' ', $unions ) . ') AS u ' . $sql[ 'order' ];
1315 1314
 
1316 1315
 						return $sql;
1317 1316
 					} );
@@ -1356,20 +1355,20 @@  discard block
 block discarded – undo
1356 1355
 				} );
1357 1356
 			} else {
1358 1357
 				$entries = $this->form->entries
1359
-					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) )
1358
+					->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) )
1360 1359
 					->offset( $this->settings->get( 'offset' ) )
1361
-					->limit( $parameters['paging']['page_size'] )
1360
+					->limit( $parameters[ 'paging' ][ 'page_size' ] )
1362 1361
 					->page( $page );
1363 1362
 
1364
-				if ( ! empty( $parameters['sorting'] ) && is_array( $parameters['sorting'] && ! isset( $parameters['sorting']['key'] ) ) ) {
1363
+				if ( ! empty( $parameters[ 'sorting' ] ) && is_array( $parameters[ 'sorting' ] && ! isset( $parameters[ 'sorting' ][ 'key' ] ) ) ) {
1365 1364
 					// Pluck off multisort arrays
1366
-					$parameters['sorting'] = $parameters['sorting'][0];
1365
+					$parameters[ 'sorting' ] = $parameters[ 'sorting' ][ 0 ];
1367 1366
 				}
1368 1367
 
1369
-				if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) {
1368
+				if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) {
1370 1369
 					$field = new \GV\Field();
1371
-					$field->ID = $parameters['sorting']['key'];
1372
-					$direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
1370
+					$field->ID = $parameters[ 'sorting' ][ 'key' ];
1371
+					$direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC;
1373 1372
 					$entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) );
1374 1373
 				}
1375 1374
 			}
@@ -1454,7 +1453,7 @@  discard block
 block discarded – undo
1454 1453
 		$allowed = $headers = array();
1455 1454
 
1456 1455
 		foreach ( $view->fields->by_position( "directory_*" )->by_visible( $view )->all() as $id => $field ) {
1457
-			$allowed[] = $field;
1456
+			$allowed[ ] = $field;
1458 1457
 		}
1459 1458
 
1460 1459
 		$renderer = new Field_Renderer();
@@ -1476,17 +1475,17 @@  discard block
 block discarded – undo
1476 1475
 			} );
1477 1476
 
1478 1477
 			foreach ( array_diff( $allowed_field_ids, wp_list_pluck( $allowed, 'ID' ) ) as $field_id ) {
1479
-				$allowed[] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id );
1478
+				$allowed[ ] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id );
1480 1479
 			}
1481 1480
 
1482 1481
 			foreach ( $allowed as $field ) {
1483 1482
 				$source = is_numeric( $field->ID ) ? $view->form : new \GV\Internal_Source();
1484 1483
 
1485
-				$return[] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' );
1484
+				$return[ ] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' );
1486 1485
 
1487 1486
 				if ( ! $headers_done ) {
1488 1487
 					$label = $field->get_label( $view, $source, $entry );
1489
-					$headers[] = $label ? $label : $field->ID;
1488
+					$headers[ ] = $label ? $label : $field->ID;
1490 1489
 				}
1491 1490
 			}
1492 1491
 
Please login to merge, or discard this patch.
future/includes/class-gv-widget.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -163,14 +163,14 @@
 block discarded – undo
163 163
 		return $settings;
164 164
 	}
165 165
 
166
-    /**
166
+	/**
167 167
 	 * Get the Widget ID.
168 168
 	 *
169
-     * @return string The Widget ID.
170
-     */
171
-    public function get_widget_id() {
172
-        return $this->widget_id;
173
-    }
169
+	 * @return string The Widget ID.
170
+	 */
171
+	public function get_widget_id() {
172
+		return $this->widget_id;
173
+	}
174 174
 
175 175
 	/**
176 176
 	 * Get the widget settings
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -393,7 +393,7 @@
 block discarded – undo
393 393
 	 * @internal
394 394
 	 * @since 2.0
395 395
 	 *
396
-	 * @return \GV\Widget|null The widget implementation from configuration or none.
396
+	 * @return Widget The widget implementation from configuration or none.
397 397
 	 */
398 398
 	public static function from_configuration( $configuration ) {
399 399
 		$registered_widgets = self::registered();
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		$enable_custom_class = apply_filters( 'gravityview/widget/enable_custom_class', false, $this );
154 154
 
155 155
 		if ( $enable_custom_class ) {
156
-			$settings['custom_class'] = array(
156
+			$settings[ 'custom_class' ] = array(
157 157
 				'type'       => 'text',
158 158
 				'label'      => __( 'Custom CSS Class:', 'gravityview' ),
159 159
 				'desc'       => __( 'This class will be added to the widget container', 'gravityview' ),
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	public static function get_default_widget_areas() {
208 208
 		$default_areas = array(
209
-			array( '1-1' => array( array( 'areaid' => 'top', 'title' => __( 'Top', 'gravityview' ) , 'subtitle' => '' ) ) ),
210
-			array( '1-2' => array( array( 'areaid' => 'left', 'title' => __( 'Left', 'gravityview' ) , 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __( 'Right', 'gravityview' ) , 'subtitle' => '' ) ) ),
209
+			array( '1-1' => array( array( 'areaid' => 'top', 'title' => __( 'Top', 'gravityview' ), 'subtitle' => '' ) ) ),
210
+			array( '1-2' => array( array( 'areaid' => 'left', 'title' => __( 'Left', 'gravityview' ), 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __( 'Right', 'gravityview' ), 'subtitle' => '' ) ) ),
211 211
 		);
212 212
 
213 213
 		/**
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 		}
239 239
 
240 240
 		$widgets[ $this->get_widget_id() ] = array(
241
-			'label' => $this->widget_label ,
241
+			'label' => $this->widget_label,
242 242
 			'description' => $this->widget_description,
243 243
 			'subtitle' => $this->widget_subtitle,
244 244
 			'icon' => $this->icon,
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	 */
261 261
 	public function assign_widget_options( $options = array(), $template = '', $widget = '' ) {
262 262
 		if ( $this->get_widget_id() === $widget ) {
263
-			if( $settings = $this->get_settings() ) {
263
+			if ( $settings = $this->get_settings() ) {
264 264
 				$options = array_merge( $options, $settings );
265 265
 			}
266 266
 		}
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 			return;
315 315
 		}
316 316
 
317
-		add_shortcode( $this->shortcode_name, array( $this, 'render_shortcode') );
317
+		add_shortcode( $this->shortcode_name, array( $this, 'render_shortcode' ) );
318 318
 	}
319 319
 
320 320
 	/**
Please login to merge, or discard this patch.
future/includes/class-gv-template-entry-legacy.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
 		global $post;
35 35
 
36 36
 		if ( $post ) {
37
-			$context['post'] = $post;
37
+			$context[ 'post' ] = $post;
38 38
 		}
39 39
 
40 40
 		\GV\Mocks\Legacy_Context::push( $context );
Please login to merge, or discard this patch.
future/includes/class-gv-core.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -113,14 +113,14 @@
 block discarded – undo
113 113
 
114 114
 		/** Require critical legacy core files. @todo Deprecate */
115 115
 		require_once $this->plugin->dir( 'includes/helper-functions.php' );
116
-		require_once $this->plugin->dir( 'includes/class-common.php');
117
-		require_once $this->plugin->dir( 'includes/connector-functions.php');
116
+		require_once $this->plugin->dir( 'includes/class-common.php' );
117
+		require_once $this->plugin->dir( 'includes/connector-functions.php' );
118 118
 		require_once $this->plugin->dir( 'includes/class-gravityview-compatibility.php' );
119 119
 		require_once $this->plugin->dir( 'includes/class-gravityview-roles-capabilities.php' );
120 120
 		require_once $this->plugin->dir( 'includes/class-gravityview-admin-notices.php' );
121 121
 		require_once $this->plugin->dir( 'includes/class-admin.php' );
122
-		require_once $this->plugin->dir( 'includes/class-post-types.php');
123
-		require_once $this->plugin->dir( 'includes/class-cache.php');
122
+		require_once $this->plugin->dir( 'includes/class-post-types.php' );
123
+		require_once $this->plugin->dir( 'includes/class-cache.php' );
124 124
 
125 125
 		/**
126 126
 		 * GravityView extensions and widgets.
Please login to merge, or discard this patch.
future/includes/class-gv-collection-entry-sort.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
 		if ( $this->field ) {
79 79
 			return array(
80 80
 				'key' => $this->field->ID,
81
-				'direction' => $this->direction ? : self::ASC,
81
+				'direction' => $this->direction ?: self::ASC,
82 82
 				'is_numeric' => self::ALPHA ? true : false,
83 83
 			);
84 84
 		}
Please login to merge, or discard this patch.
future/includes/class-gv-wrappers.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,8 +50,8 @@
 block discarded – undo
50 50
 		/**
51 51
 		 * By array.
52 52
 		 */
53
-		if ( is_array( $view ) && ! empty( $view['id'] ) ) {
54
-			return $this->get( $view['id'] );
53
+		if ( is_array( $view ) && ! empty( $view[ 'id' ] ) ) {
54
+			return $this->get( $view[ 'id' ] );
55 55
 		}
56 56
 
57 57
 		/**
Please login to merge, or discard this patch.
future/includes/rest/class-gv-rest-core.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 		require_once gravityview()->plugin->dir( 'future/includes/rest/class-gv-rest-route.php' );
22 22
 		require_once gravityview()->plugin->dir( 'future/includes/rest/class-gv-rest-views-route.php' );
23 23
 
24
-		self::$routes['views'] = $views = new Views_Route();
24
+		self::$routes[ 'views' ] = $views = new Views_Route();
25 25
 		$views->register_routes();
26 26
 	}
27 27
 
Please login to merge, or discard this patch.
future/includes/class-gv-shortcode-gvfield.php 2 patches
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
 		 */
44 44
 		$atts = apply_filters( 'gravityview/shortcodes/gvfield/atts', $atts );
45 45
 
46
-		if ( ! $view = \GV\View::by_id( $atts['view_id'] ) ) {
47
-			gravityview()->log->error( 'View #{view_id} not found', array( 'view_id' => $atts['view_id'] ) );
46
+		if ( ! $view = \GV\View::by_id( $atts[ 'view_id' ] ) ) {
47
+			gravityview()->log->error( 'View #{view_id} not found', array( 'view_id' => $atts[ 'view_id' ] ) );
48 48
 			return apply_filters( 'gravityview/shortcodes/gvfield/output', '', $view, null, null, $atts );
49 49
 		}
50 50
 
51
-		switch( $atts['entry_id'] ):
51
+		switch ( $atts[ 'entry_id' ] ):
52 52
 			case 'last':
53 53
 				if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) {
54 54
 					/**
@@ -57,17 +57,17 @@  discard block
 block discarded – undo
57 57
 					 * Since we're using \GF_Query shorthand initialization we have to reverse the order parameters here.
58 58
 					 */
59 59
 					add_filter( 'gravityview_get_entries', $filter = function( $parameters, $args, $form_id ) {
60
-						if ( ! empty( $parameters['sorting'] ) ) {
60
+						if ( ! empty( $parameters[ 'sorting' ] ) ) {
61 61
 							/**
62 62
 							 * Reverse existing sorts.
63 63
 							 */
64
-							$sort = &$parameters['sorting'];
65
-							$sort['direction'] = $sort['direction'] == 'RAND' ? : ( $sort['direction'] == 'ASC' ? 'DESC' : 'ASC' );
64
+							$sort = &$parameters[ 'sorting' ];
65
+							$sort[ 'direction' ] = $sort[ 'direction' ] == 'RAND' ?: ( $sort[ 'direction' ] == 'ASC' ? 'DESC' : 'ASC' );
66 66
 						} else {
67 67
 							/**
68 68
 							 * Otherwise, sort by date_created.
69 69
 							 */
70
-							$parameters['sorting'] = array(
70
+							$parameters[ 'sorting' ] = array(
71 71
 								'key' => 'id',
72 72
 								'direction' => 'ASC',
73 73
 								'is_numeric' => true
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
 					/** If a sort already exists, reverse it. */
84 84
 					if ( $sort = end( $entries->sorts ) ) {
85
-						$entries = $entries->sort( new \GV\Entry_Sort( $sort->field, $sort->direction == \GV\Entry_Sort::RAND ? : ( $sort->direction == \GV\Entry_Sort::ASC ? \GV\Entry_Sort::DESC : \GV\Entry_Sort::ASC ) ), $sort->mode );
85
+						$entries = $entries->sort( new \GV\Entry_Sort( $sort->field, $sort->direction == \GV\Entry_Sort::RAND ?: ( $sort->direction == \GV\Entry_Sort::ASC ? \GV\Entry_Sort::DESC : \GV\Entry_Sort::ASC ) ), $sort->mode );
86 86
 					} else {
87 87
 						/** Otherwise, sort by date_created */
88 88
 						$entries = $entries->sort( new \GV\Entry_Sort( \GV\Internal_Field::by_id( 'id' ), \GV\Entry_Sort::ASC ), \GV\Entry_Sort::NUMERIC );
@@ -99,20 +99,20 @@  discard block
 block discarded – undo
99 99
 				}
100 100
 				break;
101 101
 			default:
102
-				if ( ! $entry = \GV\GF_Entry::by_id( $atts['entry_id'] ) ) {
103
-					gravityview()->log->error( 'Entry #{entry_id} not found', array( 'view_id' => $atts['view_id'] ) );
102
+				if ( ! $entry = \GV\GF_Entry::by_id( $atts[ 'entry_id' ] ) ) {
103
+					gravityview()->log->error( 'Entry #{entry_id} not found', array( 'view_id' => $atts[ 'view_id' ] ) );
104 104
 					return apply_filters( 'gravityview/shortcodes/gvfield/output', '', $view, $entry, null, $atts );
105 105
 				}
106 106
 		endswitch;
107 107
 
108
-		$field = is_numeric( $atts['field_id'] ) ? \GV\GF_Field::by_id( $view->form, $atts['field_id'] ) : \GV\Internal_Field::by_id( $atts['field_id'] );
108
+		$field = is_numeric( $atts[ 'field_id' ] ) ? \GV\GF_Field::by_id( $view->form, $atts[ 'field_id' ] ) : \GV\Internal_Field::by_id( $atts[ 'field_id' ] );
109 109
 
110 110
 		if ( ! $field ) {
111
-			gravityview()->log->error( 'Field #{field_id} not found', array( 'view_id' => $atts['field_id'] ) );
111
+			gravityview()->log->error( 'Field #{field_id} not found', array( 'view_id' => $atts[ 'field_id' ] ) );
112 112
 			return apply_filters( 'gravityview/shortcodes/gvfield/output', '', $view, $entry, $field, $atts );
113 113
 		}
114 114
 
115
-		if ( $view->form->ID != $entry['form_id'] ) {
115
+		if ( $view->form->ID != $entry[ 'form_id' ] ) {
116 116
 			gravityview()->log->error( 'Entry does not belong to view (form mismatch)' );
117 117
 			return apply_filters( 'gravityview/shortcodes/gvfield/output', '', $view, $entry, $atts );
118 118
 		}
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 			return apply_filters( 'gravityview/shortcodes/gvfield/output', get_the_password_form( $view->ID ), $view, $entry, $atts );
123 123
 		}
124 124
 
125
-		if ( ! $view->form  ) {
125
+		if ( ! $view->form ) {
126 126
 			gravityview()->log->notice( 'View #{id} has no form attached to it.', array( 'id' => $view->ID ) );
127 127
 
128 128
 			/**
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
 		}
146 146
 
147 147
 		/** Unapproved entries. */
148
-		if ( $entry['status'] != 'active' ) {
148
+		if ( $entry[ 'status' ] != 'active' ) {
149 149
 			gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
150 150
 			return apply_filters( 'gravityview/shortcodes/gvfield/output', '', $view, $entry, $atts );
151 151
 		}
152 152
 
153 153
 		if ( $view->settings->get( 'show_only_approved' ) ) {
154
-			if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
154
+			if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
155 155
 				gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
156 156
 				return apply_filters( 'gravityview/shortcodes/gvfield/output', '', $view, $entry, $atts );
157 157
 			}
Please login to merge, or discard this patch.
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,6 @@
 block discarded – undo
18 18
 	/**
19 19
 	 * Process and output the [gvfield] shortcode.
20 20
 	 *
21
-	 * @param array $passed_atts The attributes passed.
22 21
 	 * @param string $content The content inside the shortcode.
23 22
 	 * @param string $tag The shortcode tag.
24 23
 	 *
Please login to merge, or discard this patch.
future/includes/class-gv-template-view.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -108,13 +108,13 @@
 block discarded – undo
108 108
 		global $post;
109 109
 
110 110
 		if ( ! $this->request->is_view() && $post ) {
111
-			$specifics []= sprintf( '%spost-%d-view-%d-%s.php', $slug_dir, $post->ID, $this->view->ID, $slug_name );
112
-			$specifics []= sprintf( '%spost-%d-%s.php', $slug_dir, $post->ID, $slug_name );
111
+			$specifics [ ] = sprintf( '%spost-%d-view-%d-%s.php', $slug_dir, $post->ID, $this->view->ID, $slug_name );
112
+			$specifics [ ] = sprintf( '%spost-%d-%s.php', $slug_dir, $post->ID, $slug_name );
113 113
 		}
114 114
 
115 115
 		
116
-		$specifics []= sprintf( '%sview-%d-%s.php', $slug_dir, $this->view->ID, $slug_name );
117
-		$specifics []= sprintf( '%sform-%d-%s.php', $slug_dir, $this->view->form->ID, $slug_name );
116
+		$specifics [ ] = sprintf( '%sview-%d-%s.php', $slug_dir, $this->view->ID, $slug_name );
117
+		$specifics [ ] = sprintf( '%sform-%d-%s.php', $slug_dir, $this->view->form->ID, $slug_name );
118 118
 
119 119
 		return array_merge( $specifics, $templates );
120 120
 	}
Please login to merge, or discard this patch.