Completed
Push — develop ( b948c4...a1d7eb )
by Zack
19:39
created
future/includes/class-gv-view.php 1 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.
includes/presets/register-default-templates.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 		'GravityView_DataTables_Template' => array(
60 60
 			'slug' => 'dt_placeholder',
61 61
 			'label' =>  __( 'DataTables Table', 'gv-datatables', 'gravityview' ),
62
-			'description' => __('Display items in a dynamic table powered by DataTables.', 'gravityview'),
63
-			'logo' => plugins_url('assets/images/templates/logo-datatables.png', GRAVITYVIEW_FILE ),
62
+			'description' => __( 'Display items in a dynamic table powered by DataTables.', 'gravityview' ),
63
+			'logo' => plugins_url( 'assets/images/templates/logo-datatables.png', GRAVITYVIEW_FILE ),
64 64
 			'buy_source' => 'https://gravityview.co/pricing/?utm_source=plugin&utm_medium=buy_now&utm_campaign=view_type&utm_term=datatables',
65 65
 			'preview' => 'https://try.gravityview.co/view/datatables/?utm_source=plugin&utm_medium=try_demo&utm_campaign=view_type&utm_term=datatables',
66 66
 			'license' => esc_html__( 'All Access', 'gravityview' ),
@@ -99,10 +99,10 @@  discard block
 block discarded – undo
99 99
 				continue;
100 100
 			}
101 101
 
102
-			$placeholder['type']     = 'custom';
103
-			$placeholder['included'] = ( (int) $license['price_id'] >= $placeholder['price_id'] );
102
+			$placeholder[ 'type' ]     = 'custom';
103
+			$placeholder[ 'included' ] = ( (int)$license[ 'price_id' ] >= $placeholder[ 'price_id' ] );
104 104
 
105
-			new GravityView_Placeholder_Template( $placeholder['slug'], $placeholder );
105
+			new GravityView_Placeholder_Template( $placeholder[ 'slug' ], $placeholder );
106 106
 		}
107 107
 
108 108
 	} catch ( Exception $exception ) {
Please login to merge, or discard this patch.
includes/class-admin-installer.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function register_noconflict( $items ) {
55 55
 
56
-		$items[] = 'gravityview-admin-installer';
56
+		$items[ ] = 'gravityview-admin-installer';
57 57
 
58 58
 		return $items;
59 59
 	}
@@ -68,21 +68,21 @@  discard block
 block discarded – undo
68 68
 
69 69
 	    $downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT );
70 70
 
71
-	    if ( ! $downloads_data && ! isset( $_GET['cache'] ) ) {
71
+	    if ( ! $downloads_data && ! isset( $_GET[ 'cache' ] ) ) {
72 72
 			return;
73 73
 		}
74 74
 
75
-		add_filter( 'plugins_api', function ( $data, $action, $args ) use ( $downloads_data ) {
75
+		add_filter( 'plugins_api', function( $data, $action, $args ) use ( $downloads_data ) {
76 76
 			foreach ( $downloads_data as $extension ) {
77
-				if ( empty( $extension['info'] ) || empty( $args->slug ) || $args->slug !== $extension['info']['slug'] ) {
77
+				if ( empty( $extension[ 'info' ] ) || empty( $args->slug ) || $args->slug !== $extension[ 'info' ][ 'slug' ] ) {
78 78
 					continue;
79 79
 				}
80 80
 
81
-				return (object) array(
82
-					'slug'          => $extension['info']['slug'],
83
-					'name'          => $extension['info']['title'],
84
-					'version'       => $extension['licensing']['version'],
85
-					'download_link' => $extension['files'][0]['file'],
81
+				return (object)array(
82
+					'slug'          => $extension[ 'info' ][ 'slug' ],
83
+					'name'          => $extension[ 'info' ][ 'title' ],
84
+					'version'       => $extension[ 'licensing' ][ 'version' ],
85
+					'download_link' => $extension[ 'files' ][ 0 ][ 'file' ],
86 86
 				);
87 87
 			}
88 88
 
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 
145 145
 		foreach ( $all_plugins as $path => $plugin ) {
146 146
 
147
-			if ( empty( $plugin['TextDomain'] ) ) {
147
+			if ( empty( $plugin[ 'TextDomain' ] ) ) {
148 148
 				continue;
149 149
 			}
150 150
 
151
-			$wp_plugins[ $plugin['TextDomain'] ] = array(
151
+			$wp_plugins[ $plugin[ 'TextDomain' ] ] = array(
152 152
 				'path'      => $path,
153
-				'version'   => $plugin['Version'],
153
+				'version'   => $plugin[ 'Version' ],
154 154
 				'activated' => is_plugin_active( $path )
155 155
 			);
156 156
 		}
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
 
205 205
 		$downloads_data = get_site_transient( self::DOWNLOADS_DATA_TRANSIENT );
206 206
 
207
-		if ( $downloads_data && ! isset( $_GET['cache'] ) ) {
207
+		if ( $downloads_data && ! isset( $_GET[ 'cache' ] ) ) {
208 208
 			return $downloads_data;
209 209
 		}
210 210
 
211
-		if( \GV\Plugin::is_network_activated() ) {
211
+		if ( \GV\Plugin::is_network_activated() ) {
212 212
 			$home_url = network_home_url();
213 213
 		} else {
214 214
 			$home_url = home_url();
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
 
237 237
 		$downloads_data = json_decode( wp_remote_retrieve_body( $response ), true );
238 238
 
239
-		if ( empty( $downloads_data['products'] ) ) {
239
+		if ( empty( $downloads_data[ 'products' ] ) ) {
240 240
 			return array();
241 241
 		}
242 242
 
243
-		$this->set_downloads_data( $downloads_data['products'] );
243
+		$this->set_downloads_data( $downloads_data[ 'products' ] );
244 244
 
245
-		return $downloads_data['products'];
245
+		return $downloads_data[ 'products' ];
246 246
 	}
247 247
 
248 248
 	/**
@@ -317,9 +317,9 @@  discard block
 block discarded – undo
317 317
 
318 318
 				$this->render_section( 'extensions', esc_html__( 'GravityView Extensions', 'gravityview' ), $downloads_data, $wp_plugins );
319 319
 
320
-				$this->render_section(  'plugins', esc_html__( 'Gravity Forms Add-Ons', 'gravityview' ), $downloads_data, $wp_plugins );
320
+				$this->render_section( 'plugins', esc_html__( 'Gravity Forms Add-Ons', 'gravityview' ), $downloads_data, $wp_plugins );
321 321
 
322
-				$this->render_section(  'friends', esc_html__( 'Friends of GravityView', 'gravityview' ), $downloads_data, $wp_plugins );
322
+				$this->render_section( 'friends', esc_html__( 'Friends of GravityView', 'gravityview' ), $downloads_data, $wp_plugins );
323 323
 				?>
324 324
             </div>
325 325
         </div>
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 				continue;
337 337
 			}
338 338
 
339
-			if ( empty( $download['info'] ) ) {
339
+			if ( empty( $download[ 'info' ] ) ) {
340 340
 				continue;
341 341
 			}
342 342
 
@@ -364,29 +364,29 @@  discard block
 block discarded – undo
364 364
 
365 365
         $details = $this->get_download_display_details( $download, $wp_plugins );
366 366
 
367
-        $download_info = $details['download_info'];
367
+        $download_info = $details[ 'download_info' ];
368 368
 
369 369
 		?>
370
-        <div class="item <?php echo esc_attr( $details['item_class'] ); ?>">
370
+        <div class="item <?php echo esc_attr( $details[ 'item_class' ] ); ?>">
371 371
             <div class="addon-inner">
372
-                <a href="<?php echo esc_url( $download_info['link'] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info['thumbnail'] ); ?>" alt="" /></a>
373
-                <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info['title'] ) ); ?></h3>
372
+                <a href="<?php echo esc_url( $download_info[ 'link' ] ); ?>" rel="external noreferrer noopener" title="<?php esc_html_e( 'Visit the plugin page', 'gravityview' ); ?>"><img class="thumbnail" src="<?php echo esc_attr( $download_info[ 'thumbnail' ] ); ?>" alt="" /></a>
373
+                <h3><?php echo esc_html( \GV\Utils::get( $download_info, 'installer_title', $download_info[ 'title' ] ) ); ?></h3>
374 374
                 <div>
375
-                    <?php if( ! empty( $details['status_label'] ) ) { ?>
376
-                    <div class="status <?php echo esc_attr( $details['status'] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details['status_label'] ) ); ?>">
377
-                        <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details['status_label'] ); ?></span>
375
+                    <?php if ( ! empty( $details[ 'status_label' ] ) ) { ?>
376
+                    <div class="status <?php echo esc_attr( $details[ 'status' ] ); ?>" title="<?php printf( esc_attr__( 'Plugin status: %s', 'gravityview' ), esc_html( $details[ 'status_label' ] ) ); ?>">
377
+                        <span class="dashicons dashicons-admin-plugins"></span> <span class="status-label"><?php echo esc_html( $details[ 'status_label' ] ); ?></span>
378 378
                     </div>
379 379
 			        <?php } ?>
380 380
 
381
-                    <a data-status="<?php echo esc_attr( $details['status'] ); ?>" data-plugin-path="<?php echo esc_attr( $details['plugin_path'] ); ?>" href="<?php echo esc_url( $details['href'] ); ?>" class="button <?php echo esc_attr( $details['button_class'] ); ?>" title="<?php echo esc_attr( $details['button_title'] ); ?>">
382
-                        <span class="title"><?php echo esc_html( $details['button_label'] ); ?></span>
383
-                        <?php if( $details['spinner'] ) { ?><span class="spinner"></span><?php } ?>
381
+                    <a data-status="<?php echo esc_attr( $details[ 'status' ] ); ?>" data-plugin-path="<?php echo esc_attr( $details[ 'plugin_path' ] ); ?>" href="<?php echo esc_url( $details[ 'href' ] ); ?>" class="button <?php echo esc_attr( $details[ 'button_class' ] ); ?>" title="<?php echo esc_attr( $details[ 'button_title' ] ); ?>">
382
+                        <span class="title"><?php echo esc_html( $details[ 'button_label' ] ); ?></span>
383
+                        <?php if ( $details[ 'spinner' ] ) { ?><span class="spinner"></span><?php } ?>
384 384
                     </a>
385 385
                 </div>
386 386
 
387 387
                 <div class="addon-excerpt"><?php
388 388
 
389
-                    $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info['excerpt'] );
389
+                    $excerpt = \GV\Utils::get( $download_info, 'installer_excerpt', $download_info[ 'excerpt' ] );
390 390
 
391 391
                     // Allow some pure HTML tags, but remove everything else from the excerpt.
392 392
                     $tags = array( '<strong>', '</strong>', '<em>', '</em>', '<code>', '</code>' );
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 	 */
427 427
 	private function get_download_display_details( $download, $wp_plugins ) {
428 428
 
429
-		$download_info = wp_parse_args( (array) $download['info'], array(
429
+		$download_info = wp_parse_args( (array)$download[ 'info' ], array(
430 430
 			'thumbnail' => '',
431 431
 			'title' => '',
432 432
 			'textdomain' => '',
@@ -438,9 +438,9 @@  discard block
 block discarded – undo
438 438
 			'installer_excerpt' => null, // May not be defined
439 439
 		) );
440 440
 
441
-		$wp_plugin = \GV\Utils::get( $wp_plugins, $download_info['textdomain'], false );
441
+		$wp_plugin = \GV\Utils::get( $wp_plugins, $download_info[ 'textdomain' ], false );
442 442
 
443
-		$has_access = ! empty( $download['files'] );
443
+		$has_access = ! empty( $download[ 'files' ] );
444 444
 		$spinner = true;
445 445
 		$href = $plugin_path = '#';
446 446
 		$status = $item_class = $button_title = $button_class = '';
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 		$required_license = $galactic_only ? __( 'All Access', 'gravityview' ) : __( 'Core + Extensions', 'gravityview' );
451 451
 
452 452
 		// The license is not active - no matter what level, this should not work
453
-		if( ! $is_active  && empty( $base_price ) ) {
453
+		if ( ! $is_active && empty( $base_price ) ) {
454 454
 			$spinner      = false;
455 455
 			$status_label = '';
456 456
 			$button_class = 'disabled disabled-license';
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 			$status_label = '';
464 464
 			$button_label = sprintf( __( 'Purchase Now for %s', 'gravityview' ), '$' . $base_price );
465 465
 			$button_class = 'button-primary button-large';
466
-			$href         = $download_info['link'];
466
+			$href         = $download_info[ 'link' ];
467 467
 			$item_class   = 'featured';
468 468
 		}
469 469
 
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 			$href         = 'https://gravityview.co/pricing/?utm_source=admin-installer&utm_medium=admin&utm_campaign=Admin%20Notice&utm_content=' . $required_license;
477 477
 		}
478 478
 
479
-        elseif ( ! empty( $download_info['coming_soon'] ) ) {
479
+        elseif ( ! empty( $download_info[ 'coming_soon' ] ) ) {
480 480
 	        $spinner      = false;
481 481
 	        $status       = 'notinstalled';
482 482
 	        $status_label = __( 'Coming Soon', 'gravityview' );
@@ -491,8 +491,8 @@  discard block
 block discarded – undo
491 491
 			$href = add_query_arg(
492 492
 				array(
493 493
 					'action'   => 'install-plugin',
494
-					'plugin'   => $download_info['slug'],
495
-					'_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info['slug'] ),
494
+					'plugin'   => $download_info[ 'slug' ],
495
+					'_wpnonce' => wp_create_nonce( 'install-plugin_' . $download_info[ 'slug' ] ),
496 496
 				),
497 497
 				self_admin_url( 'update.php' )
498 498
 			);
@@ -504,25 +504,25 @@  discard block
 block discarded – undo
504 504
 		}
505 505
 
506 506
 		// Access and the plugin is installed but not active
507
-		elseif ( false === $wp_plugin['activated'] ) {
507
+		elseif ( false === $wp_plugin[ 'activated' ] ) {
508 508
 			$status = 'inactive';
509 509
 			$status_label = __( 'Inactive', 'gravityview' );
510 510
 			$button_label = __( 'Activate', 'gravityview' );
511
-			$plugin_path = $wp_plugin['path'];
511
+			$plugin_path = $wp_plugin[ 'path' ];
512 512
 
513 513
 		}
514 514
 
515 515
 		// Access and the plugin is installed and active
516 516
 		else {
517 517
 
518
-			$plugin_path = $wp_plugin['path'];
518
+			$plugin_path = $wp_plugin[ 'path' ];
519 519
 			$status = 'active';
520 520
 			$status_label = __( 'Active', 'gravityview' );
521 521
 			$button_label = __( 'Deactivate', 'gravityview' );
522 522
 
523 523
 		}
524 524
 
525
-		return compact( 'download_info','plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' );
525
+		return compact( 'download_info', 'plugin_path', 'status', 'status_label', 'button_title', 'button_class', 'button_label', 'href', 'spinner', 'item_class', 'required_license', 'is_active' );
526 526
     }
527 527
 
528 528
 	/**
@@ -537,11 +537,11 @@  discard block
 block discarded – undo
537 537
 	    $base_price = \GV\Utils::get( $download, 'pricing/amount', 0 );
538 538
 		$base_price = \GFCommon::to_number( $base_price );
539 539
 
540
-		unset( $download['pricing']['amount'] );
540
+		unset( $download[ 'pricing' ][ 'amount' ] );
541 541
 
542 542
 		// Price options array, not single price
543
-		if ( ! $base_price && ! empty( $download['pricing'] ) ) {
544
-			$base_price = array_shift( $download['pricing'] );
543
+		if ( ! $base_price && ! empty( $download[ 'pricing' ] ) ) {
544
+			$base_price = array_shift( $download[ 'pricing' ] );
545 545
 		}
546 546
 
547 547
 		return floatval( $base_price );
@@ -555,13 +555,13 @@  discard block
 block discarded – undo
555 555
 	public function activate_download() {
556 556
 		$data = \GV\Utils::_POST( 'data', array() );
557 557
 
558
-		if ( empty( $data['path'] ) ) {
558
+		if ( empty( $data[ 'path' ] ) ) {
559 559
 			return;
560 560
 		}
561 561
 
562
-		$result = activate_plugin( $data['path'] );
562
+		$result = activate_plugin( $data[ 'path' ] );
563 563
 
564
-		if ( is_wp_error( $result ) || ! is_plugin_active( $data['path'] ) ) {
564
+		if ( is_wp_error( $result ) || ! is_plugin_active( $data[ 'path' ] ) ) {
565 565
 			wp_send_json_error( array(
566 566
                 'error' => sprintf( __( 'Plugin activation failed: %s', 'gravityview' ), $result->get_error_message() )
567 567
             ) );
@@ -578,13 +578,13 @@  discard block
 block discarded – undo
578 578
 	public function deactivate_download() {
579 579
 		$data = \GV\Utils::_POST( 'data', array() );
580 580
 
581
-		if ( empty( $data['path'] ) ) {
581
+		if ( empty( $data[ 'path' ] ) ) {
582 582
 			return;
583 583
 		}
584 584
 
585
-		deactivate_plugins( $data['path'] );
585
+		deactivate_plugins( $data[ 'path' ] );
586 586
 
587
-		if( is_plugin_active( $data['path'] ) ) {
587
+		if ( is_plugin_active( $data[ 'path' ] ) ) {
588 588
             wp_send_json_error( array(
589 589
                 'error' => sprintf( __( 'Plugin deactivation failed.', 'gravityview' ) )
590 590
             ) );
Please login to merge, or discard this patch.
includes/widgets/search-widget/class-search-widget.php 1 patch
Spacing   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 			'search_clear' => array(
55 55
 				'type'  => 'checkbox',
56 56
 				'label' => __( 'Show Clear button', 'gravityview' ),
57
-				'desc'  => __( 'When a search is performed, display a button that removes all search values.', 'gravityview'),
57
+				'desc'  => __( 'When a search is performed, display a button that removes all search values.', 'gravityview' ),
58 58
 				'value' => true,
59 59
 			),
60 60
 			'search_fields' => array(
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 				'type' => 'radio',
68 68
 				'full_width' => true,
69 69
 				'label' => esc_html__( 'Search Mode', 'gravityview' ),
70
-				'desc' => __('Should search results match all search fields, or any?', 'gravityview'),
70
+				'desc' => __( 'Should search results match all search fields, or any?', 'gravityview' ),
71 71
 				'value' => 'any',
72 72
 				'class' => 'hide-if-js',
73 73
 				'options' => array(
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 
87 87
 			// admin - add scripts - run at 1100 to make sure GravityView_Admin_Views::add_scripts_and_styles() runs first at 999
88 88
 			add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 1100 );
89
-			add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts') );
89
+			add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) );
90 90
 			add_filter( 'gravityview_noconflict_scripts', array( $this, 'register_no_conflict' ) );
91 91
 
92 92
 			// ajax - get the searchable fields
@@ -122,19 +122,19 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	public function add_reserved_args( $args ) {
124 124
 
125
-		$args[] = 'gv_search';
126
-		$args[] = 'gv_start';
127
-		$args[] = 'gv_end';
128
-		$args[] = 'gv_id';
129
-		$args[] = 'gv_by';
130
-		$args[] = 'mode';
125
+		$args[ ] = 'gv_search';
126
+		$args[ ] = 'gv_start';
127
+		$args[ ] = 'gv_end';
128
+		$args[ ] = 'gv_id';
129
+		$args[ ] = 'gv_by';
130
+		$args[ ] = 'mode';
131 131
 
132
-		$get = (array) $_GET;
132
+		$get = (array)$_GET;
133 133
 
134 134
 		// If the fields being searched as reserved; not to be considered user-passed variables
135 135
 		foreach ( $get as $key => $value ) {
136 136
 			if ( $key !== $this->convert_request_key_to_filter_key( $key ) ) {
137
-				$args[] = $key;
137
+				$args[ ] = $key;
138 138
 			}
139 139
 		}
140 140
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 		$script_min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
259 259
 		$script_source = empty( $script_min ) ? '/source' : '';
260 260
 
261
-		wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js'.$script_source.'/admin-search-widget'.$script_min.'.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version );
261
+		wp_enqueue_script( 'gravityview_searchwidget_admin', plugins_url( 'assets/js' . $script_source . '/admin-search-widget' . $script_min . '.js', __FILE__ ), array( 'jquery', 'gravityview_views_scripts' ), \GV\Plugin::$version );
262 262
 
263 263
 		wp_localize_script( 'gravityview_searchwidget_admin', 'gvSearchVar', array(
264 264
 			'nonce' => wp_create_nonce( 'gravityview_ajaxsearchwidget' ),
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 * @return array Scripts allowed in no-conflict mode, plus the search widget script
281 281
 	 */
282 282
 	public function register_no_conflict( $allowed ) {
283
-		$allowed[] = 'gravityview_searchwidget_admin';
283
+		$allowed[ ] = 'gravityview_searchwidget_admin';
284 284
 		return $allowed;
285 285
 	}
286 286
 
@@ -292,24 +292,24 @@  discard block
 block discarded – undo
292 292
 	 */
293 293
 	public static function get_searchable_fields() {
294 294
 
295
-		if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxsearchwidget' ) ) {
295
+		if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxsearchwidget' ) ) {
296 296
 			exit( '0' );
297 297
 		}
298 298
 
299 299
 		$form = '';
300 300
 
301 301
 		// Fetch the form for the current View
302
-		if ( ! empty( $_POST['view_id'] ) ) {
302
+		if ( ! empty( $_POST[ 'view_id' ] ) ) {
303 303
 
304
-			$form = gravityview_get_form_id( $_POST['view_id'] );
304
+			$form = gravityview_get_form_id( $_POST[ 'view_id' ] );
305 305
 
306
-		} elseif ( ! empty( $_POST['formid'] ) ) {
306
+		} elseif ( ! empty( $_POST[ 'formid' ] ) ) {
307 307
 
308
-			$form = (int) $_POST['formid'];
308
+			$form = (int)$_POST[ 'formid' ];
309 309
 
310
-		} elseif ( ! empty( $_POST['template_id'] ) && class_exists( 'GravityView_Ajax' ) ) {
310
+		} elseif ( ! empty( $_POST[ 'template_id' ] ) && class_exists( 'GravityView_Ajax' ) ) {
311 311
 
312
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
312
+			$form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] );
313 313
 
314 314
 		}
315 315
 
@@ -359,14 +359,14 @@  discard block
 block discarded – undo
359 359
 		);
360 360
 
361 361
 		if ( gravityview()->plugin->supports( \GV\Plugin::FEATURE_GFQUERY ) ) {
362
-			$custom_fields['is_approved'] = array(
362
+			$custom_fields[ 'is_approved' ] = array(
363 363
 				'text' => esc_html__( 'Approval Status', 'gravityview' ),
364 364
 				'type' => 'multi',
365 365
 			);
366 366
 		}
367 367
 
368
-		foreach( $custom_fields as $custom_field_key => $custom_field ) {
369
-			$output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field['type'], self::get_field_label( array('field' => $custom_field_key ) ), $custom_field['text'] );
368
+		foreach ( $custom_fields as $custom_field_key => $custom_field ) {
369
+			$output .= sprintf( '<option value="%s" %s data-inputtypes="%s" data-placeholder="%s">%s</option>', $custom_field_key, selected( $custom_field_key, $current, false ), $custom_field[ 'type' ], self::get_field_label( array( 'field' => $custom_field_key ) ), $custom_field[ 'text' ] );
370 370
 		}
371 371
 
372 372
 		// Get fields with sub-inputs and no parent
@@ -388,13 +388,13 @@  discard block
 block discarded – undo
388 388
 
389 389
 			foreach ( $fields as $id => $field ) {
390 390
 
391
-				if ( in_array( $field['type'], $blacklist_field_types ) ) {
391
+				if ( in_array( $field[ 'type' ], $blacklist_field_types ) ) {
392 392
 					continue;
393 393
 				}
394 394
 
395
-				$types = self::get_search_input_types( $id, $field['type'] );
395
+				$types = self::get_search_input_types( $id, $field[ 'type' ] );
396 396
 
397
-				$output .= '<option value="'. $id .'" '. selected( $id, $current, false ).'data-inputtypes="'. esc_attr( $types ) .'">'. esc_html( $field['label'] ) .'</option>';
397
+				$output .= '<option value="' . $id . '" ' . selected( $id, $current, false ) . 'data-inputtypes="' . esc_attr( $types ) . '">' . esc_html( $field[ 'label' ] ) . '</option>';
398 398
 			}
399 399
 		}
400 400
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 	public static function get_search_input_types( $field_id = '', $field_type = null ) {
418 418
 
419 419
 		// @todo - This needs to be improved - many fields have . including products and addresses
420
-		if ( false !== strpos( (string) $field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) {
420
+		if ( false !== strpos( (string)$field_id, '.' ) && in_array( $field_type, array( 'checkbox' ) ) || in_array( $field_id, array( 'is_fulfilled' ) ) ) {
421 421
 			$input_type = 'boolean'; // on/off checkbox
422 422
 		} elseif ( in_array( $field_type, array( 'checkbox', 'post_category', 'multiselect' ) ) ) {
423 423
 			$input_type = 'multi'; //multiselect
@@ -463,19 +463,19 @@  discard block
 block discarded – undo
463 463
 			$post_id = 0;
464 464
 
465 465
 			// We're in the WordPress Widget context, and an overriding post ID has been set.
466
-			if ( ! empty( $widget_args['post_id'] ) ) {
467
-				$post_id = absint( $widget_args['post_id'] );
466
+			if ( ! empty( $widget_args[ 'post_id' ] ) ) {
467
+				$post_id = absint( $widget_args[ 'post_id' ] );
468 468
 			}
469 469
 			// We're in the WordPress Widget context, and the base View ID should be used
470
-			else if ( ! empty( $widget_args['view_id'] ) ) {
471
-				$post_id = absint( $widget_args['view_id'] );
470
+			else if ( ! empty( $widget_args[ 'view_id' ] ) ) {
471
+				$post_id = absint( $widget_args[ 'view_id' ] );
472 472
 			}
473 473
 
474 474
 			$args = gravityview_get_permalink_query_args( $post_id );
475 475
 
476 476
 			// Add hidden fields to the search form
477 477
 			foreach ( $args as $key => $value ) {
478
-				$search_fields[] = array(
478
+				$search_fields[ ] = array(
479 479
 					'name'  => $key,
480 480
 					'input' => 'hidden',
481 481
 					'value' => $value,
@@ -514,28 +514,28 @@  discard block
 block discarded – undo
514 514
 		/**
515 515
 		 * Include the sidebar Widgets.
516 516
 		 */
517
-		$widgets = (array) get_option( 'widget_gravityview_search', array() );
517
+		$widgets = (array)get_option( 'widget_gravityview_search', array() );
518 518
 
519 519
 		foreach ( $widgets as $widget ) {
520
-			if ( ! empty( $widget['view_id'] ) && $widget['view_id'] == $view->ID ) {
521
-				if( $_fields = json_decode( $widget['search_fields'], true ) ) {
520
+			if ( ! empty( $widget[ 'view_id' ] ) && $widget[ 'view_id' ] == $view->ID ) {
521
+				if ( $_fields = json_decode( $widget[ 'search_fields' ], true ) ) {
522 522
 					foreach ( $_fields as $field ) {
523
-						if ( empty( $field['form_id'] ) ) {
524
-							$field['form_id'] = $view->form ? $view->form->ID : 0;
523
+						if ( empty( $field[ 'form_id' ] ) ) {
524
+							$field[ 'form_id' ] = $view->form ? $view->form->ID : 0;
525 525
 						}
526
-						$searchable_fields[] = $with_full_field ? $field : $field['field'];
526
+						$searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ];
527 527
 					}
528 528
 				}
529 529
 			}
530 530
 		}
531 531
 
532 532
 		foreach ( $view->widgets->by_id( $this->get_widget_id() )->all() as $widget ) {
533
-			if( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) {
533
+			if ( $_fields = json_decode( $widget->configuration->get( 'search_fields' ), true ) ) {
534 534
 				foreach ( $_fields as $field ) {
535
-					if ( empty( $field['form_id'] ) ) {
536
-						$field['form_id'] = $view->form ? $view->form->ID : 0;
535
+					if ( empty( $field[ 'form_id' ] ) ) {
536
+						$field[ 'form_id' ] = $view->form ? $view->form->ID : 0;
537 537
 					}
538
-					$searchable_fields[] = $with_full_field ? $field : $field['field'];
538
+					$searchable_fields[ ] = $with_full_field ? $field : $field[ 'field' ];
539 539
 				}
540 540
 			}
541 541
 		}
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 			return $search_criteria; // Return the original criteria, GF_Query modification kicks in later
574 574
 		}
575 575
 
576
-		if( 'post' === $this->search_method ) {
576
+		if ( 'post' === $this->search_method ) {
577 577
 			$get = $_POST;
578 578
 		} else {
579 579
 			$get = $_GET;
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 		$get = gv_map_deep( $get, 'rawurldecode' );
593 593
 
594 594
 		// Make sure array key is set up
595
-		$search_criteria['field_filters'] = \GV\Utils::get( $search_criteria, 'field_filters', array() );
595
+		$search_criteria[ 'field_filters' ] = \GV\Utils::get( $search_criteria, 'field_filters', array() );
596 596
 
597 597
 		$searchable_fields = $this->get_view_searchable_fields( $view );
598 598
 		$searchable_field_objects = $this->get_view_searchable_fields( $view, true );
@@ -612,9 +612,9 @@  discard block
 block discarded – undo
612 612
 		$trim_search_value = apply_filters( 'gravityview/search-trim-input', true );
613 613
 
614 614
 		// add free search
615
-		if ( isset( $get['gv_search'] ) && '' !== $get['gv_search'] && in_array( 'search_all', $searchable_fields ) ) {
615
+		if ( isset( $get[ 'gv_search' ] ) && '' !== $get[ 'gv_search' ] && in_array( 'search_all', $searchable_fields ) ) {
616 616
 
617
-			$search_all_value = $trim_search_value ? trim( $get['gv_search'] ) : $get['gv_search'];
617
+			$search_all_value = $trim_search_value ? trim( $get[ 'gv_search' ] ) : $get[ 'gv_search' ];
618 618
 
619 619
 			if ( $split_words ) {
620 620
 				// Search for a piece
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 			}
631 631
 
632 632
 			foreach ( $words as $word ) {
633
-				$search_criteria['field_filters'][] = array(
633
+				$search_criteria[ 'field_filters' ][ ] = array(
634 634
 					'key' => null, // The field ID to search
635 635
 					'value' => $word, // The value to search
636 636
 					'operator' => 'contains', // What to search in. Options: `is` or `contains`
@@ -643,14 +643,14 @@  discard block
 block discarded – undo
643 643
 			/**
644 644
 			 * Get and normalize the dates according to the input format.
645 645
 			 */
646
-			if ( $curr_start = ! empty( $get['gv_start'] ) ? $get['gv_start'] : '' ) {
647
-				if( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) {
646
+			if ( $curr_start = ! empty( $get[ 'gv_start' ] ) ? $get[ 'gv_start' ] : '' ) {
647
+				if ( $curr_start_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_start ) ) {
648 648
 					$curr_start = $curr_start_date->format( 'Y-m-d' );
649 649
 				}
650 650
 			}
651 651
 
652
-			if ( $curr_end = ! empty( $get['gv_start'] ) ? ( ! empty( $get['gv_end'] ) ? $get['gv_end'] : '' ) : '' ) {
653
-				if( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) {
652
+			if ( $curr_end = ! empty( $get[ 'gv_start' ] ) ? ( ! empty( $get[ 'gv_end' ] ) ? $get[ 'gv_end' ] : '' ) : '' ) {
653
+				if ( $curr_end_date = date_create_from_format( $this->get_datepicker_format( true ), $curr_end ) ) {
654 654
 					$curr_end = $curr_end_date->format( 'Y-m-d' );
655 655
 				}
656 656
 			}
@@ -686,22 +686,22 @@  discard block
 block discarded – undo
686 686
 			 */
687 687
 			if ( ! empty( $curr_start ) ) {
688 688
 				$curr_start = date( 'Y-m-d H:i:s', strtotime( $curr_start ) );
689
-				$search_criteria['start_date'] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
689
+				$search_criteria[ 'start_date' ] = $adjust_tz ? get_gmt_from_date( $curr_start ) : $curr_start;
690 690
 			}
691 691
 
692 692
 			if ( ! empty( $curr_end ) ) {
693 693
 				// Fast-forward 24 hour on the end time
694 694
 				$curr_end = date( 'Y-m-d H:i:s', strtotime( $curr_end ) + DAY_IN_SECONDS );
695
-				$search_criteria['end_date'] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
696
-				if ( strpos( $search_criteria['end_date'], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056
697
-					$search_criteria['end_date'] = date( 'Y-m-d H:i:s', strtotime( $search_criteria['end_date'] ) - 1 );
695
+				$search_criteria[ 'end_date' ] = $adjust_tz ? get_gmt_from_date( $curr_end ) : $curr_end;
696
+				if ( strpos( $search_criteria[ 'end_date' ], '00:00:00' ) ) { // See https://github.com/gravityview/GravityView/issues/1056
697
+					$search_criteria[ 'end_date' ] = date( 'Y-m-d H:i:s', strtotime( $search_criteria[ 'end_date' ] ) - 1 );
698 698
 				}
699 699
 			}
700 700
 		}
701 701
 
702 702
 		// search for a specific entry ID
703 703
 		if ( ! empty( $get[ 'gv_id' ] ) && in_array( 'entry_id', $searchable_fields ) ) {
704
-			$search_criteria['field_filters'][] = array(
704
+			$search_criteria[ 'field_filters' ][ ] = array(
705 705
 				'key' => 'id',
706 706
 				'value' => absint( $get[ 'gv_id' ] ),
707 707
 				'operator' => $this->get_operator( $get, 'gv_id', array( '=' ), '=' ),
@@ -710,15 +710,15 @@  discard block
 block discarded – undo
710 710
 
711 711
 		// search for a specific Created_by ID
712 712
 		if ( ! empty( $get[ 'gv_by' ] ) && in_array( 'created_by', $searchable_fields ) ) {
713
-			$search_criteria['field_filters'][] = array(
713
+			$search_criteria[ 'field_filters' ][ ] = array(
714 714
 				'key' => 'created_by',
715
-				'value' => $get['gv_by'],
715
+				'value' => $get[ 'gv_by' ],
716 716
 				'operator' => $this->get_operator( $get, 'gv_by', array( '=' ), '=' ),
717 717
 			);
718 718
 		}
719 719
 
720 720
 		// Get search mode passed in URL
721
-		$mode = isset( $get['mode'] ) && in_array( $get['mode'], array( 'any', 'all' ) ) ?  $get['mode'] : 'any';
721
+		$mode = isset( $get[ 'mode' ] ) && in_array( $get[ 'mode' ], array( 'any', 'all' ) ) ? $get[ 'mode' ] : 'any';
722 722
 
723 723
 		// get the other search filters
724 724
 		foreach ( $get as $key => $value ) {
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 				$value = is_array( $value ) ? array_map( 'trim', $value ) : trim( $value );
728 728
 			}
729 729
 
730
-			if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[0], false, false ) ) ) {
730
+			if ( 0 !== strpos( $key, 'filter_' ) || gv_empty( $value, false, false ) || ( is_array( $value ) && count( $value ) === 1 && gv_empty( $value[ 0 ], false, false ) ) ) {
731 731
 				continue; // Not a filter, or empty
732 732
 			}
733 733
 
@@ -741,21 +741,21 @@  discard block
 block discarded – undo
741 741
 				continue;
742 742
 			}
743 743
 
744
-			if ( ! isset( $filter['operator'] ) ) {
745
-				$filter['operator'] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' );
744
+			if ( ! isset( $filter[ 'operator' ] ) ) {
745
+				$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'contains' ), 'contains' );
746 746
 			}
747 747
 
748
-			if ( isset( $filter[0]['value'] ) ) {
749
-				$filter[0]['value'] = $trim_search_value ? trim( $filter[0]['value'] ) : $filter[0]['value'];
748
+			if ( isset( $filter[ 0 ][ 'value' ] ) ) {
749
+				$filter[ 0 ][ 'value' ] = $trim_search_value ? trim( $filter[ 0 ][ 'value' ] ) : $filter[ 0 ][ 'value' ];
750 750
 
751
-				$search_criteria['field_filters'] = array_merge( $search_criteria['field_filters'], $filter );
751
+				$search_criteria[ 'field_filters' ] = array_merge( $search_criteria[ 'field_filters' ], $filter );
752 752
 
753 753
 				// if date range type, set search mode to ALL
754
-				if ( ! empty( $filter[0]['operator'] ) && in_array( $filter[0]['operator'], array( '>=', '<=', '>', '<' ) ) ) {
754
+				if ( ! empty( $filter[ 0 ][ 'operator' ] ) && in_array( $filter[ 0 ][ 'operator' ], array( '>=', '<=', '>', '<' ) ) ) {
755 755
 					$mode = 'all';
756 756
 				}
757
-			} elseif( !empty( $filter ) ) {
758
-				$search_criteria['field_filters'][] = $filter;
757
+			} elseif ( ! empty( $filter ) ) {
758
+				$search_criteria[ 'field_filters' ][ ] = $filter;
759 759
 			}
760 760
 		}
761 761
 
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 		 * @since 1.5.1
765 765
 		 * @param[out,in] string $mode Search mode (`any` vs `all`)
766 766
 		 */
767
-		$search_criteria['field_filters']['mode'] = apply_filters( 'gravityview/search/mode', $mode );
767
+		$search_criteria[ 'field_filters' ][ 'mode' ] = apply_filters( 'gravityview/search/mode', $mode );
768 768
 
769 769
 		gravityview()->log->debug( 'Returned Search Criteria: ', array( 'data' => $search_criteria ) );
770 770
 
@@ -798,19 +798,19 @@  discard block
 block discarded – undo
798 798
 
799 799
 		$query_class = $view->get_query_class();
800 800
 
801
-		if ( empty( $search_criteria['field_filters'] ) ) {
801
+		if ( empty( $search_criteria[ 'field_filters' ] ) ) {
802 802
 			return;
803 803
 		}
804 804
 
805 805
 		$widgets = $view->widgets->by_id( $this->widget_id );
806 806
 		if ( $widgets->count() ) {
807 807
 			$widgets = $widgets->all();
808
-			$widget  = $widgets[0];
808
+			$widget  = $widgets[ 0 ];
809 809
 
810 810
 			$search_fields = json_decode( $widget->configuration->get( 'search_fields' ), true );
811 811
 
812
-			foreach ( (array) $search_fields as $search_field ) {
813
-				if ( 'created_by' === $search_field['field'] && 'input_text' === $search_field['input'] ) {
812
+			foreach ( (array)$search_fields as $search_field ) {
813
+				if ( 'created_by' === $search_field[ 'field' ] && 'input_text' === $search_field[ 'input' ] ) {
814 814
 					$created_by_text_mode = true;
815 815
 				}
816 816
 			}
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 		$extra_conditions = array();
820 820
 		$mode = 'any';
821 821
 
822
-		foreach ( $search_criteria['field_filters'] as &$filter ) {
822
+		foreach ( $search_criteria[ 'field_filters' ] as &$filter ) {
823 823
 			if ( ! is_array( $filter ) ) {
824 824
 				if ( in_array( strtolower( $filter ), array( 'any', 'all' ) ) ) {
825 825
 					$mode = $filter;
@@ -828,13 +828,13 @@  discard block
 block discarded – undo
828 828
 			}
829 829
 
830 830
 			// Construct a manual query for unapproved statuses
831
-			if ( 'is_approved' === $filter['key'] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array) $filter['value'] ) ) {
832
-				$_tmp_query       = new $query_class( $view->form->ID, array(
831
+			if ( 'is_approved' === $filter[ 'key' ] && in_array( \GravityView_Entry_Approval_Status::UNAPPROVED, (array)$filter[ 'value' ] ) ) {
832
+				$_tmp_query = new $query_class( $view->form->ID, array(
833 833
 					'field_filters' => array(
834 834
 						array(
835 835
 							'operator' => 'in',
836 836
 							'key'      => 'is_approved',
837
-							'value'    => (array) $filter['value'],
837
+							'value'    => (array)$filter[ 'value' ],
838 838
 						),
839 839
 						array(
840 840
 							'operator' => 'is',
@@ -846,30 +846,30 @@  discard block
 block discarded – undo
846 846
 				) );
847 847
 				$_tmp_query_parts = $_tmp_query->_introspect();
848 848
 
849
-				$extra_conditions[] = $_tmp_query_parts['where'];
849
+				$extra_conditions[ ] = $_tmp_query_parts[ 'where' ];
850 850
 
851 851
 				$filter = false;
852 852
 				continue;
853 853
 			}
854 854
 
855 855
 			// Construct manual query for text mode creator search
856
-			if ( 'created_by' === $filter['key'] && ! empty( $created_by_text_mode ) ) {
857
-				$extra_conditions[] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view );
856
+			if ( 'created_by' === $filter[ 'key' ] && ! empty( $created_by_text_mode ) ) {
857
+				$extra_conditions[ ] = new GravityView_Widget_Search_Author_GF_Query_Condition( $filter, $view );
858 858
 				$filter = false;
859 859
 				continue;
860 860
 			}
861 861
 
862 862
 			// By default, we want searches to be wildcard for each field.
863
-			$filter['operator'] = empty( $filter['operator'] ) ? 'contains' : $filter['operator'];
863
+			$filter[ 'operator' ] = empty( $filter[ 'operator' ] ) ? 'contains' : $filter[ 'operator' ];
864 864
 
865 865
 			// For multichoice, let's have an in (OR) search.
866
-			if ( is_array( $filter['value'] ) ) {
867
-				$filter['operator'] = 'in'; // @todo what about in contains (OR LIKE chains)?
866
+			if ( is_array( $filter[ 'value' ] ) ) {
867
+				$filter[ 'operator' ] = 'in'; // @todo what about in contains (OR LIKE chains)?
868 868
 			}
869 869
 
870 870
 			// Default form with joins functionality
871
-			if ( empty( $filter['form_id'] ) ) {
872
-				$filter['form_id'] = $view->form ? $view->form->ID : 0;
871
+			if ( empty( $filter[ 'form_id' ] ) ) {
872
+				$filter[ 'form_id' ] = $view->form ? $view->form->ID : 0;
873 873
 			}
874 874
 
875 875
 			/**
@@ -879,28 +879,28 @@  discard block
 block discarded – undo
879 879
 			 * @since develop
880 880
 			 * @param \GV\View $view The View we're operating on.
881 881
 			 */
882
-			$filter['operator'] = apply_filters( 'gravityview_search_operator', $filter['operator'], $filter, $view );
882
+			$filter[ 'operator' ] = apply_filters( 'gravityview_search_operator', $filter[ 'operator' ], $filter, $view );
883 883
 		}
884 884
 
885
-		if ( ! empty( $search_criteria['start_date'] ) || ! empty( $search_criteria['end_date'] ) ) {
885
+		if ( ! empty( $search_criteria[ 'start_date' ] ) || ! empty( $search_criteria[ 'end_date' ] ) ) {
886 886
 			$date_criteria = array();
887 887
 
888
-			if ( isset( $search_criteria['start_date'] ) ) {
889
-				$date_criteria['start_date'] = $search_criteria['start_date'];
888
+			if ( isset( $search_criteria[ 'start_date' ] ) ) {
889
+				$date_criteria[ 'start_date' ] = $search_criteria[ 'start_date' ];
890 890
 			}
891 891
 
892
-			if ( isset( $search_criteria['end_date'] ) ) {
893
-				$date_criteria['end_date'] = $search_criteria['end_date'];
892
+			if ( isset( $search_criteria[ 'end_date' ] ) ) {
893
+				$date_criteria[ 'end_date' ] = $search_criteria[ 'end_date' ];
894 894
 			}
895 895
 
896 896
 			$_tmp_query         = new $query_class( $view->form->ID, $date_criteria );
897 897
 			$_tmp_query_parts   = $_tmp_query->_introspect();
898
-			$extra_conditions[] = $_tmp_query_parts['where'];
898
+			$extra_conditions[ ] = $_tmp_query_parts[ 'where' ];
899 899
 		}
900 900
 
901 901
 		$search_conditions = array();
902 902
 
903
-		if ( $filters = array_filter( $search_criteria['field_filters'] ) ) {
903
+		if ( $filters = array_filter( $search_criteria[ 'field_filters' ] ) ) {
904 904
 			foreach ( $filters as &$filter ) {
905 905
 				if ( ! is_array( $filter ) ) {
906 906
 					continue;
@@ -912,12 +912,12 @@  discard block
 block discarded – undo
912 912
 				 * code by reusing what's inside GF_Query already as they
913 913
 				 * take care of many small things like forcing numeric, etc.
914 914
 				 */
915
-				$_tmp_query       = new $query_class( $filter['form_id'], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) );
915
+				$_tmp_query       = new $query_class( $filter[ 'form_id' ], array( 'mode' => 'any', 'field_filters' => array( $filter ) ) );
916 916
 				$_tmp_query_parts = $_tmp_query->_introspect();
917
-				$search_condition = $_tmp_query_parts['where'];
917
+				$search_condition = $_tmp_query_parts[ 'where' ];
918 918
 
919
-				if ( empty( $filter['key'] ) && $search_condition->expressions ) {
920
-					$search_conditions[] = $search_condition;
919
+				if ( empty( $filter[ 'key' ] ) && $search_condition->expressions ) {
920
+					$search_conditions[ ] = $search_condition;
921 921
 				} else {
922 922
 					$left = $search_condition->left;
923 923
 					$alias = $query->_alias( $left->field_id, $left->source, $left->is_entry_column() ? 't' : 'm' );
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 							$on = $_join->join_on;
928 928
 							$join = $_join->join;
929 929
 
930
-							$search_conditions[] = GF_Query_Condition::_or(
930
+							$search_conditions[ ] = GF_Query_Condition::_or(
931 931
 								// Join
932 932
 								new GF_Query_Condition(
933 933
 									new GF_Query_Column( GF_Query_Column::META, $join->ID, $query->_alias( GF_Query_Column::META, $join->ID, 'm' ) ),
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 							);
944 944
 						}
945 945
 					} else {
946
-						$search_conditions[] = new GF_Query_Condition(
946
+						$search_conditions[ ] = new GF_Query_Condition(
947 947
 							new GF_Query_Column( $left->field_id, $left->source, $alias ),
948 948
 							$search_condition->operator,
949 949
 							$search_condition->right
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
 		/**
966 966
 		 * Combine the parts as a new WHERE clause.
967 967
 		 */
968
-		$where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts['where'] ), $search_conditions, $extra_conditions ) );
968
+		$where = call_user_func_array( '\GF_Query_Condition::_and', array_merge( array( $query_parts[ 'where' ] ), $search_conditions, $extra_conditions ) );
969 969
 		$query->where( $where );
970 970
 	}
971 971
 
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 		$field_id = str_replace( 'filter_', '', $key );
989 989
 
990 990
 		// calculates field_id, removing 'filter_' and for '_' for advanced fields ( like name or checkbox )
991
-		if ( preg_match('/^[0-9_]+$/ism', $field_id ) ) {
991
+		if ( preg_match( '/^[0-9_]+$/ism', $field_id ) ) {
992 992
 			$field_id = str_replace( '_', '.', $field_id );
993 993
 		}
994 994
 
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
 			// form is in searchable fields
1046 1046
 			$found = false;
1047 1047
 			foreach ( $searchable_fields as $field ) {
1048
-				if ( $field_id == $field['field'] && $form->ID == $field['form_id'] ) {
1048
+				if ( $field_id == $field[ 'field' ] && $form->ID == $field[ 'form_id' ] ) {
1049 1049
 					$found = true;
1050 1050
 					break;
1051 1051
 				}
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 
1086 1086
 			case 'select':
1087 1087
 			case 'radio':
1088
-				$filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1088
+				$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1089 1089
 				break;
1090 1090
 
1091 1091
 			case 'post_category':
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
 
1100 1100
 				foreach ( $value as $val ) {
1101 1101
 					$cat = get_term( $val, 'category' );
1102
-					$filter[] = array(
1102
+					$filter[ ] = array(
1103 1103
 						'key'      => $field_id,
1104 1104
 						'value'    => esc_attr( $cat->name ) . ':' . $val,
1105 1105
 						'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ),
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 				$filter = array();
1119 1119
 
1120 1120
 				foreach ( $value as $val ) {
1121
-					$filter[] = array( 'key' => $field_id, 'value' => $val );
1121
+					$filter[ ] = array( 'key' => $field_id, 'value' => $val );
1122 1122
 				}
1123 1123
 
1124 1124
 				break;
@@ -1127,9 +1127,9 @@  discard block
 block discarded – undo
1127 1127
 				// convert checkbox on/off into the correct search filter
1128 1128
 				if ( false !== strpos( $field_id, '.' ) && ! empty( $form_field->inputs ) && ! empty( $form_field->choices ) ) {
1129 1129
 					foreach ( $form_field->inputs as $k => $input ) {
1130
-						if ( $input['id'] == $field_id ) {
1131
-							$filter['value'] = $form_field->choices[ $k ]['value'];
1132
-							$filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1130
+						if ( $input[ 'id' ] == $field_id ) {
1131
+							$filter[ 'value' ] = $form_field->choices[ $k ][ 'value' ];
1132
+							$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1133 1133
 							break;
1134 1134
 						}
1135 1135
 					}
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 					$filter = array();
1140 1140
 
1141 1141
 					foreach ( $value as $val ) {
1142
-						$filter[] = array(
1142
+						$filter[ ] = array(
1143 1143
 							'key'      => $field_id,
1144 1144
 							'value'    => $val,
1145 1145
 							'operator' => $this->get_operator( $get, $key, array( 'is' ), 'is' ),
@@ -1160,9 +1160,9 @@  discard block
 block discarded – undo
1160 1160
 					foreach ( $words as $word ) {
1161 1161
 						if ( ! empty( $word ) && strlen( $word ) > 1 ) {
1162 1162
 							// Keep the same key for each filter
1163
-							$filter['value'] = $word;
1163
+							$filter[ 'value' ] = $word;
1164 1164
 							// Add a search for the value
1165
-							$filters[] = $filter;
1165
+							$filters[ ] = $filter;
1166 1166
 						}
1167 1167
 					}
1168 1168
 
@@ -1176,19 +1176,19 @@  discard block
 block discarded – undo
1176 1176
 
1177 1177
 					foreach ( $searchable_fields as $searchable_field ) {
1178 1178
 
1179
-						if( $form_field->ID !== $searchable_field['field'] ) {
1179
+						if ( $form_field->ID !== $searchable_field[ 'field' ] ) {
1180 1180
 							continue;
1181 1181
 						}
1182 1182
 
1183 1183
 						// Only exact-match dropdowns, not text search
1184
-						if( in_array( $searchable_field['input'], array( 'text', 'search' ), true ) ) {
1184
+						if ( in_array( $searchable_field[ 'input' ], array( 'text', 'search' ), true ) ) {
1185 1185
 							continue;
1186 1186
 						}
1187 1187
 
1188 1188
 						$input_id = gravityview_get_input_id_from_id( $form_field->ID );
1189 1189
 
1190 1190
 						if ( 4 === $input_id ) {
1191
-							$filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1191
+							$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1192 1192
 						};
1193 1193
 					}
1194 1194
 				}
@@ -1216,12 +1216,12 @@  discard block
 block discarded – undo
1216 1216
 						 * @since 1.16.3
1217 1217
 						 * Safeguard until GF implements '<=' operator
1218 1218
 						 */
1219
-						if( !GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
1219
+						if ( ! GFFormsModel::is_valid_operator( $operator ) && $operator === '<=' ) {
1220 1220
 							$operator = '<';
1221 1221
 							$date = date( 'Y-m-d', strtotime( self::get_formatted_date( $date, 'Y-m-d', $date_format ) . ' +1 day' ) );
1222 1222
 						}
1223 1223
 
1224
-						$filter[] = array(
1224
+						$filter[ ] = array(
1225 1225
 							'key'      => $field_id,
1226 1226
 							'value'    => self::get_formatted_date( $date, 'Y-m-d', $date_format ),
1227 1227
 							'operator' => $this->get_operator( $get, $key, array( $operator ), $operator ),
@@ -1229,12 +1229,12 @@  discard block
 block discarded – undo
1229 1229
 					}
1230 1230
 				} else {
1231 1231
 					$date = $value;
1232
-					$filter['value'] = self::get_formatted_date( $date, 'Y-m-d', $date_format );
1233
-					$filter['operator'] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1232
+					$filter[ 'value' ] = self::get_formatted_date( $date, 'Y-m-d', $date_format );
1233
+					$filter[ 'operator' ] = $this->get_operator( $get, $key, array( 'is' ), 'is' );
1234 1234
 				}
1235 1235
 
1236
-				if ('payment_date' === $key) {
1237
-					$filter['operator'] = 'contains';
1236
+				if ( 'payment_date' === $key ) {
1237
+					$filter[ 'operator' ] = 'contains';
1238 1238
 				}
1239 1239
 
1240 1240
 				break;
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
 			'ymd_dot' => 'Y.m.d',
1264 1264
 		);
1265 1265
 
1266
-		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ){
1266
+		if ( ! empty( $field->dateFormat ) && isset( $datepicker[ $field->dateFormat ] ) ) {
1267 1267
 			$format = $datepicker[ $field->dateFormat ];
1268 1268
 		}
1269 1269
 
@@ -1300,7 +1300,7 @@  discard block
 block discarded – undo
1300 1300
 	public function add_template_path( $file_paths ) {
1301 1301
 
1302 1302
 		// Index 100 is the default GravityView template path.
1303
-		$file_paths[102] = self::$file . 'templates/';
1303
+		$file_paths[ 102 ] = self::$file . 'templates/';
1304 1304
 
1305 1305
 		return $file_paths;
1306 1306
 	}
@@ -1319,7 +1319,7 @@  discard block
 block discarded – undo
1319 1319
 		$has_date = false;
1320 1320
 
1321 1321
 		foreach ( $search_fields as $k => $field ) {
1322
-			if ( in_array( $field['input'], array( 'date', 'date_range', 'entry_date' ) ) ) {
1322
+			if ( in_array( $field[ 'input' ], array( 'date', 'date_range', 'entry_date' ) ) ) {
1323 1323
 				$has_date = true;
1324 1324
 				break;
1325 1325
 			}
@@ -1348,7 +1348,7 @@  discard block
 block discarded – undo
1348 1348
 		$view = \GV\View::by_id( $gravityview_view->view_id );
1349 1349
 
1350 1350
 		// get configured search fields
1351
-		$search_fields = ! empty( $widget_args['search_fields'] ) ? json_decode( $widget_args['search_fields'], true ) : '';
1351
+		$search_fields = ! empty( $widget_args[ 'search_fields' ] ) ? json_decode( $widget_args[ 'search_fields' ], true ) : '';
1352 1352
 
1353 1353
 		if ( empty( $search_fields ) || ! is_array( $search_fields ) ) {
1354 1354
 			gravityview()->log->debug( 'No search fields configured for widget:', array( 'data' => $widget_args ) );
@@ -1362,40 +1362,40 @@  discard block
 block discarded – undo
1362 1362
 
1363 1363
 			$updated_field = $this->get_search_filter_details( $updated_field, $context );
1364 1364
 
1365
-			switch ( $field['field'] ) {
1365
+			switch ( $field[ 'field' ] ) {
1366 1366
 
1367 1367
 				case 'search_all':
1368
-					$updated_field['key'] = 'search_all';
1369
-					$updated_field['input'] = 'search_all';
1370
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_search' );
1368
+					$updated_field[ 'key' ] = 'search_all';
1369
+					$updated_field[ 'input' ] = 'search_all';
1370
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_search' );
1371 1371
 					break;
1372 1372
 
1373 1373
 				case 'entry_date':
1374
-					$updated_field['key'] = 'entry_date';
1375
-					$updated_field['input'] = 'entry_date';
1376
-					$updated_field['value'] = array(
1374
+					$updated_field[ 'key' ] = 'entry_date';
1375
+					$updated_field[ 'input' ] = 'entry_date';
1376
+					$updated_field[ 'value' ] = array(
1377 1377
 						'start' => $this->rgget_or_rgpost( 'gv_start' ),
1378 1378
 						'end' => $this->rgget_or_rgpost( 'gv_end' ),
1379 1379
 					);
1380 1380
 					break;
1381 1381
 
1382 1382
 				case 'entry_id':
1383
-					$updated_field['key'] = 'entry_id';
1384
-					$updated_field['input'] = 'entry_id';
1385
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_id' );
1383
+					$updated_field[ 'key' ] = 'entry_id';
1384
+					$updated_field[ 'input' ] = 'entry_id';
1385
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_id' );
1386 1386
 					break;
1387 1387
 
1388 1388
 				case 'created_by':
1389
-					$updated_field['key'] = 'created_by';
1390
-					$updated_field['name'] = 'gv_by';
1391
-					$updated_field['value'] = $this->rgget_or_rgpost( 'gv_by' );
1392
-					$updated_field['choices'] = self::get_created_by_choices( $view );
1389
+					$updated_field[ 'key' ] = 'created_by';
1390
+					$updated_field[ 'name' ] = 'gv_by';
1391
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'gv_by' );
1392
+					$updated_field[ 'choices' ] = self::get_created_by_choices( $view );
1393 1393
 					break;
1394 1394
 
1395 1395
 				case 'is_approved':
1396
-					$updated_field['key'] = 'is_approved';
1397
-					$updated_field['value'] = $this->rgget_or_rgpost( 'filter_is_approved' );
1398
-					$updated_field['choices'] = self::get_is_approved_choices();
1396
+					$updated_field[ 'key' ] = 'is_approved';
1397
+					$updated_field[ 'value' ] = $this->rgget_or_rgpost( 'filter_is_approved' );
1398
+					$updated_field[ 'choices' ] = self::get_is_approved_choices();
1399 1399
 					break;
1400 1400
 			}
1401 1401
 
@@ -1416,16 +1416,16 @@  discard block
 block discarded – undo
1416 1416
 
1417 1417
 		$gravityview_view->permalink_fields = $this->add_no_permalink_fields( array(), $this, $widget_args );
1418 1418
 
1419
-		$gravityview_view->search_layout = ! empty( $widget_args['search_layout'] ) ? $widget_args['search_layout'] : 'horizontal';
1419
+		$gravityview_view->search_layout = ! empty( $widget_args[ 'search_layout' ] ) ? $widget_args[ 'search_layout' ] : 'horizontal';
1420 1420
 
1421 1421
 		/** @since 1.14 */
1422
-		$gravityview_view->search_mode = ! empty( $widget_args['search_mode'] ) ? $widget_args['search_mode'] : 'any';
1422
+		$gravityview_view->search_mode = ! empty( $widget_args[ 'search_mode' ] ) ? $widget_args[ 'search_mode' ] : 'any';
1423 1423
 
1424
-		$custom_class = ! empty( $widget_args['custom_class'] ) ? $widget_args['custom_class'] : '';
1424
+		$custom_class = ! empty( $widget_args[ 'custom_class' ] ) ? $widget_args[ 'custom_class' ] : '';
1425 1425
 
1426 1426
 		$gravityview_view->search_class = self::get_search_class( $custom_class );
1427 1427
 
1428
-		$gravityview_view->search_clear = ! empty( $widget_args['search_clear'] ) ? $widget_args['search_clear'] : false;
1428
+		$gravityview_view->search_clear = ! empty( $widget_args[ 'search_clear' ] ) ? $widget_args[ 'search_clear' ] : false;
1429 1429
 
1430 1430
 		if ( $this->has_date_field( $search_fields ) ) {
1431 1431
 			// enqueue datepicker stuff only if needed!
@@ -1447,10 +1447,10 @@  discard block
 block discarded – undo
1447 1447
 	public static function get_search_class( $custom_class = '' ) {
1448 1448
 		$gravityview_view = GravityView_View::getInstance();
1449 1449
 
1450
-		$search_class = 'gv-search-'.$gravityview_view->search_layout;
1450
+		$search_class = 'gv-search-' . $gravityview_view->search_layout;
1451 1451
 
1452
-		if ( ! empty( $custom_class )  ) {
1453
-			$search_class .= ' '.$custom_class;
1452
+		if ( ! empty( $custom_class ) ) {
1453
+			$search_class .= ' ' . $custom_class;
1454 1454
 		}
1455 1455
 
1456 1456
 		/**
@@ -1501,9 +1501,9 @@  discard block
 block discarded – undo
1501 1501
 
1502 1502
 		if ( ! $label ) {
1503 1503
 
1504
-			$label = isset( $form_field['label'] ) ? $form_field['label'] : '';
1504
+			$label = isset( $form_field[ 'label' ] ) ? $form_field[ 'label' ] : '';
1505 1505
 
1506
-			switch( $field['field'] ) {
1506
+			switch ( $field[ 'field' ] ) {
1507 1507
 				case 'search_all':
1508 1508
 					$label = __( 'Search Entries:', 'gravityview' );
1509 1509
 					break;
@@ -1515,10 +1515,10 @@  discard block
 block discarded – undo
1515 1515
 					break;
1516 1516
 				default:
1517 1517
 					// If this is a field input, not a field
1518
-					if ( strpos( $field['field'], '.' ) > 0 && ! empty( $form_field['inputs'] ) ) {
1518
+					if ( strpos( $field[ 'field' ], '.' ) > 0 && ! empty( $form_field[ 'inputs' ] ) ) {
1519 1519
 
1520 1520
 						// Get the label for the field in question, which returns an array
1521
-						$items = wp_list_filter( $form_field['inputs'], array( 'id' => $field['field'] ) );
1521
+						$items = wp_list_filter( $form_field[ 'inputs' ], array( 'id' => $field[ 'field' ] ) );
1522 1522
 
1523 1523
 						// Get the item with the `label` key
1524 1524
 						$values = wp_list_pluck( $items, 'label' );
@@ -1559,13 +1559,13 @@  discard block
 block discarded – undo
1559 1559
 		$form = $gravityview_view->getForm();
1560 1560
 
1561 1561
 		// for advanced field ids (eg, first name / last name )
1562
-		$name = 'filter_' . str_replace( '.', '_', $field['field'] );
1562
+		$name = 'filter_' . str_replace( '.', '_', $field[ 'field' ] );
1563 1563
 
1564 1564
 		// get searched value from $_GET/$_POST (string or array)
1565 1565
 		$value = $this->rgget_or_rgpost( $name );
1566 1566
 
1567 1567
 		// get form field details
1568
-		$form_field = gravityview_get_field( $form, $field['field'] );
1568
+		$form_field = gravityview_get_field( $form, $field[ 'field' ] );
1569 1569
 
1570 1570
 		$form_field_type = \GV\Utils::get( $form_field, 'type' );
1571 1571
 
@@ -1579,17 +1579,17 @@  discard block
 block discarded – undo
1579 1579
 		);
1580 1580
 
1581 1581
 		// collect choices
1582
-		if ( 'post_category' === $form_field_type && ! empty( $form_field['displayAllCategories'] ) && empty( $form_field['choices'] ) ) {
1583
-			$filter['choices'] = gravityview_get_terms_choices();
1584
-		} elseif ( ! empty( $form_field['choices'] ) ) {
1585
-			$filter['choices'] = $form_field['choices'];
1582
+		if ( 'post_category' === $form_field_type && ! empty( $form_field[ 'displayAllCategories' ] ) && empty( $form_field[ 'choices' ] ) ) {
1583
+			$filter[ 'choices' ] = gravityview_get_terms_choices();
1584
+		} elseif ( ! empty( $form_field[ 'choices' ] ) ) {
1585
+			$filter[ 'choices' ] = $form_field[ 'choices' ];
1586 1586
 		}
1587 1587
 
1588
-		if ( 'date_range' === $field['input'] && empty( $value ) ) {
1589
-			$filter['value'] = array( 'start' => '', 'end' => '' );
1588
+		if ( 'date_range' === $field[ 'input' ] && empty( $value ) ) {
1589
+			$filter[ 'value' ] = array( 'start' => '', 'end' => '' );
1590 1590
 		}
1591 1591
 
1592
-		if ( ! empty( $filter['choices'] ) ) {
1592
+		if ( ! empty( $filter[ 'choices' ] ) ) {
1593 1593
 			/**
1594 1594
 			 * @filter `gravityview/search/sieve_choices` Only output used choices for this field.
1595 1595
 			 * @param[in,out] bool Yes or no.
@@ -1597,7 +1597,7 @@  discard block
 block discarded – undo
1597 1597
 			 * @param \GV\Context The context.
1598 1598
 			 */
1599 1599
 			if ( apply_filters( 'gravityview/search/sieve_choices', false, $field, $context ) ) {
1600
-				$filter['choices'] = $this->sieve_filter_choices( $filter, $context );
1600
+				$filter[ 'choices' ] = $this->sieve_filter_choices( $filter, $context );
1601 1601
 			}
1602 1602
 		}
1603 1603
 
@@ -1626,11 +1626,11 @@  discard block
 block discarded – undo
1626 1626
 	 * @return array The filter choices.
1627 1627
 	 */
1628 1628
 	private function sieve_filter_choices( $filter, $context ) {
1629
-		if ( empty( $filter['key'] ) || empty( $filter['choices'] ) ) {
1629
+		if ( empty( $filter[ 'key' ] ) || empty( $filter[ 'choices' ] ) ) {
1630 1630
 			return $filter; // @todo Populate plugins might give us empty choices
1631 1631
 		}
1632 1632
 
1633
-		if ( ! is_numeric( $filter['key'] ) ) {
1633
+		if ( ! is_numeric( $filter[ 'key' ] ) ) {
1634 1634
 			return $filter;
1635 1635
 		}
1636 1636
 
@@ -1640,29 +1640,29 @@  discard block
 block discarded – undo
1640 1640
 
1641 1641
 		$table = GFFormsModel::get_entry_meta_table_name();
1642 1642
 
1643
-		$key_like = $wpdb->esc_like( $filter['key'] ) . '.%';
1643
+		$key_like = $wpdb->esc_like( $filter[ 'key' ] ) . '.%';
1644 1644
 
1645 1645
 		switch ( \GV\Utils::get( $filter, 'type' ) ):
1646 1646
 			case 'post_category':
1647 1647
 				$choices = $wpdb->get_col( $wpdb->prepare(
1648 1648
 					"SELECT DISTINCT SUBSTRING_INDEX(meta_value, ':', 1) FROM $table WHERE (meta_key LIKE %s OR meta_key = %d) AND form_id = %d",
1649
-					$key_like, $filter['key'], $form_id
1649
+					$key_like, $filter[ 'key' ], $form_id
1650 1650
 				) );
1651 1651
 				break;
1652 1652
 			default:
1653 1653
 				$choices = $wpdb->get_col( $wpdb->prepare(
1654 1654
 					"SELECT DISTINCT meta_value FROM $table WHERE (meta_key LIKE %s OR meta_key = %d) AND form_id = %d",
1655
-					$key_like, $filter['key'], $form_id
1655
+					$key_like, $filter[ 'key' ], $form_id
1656 1656
 				) );
1657 1657
 
1658
-				if ( ( $field = gravityview_get_field( $form_id, $filter['key'] ) ) && 'json' === $field->storageType ) {
1658
+				if ( ( $field = gravityview_get_field( $form_id, $filter[ 'key' ] ) ) && 'json' === $field->storageType ) {
1659 1659
 					$choices = array_map( 'json_decode', $choices );
1660 1660
 					$_choices_array = array();
1661 1661
 					foreach ( $choices as $choice ) {
1662 1662
 						if ( is_array( $choice ) ) {
1663 1663
 							$_choices_array = array_merge( $_choices_array, $choice );
1664 1664
 						} else {
1665
-							$_choices_array []= $choice;
1665
+							$_choices_array [ ] = $choice;
1666 1666
 						}
1667 1667
 					}
1668 1668
 					$choices = array_unique( $_choices_array );
@@ -1672,9 +1672,9 @@  discard block
 block discarded – undo
1672 1672
 		endswitch;
1673 1673
 
1674 1674
 		$filter_choices = array();
1675
-		foreach ( $filter['choices'] as $choice ) {
1676
-			if ( in_array( $choice['text'], $choices, true ) || in_array( $choice['value'], $choices, true ) ) {
1677
-				$filter_choices[] = $choice;
1675
+		foreach ( $filter[ 'choices' ] as $choice ) {
1676
+			if ( in_array( $choice[ 'text' ], $choices, true ) || in_array( $choice[ 'value' ], $choices, true ) ) {
1677
+				$filter_choices[ ] = $choice;
1678 1678
 			}
1679 1679
 		}
1680 1680
 
@@ -1709,7 +1709,7 @@  discard block
 block discarded – undo
1709 1709
 			 * @param \GV\View $view The view.
1710 1710
 			 */
1711 1711
 			$text = apply_filters( 'gravityview/search/created_by/text', $user->display_name, $user, $view );
1712
-			$choices[] = array(
1712
+			$choices[ ] = array(
1713 1713
 				'value' => $user->ID,
1714 1714
 				'text' => $text,
1715 1715
 			);
@@ -1729,9 +1729,9 @@  discard block
 block discarded – undo
1729 1729
 
1730 1730
 		$choices = array();
1731 1731
 		foreach ( GravityView_Entry_Approval_Status::get_all() as $status ) {
1732
-			$choices[] = array(
1733
-				'value' => $status['value'],
1734
-				'text' => $status['label'],
1732
+			$choices[ ] = array(
1733
+				'value' => $status[ 'value' ],
1734
+				'text' => $status[ 'label' ],
1735 1735
 			);
1736 1736
 		}
1737 1737
 
@@ -1783,7 +1783,7 @@  discard block
 block discarded – undo
1783 1783
 	 */
1784 1784
 	public function add_datepicker_js_dependency( $js_dependencies ) {
1785 1785
 
1786
-		$js_dependencies[] = 'jquery-ui-datepicker';
1786
+		$js_dependencies[ ] = 'jquery-ui-datepicker';
1787 1787
 
1788 1788
 		return $js_dependencies;
1789 1789
 	}
@@ -1827,7 +1827,7 @@  discard block
 block discarded – undo
1827 1827
 			'isRTL'             => is_rtl(),
1828 1828
 		), $view_data );
1829 1829
 
1830
-		$localizations['datepicker'] = $datepicker_settings;
1830
+		$localizations[ 'datepicker' ] = $datepicker_settings;
1831 1831
 
1832 1832
 		return $localizations;
1833 1833
 
@@ -1854,7 +1854,7 @@  discard block
 block discarded – undo
1854 1854
 	 * @return void
1855 1855
 	 */
1856 1856
 	private function maybe_enqueue_flexibility() {
1857
-		if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/MSIE [8-9]/', $_SERVER['HTTP_USER_AGENT'] ) ) {
1857
+		if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) && preg_match( '/MSIE [8-9]/', $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
1858 1858
 			wp_enqueue_script( 'gv-flexibility' );
1859 1859
 		}
1860 1860
 	}
@@ -1876,7 +1876,7 @@  discard block
 block discarded – undo
1876 1876
 		add_filter( 'gravityview_js_localization', array( $this, 'add_datepicker_localization' ), 10, 2 );
1877 1877
 
1878 1878
 		$scheme = is_ssl() ? 'https://' : 'http://';
1879
-		wp_enqueue_style( 'jquery-ui-datepicker', $scheme.'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1879
+		wp_enqueue_style( 'jquery-ui-datepicker', $scheme . 'ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css' );
1880 1880
 
1881 1881
 		/**
1882 1882
 		 * @filter `gravityview_search_datepicker_class`
@@ -1955,7 +1955,7 @@  discard block
 block discarded – undo
1955 1955
 	public function add_preview_inputs() {
1956 1956
 		global $wp;
1957 1957
 
1958
-		if ( ! is_preview() || ! current_user_can( 'publish_gravityviews') ) {
1958
+		if ( ! is_preview() || ! current_user_can( 'publish_gravityviews' ) ) {
1959 1959
 			return;
1960 1960
 		}
1961 1961
 
@@ -2007,7 +2007,7 @@  discard block
 block discarded – undo
2007 2007
  */
2008 2008
 class GravityView_Widget_Search_Author_GF_Query_Condition extends \GF_Query_Condition {
2009 2009
 	public function __construct( $filter, $view ) {
2010
-		$this->value = $filter['value'];
2010
+		$this->value = $filter[ 'value' ];
2011 2011
 		$this->view = $view;
2012 2012
 	}
2013 2013
 
@@ -2039,11 +2039,11 @@  discard block
 block discarded – undo
2039 2039
 		$conditions = array();
2040 2040
 
2041 2041
 		foreach ( $user_fields as $user_field ) {
2042
-			$conditions[] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) .  '%' );
2042
+			$conditions[ ] = $wpdb->prepare( "`u`.`$user_field` LIKE %s", '%' . $wpdb->esc_like( $this->value ) . '%' );
2043 2043
 		}
2044 2044
 
2045 2045
 		foreach ( $user_meta_fields as $meta_field ) {
2046
-			$conditions[] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) .  '%' );
2046
+			$conditions[ ] = $wpdb->prepare( "(`um`.`meta_key` = %s AND `um`.`meta_value` LIKE %s)", $meta_field, '%' . $wpdb->esc_like( $this->value ) . '%' );
2047 2047
 		}
2048 2048
 
2049 2049
 		$conditions = '(' . implode( ' OR ', $conditions ) . ')';
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-sequence.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 		$this->label = esc_html__( 'Number Sequence', 'gravityview' );
42 42
 		$this->description = esc_html__( 'Display a sequential result number for each entry.', 'gravityview' );
43 43
 
44
-		add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'field_tooltips') );
44
+		add_filter( 'gravityview/metaboxes/tooltips', array( $this, 'field_tooltips' ) );
45 45
 
46 46
 		add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field' ), 10, 3 );
47 47
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 			return $entry_default_fields;
66 66
 		}
67 67
 
68
-		$entry_default_fields['sequence'] = array(
68
+		$entry_default_fields[ 'sequence' ] = array(
69 69
 			'label' => __( 'Result Number', 'gravityview' ),
70 70
 			'type'  => $this->name,
71 71
 			'desc'  => $this->description,
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 
85 85
 		$return = $tooltips;
86 86
 
87
-		$return['reverse_sequence'] = array(
88
-			'title' => __('Reverse the order of the result numbers', 'gravityview'),
89
-			'value' => __('Output the number sequence in descending order. If enabled, numbers will count down from high to low.', 'gravityview'),
87
+		$return[ 'reverse_sequence' ] = array(
88
+			'title' => __( 'Reverse the order of the result numbers', 'gravityview' ),
89
+			'value' => __( 'Output the number sequence in descending order. If enabled, numbers will count down from high to low.', 'gravityview' ),
90 90
 		);
91 91
 
92 92
 		return $return;
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 
95 95
 	public function field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id ) {
96 96
 
97
-		unset ( $field_options['search_filter'] );
97
+		unset ( $field_options[ 'search_filter' ] );
98 98
 
99 99
 		$new_fields = array(
100 100
 			'start' => array(
101 101
 				'type' => 'number',
102 102
 				'label' => __( 'First Number in the Sequence', 'gravityview' ),
103
-				'desc' => __('For each entry, the displayed number will increase by one. When displaying ten entries, the first entry will display "1", and the last entry will show "10".', 'gravityview'),
103
+				'desc' => __( 'For each entry, the displayed number will increase by one. When displaying ten entries, the first entry will display "1", and the last entry will show "10".', 'gravityview' ),
104 104
 				'value' => '1',
105 105
 				'merge_tags' => false,
106 106
 			),
@@ -156,17 +156,17 @@  discard block
 block discarded – undo
156 156
 		$return = $text;
157 157
 
158 158
 		$context = new \GV\Template_Context();
159
-		$context->view = \GV\View::by_id( $view_data['view_id'] );
159
+		$context->view = \GV\View::by_id( $view_data[ 'view_id' ] );
160 160
 		$context->entry = \GV\GF_Entry::from_entry( $entry );
161 161
 
162 162
 		$gv_field = \GV\Internal_Field::by_id( 'sequence' );
163 163
 		$merge_tag_context = \GV\Utils::get( $legacy_field, 'UID' );
164
-		$merge_tag_context = $entry['id'] . "/{$merge_tag_context}";
164
+		$merge_tag_context = $entry[ 'id' ] . "/{$merge_tag_context}";
165 165
 
166 166
 		foreach ( $matches as $match ) {
167 167
 
168
-			$full_tag = $match[0];
169
-			$property = $match[1];
168
+			$full_tag = $match[ 0 ];
169
+			$property = $match[ 1 ];
170 170
 
171 171
 			$gv_field->reverse = false;
172 172
 			$gv_field->start = 1;
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
 
186 186
 				// If there is a field with the ID of the start number, the merge tag won't work.
187 187
 				// In that case, you can use "=" instead: `{sequence start=10}`
188
-				if( 1 === sizeof( $maybe_start ) ) {
188
+				if ( 1 === sizeof( $maybe_start ) ) {
189 189
 					$maybe_start = explode( '=', $modifier );
190 190
 				}
191 191
 
192 192
 				if ( 'start' === rgar( $maybe_start, 0 ) && is_numeric( rgar( $maybe_start, 1 ) ) ) {
193
-					$gv_field->start = (int) rgar( $maybe_start, 1 );
193
+					$gv_field->start = (int)rgar( $maybe_start, 1 );
194 194
 				}
195 195
 			}
196 196
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 			$merge_tag_context_modifiers = $merge_tag_context . '/' . var_export( $gv_field->reverse, true ) . '/' . $gv_field->start;
202 202
 
203 203
 			if ( ! isset( $merge_tag_sequences[ $merge_tag_context_modifiers ] ) ) {
204
-				$gv_field->UID = $legacy_field['UID'] . '/' . var_export( $gv_field->reverse, true ) . '/' . $gv_field->start;
204
+				$gv_field->UID = $legacy_field[ 'UID' ] . '/' . var_export( $gv_field->reverse, true ) . '/' . $gv_field->start;
205 205
 				$context->field = $gv_field;
206 206
 				$sequence = $merge_tag_sequences[ $merge_tag_context_modifiers ] = $this->get_sequence( $context );
207 207
 			} else {
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 			$total = $context->view->get_entries()->total();
247 247
 			remove_filter( 'gform_gf_query_sql', $callback );
248 248
 
249
-			unset( $sql_query['paginate'] );
249
+			unset( $sql_query[ 'paginate' ] );
250 250
 
251 251
 			global $wpdb;
252 252
 
Please login to merge, or discard this patch.
includes/admin/metaboxes/views/select-template.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -26,52 +26,52 @@
 block discarded – undo
26 26
 
27 27
 <?php // list all the available templates (type= fresh or custom ) ?>
28 28
 <div class="gv-grid">
29
-	<?php foreach( $templates as $id => $template ) {
29
+	<?php foreach ( $templates as $id => $template ) {
30 30
 		$selected     = ( $id == $current_template ) ? ' gv-selected' : '';
31
-		$placeholder  = ! empty( $template['buy_source'] );
32
-		$is_included  = ! empty( $template['included'] );
31
+		$placeholder  = ! empty( $template[ 'buy_source' ] );
32
+		$is_included  = ! empty( $template[ 'included' ] );
33 33
 		$plugin_data  = GravityView_Admin_Installer::get_wp_plugins_data( \GV\Utils::get( $template, 'textdomain', '' ) );
34 34
 		$button_text  = empty( $plugin_data ) ? esc_html__( 'Install Layout', 'gravityview' ) : esc_html__( 'Activate & Select Layout', 'gravityview' );
35 35
 		$button_class = 'gv-layout-' . ( empty( $plugin_data ) ? 'install' : 'activate' );
36
-		$template_path = isset($plugin_data['path']) ? $plugin_data['path'] : '';
36
+		$template_path = isset( $plugin_data[ 'path' ] ) ? $plugin_data[ 'path' ] : '';
37 37
 
38 38
 		?>
39 39
 		<div class="gv-grid-col-1-4">
40
-			<div class="gv-view-types-module<?php echo $selected; if( $placeholder ) { echo ' gv-view-template-placeholder'; } ?>" data-filter="<?php echo esc_attr( $template['type'] ); ?>">
40
+			<div class="gv-view-types-module<?php echo $selected; if ( $placeholder ) { echo ' gv-view-template-placeholder'; } ?>" data-filter="<?php echo esc_attr( $template[ 'type' ] ); ?>">
41 41
 				<div class="gv-view-types-normal">
42
-					<img src="<?php echo esc_url( $template['logo'] ); ?>" alt="<?php echo esc_attr( $template['label'] ); ?>">
43
-					<h5><?php echo esc_html( $template['label'] ); ?></h5>
44
-					<p class="description"><?php echo esc_html( $template['description'] ); ?></p>
42
+					<img src="<?php echo esc_url( $template[ 'logo' ] ); ?>" alt="<?php echo esc_attr( $template[ 'label' ] ); ?>">
43
+					<h5><?php echo esc_html( $template[ 'label' ] ); ?></h5>
44
+					<p class="description"><?php echo esc_html( $template[ 'description' ] ); ?></p>
45 45
 				</div>
46 46
 				<div class="gv-view-types-hover">
47 47
 					<div>
48 48
 						<?php
49
-						if( $is_included ) {
49
+						if ( $is_included ) {
50 50
 						?>
51 51
 							<p><a href="<?php echo esc_url( admin_url( 'edit.php?post_type=gravityview&page=gv-admin-installer' ) ); ?>" class="button button-secondary button-hero <?php echo $button_class; ?>" rel="internal" data-template-path="<?php echo $template_path; ?>"><?php echo $button_text; ?></a></p>
52
-							<?php if( !empty( $template['license'] ) ) { ?>
53
-								<p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gravityview' ), esc_html( str_replace( ' ', '&nbsp;', $template['license'] ) ) ); ?></p>
52
+							<?php if ( ! empty( $template[ 'license' ] ) ) { ?>
53
+								<p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gravityview' ), esc_html( str_replace( ' ', '&nbsp;', $template[ 'license' ] ) ) ); ?></p>
54 54
 							<?php } ?>
55 55
 						<?php
56
-						} elseif( $placeholder ) {
57
-							$utm_string = '?utm_source=plugin&utm_medium=buy_now&utm_campaign=view_type&utm_term=' . urlencode( $template['license'] ) . '&utm_content=' . urlencode( $template['slug'] );
56
+						} elseif ( $placeholder ) {
57
+							$utm_string = '?utm_source=plugin&utm_medium=buy_now&utm_campaign=view_type&utm_term=' . urlencode( $template[ 'license' ] ) . '&utm_content=' . urlencode( $template[ 'slug' ] );
58 58
 							?>
59
-							<p><a href="<?php echo esc_url( $template['buy_source'] ); ?>" class="button button-primary button-hero" rel="noreferrer noopener external"><?php esc_html_e( 'Buy Now', 'gravityview'); ?></a></p>
59
+							<p><a href="<?php echo esc_url( $template[ 'buy_source' ] ); ?>" class="button button-primary button-hero" rel="noreferrer noopener external"><?php esc_html_e( 'Buy Now', 'gravityview' ); ?></a></p>
60 60
 
61
-							<?php if( !empty( $template['preview'] ) ) { ?>
62
-								<p><a href="<?php echo esc_url( $template['preview'] ); ?>" rel="noreferrer noopener external" class="button button-secondary"><i class="dashicons dashicons-external" style="vertical-align: middle;" title="<?php esc_html_e( 'View a live demo of this layout', 'gravityview'); ?>"></i> <?php esc_html_e( 'Try a demo', 'gravityview' ); ?></a></p>
61
+							<?php if ( ! empty( $template[ 'preview' ] ) ) { ?>
62
+								<p><a href="<?php echo esc_url( $template[ 'preview' ] ); ?>" rel="noreferrer noopener external" class="button button-secondary"><i class="dashicons dashicons-external" style="vertical-align: middle;" title="<?php esc_html_e( 'View a live demo of this layout', 'gravityview' ); ?>"></i> <?php esc_html_e( 'Try a demo', 'gravityview' ); ?></a></p>
63 63
 							<?php } ?>
64 64
 
65
-							<?php if( ! empty( $template['license'] ) ) { ?>
66
-								<p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gravityview' ), '<a href="https://gravityview.co/pricing/' . esc_attr( $utm_string ) . '" rel="noreferrer noopener external">' . esc_html( str_replace( ' ', '&nbsp;', $template['license'] ) ) . '</a>' ); ?></p>
65
+							<?php if ( ! empty( $template[ 'license' ] ) ) { ?>
66
+								<p class="gv-included-in"><?php echo sprintf( esc_html__( 'This layout is included in the %s license.', 'gravityview' ), '<a href="https://gravityview.co/pricing/' . esc_attr( $utm_string ) . '" rel="noreferrer noopener external">' . esc_html( str_replace( ' ', '&nbsp;', $template[ 'license' ] ) ) . '</a>' ); ?></p>
67 67
 							<?php } ?>
68 68
 						<?php }
69 69
 
70
-						if ($placeholder || $is_included) { ?> </div><div class="hidden"> <?php } ?>
70
+						if ( $placeholder || $is_included ) { ?> </div><div class="hidden"> <?php } ?>
71 71
 
72
-                        <p><a href="#gv_select_template" role="button" class="gv_select_template button button-hero button-primary" data-templateid="<?php echo esc_attr( $id ); ?>"><?php esc_html_e( 'Select', 'gravityview'); ?></a></p>
73
-                        <?php if( !empty( $template['preview'] ) ) { ?>
74
-                            <a href="<?php echo esc_url( $template['preview'] ); ?>" rel="external" class="gv-site-preview"><i class="dashicons dashicons-admin-links" title="<?php esc_html_e( 'View a live demo of this preset', 'gravityview'); ?>"></i></a>
72
+                        <p><a href="#gv_select_template" role="button" class="gv_select_template button button-hero button-primary" data-templateid="<?php echo esc_attr( $id ); ?>"><?php esc_html_e( 'Select', 'gravityview' ); ?></a></p>
73
+                        <?php if ( ! empty( $template[ 'preview' ] ) ) { ?>
74
+                            <a href="<?php echo esc_url( $template[ 'preview' ] ); ?>" rel="external" class="gv-site-preview"><i class="dashicons dashicons-admin-links" title="<?php esc_html_e( 'View a live demo of this preset', 'gravityview' ); ?>"></i></a>
75 75
                         <?php } ?>
76 76
 					</div>
77 77
 				</div>
Please login to merge, or discard this patch.
includes/fields/class-gravityview-field-consent.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -97,13 +97,13 @@
 block discarded – undo
97 97
 		// Set the $_field_id var
98 98
 		$field_options = parent::field_options( $field_options, $template_id, $field_id, $context, $input_type, $form_id );
99 99
 
100
-		if( floor( $field_id ) !== floatval( $field_id ) ) {
100
+		if ( floor( $field_id ) !== floatval( $field_id ) ) {
101 101
 			$default = 'tick';
102 102
 		} else {
103 103
 			$default = 'both';
104 104
 		}
105 105
 
106
-		$field_options['choice_display'] = array(
106
+		$field_options[ 'choice_display' ] = array(
107 107
 			'type'    => 'radio',
108 108
 			'class'   => 'vertical',
109 109
 			'label'   => __( 'What should be displayed:', 'gravityview' ),
Please login to merge, or discard this patch.
includes/admin/class-gravityview-admin-view-field.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,42 +14,42 @@
 block discarded – undo
14 14
 
15 15
 		$field_info_items = array();
16 16
 
17
-		if( !empty( $this->item['adminLabel'] ) ) {
18
-			$field_info_items[] = array(
19
-				'value' => sprintf( __('Admin Label: %s', 'gravityview' ), $this->item['adminLabel'] ),
17
+		if ( ! empty( $this->item[ 'adminLabel' ] ) ) {
18
+			$field_info_items[ ] = array(
19
+				'value' => sprintf( __( 'Admin Label: %s', 'gravityview' ), $this->item[ 'adminLabel' ] ),
20 20
 				'class'	=> 'gv-sublabel'
21 21
 			);
22 22
 		}
23 23
 
24 24
 		// Fields with IDs, not like Source URL or Entry ID
25
-		if( is_numeric( $this->id ) ) {
25
+		if ( is_numeric( $this->id ) ) {
26 26
 
27
-			$field_type_title = GFCommon::get_field_type_title( $this->item['input_type'] );
27
+			$field_type_title = GFCommon::get_field_type_title( $this->item[ 'input_type' ] );
28 28
 
29
-			if ( ! empty( $this->item['parent'] ) ) {
30
-				$field_info_items[] = array(
31
-					'value' => sprintf( esc_html__( 'Parent: %s', 'gravityview' ), esc_attr( $this->item['parent']['label'] ) ),
29
+			if ( ! empty( $this->item[ 'parent' ] ) ) {
30
+				$field_info_items[ ] = array(
31
+					'value' => sprintf( esc_html__( 'Parent: %s', 'gravityview' ), esc_attr( $this->item[ 'parent' ][ 'label' ] ) ),
32 32
 				);
33 33
 			}
34 34
 
35
-			$field_info_items[] = array(
36
-				'value' => sprintf( __('Type: %s', 'gravityview'), $field_type_title ),
37
-				'hide_in_picker' => ! empty( $this->item['parent'] ),
35
+			$field_info_items[ ] = array(
36
+				'value' => sprintf( __( 'Type: %s', 'gravityview' ), $field_type_title ),
37
+				'hide_in_picker' => ! empty( $this->item[ 'parent' ] ),
38 38
 			);
39 39
 
40
-			$field_info_items[] = array(
41
-				'value' => sprintf( __('Field ID: %s', 'gravityview'), $this->id ),
40
+			$field_info_items[ ] = array(
41
+				'value' => sprintf( __( 'Field ID: %s', 'gravityview' ), $this->id ),
42 42
 			);
43 43
 		}
44 44
 
45
-		if( !empty( $this->item['desc'] ) ) {
46
-			$field_info_items[] = array(
47
-				'value' => $this->item['desc']
45
+		if ( ! empty( $this->item[ 'desc' ] ) ) {
46
+			$field_info_items[ ] = array(
47
+				'value' => $this->item[ 'desc' ]
48 48
 			);
49 49
 		}
50 50
 
51
-		$field_info_items[] = array(
52
-			'value'          => sprintf( __('Form ID: %s', 'gravityview' ), $this->form_id ),
51
+		$field_info_items[ ] = array(
52
+			'value'          => sprintf( __( 'Form ID: %s', 'gravityview' ), $this->form_id ),
53 53
 			'hide_in_picker' => true,
54 54
 		);
55 55
 
Please login to merge, or discard this patch.
includes/admin/class-gravityview-admin-view-item.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	protected $form_id;
46 46
 
47
-	function __construct( $title = '', $item_id = '', $item = array(), $settings = array(), $form_id = null) {
47
+	function __construct( $title = '', $item_id = '', $item = array(), $settings = array(), $form_id = null ) {
48 48
 
49 49
 		// Backward compat
50
-		if ( ! empty( $item['type'] ) ) {
51
-			$item['input_type'] = $item['type'];
52
-			unset( $item['type'] );
50
+		if ( ! empty( $item[ 'type' ] ) ) {
51
+			$item[ 'input_type' ] = $item[ 'type' ];
52
+			unset( $item[ 'type' ] );
53 53
 		}
54 54
 
55 55
 		if ( $admin_label = \GV\Utils::get( $settings, 'admin_label' ) ) {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		$this->id         = $item_id;
77 77
 		$this->form_id    = $form_id;
78 78
 		$this->settings   = $settings;
79
-		$this->label_type = $item['label_type'];
79
+		$this->label_type = $item[ 'label_type' ];
80 80
 	}
81 81
 
82 82
 	/**
@@ -120,14 +120,14 @@  discard block
 block discarded – undo
120 120
 
121 121
 			foreach ( $field_info_items as $item ) {
122 122
 
123
-				if( \GV\Utils::get( $item, 'hide_in_picker', false ) ) {
123
+				if ( \GV\Utils::get( $item, 'hide_in_picker', false ) ) {
124 124
 					continue;
125 125
 				}
126 126
 
127
-				$class = isset( $item['class'] ) ? sanitize_html_class( $item['class'] ) . ' description' : 'description';
127
+				$class = isset( $item[ 'class' ] ) ? sanitize_html_class( $item[ 'class' ] ) . ' description' : 'description';
128 128
 				// Add the title in case the value's long, in which case, it'll be truncated by CSS.
129 129
 				$output .= '<span class="' . $class . '">';
130
-				$output .= esc_html( $item['value'] );
130
+				$output .= esc_html( $item[ 'value' ] );
131 131
 				$output .= '</span>';
132 132
 			}
133 133
 
@@ -156,39 +156,39 @@  discard block
 block discarded – undo
156 156
 
157 157
 		// $settings_html will just be hidden inputs if empty. Otherwise, it'll have an <ul>. Ugly hack, I know.
158 158
 		// TODO: Un-hack this
159
-		$hide_settings_link_class = ( empty( $this->item['settings_html'] ) || strpos( $this->item['settings_html'], '<!-- No Options -->' ) > 0 ) ? 'hide-if-js' : '';
160
-		$settings_link      = sprintf( '<button class="gv-field-settings %2$s" title="%1$s" aria-label="%1$s"><span class="dashicons-admin-generic dashicons"></span></button>', esc_attr( $settings_title ), $hide_settings_link_class );
159
+		$hide_settings_link_class = ( empty( $this->item[ 'settings_html' ] ) || strpos( $this->item[ 'settings_html' ], '<!-- No Options -->' ) > 0 ) ? 'hide-if-js' : '';
160
+		$settings_link = sprintf( '<button class="gv-field-settings %2$s" title="%1$s" aria-label="%1$s"><span class="dashicons-admin-generic dashicons"></span></button>', esc_attr( $settings_title ), $hide_settings_link_class );
161 161
 
162 162
 		// When a field label is empty, use the Field ID
163 163
 		$label = empty( $this->title ) ? sprintf( _x( 'Field #%s (No Label)', 'Label in field picker for empty label', 'gravityview' ), $this->id ) : $this->title;
164 164
 
165 165
 		// If there's a custom label, and show label is checked, use that as the field heading
166
-		if ( ! empty( $this->settings['custom_label'] ) && ! empty( $this->settings['show_label'] ) ) {
167
-			$label = $this->settings['custom_label'];
168
-		} else if ( ! empty( $this->item['customLabel'] ) ) {
169
-			$label = $this->item['customLabel'];
166
+		if ( ! empty( $this->settings[ 'custom_label' ] ) && ! empty( $this->settings[ 'show_label' ] ) ) {
167
+			$label = $this->settings[ 'custom_label' ];
168
+		} else if ( ! empty( $this->item[ 'customLabel' ] ) ) {
169
+			$label = $this->item[ 'customLabel' ];
170 170
 		}
171 171
 		$label = esc_attr( $label );
172 172
 
173 173
 		$field_icon = '';
174 174
 
175
-		if ( $this->item['icon'] && ! \GV\Utils::get( $this->item, 'parent' ) ) {
175
+		if ( $this->item[ 'icon' ] && ! \GV\Utils::get( $this->item, 'parent' ) ) {
176 176
 
177
-			$has_gf_icon = ( false !== strpos( $this->item['icon'], 'gform-icon' ) );
178
-			$has_dashicon = ( false !== strpos( $this->item['icon'], 'dashicons' ) );
177
+			$has_gf_icon = ( false !== strpos( $this->item[ 'icon' ], 'gform-icon' ) );
178
+			$has_dashicon = ( false !== strpos( $this->item[ 'icon' ], 'dashicons' ) );
179 179
 
180
-			if ( 0 === strpos( $this->item['icon'], 'data:' ) ) {
180
+			if ( 0 === strpos( $this->item[ 'icon' ], 'data:' ) ) {
181 181
 				// Inline icon SVG
182
-				$field_icon = '<i class="dashicons background-icon" style="background-image: url(\'' . esc_attr( $this->item['icon'] ) . '\');"></i>';
183
-			} elseif( $has_gf_icon && gravityview()->plugin->is_GF_25() ) {
182
+				$field_icon = '<i class="dashicons background-icon" style="background-image: url(\'' . esc_attr( $this->item[ 'icon' ] ) . '\');"></i>';
183
+			} elseif ( $has_gf_icon && gravityview()->plugin->is_GF_25() ) {
184 184
 				// Gravity Forms icon font
185
-				$field_icon = '<i class="gform-icon ' . esc_attr( $this->item['icon'] ) . '"></i>';
186
-			} elseif( $has_dashicon ) {
185
+				$field_icon = '<i class="gform-icon ' . esc_attr( $this->item[ 'icon' ] ) . '"></i>';
186
+			} elseif ( $has_dashicon ) {
187 187
 				// Dashicon; prefix with "dashicons"
188
-				$field_icon = '<i class="dashicons ' . esc_attr( $this->item['icon'] ) . '"></i>';
188
+				$field_icon = '<i class="dashicons ' . esc_attr( $this->item[ 'icon' ] ) . '"></i>';
189 189
 			} else {
190 190
 				// Not dashicon icon
191
-				$field_icon = '<i class="' . esc_attr( $this->item['icon'] ) . '"></i>';
191
+				$field_icon = '<i class="' . esc_attr( $this->item[ 'icon' ] ) . '"></i>';
192 192
 			}
193 193
 
194 194
 			$field_icon = $field_icon . ' ';
@@ -210,17 +210,17 @@  discard block
 block discarded – undo
210 210
 
211 211
 		$output .= '</h5>';
212 212
 
213
-		$container_class = ! empty( $this->item['parent'] ) ? ' gv-child-field' : '';
213
+		$container_class = ! empty( $this->item[ 'parent' ] ) ? ' gv-child-field' : '';
214 214
 
215
-		$container_class .= empty( $this->settings['show_as_link'] ) ? '' : ' has-single-entry-link';
215
+		$container_class .= empty( $this->settings[ 'show_as_link' ] ) ? '' : ' has-single-entry-link';
216 216
 
217
-		$container_class .= empty( $this->settings['only_loggedin'] ) ? '' : ' has-custom-visibility';
217
+		$container_class .= empty( $this->settings[ 'only_loggedin' ] ) ? '' : ' has-custom-visibility';
218 218
 
219
-		$data_form_id   = ! empty( $this->form_id ) ? ' data-formid="' . esc_attr( $this->form_id ) . '"' : '';
219
+		$data_form_id = ! empty( $this->form_id ) ? ' data-formid="' . esc_attr( $this->form_id ) . '"' : '';
220 220
 
221
-		$data_parent_label = ! empty( $this->item['parent'] ) ? ' data-parent-label="' . esc_attr( $this->item['parent']['label'] ) . '"' : '';
221
+		$data_parent_label = ! empty( $this->item[ 'parent' ] ) ? ' data-parent-label="' . esc_attr( $this->item[ 'parent' ][ 'label' ] ) . '"' : '';
222 222
 
223
-		$output = '<div data-fieldid="' . esc_attr( $this->id ) . '" ' . $data_form_id . $data_parent_label . ' data-inputtype="' . esc_attr( $this->item['input_type'] ) . '" class="gv-fields' . $container_class . '">' . $output . $this->item['settings_html'] . '</div>';
223
+		$output = '<div data-fieldid="' . esc_attr( $this->id ) . '" ' . $data_form_id . $data_parent_label . ' data-inputtype="' . esc_attr( $this->item[ 'input_type' ] ) . '" class="gv-fields' . $container_class . '">' . $output . $this->item[ 'settings_html' ] . '</div>';
224 224
 
225 225
 		return $output;
226 226
 	}
@@ -238,12 +238,12 @@  discard block
 block discarded – undo
238 238
 
239 239
 		$icons = array(
240 240
 			'show_as_link' => array(
241
-				'visible' => ( ! empty( $this->settings['show_as_link'] ) ),
241
+				'visible' => ( ! empty( $this->settings[ 'show_as_link' ] ) ),
242 242
 				'title' => __( 'This field links to the Single Entry', 'gravityview' ),
243 243
 				'css_class' => 'dashicons dashicons-media-default icon-link-to-single-entry',
244 244
 			),
245 245
 			'only_loggedin' => array(
246
-				'visible' => ( \GV\Utils::get( $this->settings, 'only_loggedin' ) || isset( $this->settings['allow_edit_cap'] ) && 'read' !== $this->settings['allow_edit_cap'] ),
246
+				'visible' => ( \GV\Utils::get( $this->settings, 'only_loggedin' ) || isset( $this->settings[ 'allow_edit_cap' ] ) && 'read' !== $this->settings[ 'allow_edit_cap' ] ),
247 247
 				'title' => __( 'This field has modified visibility', 'gravityview' ),
248 248
 				'css_class' => 'dashicons dashicons-lock icon-custom-visibility',
249 249
 			),
@@ -257,21 +257,21 @@  discard block
 block discarded – undo
257 257
 		 * @param array $icons Array of icons to be shown, with `visible`, `title`, `css_class` keys.
258 258
 		 * @param array $item_settings Settings for the current item (widget or field)
259 259
 		 */
260
-		$icons = (array) apply_filters( 'gravityview/admin/indicator_icons', $icons, $this->settings );
260
+		$icons = (array)apply_filters( 'gravityview/admin/indicator_icons', $icons, $this->settings );
261 261
 
262 262
 		foreach ( $icons as $icon ) {
263 263
 
264
-			if ( empty( $icon['css_class'] ) || empty( $icon['title'] ) ) {
264
+			if ( empty( $icon[ 'css_class' ] ) || empty( $icon[ 'title' ] ) ) {
265 265
 				continue;
266 266
 			}
267 267
 
268
-			$css_class = trim( $icon['css_class'] );
268
+			$css_class = trim( $icon[ 'css_class' ] );
269 269
 
270
-			if ( empty( $icon['visible'] ) ) {
270
+			if ( empty( $icon[ 'visible' ] ) ) {
271 271
 				$css_class .= ' hide-if-js';
272 272
 			}
273 273
 
274
-			$output .= '<span class="' . gravityview_sanitize_html_class( $css_class ) . '" title="' . esc_attr( $icon['title'] ) . '"></span>';
274
+			$output .= '<span class="' . gravityview_sanitize_html_class( $css_class ) . '" title="' . esc_attr( $icon[ 'title' ] ) . '"></span>';
275 275
 		}
276 276
 
277 277
 		return $output;
Please login to merge, or discard this patch.