@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $supports = array( 'title', 'revisions' ); |
135 | 135 | |
136 | 136 | if ( $is_hierarchical ) { |
137 | - $supports[] = 'page-attributes'; |
|
137 | + $supports[ ] = 'page-attributes'; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -243,12 +243,12 @@ discard block |
||
243 | 243 | $tsv_rule = array( sprintf( '%s/([^/]+)/tsv/?', $slug ), 'index.php?gravityview=$matches[1]&tsv=1', 'top' ); |
244 | 244 | |
245 | 245 | add_filter( 'query_vars', function( $query_vars ) { |
246 | - $query_vars[] = 'csv'; |
|
247 | - $query_vars[] = 'tsv'; |
|
246 | + $query_vars[ ] = 'csv'; |
|
247 | + $query_vars[ ] = 'tsv'; |
|
248 | 248 | return $query_vars; |
249 | 249 | } ); |
250 | 250 | |
251 | - if ( ! isset( $wp_rewrite->extra_rules_top[ $csv_rule[0] ] ) ) { |
|
251 | + if ( ! isset( $wp_rewrite->extra_rules_top[ $csv_rule[ 0 ] ] ) ) { |
|
252 | 252 | call_user_func_array( 'add_rewrite_rule', $csv_rule ); |
253 | 253 | call_user_func_array( 'add_rewrite_rule', $tsv_rule ); |
254 | 254 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | |
310 | 310 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
311 | 311 | |
312 | - $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 ) ) ); |
|
312 | + $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 ) ) ); |
|
313 | 313 | |
314 | 314 | return \GVCommon::generate_notice( '<h3>' . $title . '</h3>' . wpautop( $message . $image ), 'notice' ); |
315 | 315 | } |
@@ -335,13 +335,13 @@ discard block |
||
335 | 335 | return $content; |
336 | 336 | } |
337 | 337 | |
338 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
338 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
339 | 339 | |
340 | 340 | /** |
341 | 341 | * Editing a single entry. |
342 | 342 | */ |
343 | 343 | if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) { |
344 | - if ( $entry['status'] != 'active' ) { |
|
344 | + if ( $entry[ 'status' ] != 'active' ) { |
|
345 | 345 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
346 | 346 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
347 | 347 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | } |
353 | 353 | |
354 | 354 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
355 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
355 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
356 | 356 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
357 | 357 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
358 | 358 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | |
376 | 376 | foreach ( $entryset as $e ) { |
377 | 377 | |
378 | - if ( 'active' !== $e['status'] ) { |
|
378 | + if ( 'active' !== $e[ 'status' ] ) { |
|
379 | 379 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $e->ID ) ); |
380 | 380 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
381 | 381 | } |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | } |
387 | 387 | |
388 | 388 | if ( $show_only_approved && ! $is_admin_and_can_view ) { |
389 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
389 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
390 | 390 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $e->ID ) ); |
391 | 391 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
392 | 392 | } |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | $join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field::by_id( $join_column ); |
562 | 562 | $join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field::by_id( $join_on_column ); |
563 | 563 | |
564 | - $joins [] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
564 | + $joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | return $joins; |
@@ -651,13 +651,13 @@ discard block |
||
651 | 651 | } |
652 | 652 | |
653 | 653 | foreach ( $_fields as $field ) { |
654 | - if ( ! empty( $field['unions'] ) ) { |
|
655 | - foreach ( $field['unions'] as $form_id => $field_id ) { |
|
654 | + if ( ! empty( $field[ 'unions' ] ) ) { |
|
655 | + foreach ( $field[ 'unions' ] as $form_id => $field_id ) { |
|
656 | 656 | if ( ! isset( $unions[ $form_id ] ) ) { |
657 | 657 | $unions[ $form_id ] = array(); |
658 | 658 | } |
659 | 659 | |
660 | - $unions[ $form_id ][ $field['id'] ] = |
|
660 | + $unions[ $form_id ][ $field[ 'id' ] ] = |
|
661 | 661 | 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 ); |
662 | 662 | } |
663 | 663 | } |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | if ( ! $view->form ) { |
713 | 713 | gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
714 | 714 | 'view_id' => $view->ID, |
715 | - 'form_id' => $view->_gravityview_form_id ? : 0, |
|
715 | + 'form_id' => $view->_gravityview_form_id ?: 0, |
|
716 | 716 | ) ); |
717 | 717 | } |
718 | 718 | |
@@ -956,11 +956,11 @@ discard block |
||
956 | 956 | * Remove multiple sorting before calling legacy filters. |
957 | 957 | * This allows us to fake it till we make it. |
958 | 958 | */ |
959 | - if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) { |
|
959 | + if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) { |
|
960 | 960 | $has_multisort = true; |
961 | - $parameters['sort_field'] = reset( $parameters['sort_field'] ); |
|
962 | - if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) { |
|
963 | - $parameters['sort_direction'] = reset( $parameters['sort_direction'] ); |
|
961 | + $parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] ); |
|
962 | + if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) { |
|
963 | + $parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] ); |
|
964 | 964 | } |
965 | 965 | } |
966 | 966 | |
@@ -969,31 +969,30 @@ discard block |
||
969 | 969 | */ |
970 | 970 | $parameters = \GravityView_frontend::get_view_entries_parameters( $parameters, $this->form->ID ); |
971 | 971 | |
972 | - $parameters['context_view_id'] = $this->ID; |
|
972 | + $parameters[ 'context_view_id' ] = $this->ID; |
|
973 | 973 | $parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
974 | 974 | |
975 | 975 | if ( ! is_array( $parameters ) ) { |
976 | 976 | $parameters = array(); |
977 | 977 | } |
978 | 978 | |
979 | - if ( ! is_array( $parameters['search_criteria'] ) ) { |
|
980 | - $parameters['search_criteria'] = array(); |
|
979 | + if ( ! is_array( $parameters[ 'search_criteria' ] ) ) { |
|
980 | + $parameters[ 'search_criteria' ] = array(); |
|
981 | 981 | } |
982 | 982 | |
983 | - if ( ( ! isset( $parameters['search_criteria']['field_filters'] ) ) || ( ! is_array( $parameters['search_criteria']['field_filters'] ) ) ) { |
|
984 | - $parameters['search_criteria']['field_filters'] = array(); |
|
983 | + if ( ( ! isset( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) || ( ! is_array( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) ) { |
|
984 | + $parameters[ 'search_criteria' ][ 'field_filters' ] = array(); |
|
985 | 985 | } |
986 | 986 | |
987 | 987 | if ( $request instanceof REST\Request ) { |
988 | 988 | $atts = $this->settings->as_atts(); |
989 | 989 | $paging_parameters = wp_parse_args( $request->get_paging(), array( |
990 | - 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
990 | + 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
991 | 991 | ) ); |
992 | - $parameters['paging'] = $paging_parameters['paging']; |
|
992 | + $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
993 | 993 | } |
994 | 994 | |
995 | - $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
996 | - : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 ); |
|
995 | + $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / \GV\Utils::get( $parameters, 'paging/page_size', 25 ) ) + 1 ); |
|
997 | 996 | |
998 | 997 | /** |
999 | 998 | * Cleanup duplicate field_filter parameters to simplify the query. |
@@ -1001,14 +1000,14 @@ discard block |
||
1001 | 1000 | $unique_field_filters = array(); |
1002 | 1001 | foreach ( Utils::get( $parameters, 'search_criteria/field_filters', array() ) as $key => $filter ) { |
1003 | 1002 | if ( 'mode' === $key ) { |
1004 | - $unique_field_filters['mode'] = $filter; |
|
1003 | + $unique_field_filters[ 'mode' ] = $filter; |
|
1005 | 1004 | } else if ( ! in_array( $filter, $unique_field_filters ) ) { |
1006 | - $unique_field_filters[] = $filter; |
|
1005 | + $unique_field_filters[ ] = $filter; |
|
1007 | 1006 | } |
1008 | 1007 | } |
1009 | - $parameters['search_criteria']['field_filters'] = $unique_field_filters; |
|
1008 | + $parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters; |
|
1010 | 1009 | |
1011 | - if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) { |
|
1010 | + if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
1012 | 1011 | gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' ); |
1013 | 1012 | } |
1014 | 1013 | |
@@ -1017,7 +1016,7 @@ discard block |
||
1017 | 1016 | $query_class = $this->get_query_class(); |
1018 | 1017 | |
1019 | 1018 | /** @type \GF_Query $query */ |
1020 | - $query = new $query_class( $this->form->ID, $parameters['search_criteria'], Utils::get( $parameters, 'sorting' ) ); |
|
1019 | + $query = new $query_class( $this->form->ID, $parameters[ 'search_criteria' ], Utils::get( $parameters, 'sorting' ) ); |
|
1021 | 1020 | |
1022 | 1021 | /** |
1023 | 1022 | * Apply multisort. |
@@ -1028,15 +1027,15 @@ discard block |
||
1028 | 1027 | $view_setting_sort_field_ids = \GV\Utils::get( $atts, 'sort_field', array() ); |
1029 | 1028 | $view_setting_sort_directions = \GV\Utils::get( $atts, 'sort_direction', array() ); |
1030 | 1029 | |
1031 | - $has_sort_query_param = ! empty( $_GET['sort'] ) && is_array( $_GET['sort'] ); |
|
1030 | + $has_sort_query_param = ! empty( $_GET[ 'sort' ] ) && is_array( $_GET[ 'sort' ] ); |
|
1032 | 1031 | |
1033 | - if( $has_sort_query_param ) { |
|
1034 | - $has_sort_query_param = array_filter( array_values( $_GET['sort'] ) ); |
|
1032 | + if ( $has_sort_query_param ) { |
|
1033 | + $has_sort_query_param = array_filter( array_values( $_GET[ 'sort' ] ) ); |
|
1035 | 1034 | } |
1036 | 1035 | |
1037 | 1036 | if ( $this->settings->get( 'sort_columns' ) && $has_sort_query_param ) { |
1038 | - $sort_field_ids = array_keys( $_GET['sort'] ); |
|
1039 | - $sort_directions = array_values( $_GET['sort'] ); |
|
1037 | + $sort_field_ids = array_keys( $_GET[ 'sort' ] ); |
|
1038 | + $sort_directions = array_values( $_GET[ 'sort' ] ); |
|
1040 | 1039 | } else { |
1041 | 1040 | $sort_field_ids = $view_setting_sort_field_ids; |
1042 | 1041 | $sort_directions = $view_setting_sort_directions; |
@@ -1044,7 +1043,7 @@ discard block |
||
1044 | 1043 | |
1045 | 1044 | $skip_first = false; |
1046 | 1045 | |
1047 | - foreach ( (array) $sort_field_ids as $key => $sort_field_id ) { |
|
1046 | + foreach ( (array)$sort_field_ids as $key => $sort_field_id ) { |
|
1048 | 1047 | |
1049 | 1048 | if ( ! $skip_first && ! $has_sort_query_param ) { |
1050 | 1049 | $skip_first = true; // Skip the first one, it's already in the query |
@@ -1074,18 +1073,18 @@ discard block |
||
1074 | 1073 | |
1075 | 1074 | $merged_time = false; |
1076 | 1075 | |
1077 | - foreach ( $q['order'] as $oid => $order ) { |
|
1076 | + foreach ( $q[ 'order' ] as $oid => $order ) { |
|
1078 | 1077 | |
1079 | 1078 | $column = null; |
1080 | 1079 | |
1081 | - if ( $order[0] instanceof \GF_Query_Column ) { |
|
1082 | - $column = $order[0]; |
|
1083 | - } else if ( $order[0] instanceof \GF_Query_Call ) { |
|
1084 | - if ( count( $order[0]->columns ) != 1 || ! $order[0]->columns[0] instanceof \GF_Query_Column ) { |
|
1080 | + if ( $order[ 0 ] instanceof \GF_Query_Column ) { |
|
1081 | + $column = $order[ 0 ]; |
|
1082 | + } else if ( $order[ 0 ] instanceof \GF_Query_Call ) { |
|
1083 | + if ( count( $order[ 0 ]->columns ) != 1 || ! $order[ 0 ]->columns[ 0 ] instanceof \GF_Query_Column ) { |
|
1085 | 1084 | $orders[ $oid ] = $order; |
1086 | 1085 | continue; // Need something that resembles a single sort |
1087 | 1086 | } |
1088 | - $column = $order[0]->columns[0]; |
|
1087 | + $column = $order[ 0 ]->columns[ 0 ]; |
|
1089 | 1088 | } |
1090 | 1089 | |
1091 | 1090 | if ( ! $column || ( ! $field = \GFAPI::get_field( $column->source, $column->field_id ) ) || $field->type !== 'time' ) { |
@@ -1099,7 +1098,7 @@ discard block |
||
1099 | 1098 | |
1100 | 1099 | $orders[ $oid ] = array( |
1101 | 1100 | new \GV\Mocks\GF_Query_Call_TIMESORT( 'timesort', array( $column, $sql ) ), |
1102 | - $order[1] // Mock it! |
|
1101 | + $order[ 1 ] // Mock it! |
|
1103 | 1102 | ); |
1104 | 1103 | |
1105 | 1104 | $merged_time = true; |
@@ -1110,15 +1109,15 @@ discard block |
||
1110 | 1109 | * ORDER again. |
1111 | 1110 | */ |
1112 | 1111 | if ( ! empty( $orders ) && $_orders = $query->_order_generate( $orders ) ) { |
1113 | - $sql['order'] = 'ORDER BY ' . implode( ', ', $_orders ); |
|
1112 | + $sql[ 'order' ] = 'ORDER BY ' . implode( ', ', $_orders ); |
|
1114 | 1113 | } |
1115 | 1114 | } |
1116 | 1115 | |
1117 | 1116 | return $sql; |
1118 | 1117 | } ); |
1119 | 1118 | |
1120 | - $query->limit( $parameters['paging']['page_size'] ) |
|
1121 | - ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
1119 | + $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
1120 | + ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
1122 | 1121 | |
1123 | 1122 | /** |
1124 | 1123 | * Any joins? |
@@ -1141,7 +1140,7 @@ discard block |
||
1141 | 1140 | |
1142 | 1141 | $query_parameters = $query->_introspect(); |
1143 | 1142 | |
1144 | - $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
1143 | + $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
1145 | 1144 | } |
1146 | 1145 | |
1147 | 1146 | /** |
@@ -1175,7 +1174,7 @@ discard block |
||
1175 | 1174 | } |
1176 | 1175 | |
1177 | 1176 | $q = $query->_introspect(); |
1178 | - $query->where( \GF_Query_Condition::_and( $q['where'], $condition ) ); |
|
1177 | + $query->where( \GF_Query_Condition::_and( $q[ 'where' ], $condition ) ); |
|
1179 | 1178 | |
1180 | 1179 | if ( $this->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
1181 | 1180 | |
@@ -1200,7 +1199,7 @@ discard block |
||
1200 | 1199 | |
1201 | 1200 | $query_parameters = $query->_introspect(); |
1202 | 1201 | |
1203 | - $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
1202 | + $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
1204 | 1203 | } |
1205 | 1204 | } |
1206 | 1205 | |
@@ -1224,7 +1223,7 @@ discard block |
||
1224 | 1223 | $conditions = array(); |
1225 | 1224 | |
1226 | 1225 | foreach ( $condition->expressions as $_condition ) { |
1227 | - $conditions[] = $recurse( $_condition, $fields, $recurse ); |
|
1226 | + $conditions[ ] = $recurse( $_condition, $fields, $recurse ); |
|
1228 | 1227 | } |
1229 | 1228 | |
1230 | 1229 | return call_user_func_array( |
@@ -1253,10 +1252,10 @@ discard block |
||
1253 | 1252 | $q = new $query_class( $form_id ); |
1254 | 1253 | |
1255 | 1254 | // Copy the WHERE clauses but substitute the field_ids to the respective ones |
1256 | - $q->where( $where_union_substitute( $query_parameters['where'], $fields, $where_union_substitute ) ); |
|
1255 | + $q->where( $where_union_substitute( $query_parameters[ 'where' ], $fields, $where_union_substitute ) ); |
|
1257 | 1256 | |
1258 | 1257 | // Copy the ORDER clause and substitute the field_ids to the respective ones |
1259 | - foreach ( $query_parameters['order'] as $order ) { |
|
1258 | + foreach ( $query_parameters[ 'order' ] as $order ) { |
|
1260 | 1259 | list( $column, $_order ) = $order; |
1261 | 1260 | |
1262 | 1261 | if ( $column && $column instanceof \GF_Query_Column ) { |
@@ -1270,15 +1269,15 @@ discard block |
||
1270 | 1269 | |
1271 | 1270 | add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( &$unions_sql ) { |
1272 | 1271 | // Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
1273 | - $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
1272 | + $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
1274 | 1273 | |
1275 | 1274 | // Record the SQL |
1276 | - $unions_sql[] = array( |
|
1275 | + $unions_sql[ ] = array( |
|
1277 | 1276 | // Remove columns, we'll rebuild them |
1278 | 1277 | 'select' => preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $select ), |
1279 | - 'from' => $sql['from'], |
|
1280 | - 'join' => $sql['join'], |
|
1281 | - 'where' => $sql['where'], |
|
1278 | + 'from' => $sql[ 'from' ], |
|
1279 | + 'join' => $sql[ 'join' ], |
|
1280 | + 'where' => $sql[ 'where' ], |
|
1282 | 1281 | // Remove order and limit |
1283 | 1282 | ); |
1284 | 1283 | |
@@ -1295,11 +1294,11 @@ discard block |
||
1295 | 1294 | |
1296 | 1295 | add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( $unions_sql ) { |
1297 | 1296 | // Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
1298 | - $sql['select'] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
1297 | + $sql[ 'select' ] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
1299 | 1298 | |
1300 | 1299 | // Remove columns, we'll rebuild them |
1301 | - preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql['select'], $select_match ); |
|
1302 | - $sql['select'] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql['select'] ); |
|
1300 | + preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql[ 'select' ], $select_match ); |
|
1301 | + $sql[ 'select' ] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql[ 'select' ] ); |
|
1303 | 1302 | |
1304 | 1303 | $unions = array(); |
1305 | 1304 | |
@@ -1310,30 +1309,30 @@ discard block |
||
1310 | 1309 | }; |
1311 | 1310 | |
1312 | 1311 | // Add all the order columns into the selects, so we can order by the whole union group |
1313 | - preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql['order'], $order_matches ); |
|
1312 | + preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql[ 'order' ], $order_matches ); |
|
1314 | 1313 | |
1315 | 1314 | $columns = array( |
1316 | - sprintf( '%s AS %s', $select_match[1], $column_to_alias( $select_match[1] ) ) |
|
1315 | + sprintf( '%s AS %s', $select_match[ 1 ], $column_to_alias( $select_match[ 1 ] ) ) |
|
1317 | 1316 | ); |
1318 | 1317 | |
1319 | 1318 | foreach ( array_slice( $order_matches, 1 ) as $match ) { |
1320 | - $columns[] = sprintf( '%s AS %s', $match[0], $column_to_alias( $match[0] ) ); |
|
1319 | + $columns[ ] = sprintf( '%s AS %s', $match[ 0 ], $column_to_alias( $match[ 0 ] ) ); |
|
1321 | 1320 | |
1322 | 1321 | // Rewrite the order columns to the shared aliases |
1323 | - $sql['order'] = str_replace( $match[0], $column_to_alias( $match[0] ), $sql['order'] ); |
|
1322 | + $sql[ 'order' ] = str_replace( $match[ 0 ], $column_to_alias( $match[ 0 ] ), $sql[ 'order' ] ); |
|
1324 | 1323 | } |
1325 | 1324 | |
1326 | 1325 | $columns = array_unique( $columns ); |
1327 | 1326 | |
1328 | 1327 | // Add the columns to every UNION |
1329 | 1328 | foreach ( $unions_sql as $union_sql ) { |
1330 | - $union_sql['select'] .= implode( ', ', $columns ); |
|
1331 | - $unions []= implode( ' ', $union_sql ); |
|
1329 | + $union_sql[ 'select' ] .= implode( ', ', $columns ); |
|
1330 | + $unions [ ] = implode( ' ', $union_sql ); |
|
1332 | 1331 | } |
1333 | 1332 | |
1334 | 1333 | // Add the columns to the main SELECT, but only grab the entry id column |
1335 | - $sql['select'] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql['select'] . implode( ', ', $columns ); |
|
1336 | - $sql['order'] = implode( ' ', $unions ) . ') AS u ' . $sql['order']; |
|
1334 | + $sql[ 'select' ] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql[ 'select' ] . implode( ', ', $columns ); |
|
1335 | + $sql[ 'order' ] = implode( ' ', $unions ) . ') AS u ' . $sql[ 'order' ]; |
|
1337 | 1336 | |
1338 | 1337 | return $sql; |
1339 | 1338 | } ); |
@@ -1378,20 +1377,20 @@ discard block |
||
1378 | 1377 | } ); |
1379 | 1378 | } else { |
1380 | 1379 | $entries = $this->form->entries |
1381 | - ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
1380 | + ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
1382 | 1381 | ->offset( $this->settings->get( 'offset' ) ) |
1383 | - ->limit( $parameters['paging']['page_size'] ) |
|
1382 | + ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
1384 | 1383 | ->page( $page ); |
1385 | 1384 | |
1386 | - if ( ! empty( $parameters['sorting'] ) && is_array( $parameters['sorting'] && ! isset( $parameters['sorting']['key'] ) ) ) { |
|
1385 | + if ( ! empty( $parameters[ 'sorting' ] ) && is_array( $parameters[ 'sorting' ] && ! isset( $parameters[ 'sorting' ][ 'key' ] ) ) ) { |
|
1387 | 1386 | // Pluck off multisort arrays |
1388 | - $parameters['sorting'] = $parameters['sorting'][0]; |
|
1387 | + $parameters[ 'sorting' ] = $parameters[ 'sorting' ][ 0 ]; |
|
1389 | 1388 | } |
1390 | 1389 | |
1391 | - if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
1390 | + if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
1392 | 1391 | $field = new \GV\Field(); |
1393 | - $field->ID = $parameters['sorting']['key']; |
|
1394 | - $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
1392 | + $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
1393 | + $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
1395 | 1394 | $entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
1396 | 1395 | } |
1397 | 1396 | } |
@@ -1475,7 +1474,7 @@ discard block |
||
1475 | 1474 | $allowed = $headers = array(); |
1476 | 1475 | |
1477 | 1476 | foreach ( $view->fields->by_position( "directory_*" )->by_visible( $view )->all() as $id => $field ) { |
1478 | - $allowed[] = $field; |
|
1477 | + $allowed[ ] = $field; |
|
1479 | 1478 | } |
1480 | 1479 | |
1481 | 1480 | $renderer = new Field_Renderer(); |
@@ -1497,17 +1496,17 @@ discard block |
||
1497 | 1496 | } ); |
1498 | 1497 | |
1499 | 1498 | foreach ( array_diff( $allowed_field_ids, wp_list_pluck( $allowed, 'ID' ) ) as $field_id ) { |
1500 | - $allowed[] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
1499 | + $allowed[ ] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
1501 | 1500 | } |
1502 | 1501 | |
1503 | 1502 | foreach ( $allowed as $field ) { |
1504 | 1503 | $source = is_numeric( $field->ID ) ? $view->form : new \GV\Internal_Source(); |
1505 | 1504 | |
1506 | - $return[] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
1505 | + $return[ ] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
1507 | 1506 | |
1508 | 1507 | if ( ! $headers_done ) { |
1509 | 1508 | $label = $field->get_label( $view, $source, $entry ); |
1510 | - $headers[] = $label ? $label : $field->ID; |
|
1509 | + $headers[ ] = $label ? $label : $field->ID; |
|
1511 | 1510 | } |
1512 | 1511 | } |
1513 | 1512 | |
@@ -1605,7 +1604,7 @@ discard block |
||
1605 | 1604 | * @return void |
1606 | 1605 | */ |
1607 | 1606 | public function set_anchor_id( $counter = 1 ) { |
1608 | - $this->anchor_id = sprintf( 'gv-view-%d-%d', $this->ID, (int) $counter ); |
|
1607 | + $this->anchor_id = sprintf( 'gv-view-%d-%d', $this->ID, (int)$counter ); |
|
1609 | 1608 | } |
1610 | 1609 | |
1611 | 1610 | /** |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @uses {@var $counter} |
124 | 124 | * @param Template_Context $context |
125 | 125 | */ |
126 | - add_action( 'gravityview/template/view/render', $add_anchor_id_filter = function ( $context ) use ( &$counter ) { |
|
126 | + add_action( 'gravityview/template/view/render', $add_anchor_id_filter = function( $context ) use ( &$counter ) { |
|
127 | 127 | /** @see \GV\View::set_anchor_id() */ |
128 | 128 | $context->view->set_anchor_id( $counter[ $context->view->ID ] ); |
129 | 129 | } ); |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @uses {@var View $view} |
145 | 145 | */ |
146 | - add_filter( 'gravityview/widget/search/form/action', $add_search_action_filter = function ( $action ) use ( $view ) { |
|
146 | + add_filter( 'gravityview/widget/search/form/action', $add_search_action_filter = function( $action ) use ( $view ) { |
|
147 | 147 | return $action . '#' . $view->get_anchor_id(); |
148 | 148 | } ); |
149 | 149 | } |
@@ -153,11 +153,11 @@ discard block |
||
153 | 153 | * This allows us to fake it till we make it. |
154 | 154 | */ |
155 | 155 | $parameters = $view->settings->as_atts(); |
156 | - if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) { |
|
156 | + if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) { |
|
157 | 157 | $has_multisort = true; |
158 | - $parameters['sort_field'] = reset( $parameters['sort_field'] ); |
|
159 | - if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) { |
|
160 | - $parameters['sort_direction'] = reset( $parameters['sort_direction'] ); |
|
158 | + $parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] ); |
|
159 | + if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) { |
|
160 | + $parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] ); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | 'entries' => $entries, |
173 | 173 | 'request' => $request, |
174 | 174 | ), empty( $parameters ) ? array() : array( |
175 | - 'paging' => $parameters['paging'], |
|
176 | - 'sorting' => $parameters['sorting'], |
|
175 | + 'paging' => $parameters[ 'paging' ], |
|
176 | + 'sorting' => $parameters[ 'sorting' ], |
|
177 | 177 | ), empty( $post ) ? array() : array( |
178 | 178 | 'post' => $post, |
179 | 179 | ) ) ); |