@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public static function remove() { |
78 | 78 | $shortcode = new static(); |
79 | - unset( self::$shortcodes[$shortcode->name] ); |
|
79 | + unset( self::$shortcodes[ $shortcode->name ] ); |
|
80 | 80 | remove_shortcode( $shortcode->name ); |
81 | 81 | } |
82 | 82 | |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | preg_match_all( '/' . get_shortcode_regex() . '/', $content, $matches, PREG_SET_ORDER ); |
109 | 109 | |
110 | 110 | foreach ( $matches as $shortcode ) { |
111 | - $shortcode_name = $shortcode[2]; |
|
111 | + $shortcode_name = $shortcode[ 2 ]; |
|
112 | 112 | |
113 | - $shortcode_atts = shortcode_parse_atts( $shortcode[3] ); |
|
114 | - $shortcode_content = $shortcode[5]; |
|
113 | + $shortcode_atts = shortcode_parse_atts( $shortcode[ 3 ] ); |
|
114 | + $shortcode_content = $shortcode[ 5 ]; |
|
115 | 115 | |
116 | 116 | /** This is a registered GravityView shortcode. */ |
117 | - if ( !empty( self::$shortcodes[$shortcode_name] ) ) { |
|
118 | - $shortcode = clone self::$shortcodes[$shortcode_name]; |
|
117 | + if ( ! empty( self::$shortcodes[ $shortcode_name ] ) ) { |
|
118 | + $shortcode = clone self::$shortcodes[ $shortcode_name ]; |
|
119 | 119 | } else { |
120 | 120 | /** This is some generic shortcode. */ |
121 | 121 | $shortcode = new self; |
@@ -62,7 +62,6 @@ |
||
62 | 62 | * |
63 | 63 | * Internal static cache for gets, and whatnot. |
64 | 64 | * This is not persistent, resets across requests. |
65 | - |
|
66 | 65 | * @internal |
67 | 66 | */ |
68 | 67 | private static $cache = array(); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | $slug = apply_filters( 'gravityview_slug', 'view' ); |
210 | 210 | $rule = array( sprintf( '%s/([^/]+)/csv/?', $slug ), 'index.php?gravityview=$matches[1]&csv=1', 'top' ); |
211 | 211 | |
212 | - add_filter( 'query_vars', function( $query_vars ) { |
|
212 | + add_filter( 'query_vars', function( $query_vars ) { |
|
213 | 213 | $query_vars[] = 'csv'; |
214 | 214 | return $query_vars; |
215 | 215 | } ); |
@@ -254,8 +254,9 @@ discard block |
||
254 | 254 | * Check permissions. |
255 | 255 | */ |
256 | 256 | while ( $error = $view->can_render( null, $request ) ) { |
257 | - if ( ! is_wp_error( $error ) ) |
|
258 | - break; |
|
257 | + if ( ! is_wp_error( $error ) ) { |
|
258 | + break; |
|
259 | + } |
|
259 | 260 | |
260 | 261 | switch ( str_replace( 'gravityview/', '', $error->get_error_code() ) ) { |
261 | 262 | case 'post_password_required': |
@@ -795,6 +795,7 @@ |
||
795 | 795 | * Retrieve the entries for the current view and request. |
796 | 796 | * |
797 | 797 | * @param \GV\Request The request. Unused for now. |
798 | + * @param Request $request |
|
798 | 799 | * |
799 | 800 | * @return \GV\Entry_Collection The entries. |
800 | 801 | */ |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $supports = array( 'title', 'revisions' ); |
126 | 126 | |
127 | 127 | if ( $is_hierarchical ) { |
128 | - $supports[] = 'page-attributes'; |
|
128 | + $supports[ ] = 'page-attributes'; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -227,11 +227,11 @@ discard block |
||
227 | 227 | $rule = array( sprintf( '%s/([^/]+)/csv/?', $slug ), 'index.php?gravityview=$matches[1]&csv=1', 'top' ); |
228 | 228 | |
229 | 229 | add_filter( 'query_vars', function( $query_vars ) { |
230 | - $query_vars[] = 'csv'; |
|
230 | + $query_vars[ ] = 'csv'; |
|
231 | 231 | return $query_vars; |
232 | 232 | } ); |
233 | 233 | |
234 | - if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[0] ] ) ) { |
|
234 | + if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[ 0 ] ] ) ) { |
|
235 | 235 | call_user_func_array( 'add_rewrite_rule', $rule ); |
236 | 236 | } |
237 | 237 | } |
@@ -308,13 +308,13 @@ discard block |
||
308 | 308 | return $content; |
309 | 309 | } |
310 | 310 | |
311 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
311 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
312 | 312 | |
313 | 313 | /** |
314 | 314 | * Editing a single entry. |
315 | 315 | */ |
316 | 316 | if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) { |
317 | - if ( $entry['status'] != 'active' ) { |
|
317 | + if ( $entry[ 'status' ] != 'active' ) { |
|
318 | 318 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
319 | 319 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
320 | 320 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | } |
326 | 326 | |
327 | 327 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
328 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
328 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
329 | 329 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
330 | 330 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
331 | 331 | } |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | |
349 | 349 | foreach ( $entryset as $e ) { |
350 | 350 | |
351 | - if ( 'active' !== $e['status'] ) { |
|
351 | + if ( 'active' !== $e[ 'status' ] ) { |
|
352 | 352 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $e->ID ) ); |
353 | 353 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
354 | 354 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | } |
360 | 360 | |
361 | 361 | if ( $show_only_approved && ! $is_admin_and_can_view ) { |
362 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
362 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
363 | 363 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $e->ID ) ); |
364 | 364 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
365 | 365 | } |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | $join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field::by_id( $join_column ); |
535 | 535 | $join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field::by_id( $join_on_column ); |
536 | 536 | |
537 | - $joins [] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
537 | + $joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | return $joins; |
@@ -629,13 +629,13 @@ discard block |
||
629 | 629 | } |
630 | 630 | |
631 | 631 | foreach ( $_fields as $field ) { |
632 | - if ( ! empty( $field['unions'] ) ) { |
|
633 | - foreach ( $field['unions'] as $form_id => $field_id ) { |
|
632 | + if ( ! empty( $field[ 'unions' ] ) ) { |
|
633 | + foreach ( $field[ 'unions' ] as $form_id => $field_id ) { |
|
634 | 634 | if ( ! isset( $unions[ $form_id ] ) ) { |
635 | 635 | $unions[ $form_id ] = array(); |
636 | 636 | } |
637 | 637 | |
638 | - $unions[ $form_id ][ $field['id'] ] = |
|
638 | + $unions[ $form_id ][ $field[ 'id' ] ] = |
|
639 | 639 | 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 ); |
640 | 640 | } |
641 | 641 | } |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | if ( ! $view->form ) { |
685 | 685 | gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
686 | 686 | 'view_id' => $view->ID, |
687 | - 'form_id' => $view->_gravityview_form_id ? : 0, |
|
687 | + 'form_id' => $view->_gravityview_form_id ?: 0, |
|
688 | 688 | ) ); |
689 | 689 | } |
690 | 690 | |
@@ -923,11 +923,11 @@ discard block |
||
923 | 923 | * Remove multiple sorting before calling legacy filters. |
924 | 924 | * This allows us to fake it till we make it. |
925 | 925 | */ |
926 | - if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) { |
|
926 | + if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) { |
|
927 | 927 | $has_multisort = true; |
928 | - $parameters['sort_field'] = reset( $parameters['sort_field'] ); |
|
929 | - if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) { |
|
930 | - $parameters['sort_direction'] = reset( $parameters['sort_direction'] ); |
|
928 | + $parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] ); |
|
929 | + if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) { |
|
930 | + $parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] ); |
|
931 | 931 | } |
932 | 932 | } |
933 | 933 | |
@@ -935,34 +935,33 @@ discard block |
||
935 | 935 | * @todo: Stop using _frontend and use something like $request->get_search_criteria() instead |
936 | 936 | */ |
937 | 937 | $parameters = \GravityView_frontend::get_view_entries_parameters( $parameters, $this->form->ID ); |
938 | - $parameters['context_view_id'] = $this->ID; |
|
938 | + $parameters[ 'context_view_id' ] = $this->ID; |
|
939 | 939 | $parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
940 | 940 | |
941 | 941 | if ( $request instanceof REST\Request ) { |
942 | 942 | $atts = $this->settings->as_atts(); |
943 | 943 | $paging_parameters = wp_parse_args( $request->get_paging(), array( |
944 | - 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
944 | + 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
945 | 945 | ) ); |
946 | - $parameters['paging'] = $paging_parameters['paging']; |
|
946 | + $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
947 | 947 | } |
948 | 948 | |
949 | - $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
950 | - : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 ); |
|
949 | + $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 ); |
|
951 | 950 | |
952 | 951 | /** |
953 | 952 | * Cleanup duplicate field_filter parameters to simplify the query. |
954 | 953 | */ |
955 | 954 | $unique_field_filters = array(); |
956 | - foreach ( $parameters['search_criteria']['field_filters'] as $key => $filter ) { |
|
955 | + foreach ( $parameters[ 'search_criteria' ][ 'field_filters' ] as $key => $filter ) { |
|
957 | 956 | if ( 'mode' === $key ) { |
958 | - $unique_field_filters['mode'] = $filter; |
|
957 | + $unique_field_filters[ 'mode' ] = $filter; |
|
959 | 958 | } else if ( ! in_array( $filter, $unique_field_filters ) ) { |
960 | - $unique_field_filters[] = $filter; |
|
959 | + $unique_field_filters[ ] = $filter; |
|
961 | 960 | } |
962 | 961 | } |
963 | - $parameters['search_criteria']['field_filters'] = $unique_field_filters; |
|
962 | + $parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters; |
|
964 | 963 | |
965 | - if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) { |
|
964 | + if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
966 | 965 | gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' ); |
967 | 966 | } |
968 | 967 | |
@@ -971,7 +970,7 @@ discard block |
||
971 | 970 | $query_class = $this->get_query_class(); |
972 | 971 | |
973 | 972 | /** @var \GF_Query $query */ |
974 | - $query = new $query_class( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] ); |
|
973 | + $query = new $query_class( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] ); |
|
975 | 974 | |
976 | 975 | /** |
977 | 976 | * Apply multisort. |
@@ -982,15 +981,15 @@ discard block |
||
982 | 981 | $view_setting_sort_field_ids = \GV\Utils::get( $atts, 'sort_field', array() ); |
983 | 982 | $view_setting_sort_directions = \GV\Utils::get( $atts, 'sort_direction', array() ); |
984 | 983 | |
985 | - $has_sort_query_param = ! empty( $_GET['sort'] ) && is_array( $_GET['sort'] ); |
|
984 | + $has_sort_query_param = ! empty( $_GET[ 'sort' ] ) && is_array( $_GET[ 'sort' ] ); |
|
986 | 985 | |
987 | - if( $has_sort_query_param ) { |
|
988 | - $has_sort_query_param = array_filter( array_values( $_GET['sort'] ) ); |
|
986 | + if ( $has_sort_query_param ) { |
|
987 | + $has_sort_query_param = array_filter( array_values( $_GET[ 'sort' ] ) ); |
|
989 | 988 | } |
990 | 989 | |
991 | 990 | if ( $this->settings->get( 'sort_columns' ) && $has_sort_query_param ) { |
992 | - $sort_field_ids = array_keys( $_GET['sort'] ); |
|
993 | - $sort_directions = array_values( $_GET['sort'] ); |
|
991 | + $sort_field_ids = array_keys( $_GET[ 'sort' ] ); |
|
992 | + $sort_directions = array_values( $_GET[ 'sort' ] ); |
|
994 | 993 | } else { |
995 | 994 | $sort_field_ids = $view_setting_sort_field_ids; |
996 | 995 | $sort_directions = $view_setting_sort_directions; |
@@ -998,7 +997,7 @@ discard block |
||
998 | 997 | |
999 | 998 | $skip_first = false; |
1000 | 999 | |
1001 | - foreach ( (array) $sort_field_ids as $key => $sort_field_id ) { |
|
1000 | + foreach ( (array)$sort_field_ids as $key => $sort_field_id ) { |
|
1002 | 1001 | |
1003 | 1002 | if ( ! $skip_first && ! $has_sort_query_param ) { |
1004 | 1003 | $skip_first = true; // Skip the first one, it's already in the query |
@@ -1028,15 +1027,15 @@ discard block |
||
1028 | 1027 | |
1029 | 1028 | $merged_time = false; |
1030 | 1029 | |
1031 | - foreach ( $q['order'] as $oid => $order ) { |
|
1032 | - if ( $order[0] instanceof \GF_Query_Column ) { |
|
1033 | - $column = $order[0]; |
|
1034 | - } else if ( $order[0] instanceof \GF_Query_Call ) { |
|
1035 | - if ( count( $order[0]->columns ) != 1 || ! $order[0]->columns[0] instanceof \GF_Query_Column ) { |
|
1030 | + foreach ( $q[ 'order' ] as $oid => $order ) { |
|
1031 | + if ( $order[ 0 ] instanceof \GF_Query_Column ) { |
|
1032 | + $column = $order[ 0 ]; |
|
1033 | + } else if ( $order[ 0 ] instanceof \GF_Query_Call ) { |
|
1034 | + if ( count( $order[ 0 ]->columns ) != 1 || ! $order[ 0 ]->columns[ 0 ] instanceof \GF_Query_Column ) { |
|
1036 | 1035 | $orders[ $oid ] = $order; |
1037 | 1036 | continue; // Need something that resembles a single sort |
1038 | 1037 | } |
1039 | - $column = $order[0]->columns[0]; |
|
1038 | + $column = $order[ 0 ]->columns[ 0 ]; |
|
1040 | 1039 | } |
1041 | 1040 | |
1042 | 1041 | if ( ( ! $field = \GFAPI::get_field( $column->source, $column->field_id ) ) || $field->type !== 'time' ) { |
@@ -1050,7 +1049,7 @@ discard block |
||
1050 | 1049 | |
1051 | 1050 | $orders[ $oid ] = array( |
1052 | 1051 | new \GV\Mocks\GF_Query_Call_TIMESORT( 'timesort', array( $column, $sql ) ), |
1053 | - $order[1] // Mock it! |
|
1052 | + $order[ 1 ] // Mock it! |
|
1054 | 1053 | ); |
1055 | 1054 | |
1056 | 1055 | $merged_time = true; |
@@ -1061,15 +1060,15 @@ discard block |
||
1061 | 1060 | * ORDER again. |
1062 | 1061 | */ |
1063 | 1062 | if ( ! empty( $orders ) && $_orders = $query->_order_generate( $orders ) ) { |
1064 | - $sql['order'] = 'ORDER BY ' . implode( ', ', $_orders ); |
|
1063 | + $sql[ 'order' ] = 'ORDER BY ' . implode( ', ', $_orders ); |
|
1065 | 1064 | } |
1066 | 1065 | } |
1067 | 1066 | |
1068 | 1067 | return $sql; |
1069 | 1068 | } ); |
1070 | 1069 | |
1071 | - $query->limit( $parameters['paging']['page_size'] ) |
|
1072 | - ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
1070 | + $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
1071 | + ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
1073 | 1072 | |
1074 | 1073 | /** |
1075 | 1074 | * Any joins? |
@@ -1092,7 +1091,7 @@ discard block |
||
1092 | 1091 | |
1093 | 1092 | $query_parameters = $query->_introspect(); |
1094 | 1093 | |
1095 | - $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
1094 | + $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
1096 | 1095 | } |
1097 | 1096 | |
1098 | 1097 | /** |
@@ -1126,7 +1125,7 @@ discard block |
||
1126 | 1125 | } |
1127 | 1126 | |
1128 | 1127 | $q = $query->_introspect(); |
1129 | - $query->where( \GF_Query_Condition::_and( $q['where'], $condition ) ); |
|
1128 | + $query->where( \GF_Query_Condition::_and( $q[ 'where' ], $condition ) ); |
|
1130 | 1129 | |
1131 | 1130 | if ( $this->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
1132 | 1131 | |
@@ -1151,7 +1150,7 @@ discard block |
||
1151 | 1150 | |
1152 | 1151 | $query_parameters = $query->_introspect(); |
1153 | 1152 | |
1154 | - $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
1153 | + $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
1155 | 1154 | } |
1156 | 1155 | } |
1157 | 1156 | |
@@ -1175,7 +1174,7 @@ discard block |
||
1175 | 1174 | $conditions = array(); |
1176 | 1175 | |
1177 | 1176 | foreach ( $condition->expressions as $_condition ) { |
1178 | - $conditions[] = $recurse( $_condition, $fields, $recurse ); |
|
1177 | + $conditions[ ] = $recurse( $_condition, $fields, $recurse ); |
|
1179 | 1178 | } |
1180 | 1179 | |
1181 | 1180 | return call_user_func_array( |
@@ -1204,10 +1203,10 @@ discard block |
||
1204 | 1203 | $q = new $query_class( $form_id ); |
1205 | 1204 | |
1206 | 1205 | // Copy the WHERE clauses but substitute the field_ids to the respective ones |
1207 | - $q->where( $where_union_substitute( $query_parameters['where'], $fields, $where_union_substitute ) ); |
|
1206 | + $q->where( $where_union_substitute( $query_parameters[ 'where' ], $fields, $where_union_substitute ) ); |
|
1208 | 1207 | |
1209 | 1208 | // Copy the ORDER clause and substitute the field_ids to the respective ones |
1210 | - foreach ( $query_parameters['order'] as $order ) { |
|
1209 | + foreach ( $query_parameters[ 'order' ] as $order ) { |
|
1211 | 1210 | list( $column, $_order ) = $order; |
1212 | 1211 | |
1213 | 1212 | if ( $column && $column instanceof \GF_Query_Column ) { |
@@ -1221,15 +1220,15 @@ discard block |
||
1221 | 1220 | |
1222 | 1221 | add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( &$unions_sql ) { |
1223 | 1222 | // Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
1224 | - $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
1223 | + $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
1225 | 1224 | |
1226 | 1225 | // Record the SQL |
1227 | - $unions_sql[] = array( |
|
1226 | + $unions_sql[ ] = array( |
|
1228 | 1227 | // Remove columns, we'll rebuild them |
1229 | 1228 | 'select' => preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $select ), |
1230 | - 'from' => $sql['from'], |
|
1231 | - 'join' => $sql['join'], |
|
1232 | - 'where' => $sql['where'], |
|
1229 | + 'from' => $sql[ 'from' ], |
|
1230 | + 'join' => $sql[ 'join' ], |
|
1231 | + 'where' => $sql[ 'where' ], |
|
1233 | 1232 | // Remove order and limit |
1234 | 1233 | ); |
1235 | 1234 | |
@@ -1246,11 +1245,11 @@ discard block |
||
1246 | 1245 | |
1247 | 1246 | add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( $unions_sql ) { |
1248 | 1247 | // Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
1249 | - $sql['select'] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
1248 | + $sql[ 'select' ] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
1250 | 1249 | |
1251 | 1250 | // Remove columns, we'll rebuild them |
1252 | - preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql['select'], $select_match ); |
|
1253 | - $sql['select'] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql['select'] ); |
|
1251 | + preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql[ 'select' ], $select_match ); |
|
1252 | + $sql[ 'select' ] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql[ 'select' ] ); |
|
1254 | 1253 | |
1255 | 1254 | $unions = array(); |
1256 | 1255 | |
@@ -1261,30 +1260,30 @@ discard block |
||
1261 | 1260 | }; |
1262 | 1261 | |
1263 | 1262 | // Add all the order columns into the selects, so we can order by the whole union group |
1264 | - preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql['order'], $order_matches ); |
|
1263 | + preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql[ 'order' ], $order_matches ); |
|
1265 | 1264 | |
1266 | 1265 | $columns = array( |
1267 | - sprintf( '%s AS %s', $select_match[1], $column_to_alias( $select_match[1] ) ) |
|
1266 | + sprintf( '%s AS %s', $select_match[ 1 ], $column_to_alias( $select_match[ 1 ] ) ) |
|
1268 | 1267 | ); |
1269 | 1268 | |
1270 | 1269 | foreach ( array_slice( $order_matches, 1 ) as $match ) { |
1271 | - $columns[] = sprintf( '%s AS %s', $match[0], $column_to_alias( $match[0] ) ); |
|
1270 | + $columns[ ] = sprintf( '%s AS %s', $match[ 0 ], $column_to_alias( $match[ 0 ] ) ); |
|
1272 | 1271 | |
1273 | 1272 | // Rewrite the order columns to the shared aliases |
1274 | - $sql['order'] = str_replace( $match[0], $column_to_alias( $match[0] ), $sql['order'] ); |
|
1273 | + $sql[ 'order' ] = str_replace( $match[ 0 ], $column_to_alias( $match[ 0 ] ), $sql[ 'order' ] ); |
|
1275 | 1274 | } |
1276 | 1275 | |
1277 | 1276 | $columns = array_unique( $columns ); |
1278 | 1277 | |
1279 | 1278 | // Add the columns to every UNION |
1280 | 1279 | foreach ( $unions_sql as $union_sql ) { |
1281 | - $union_sql['select'] .= implode( ', ', $columns ); |
|
1282 | - $unions []= implode( ' ', $union_sql ); |
|
1280 | + $union_sql[ 'select' ] .= implode( ', ', $columns ); |
|
1281 | + $unions [ ] = implode( ' ', $union_sql ); |
|
1283 | 1282 | } |
1284 | 1283 | |
1285 | 1284 | // Add the columns to the main SELECT, but only grab the entry id column |
1286 | - $sql['select'] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql['select'] . implode( ', ', $columns ); |
|
1287 | - $sql['order'] = implode( ' ', $unions ) . ') AS u ' . $sql['order']; |
|
1285 | + $sql[ 'select' ] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql[ 'select' ] . implode( ', ', $columns ); |
|
1286 | + $sql[ 'order' ] = implode( ' ', $unions ) . ') AS u ' . $sql[ 'order' ]; |
|
1288 | 1287 | |
1289 | 1288 | return $sql; |
1290 | 1289 | } ); |
@@ -1329,20 +1328,20 @@ discard block |
||
1329 | 1328 | } ); |
1330 | 1329 | } else { |
1331 | 1330 | $entries = $this->form->entries |
1332 | - ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
1331 | + ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
1333 | 1332 | ->offset( $this->settings->get( 'offset' ) ) |
1334 | - ->limit( $parameters['paging']['page_size'] ) |
|
1333 | + ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
1335 | 1334 | ->page( $page ); |
1336 | 1335 | |
1337 | - if ( ! empty( $parameters['sorting'] ) && is_array( $parameters['sorting'] && ! isset( $parameters['sorting']['key'] ) ) ) { |
|
1336 | + if ( ! empty( $parameters[ 'sorting' ] ) && is_array( $parameters[ 'sorting' ] && ! isset( $parameters[ 'sorting' ][ 'key' ] ) ) ) { |
|
1338 | 1337 | // Pluck off multisort arrays |
1339 | - $parameters['sorting'] = $parameters['sorting'][0]; |
|
1338 | + $parameters[ 'sorting' ] = $parameters[ 'sorting' ][ 0 ]; |
|
1340 | 1339 | } |
1341 | 1340 | |
1342 | - if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
1341 | + if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
1343 | 1342 | $field = new \GV\Field(); |
1344 | - $field->ID = $parameters['sorting']['key']; |
|
1345 | - $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
1343 | + $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
1344 | + $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
1346 | 1345 | $entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
1347 | 1346 | } |
1348 | 1347 | } |
@@ -1417,7 +1416,7 @@ discard block |
||
1417 | 1416 | $allowed = $headers = array(); |
1418 | 1417 | |
1419 | 1418 | foreach ( $view->fields->by_position( "directory_*" )->by_visible( $view )->all() as $id => $field ) { |
1420 | - $allowed[] = $field; |
|
1419 | + $allowed[ ] = $field; |
|
1421 | 1420 | } |
1422 | 1421 | |
1423 | 1422 | $renderer = new Field_Renderer(); |
@@ -1439,17 +1438,17 @@ discard block |
||
1439 | 1438 | } ); |
1440 | 1439 | |
1441 | 1440 | foreach ( array_diff( $allowed_field_ids, wp_list_pluck( $allowed, 'ID' ) ) as $field_id ) { |
1442 | - $allowed[] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
1441 | + $allowed[ ] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
1443 | 1442 | } |
1444 | 1443 | |
1445 | 1444 | foreach ( $allowed as $field ) { |
1446 | 1445 | $source = is_numeric( $field->ID ) ? $view->form : new \GV\Internal_Source(); |
1447 | 1446 | |
1448 | - $return[] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
1447 | + $return[ ] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
1449 | 1448 | |
1450 | 1449 | if ( ! $headers_done ) { |
1451 | 1450 | $label = $field->get_label( $view, $source, $entry ); |
1452 | - $headers[] = $label ? $label : $field->ID; |
|
1451 | + $headers[ ] = $label ? $label : $field->ID; |
|
1453 | 1452 | } |
1454 | 1453 | } |
1455 | 1454 |
@@ -163,14 +163,14 @@ |
||
163 | 163 | return $settings; |
164 | 164 | } |
165 | 165 | |
166 | - /** |
|
166 | + /** |
|
167 | 167 | * Get the Widget ID. |
168 | 168 | * |
169 | - * @return string The Widget ID. |
|
170 | - */ |
|
171 | - public function get_widget_id() { |
|
172 | - return $this->widget_id; |
|
173 | - } |
|
169 | + * @return string The Widget ID. |
|
170 | + */ |
|
171 | + public function get_widget_id() { |
|
172 | + return $this->widget_id; |
|
173 | + } |
|
174 | 174 | |
175 | 175 | /** |
176 | 176 | * Get the widget settings |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | $enable_custom_class = apply_filters( 'gravityview/widget/enable_custom_class', false, $this ); |
152 | 152 | |
153 | 153 | if ( $enable_custom_class ) { |
154 | - $settings['custom_class'] = array( |
|
154 | + $settings[ 'custom_class' ] = array( |
|
155 | 155 | 'type' => 'text', |
156 | 156 | 'label' => __( 'Custom CSS Class:', 'gravityview' ), |
157 | 157 | 'desc' => __( 'This class will be added to the widget container', 'gravityview' ), |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public static function get_default_widget_areas() { |
205 | 205 | $default_areas = array( |
206 | - array( '1-1' => array( array( 'areaid' => 'top', 'title' => __( 'Top', 'gravityview' ) , 'subtitle' => '' ) ) ), |
|
207 | - array( '1-2' => array( array( 'areaid' => 'left', 'title' => __( 'Left', 'gravityview' ) , 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __( 'Right', 'gravityview' ) , 'subtitle' => '' ) ) ), |
|
206 | + array( '1-1' => array( array( 'areaid' => 'top', 'title' => __( 'Top', 'gravityview' ), 'subtitle' => '' ) ) ), |
|
207 | + array( '1-2' => array( array( 'areaid' => 'left', 'title' => __( 'Left', 'gravityview' ), 'subtitle' => '' ) ), '2-2' => array( array( 'areaid' => 'right', 'title' => __( 'Right', 'gravityview' ), 'subtitle' => '' ) ) ), |
|
208 | 208 | ); |
209 | 209 | |
210 | 210 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | } |
235 | 235 | |
236 | 236 | $widgets[ $this->get_widget_id() ] = array( |
237 | - 'label' => $this->widget_label , |
|
237 | + 'label' => $this->widget_label, |
|
238 | 238 | 'description' => $this->widget_description, |
239 | 239 | 'subtitle' => $this->widget_subtitle, |
240 | 240 | 'class' => get_called_class(), |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public function assign_widget_options( $options = array(), $template = '', $widget = '' ) { |
257 | 257 | if ( $this->get_widget_id() === $widget ) { |
258 | - if( $settings = $this->get_settings() ) { |
|
258 | + if ( $settings = $this->get_settings() ) { |
|
259 | 259 | $options = array_merge( $options, $settings ); |
260 | 260 | } |
261 | 261 | } |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | return; |
307 | 307 | } |
308 | 308 | |
309 | - add_shortcode( $this->shortcode_name, array( $this, 'render_shortcode') ); |
|
309 | + add_shortcode( $this->shortcode_name, array( $this, 'render_shortcode' ) ); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | /** |
@@ -393,7 +393,7 @@ |
||
393 | 393 | * @internal |
394 | 394 | * @since 2.0 |
395 | 395 | * |
396 | - * @return \GV\Widget|null The widget implementation from configuration or none. |
|
396 | + * @return Widget The widget implementation from configuration or none. |
|
397 | 397 | */ |
398 | 398 | public static function from_configuration( $configuration ) { |
399 | 399 | $registered_widgets = self::registered(); |
@@ -34,7 +34,7 @@ |
||
34 | 34 | global $post; |
35 | 35 | |
36 | 36 | if ( $post ) { |
37 | - $context['post'] = $post; |
|
37 | + $context[ 'post' ] = $post; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | \GV\Mocks\Legacy_Context::push( $context ); |
@@ -113,14 +113,14 @@ |
||
113 | 113 | |
114 | 114 | /** Require critical legacy core files. @todo Deprecate */ |
115 | 115 | require_once $this->plugin->dir( 'includes/helper-functions.php' ); |
116 | - require_once $this->plugin->dir( 'includes/class-common.php'); |
|
117 | - require_once $this->plugin->dir( 'includes/connector-functions.php'); |
|
116 | + require_once $this->plugin->dir( 'includes/class-common.php' ); |
|
117 | + require_once $this->plugin->dir( 'includes/connector-functions.php' ); |
|
118 | 118 | require_once $this->plugin->dir( 'includes/class-gravityview-compatibility.php' ); |
119 | 119 | require_once $this->plugin->dir( 'includes/class-gravityview-roles-capabilities.php' ); |
120 | 120 | require_once $this->plugin->dir( 'includes/class-gravityview-admin-notices.php' ); |
121 | 121 | require_once $this->plugin->dir( 'includes/class-admin.php' ); |
122 | - require_once $this->plugin->dir( 'includes/class-post-types.php'); |
|
123 | - require_once $this->plugin->dir( 'includes/class-cache.php'); |
|
122 | + require_once $this->plugin->dir( 'includes/class-post-types.php' ); |
|
123 | + require_once $this->plugin->dir( 'includes/class-cache.php' ); |
|
124 | 124 | |
125 | 125 | /** |
126 | 126 | * GravityView extensions and widgets. |
@@ -78,7 +78,7 @@ |
||
78 | 78 | if ( $this->field ) { |
79 | 79 | return array( |
80 | 80 | 'key' => $this->field->ID, |
81 | - 'direction' => $this->direction ? : self::ASC, |
|
81 | + 'direction' => $this->direction ?: self::ASC, |
|
82 | 82 | 'is_numeric' => self::ALPHA ? true : false, |
83 | 83 | ); |
84 | 84 | } |
@@ -50,8 +50,8 @@ |
||
50 | 50 | /** |
51 | 51 | * By array. |
52 | 52 | */ |
53 | - if ( is_array( $view ) && ! empty( $view['id'] ) ) { |
|
54 | - return $this->get( $view['id'] ); |
|
53 | + if ( is_array( $view ) && ! empty( $view[ 'id' ] ) ) { |
|
54 | + return $this->get( $view[ 'id' ] ); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | ) ); |
267 | 267 | |
268 | 268 | if ( version_compare( \GFCommon::$version, '2.3-beta-4', '>=' ) ) { |
269 | - $default_settings['sort_direction']['options']['RAND'] = __( 'Random', 'gravityview' ); |
|
269 | + $default_settings[ 'sort_direction' ][ 'options' ][ 'RAND' ] = __( 'Random', 'gravityview' ); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -286,8 +286,8 @@ discard block |
||
286 | 286 | // By default, we only want the key => value pairing, not the whole array. |
287 | 287 | if ( ! $detailed ) { |
288 | 288 | $defaults = array(); |
289 | - foreach( $default_settings as $key => $value ) { |
|
290 | - $defaults[ $key ] = $value['value']; |
|
289 | + foreach ( $default_settings as $key => $value ) { |
|
290 | + $defaults[ $key ] = $value[ 'value' ]; |
|
291 | 291 | } |
292 | 292 | return $defaults; |
293 | 293 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | // If the $group argument is set for the method, |
299 | 299 | // ignore any settings that aren't in that group. |
300 | 300 | if ( ! empty( $group ) && is_string( $group ) ) { |
301 | - if ( empty( $value['group'] ) || $value['group'] !== $group ) { |
|
301 | + if ( empty( $value[ 'group' ] ) || $value[ 'group' ] !== $group ) { |
|
302 | 302 | unset( $default_settings[ $key ] ); |
303 | 303 | } |
304 | 304 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | require_once gravityview()->plugin->dir( 'future/includes/rest/class-gv-rest-route.php' ); |
22 | 22 | require_once gravityview()->plugin->dir( 'future/includes/rest/class-gv-rest-views-route.php' ); |
23 | 23 | |
24 | - self::$routes['views'] = $views = new Views_Route(); |
|
24 | + self::$routes[ 'views' ] = $views = new Views_Route(); |
|
25 | 25 | $views->register_routes(); |
26 | 26 | } |
27 | 27 |