@@ -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 | } |
@@ -300,13 +300,13 @@ discard block |
||
300 | 300 | return $content; |
301 | 301 | } |
302 | 302 | |
303 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
303 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
304 | 304 | |
305 | 305 | /** |
306 | 306 | * Editing a single entry. |
307 | 307 | */ |
308 | 308 | if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) { |
309 | - if ( $entry['status'] != 'active' ) { |
|
309 | + if ( $entry[ 'status' ] != 'active' ) { |
|
310 | 310 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
311 | 311 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
312 | 312 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | } |
318 | 318 | |
319 | 319 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
320 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
320 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
321 | 321 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
322 | 322 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
323 | 323 | } |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | |
341 | 341 | foreach ( $entryset as $e ) { |
342 | 342 | |
343 | - if ( 'active' !== $e['status'] ) { |
|
343 | + if ( 'active' !== $e[ 'status' ] ) { |
|
344 | 344 | gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $e->ID ) ); |
345 | 345 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
346 | 346 | } |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | } |
352 | 352 | |
353 | 353 | if ( $show_only_approved && ! $is_admin_and_can_view ) { |
354 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
354 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
355 | 355 | gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $e->ID ) ); |
356 | 356 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
357 | 357 | } |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | $join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field::by_id( $join_column ); |
527 | 527 | $join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field::by_id( $join_on_column ); |
528 | 528 | |
529 | - $joins [] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
529 | + $joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | return $joins; |
@@ -621,13 +621,13 @@ discard block |
||
621 | 621 | } |
622 | 622 | |
623 | 623 | foreach ( $_fields as $field ) { |
624 | - if ( ! empty( $field['unions'] ) ) { |
|
625 | - foreach ( $field['unions'] as $form_id => $field_id ) { |
|
624 | + if ( ! empty( $field[ 'unions' ] ) ) { |
|
625 | + foreach ( $field[ 'unions' ] as $form_id => $field_id ) { |
|
626 | 626 | if ( ! isset( $unions[ $form_id ] ) ) { |
627 | 627 | $unions[ $form_id ] = array(); |
628 | 628 | } |
629 | 629 | |
630 | - $unions[ $form_id ][ $field['id'] ] = |
|
630 | + $unions[ $form_id ][ $field[ 'id' ] ] = |
|
631 | 631 | 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 ); |
632 | 632 | } |
633 | 633 | } |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | if ( ! $view->form ) { |
677 | 677 | gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
678 | 678 | 'view_id' => $view->ID, |
679 | - 'form_id' => $view->_gravityview_form_id ? : 0, |
|
679 | + 'form_id' => $view->_gravityview_form_id ?: 0, |
|
680 | 680 | ) ); |
681 | 681 | } |
682 | 682 | |
@@ -915,11 +915,11 @@ discard block |
||
915 | 915 | * Remove multiple sorting before calling legacy filters. |
916 | 916 | * This allows us to fake it till we make it. |
917 | 917 | */ |
918 | - if ( ! empty( $parameters['sort_field'] ) && is_array( $parameters['sort_field'] ) ) { |
|
918 | + if ( ! empty( $parameters[ 'sort_field' ] ) && is_array( $parameters[ 'sort_field' ] ) ) { |
|
919 | 919 | $has_multisort = true; |
920 | - $parameters['sort_field'] = reset( $parameters['sort_field'] ); |
|
921 | - if ( ! empty( $parameters['sort_direction'] ) && is_array( $parameters['sort_direction'] ) ) { |
|
922 | - $parameters['sort_direction'] = reset( $parameters['sort_direction'] ); |
|
920 | + $parameters[ 'sort_field' ] = reset( $parameters[ 'sort_field' ] ); |
|
921 | + if ( ! empty( $parameters[ 'sort_direction' ] ) && is_array( $parameters[ 'sort_direction' ] ) ) { |
|
922 | + $parameters[ 'sort_direction' ] = reset( $parameters[ 'sort_direction' ] ); |
|
923 | 923 | } |
924 | 924 | } |
925 | 925 | |
@@ -927,34 +927,33 @@ discard block |
||
927 | 927 | * @todo: Stop using _frontend and use something like $request->get_search_criteria() instead |
928 | 928 | */ |
929 | 929 | $parameters = \GravityView_frontend::get_view_entries_parameters( $parameters, $this->form->ID ); |
930 | - $parameters['context_view_id'] = $this->ID; |
|
930 | + $parameters[ 'context_view_id' ] = $this->ID; |
|
931 | 931 | $parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
932 | 932 | |
933 | 933 | if ( $request instanceof REST\Request ) { |
934 | 934 | $atts = $this->settings->as_atts(); |
935 | 935 | $paging_parameters = wp_parse_args( $request->get_paging(), array( |
936 | - 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
936 | + 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
937 | 937 | ) ); |
938 | - $parameters['paging'] = $paging_parameters['paging']; |
|
938 | + $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
939 | 939 | } |
940 | 940 | |
941 | - $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
942 | - : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 ); |
|
941 | + $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 ); |
|
943 | 942 | |
944 | 943 | /** |
945 | 944 | * Cleanup duplicate field_filter parameters to simplify the query. |
946 | 945 | */ |
947 | 946 | $unique_field_filters = array(); |
948 | - foreach ( $parameters['search_criteria']['field_filters'] as $key => $filter ) { |
|
947 | + foreach ( $parameters[ 'search_criteria' ][ 'field_filters' ] as $key => $filter ) { |
|
949 | 948 | if ( 'mode' === $key ) { |
950 | - $unique_field_filters['mode'] = $filter; |
|
949 | + $unique_field_filters[ 'mode' ] = $filter; |
|
951 | 950 | } else if ( ! in_array( $filter, $unique_field_filters ) ) { |
952 | - $unique_field_filters[] = $filter; |
|
951 | + $unique_field_filters[ ] = $filter; |
|
953 | 952 | } |
954 | 953 | } |
955 | - $parameters['search_criteria']['field_filters'] = $unique_field_filters; |
|
954 | + $parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters; |
|
956 | 955 | |
957 | - if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) { |
|
956 | + if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
958 | 957 | gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' ); |
959 | 958 | } |
960 | 959 | |
@@ -963,7 +962,7 @@ discard block |
||
963 | 962 | $query_class = $this->get_query_class(); |
964 | 963 | |
965 | 964 | /** @var \GF_Query $query */ |
966 | - $query = new $query_class( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] ); |
|
965 | + $query = new $query_class( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] ); |
|
967 | 966 | |
968 | 967 | /** |
969 | 968 | * Apply multisort. |
@@ -974,15 +973,15 @@ discard block |
||
974 | 973 | $view_setting_sort_field_ids = \GV\Utils::get( $atts, 'sort_field', array() ); |
975 | 974 | $view_setting_sort_directions = \GV\Utils::get( $atts, 'sort_direction', array() ); |
976 | 975 | |
977 | - $has_sort_query_param = ! empty( $_GET['sort'] ) && is_array( $_GET['sort'] ); |
|
976 | + $has_sort_query_param = ! empty( $_GET[ 'sort' ] ) && is_array( $_GET[ 'sort' ] ); |
|
978 | 977 | |
979 | - if( $has_sort_query_param ) { |
|
980 | - $has_sort_query_param = array_filter( array_values( $_GET['sort'] ) ); |
|
978 | + if ( $has_sort_query_param ) { |
|
979 | + $has_sort_query_param = array_filter( array_values( $_GET[ 'sort' ] ) ); |
|
981 | 980 | } |
982 | 981 | |
983 | 982 | if ( $this->settings->get( 'sort_columns' ) && $has_sort_query_param ) { |
984 | - $sort_field_ids = array_keys( $_GET['sort'] ); |
|
985 | - $sort_directions = array_values( $_GET['sort'] ); |
|
983 | + $sort_field_ids = array_keys( $_GET[ 'sort' ] ); |
|
984 | + $sort_directions = array_values( $_GET[ 'sort' ] ); |
|
986 | 985 | } else { |
987 | 986 | $sort_field_ids = $view_setting_sort_field_ids; |
988 | 987 | $sort_directions = $view_setting_sort_directions; |
@@ -990,7 +989,7 @@ discard block |
||
990 | 989 | |
991 | 990 | $skip_first = false; |
992 | 991 | |
993 | - foreach ( (array) $sort_field_ids as $key => $sort_field_id ) { |
|
992 | + foreach ( (array)$sort_field_ids as $key => $sort_field_id ) { |
|
994 | 993 | |
995 | 994 | if ( ! $skip_first && ! $has_sort_query_param ) { |
996 | 995 | $skip_first = true; // Skip the first one, it's already in the query |
@@ -1011,8 +1010,8 @@ discard block |
||
1011 | 1010 | } |
1012 | 1011 | } |
1013 | 1012 | |
1014 | - $query->limit( $parameters['paging']['page_size'] ) |
|
1015 | - ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
1013 | + $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
1014 | + ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
1016 | 1015 | |
1017 | 1016 | /** |
1018 | 1017 | * Any joins? |
@@ -1035,7 +1034,7 @@ discard block |
||
1035 | 1034 | |
1036 | 1035 | $query_parameters = $query->_introspect(); |
1037 | 1036 | |
1038 | - $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
1037 | + $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
1039 | 1038 | } |
1040 | 1039 | |
1041 | 1040 | /** |
@@ -1069,7 +1068,7 @@ discard block |
||
1069 | 1068 | } |
1070 | 1069 | |
1071 | 1070 | $q = $query->_introspect(); |
1072 | - $query->where( \GF_Query_Condition::_and( $q['where'], $condition ) ); |
|
1071 | + $query->where( \GF_Query_Condition::_and( $q[ 'where' ], $condition ) ); |
|
1073 | 1072 | |
1074 | 1073 | if ( $this->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
1075 | 1074 | |
@@ -1094,7 +1093,7 @@ discard block |
||
1094 | 1093 | |
1095 | 1094 | $query_parameters = $query->_introspect(); |
1096 | 1095 | |
1097 | - $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
1096 | + $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
1098 | 1097 | } |
1099 | 1098 | } |
1100 | 1099 | |
@@ -1118,7 +1117,7 @@ discard block |
||
1118 | 1117 | $conditions = array(); |
1119 | 1118 | |
1120 | 1119 | foreach ( $condition->expressions as $_condition ) { |
1121 | - $conditions[] = $recurse( $_condition, $fields, $recurse ); |
|
1120 | + $conditions[ ] = $recurse( $_condition, $fields, $recurse ); |
|
1122 | 1121 | } |
1123 | 1122 | |
1124 | 1123 | return call_user_func_array( |
@@ -1147,10 +1146,10 @@ discard block |
||
1147 | 1146 | $q = new $query_class( $form_id ); |
1148 | 1147 | |
1149 | 1148 | // Copy the WHERE clauses but substitute the field_ids to the respective ones |
1150 | - $q->where( $where_union_substitute( $query_parameters['where'], $fields, $where_union_substitute ) ); |
|
1149 | + $q->where( $where_union_substitute( $query_parameters[ 'where' ], $fields, $where_union_substitute ) ); |
|
1151 | 1150 | |
1152 | 1151 | // Copy the ORDER clause and substitute the field_ids to the respective ones |
1153 | - foreach ( $query_parameters['order'] as $order ) { |
|
1152 | + foreach ( $query_parameters[ 'order' ] as $order ) { |
|
1154 | 1153 | list( $column, $_order ) = $order; |
1155 | 1154 | |
1156 | 1155 | if ( $column && $column instanceof \GF_Query_Column ) { |
@@ -1164,15 +1163,15 @@ discard block |
||
1164 | 1163 | |
1165 | 1164 | add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( &$unions_sql ) { |
1166 | 1165 | // Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
1167 | - $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
1166 | + $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
1168 | 1167 | |
1169 | 1168 | // Record the SQL |
1170 | - $unions_sql[] = array( |
|
1169 | + $unions_sql[ ] = array( |
|
1171 | 1170 | // Remove columns, we'll rebuild them |
1172 | 1171 | 'select' => preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $select ), |
1173 | - 'from' => $sql['from'], |
|
1174 | - 'join' => $sql['join'], |
|
1175 | - 'where' => $sql['where'], |
|
1172 | + 'from' => $sql[ 'from' ], |
|
1173 | + 'join' => $sql[ 'join' ], |
|
1174 | + 'where' => $sql[ 'where' ], |
|
1176 | 1175 | // Remove order and limit |
1177 | 1176 | ); |
1178 | 1177 | |
@@ -1189,11 +1188,11 @@ discard block |
||
1189 | 1188 | |
1190 | 1189 | add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( $unions_sql ) { |
1191 | 1190 | // Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
1192 | - $sql['select'] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
1191 | + $sql[ 'select' ] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
1193 | 1192 | |
1194 | 1193 | // Remove columns, we'll rebuild them |
1195 | - preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql['select'], $select_match ); |
|
1196 | - $sql['select'] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql['select'] ); |
|
1194 | + preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql[ 'select' ], $select_match ); |
|
1195 | + $sql[ 'select' ] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql[ 'select' ] ); |
|
1197 | 1196 | |
1198 | 1197 | $unions = array(); |
1199 | 1198 | |
@@ -1204,30 +1203,30 @@ discard block |
||
1204 | 1203 | }; |
1205 | 1204 | |
1206 | 1205 | // Add all the order columns into the selects, so we can order by the whole union group |
1207 | - preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql['order'], $order_matches ); |
|
1206 | + preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql[ 'order' ], $order_matches ); |
|
1208 | 1207 | |
1209 | 1208 | $columns = array( |
1210 | - sprintf( '%s AS %s', $select_match[1], $column_to_alias( $select_match[1] ) ) |
|
1209 | + sprintf( '%s AS %s', $select_match[ 1 ], $column_to_alias( $select_match[ 1 ] ) ) |
|
1211 | 1210 | ); |
1212 | 1211 | |
1213 | 1212 | foreach ( array_slice( $order_matches, 1 ) as $match ) { |
1214 | - $columns[] = sprintf( '%s AS %s', $match[0], $column_to_alias( $match[0] ) ); |
|
1213 | + $columns[ ] = sprintf( '%s AS %s', $match[ 0 ], $column_to_alias( $match[ 0 ] ) ); |
|
1215 | 1214 | |
1216 | 1215 | // Rewrite the order columns to the shared aliases |
1217 | - $sql['order'] = str_replace( $match[0], $column_to_alias( $match[0] ), $sql['order'] ); |
|
1216 | + $sql[ 'order' ] = str_replace( $match[ 0 ], $column_to_alias( $match[ 0 ] ), $sql[ 'order' ] ); |
|
1218 | 1217 | } |
1219 | 1218 | |
1220 | 1219 | $columns = array_unique( $columns ); |
1221 | 1220 | |
1222 | 1221 | // Add the columns to every UNION |
1223 | 1222 | foreach ( $unions_sql as $union_sql ) { |
1224 | - $union_sql['select'] .= implode( ', ', $columns ); |
|
1225 | - $unions []= implode( ' ', $union_sql ); |
|
1223 | + $union_sql[ 'select' ] .= implode( ', ', $columns ); |
|
1224 | + $unions [ ] = implode( ' ', $union_sql ); |
|
1226 | 1225 | } |
1227 | 1226 | |
1228 | 1227 | // Add the columns to the main SELECT, but only grab the entry id column |
1229 | - $sql['select'] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql['select'] . implode( ', ', $columns ); |
|
1230 | - $sql['order'] = implode( ' ', $unions ) . ') AS u ' . $sql['order']; |
|
1228 | + $sql[ 'select' ] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql[ 'select' ] . implode( ', ', $columns ); |
|
1229 | + $sql[ 'order' ] = implode( ' ', $unions ) . ') AS u ' . $sql[ 'order' ]; |
|
1231 | 1230 | |
1232 | 1231 | return $sql; |
1233 | 1232 | } ); |
@@ -1268,20 +1267,20 @@ discard block |
||
1268 | 1267 | } ); |
1269 | 1268 | } else { |
1270 | 1269 | $entries = $this->form->entries |
1271 | - ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
1270 | + ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
1272 | 1271 | ->offset( $this->settings->get( 'offset' ) ) |
1273 | - ->limit( $parameters['paging']['page_size'] ) |
|
1272 | + ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
1274 | 1273 | ->page( $page ); |
1275 | 1274 | |
1276 | - if ( ! empty( $parameters['sorting'] ) && is_array( $parameters['sorting'] && ! isset( $parameters['sorting']['key'] ) ) ) { |
|
1275 | + if ( ! empty( $parameters[ 'sorting' ] ) && is_array( $parameters[ 'sorting' ] && ! isset( $parameters[ 'sorting' ][ 'key' ] ) ) ) { |
|
1277 | 1276 | // Pluck off multisort arrays |
1278 | - $parameters['sorting'] = $parameters['sorting'][0]; |
|
1277 | + $parameters[ 'sorting' ] = $parameters[ 'sorting' ][ 0 ]; |
|
1279 | 1278 | } |
1280 | 1279 | |
1281 | - if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
1280 | + if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
1282 | 1281 | $field = new \GV\Field(); |
1283 | - $field->ID = $parameters['sorting']['key']; |
|
1284 | - $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
1282 | + $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
1283 | + $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
1285 | 1284 | $entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
1286 | 1285 | } |
1287 | 1286 | } |
@@ -1356,7 +1355,7 @@ discard block |
||
1356 | 1355 | $allowed = $headers = array(); |
1357 | 1356 | |
1358 | 1357 | foreach ( $view->fields->by_position( "directory_*" )->by_visible()->all() as $id => $field ) { |
1359 | - $allowed[] = $field; |
|
1358 | + $allowed[ ] = $field; |
|
1360 | 1359 | } |
1361 | 1360 | |
1362 | 1361 | $renderer = new Field_Renderer(); |
@@ -1378,17 +1377,17 @@ discard block |
||
1378 | 1377 | } ); |
1379 | 1378 | |
1380 | 1379 | foreach ( array_diff( $allowed_field_ids, wp_list_pluck( $allowed, 'ID' ) ) as $field_id ) { |
1381 | - $allowed[] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
1380 | + $allowed[ ] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
1382 | 1381 | } |
1383 | 1382 | |
1384 | 1383 | foreach ( $allowed as $field ) { |
1385 | 1384 | $source = is_numeric( $field->ID ) ? $view->form : new \GV\Internal_Source(); |
1386 | 1385 | |
1387 | - $return[] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
1386 | + $return[ ] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
1388 | 1387 | |
1389 | 1388 | if ( ! $headers_done ) { |
1390 | 1389 | $label = $field->get_label( $view, $source, $entry ); |
1391 | - $headers[] = $label ? $label : $field->ID; |
|
1390 | + $headers[ ] = $label ? $label : $field->ID; |
|
1392 | 1391 | } |
1393 | 1392 | } |
1394 | 1393 |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @return \GV\Field The field implementation from configuration (\GV\GF_Field, \GV\Internal_Field). |
167 | 167 | */ |
168 | 168 | public static function from_configuration( $configuration ) { |
169 | - if ( empty( $configuration['id'] ) ) { |
|
169 | + if ( empty( $configuration[ 'id' ] ) ) { |
|
170 | 170 | $field = new self(); |
171 | 171 | gravityview()->log->error( 'Trying to get field from configuration without a field ID.', array( 'data' => $configuration ) ); |
172 | 172 | $field->update_configuration( $configuration ); |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | } else { |
180 | 180 | $trace = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); |
181 | 181 | } |
182 | - $trace = $trace[1]; |
|
183 | - if ( $trace['function'] == 'from_configuration' && $trace['class'] == __CLASS__ ) { |
|
182 | + $trace = $trace[ 1 ]; |
|
183 | + if ( $trace[ 'function' ] == 'from_configuration' && $trace[ 'class' ] == __CLASS__ ) { |
|
184 | 184 | $field = new self(); |
185 | 185 | gravityview()->log->error( 'Infinite loop protection tripped. Returning default class here.' ); |
186 | 186 | $field->update_configuration( $configuration ); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | /** @var \GV\GF_Field|\GV\Internal_Field $field_class Determine the field implementation to use, and try to use. */ |
191 | - $field_class = is_numeric( $configuration['id'] ) ? '\GV\GF_Field' : '\GV\Internal_Field'; |
|
191 | + $field_class = is_numeric( $configuration[ 'id' ] ) ? '\GV\GF_Field' : '\GV\Internal_Field'; |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * @filter `gravityview/field/class` Filter the field class about to be created from the configuration. |
@@ -227,24 +227,24 @@ discard block |
||
227 | 227 | public function update_configuration( $configuration ) { |
228 | 228 | $configuration = wp_parse_args( $configuration, $this->as_configuration() ); |
229 | 229 | |
230 | - if ( $this->ID != $configuration['id'] ) { |
|
230 | + if ( $this->ID != $configuration[ 'id' ] ) { |
|
231 | 231 | /** Smelling trouble here... */ |
232 | 232 | gravityview()->log->warning( 'ID is being changed for {field_class} instance, but implementation is not. Use ::from_configuration instead', array( 'field_class', __CLASS__ ) ); |
233 | 233 | } |
234 | 234 | |
235 | - $this->ID = $configuration['id']; |
|
236 | - $this->label = $configuration['label']; |
|
237 | - $this->show_label = $configuration['show_label'] == '1'; |
|
238 | - $this->custom_label = $configuration['custom_label']; |
|
239 | - $this->custom_class = $configuration['custom_class']; |
|
240 | - $this->cap = $configuration['only_loggedin'] == '1' ? $configuration['only_loggedin_cap'] : ''; |
|
241 | - $this->search_filter = $configuration['search_filter'] == '1'; |
|
242 | - $this->show_as_link = $configuration['show_as_link'] == '1'; |
|
235 | + $this->ID = $configuration[ 'id' ]; |
|
236 | + $this->label = $configuration[ 'label' ]; |
|
237 | + $this->show_label = $configuration[ 'show_label' ] == '1'; |
|
238 | + $this->custom_label = $configuration[ 'custom_label' ]; |
|
239 | + $this->custom_class = $configuration[ 'custom_class' ]; |
|
240 | + $this->cap = $configuration[ 'only_loggedin' ] == '1' ? $configuration[ 'only_loggedin_cap' ] : ''; |
|
241 | + $this->search_filter = $configuration[ 'search_filter' ] == '1'; |
|
242 | + $this->show_as_link = $configuration[ 'show_as_link' ] == '1'; |
|
243 | 243 | |
244 | 244 | /** Shared among all field types (sort of). */ |
245 | 245 | $shared_configuration_keys = array( |
246 | 246 | 'id', 'label', 'show_label', 'custom_label', 'custom_class', |
247 | - 'only_loggedin' ,'only_loggedin_cap', 'search_filter', 'show_as_link', |
|
247 | + 'only_loggedin', 'only_loggedin_cap', 'search_filter', 'show_as_link', |
|
248 | 248 | ); |
249 | 249 | |
250 | 250 | /** Everything else goes into the properties for now. @todo subclasses! */ |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | |
274 | 274 | /** A custom label is available. */ |
275 | 275 | if ( ! empty( $this->custom_label ) ) { |
276 | - return \GravityView_API::replace_variables( $this->custom_label, $source ? $source->form ? : null : null, $entry ? $entry->as_entry() : null ); |
|
276 | + return \GravityView_API::replace_variables( $this->custom_label, $source ? $source->form ?: null : null, $entry ? $entry->as_entry() : null ); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | return ''; |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * @return mixed|null The value for the given configuration key, null if doesn't exist. |
351 | 351 | */ |
352 | 352 | public function __get( $key ) { |
353 | - switch( $key ) { |
|
353 | + switch ( $key ) { |
|
354 | 354 | default: |
355 | 355 | if ( isset( $this->configuration[ $key ] ) ) { |
356 | 356 | return $this->configuration[ $key ]; |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * @return boolean Whether this $key is set or not. |
369 | 369 | */ |
370 | 370 | public function __isset( $key ) { |
371 | - switch( $key ) { |
|
371 | + switch ( $key ) { |
|
372 | 372 | default: |
373 | 373 | return isset( $this->configuration[ $key ] ); |
374 | 374 | } |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | private function __construct() {} |
86 | 86 | |
87 | 87 | private function initialize() { |
88 | - add_action( 'wp', array( $this, 'parse_content'), 11 ); |
|
88 | + add_action( 'wp', array( $this, 'parse_content' ), 11 ); |
|
89 | 89 | add_filter( 'parse_query', array( $this, 'parse_query_fix_frontpage' ), 10 ); |
90 | - add_action( 'template_redirect', array( $this, 'set_entry_data'), 1 ); |
|
90 | + add_action( 'template_redirect', array( $this, 'set_entry_data' ), 1 ); |
|
91 | 91 | |
92 | 92 | // Enqueue scripts and styles after GravityView_Template::register_styles() |
93 | 93 | add_action( 'wp_enqueue_scripts', array( $this, 'add_scripts_and_styles' ), 20 ); |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | |
237 | 237 | $this->context_view_id = $view_id; |
238 | 238 | |
239 | - } elseif ( isset( $_GET['gvid'] ) && $multiple_views ) { |
|
239 | + } elseif ( isset( $_GET[ 'gvid' ] ) && $multiple_views ) { |
|
240 | 240 | /** |
241 | 241 | * used on a has_multiple_views context |
242 | 242 | * @see GravityView_API::entry_link |
243 | 243 | */ |
244 | - $this->context_view_id = $_GET['gvid']; |
|
244 | + $this->context_view_id = $_GET[ 'gvid' ]; |
|
245 | 245 | |
246 | 246 | } elseif ( ! $multiple_views ) { |
247 | 247 | $array_keys = array_keys( $this->getGvOutputData()->get_views() ); |
@@ -278,25 +278,25 @@ discard block |
||
278 | 278 | global $wp_rewrite; |
279 | 279 | |
280 | 280 | $is_front_page = ( $query->is_home || $query->is_page ); |
281 | - $show_on_front = ( 'page' === get_option('show_on_front') ); |
|
282 | - $front_page_id = get_option('page_on_front'); |
|
281 | + $show_on_front = ( 'page' === get_option( 'show_on_front' ) ); |
|
282 | + $front_page_id = get_option( 'page_on_front' ); |
|
283 | 283 | |
284 | - if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
284 | + if ( $is_front_page && $show_on_front && $front_page_id ) { |
|
285 | 285 | |
286 | 286 | // Force to be an array, potentially a query string ( entry=16 ) |
287 | 287 | $_query = wp_parse_args( $query->query ); |
288 | 288 | |
289 | 289 | // pagename can be set and empty depending on matched rewrite rules. Ignore an empty pagename. |
290 | - if ( isset( $_query['pagename'] ) && '' === $_query['pagename'] ) { |
|
291 | - unset( $_query['pagename'] ); |
|
290 | + if ( isset( $_query[ 'pagename' ] ) && '' === $_query[ 'pagename' ] ) { |
|
291 | + unset( $_query[ 'pagename' ] ); |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | // this is where will break from core wordpress |
295 | 295 | /** @internal Don't use this filter; it will be unnecessary soon - it's just a patch for specific use case */ |
296 | 296 | $ignore = apply_filters( 'gravityview/internal/ignored_endpoints', array( 'preview', 'page', 'paged', 'cpage' ), $query ); |
297 | 297 | $endpoints = \GV\Utils::get( $wp_rewrite, 'endpoints' ); |
298 | - foreach ( (array) $endpoints as $endpoint ) { |
|
299 | - $ignore[] = $endpoint[1]; |
|
298 | + foreach ( (array)$endpoints as $endpoint ) { |
|
299 | + $ignore[ ] = $endpoint[ 1 ]; |
|
300 | 300 | } |
301 | 301 | unset( $endpoints ); |
302 | 302 | |
@@ -306,21 +306,21 @@ discard block |
||
306 | 306 | // - The query includes keys that are associated with registered endpoints. `entry`, for example. |
307 | 307 | if ( empty( $_query ) || ! array_diff( array_keys( $_query ), $ignore ) ) { |
308 | 308 | |
309 | - $qv =& $query->query_vars; |
|
309 | + $qv = & $query->query_vars; |
|
310 | 310 | |
311 | 311 | // Prevent redirect when on the single entry endpoint |
312 | - if( self::is_single_entry() ) { |
|
312 | + if ( self::is_single_entry() ) { |
|
313 | 313 | add_filter( 'redirect_canonical', '__return_false' ); |
314 | 314 | } |
315 | 315 | |
316 | 316 | $query->is_page = true; |
317 | 317 | $query->is_home = false; |
318 | - $qv['page_id'] = $front_page_id; |
|
318 | + $qv[ 'page_id' ] = $front_page_id; |
|
319 | 319 | |
320 | 320 | // Correct <!--nextpage--> for page_on_front |
321 | - if ( ! empty( $qv['paged'] ) ) { |
|
322 | - $qv['page'] = $qv['paged']; |
|
323 | - unset( $qv['paged'] ); |
|
321 | + if ( ! empty( $qv[ 'paged' ] ) ) { |
|
322 | + $qv[ 'page' ] = $qv[ 'paged' ]; |
|
323 | + unset( $qv[ 'paged' ] ); |
|
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | |
351 | 351 | $this->setIsGravityviewPostType( get_post_type( $post ) === 'gravityview' ); |
352 | 352 | |
353 | - $post_id = $this->getPostId() ? $this->getPostId() : (isset( $post ) ? $post->ID : null ); |
|
353 | + $post_id = $this->getPostId() ? $this->getPostId() : ( isset( $post ) ? $post->ID : null ); |
|
354 | 354 | $this->setPostId( $post_id ); |
355 | 355 | $post_has_shortcode = ! empty( $post->post_content ) ? gravityview_has_shortcode_r( $post->post_content, 'gravityview' ) : false; |
356 | 356 | $this->setPostHasShortcode( $this->isGravityviewPostType() ? null : ! empty( $post_has_shortcode ) ); |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | |
387 | 387 | $search_method = GravityView_Widget_Search::getInstance()->get_search_method(); |
388 | 388 | |
389 | - if( 'post' === $search_method ) { |
|
389 | + if ( 'post' === $search_method ) { |
|
390 | 390 | $get = $_POST; |
391 | 391 | } else { |
392 | 392 | $get = $_GET; |
@@ -443,20 +443,20 @@ discard block |
||
443 | 443 | * @param boolean $in_the_loop Whether to apply the filter to the menu title and the meta tag <title> - outside the loop |
444 | 444 | * @param array $entry Current entry |
445 | 445 | */ |
446 | - $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop' , in_the_loop(), $entry ); |
|
446 | + $apply_outside_loop = apply_filters( 'gravityview/single/title/out_loop', in_the_loop(), $entry ); |
|
447 | 447 | |
448 | 448 | if ( ! $apply_outside_loop ) { |
449 | 449 | return $title; |
450 | 450 | } |
451 | 451 | |
452 | 452 | // User reported WooCommerce doesn't pass two args. |
453 | - if ( empty( $passed_post_id ) ) { |
|
453 | + if ( empty( $passed_post_id ) ) { |
|
454 | 454 | return $title; |
455 | 455 | } |
456 | 456 | |
457 | 457 | // Don't modify the title for anything other than the current view/post. |
458 | 458 | // This is true for embedded shortcodes and Views. |
459 | - if ( is_object( $post ) && (int) $post->ID !== (int) $passed_post_id ) { |
|
459 | + if ( is_object( $post ) && (int)$post->ID !== (int)$passed_post_id ) { |
|
460 | 460 | return $title; |
461 | 461 | } |
462 | 462 | |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | $view_meta = $this->getGvOutputData()->get_view( $context_view_id ); |
469 | 469 | } else { |
470 | 470 | foreach ( $this->getGvOutputData()->get_views() as $view_id => $view_data ) { |
471 | - if ( intval( $view_data['form_id'] ) === intval( $entry['form_id'] ) ) { |
|
471 | + if ( intval( $view_data[ 'form_id' ] ) === intval( $entry[ 'form_id' ] ) ) { |
|
472 | 472 | $view_meta = $view_data; |
473 | 473 | break; |
474 | 474 | } |
@@ -476,12 +476,12 @@ discard block |
||
476 | 476 | } |
477 | 477 | |
478 | 478 | /** Deprecated stuff in the future. See the branch above. */ |
479 | - if ( ! empty( $view_meta['atts']['single_title'] ) ) { |
|
479 | + if ( ! empty( $view_meta[ 'atts' ][ 'single_title' ] ) ) { |
|
480 | 480 | |
481 | - $title = $view_meta['atts']['single_title']; |
|
481 | + $title = $view_meta[ 'atts' ][ 'single_title' ]; |
|
482 | 482 | |
483 | 483 | // We are allowing HTML in the fields, so no escaping the output |
484 | - $title = GravityView_API::replace_variables( $title, $view_meta['form'], $entry ); |
|
484 | + $title = GravityView_API::replace_variables( $title, $view_meta[ 'form' ], $entry ); |
|
485 | 485 | |
486 | 486 | $title = do_shortcode( $title ); |
487 | 487 | } |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | |
553 | 553 | $context = GravityView_View::getInstance()->getContext(); |
554 | 554 | |
555 | - switch( $context ) { |
|
555 | + switch ( $context ) { |
|
556 | 556 | case 'directory': |
557 | 557 | $tab = __( 'Multiple Entries', 'gravityview' ); |
558 | 558 | break; |
@@ -566,12 +566,12 @@ discard block |
||
566 | 566 | } |
567 | 567 | |
568 | 568 | |
569 | - $title = sprintf( esc_html_x('The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
569 | + $title = sprintf( esc_html_x( 'The %s layout has not been configured.', 'Displayed when a View is not configured. %s is replaced by the tab label', 'gravityview' ), $tab ); |
|
570 | 570 | $edit_link = admin_url( sprintf( 'post.php?post=%d&action=edit#%s-view', $view_id, $context ) ); |
571 | - $action_text = sprintf( esc_html__('Add fields to %s', 'gravityview' ), $tab ); |
|
571 | + $action_text = sprintf( esc_html__( 'Add fields to %s', 'gravityview' ), $tab ); |
|
572 | 572 | $message = esc_html__( 'You can only see this message because you are able to edit this View.', 'gravityview' ); |
573 | 573 | |
574 | - $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url(plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
574 | + $image = sprintf( '<img alt="%s" src="%s" style="margin-top: 10px;" />', $tab, esc_url( plugins_url( sprintf( 'assets/images/tab-%s.png', $context ), GRAVITYVIEW_FILE ) ) ); |
|
575 | 575 | $output = sprintf( '<h3>%s <strong><a href="%s">%s</a></strong></h3><p>%s</p>', $title, esc_url( $edit_link ), $action_text, $message ); |
576 | 576 | |
577 | 577 | echo GVCommon::generate_notice( $output . $image, 'gv-error error', 'edit_gravityview', $view_id ); |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | $direct_access = apply_filters( 'gravityview_direct_access', true, $view->ID ); |
620 | 620 | $embed_only = $view->settings->get( 'embed_only' ); |
621 | 621 | |
622 | - if( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
622 | + if ( ! $direct_access || ( $embed_only && ! GVCommon::has_cap( 'read_private_gravityviews' ) ) ) { |
|
623 | 623 | return __( 'You are not allowed to view this content.', 'gravityview' ); |
624 | 624 | } |
625 | 625 | |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | $datetime_format = 'Y-m-d H:i:s'; |
667 | 667 | $search_is_outside_view_bounds = false; |
668 | 668 | |
669 | - if( ! empty( $search_criteria[ $key ] ) ) { |
|
669 | + if ( ! empty( $search_criteria[ $key ] ) ) { |
|
670 | 670 | |
671 | 671 | $search_date = strtotime( $search_criteria[ $key ] ); |
672 | 672 | |
@@ -694,14 +694,14 @@ discard block |
||
694 | 694 | if ( empty( $search_criteria[ $key ] ) || $search_is_outside_view_bounds ) { |
695 | 695 | |
696 | 696 | // Then we override the search and re-set the start date |
697 | - $return_search_criteria[ $key ] = date_i18n( $datetime_format , $date, true ); |
|
697 | + $return_search_criteria[ $key ] = date_i18n( $datetime_format, $date, true ); |
|
698 | 698 | } |
699 | 699 | } |
700 | 700 | } |
701 | 701 | |
702 | - if( isset( $return_search_criteria['start_date'] ) && isset( $return_search_criteria['end_date'] ) ) { |
|
702 | + if ( isset( $return_search_criteria[ 'start_date' ] ) && isset( $return_search_criteria[ 'end_date' ] ) ) { |
|
703 | 703 | // The start date is AFTER the end date. This will result in no results, but let's not force the issue. |
704 | - if ( strtotime( $return_search_criteria['start_date'] ) > strtotime( $return_search_criteria['end_date'] ) ) { |
|
704 | + if ( strtotime( $return_search_criteria[ 'start_date' ] ) > strtotime( $return_search_criteria[ 'end_date' ] ) ) { |
|
705 | 705 | gravityview()->log->error( 'Invalid search: the start date is after the end date.', array( 'data' => $return_search_criteria ) ); |
706 | 706 | } |
707 | 707 | } |
@@ -720,19 +720,19 @@ discard block |
||
720 | 720 | public static function process_search_only_approved( $args, $search_criteria ) { |
721 | 721 | |
722 | 722 | /** @since 1.19 */ |
723 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
723 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
724 | 724 | gravityview()->log->debug( 'User can moderate entries; showing all approval statuses' ); |
725 | 725 | return $search_criteria; |
726 | 726 | } |
727 | 727 | |
728 | - if ( ! empty( $args['show_only_approved'] ) ) { |
|
728 | + if ( ! empty( $args[ 'show_only_approved' ] ) ) { |
|
729 | 729 | |
730 | - $search_criteria['field_filters'][] = array( |
|
730 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
731 | 731 | 'key' => GravityView_Entry_Approval::meta_key, |
732 | 732 | 'value' => GravityView_Entry_Approval_Status::APPROVED |
733 | 733 | ); |
734 | 734 | |
735 | - $search_criteria['field_filters']['mode'] = 'all'; // force all the criterias to be met |
|
735 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; // force all the criterias to be met |
|
736 | 736 | |
737 | 737 | gravityview()->log->debug( '[process_search_only_approved] Search Criteria if show only approved: ', array( 'data' => $search_criteria ) ); |
738 | 738 | } |
@@ -759,18 +759,18 @@ discard block |
||
759 | 759 | */ |
760 | 760 | public static function is_entry_approved( $entry, $args = array() ) { |
761 | 761 | |
762 | - if ( empty( $entry['id'] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args['show_only_approved'] ) ) { |
|
762 | + if ( empty( $entry[ 'id' ] ) || ( array_key_exists( 'show_only_approved', $args ) && ! $args[ 'show_only_approved' ] ) ) { |
|
763 | 763 | // is implicitly approved if entry is null or View settings doesn't require to check for approval |
764 | 764 | return true; |
765 | 765 | } |
766 | 766 | |
767 | 767 | /** @since 1.19 */ |
768 | - if( ! empty( $args['admin_show_all_statuses'] ) && GVCommon::has_cap('gravityview_moderate_entries') ) { |
|
768 | + if ( ! empty( $args[ 'admin_show_all_statuses' ] ) && GVCommon::has_cap( 'gravityview_moderate_entries' ) ) { |
|
769 | 769 | gravityview()->log->debug( 'User can moderate entries, so entry is approved for viewing' ); |
770 | 770 | return true; |
771 | 771 | } |
772 | 772 | |
773 | - $is_approved = gform_get_meta( $entry['id'], GravityView_Entry_Approval::meta_key ); |
|
773 | + $is_approved = gform_get_meta( $entry[ 'id' ], GravityView_Entry_Approval::meta_key ); |
|
774 | 774 | |
775 | 775 | return GravityView_Entry_Approval_Status::is_approved( $is_approved ); |
776 | 776 | } |
@@ -794,7 +794,7 @@ discard block |
||
794 | 794 | * Compatibility with filters hooking in `gravityview_search_criteria` instead of `gravityview_fe_search_criteria`. |
795 | 795 | */ |
796 | 796 | $criteria = apply_filters( 'gravityview_search_criteria', array(), array( $form_id ), \GV\Utils::get( $args, 'id' ) ); |
797 | - $search_criteria = isset( $criteria['search_criteria'] ) ? $criteria['search_criteria'] : array( 'field_filters' => array() ); |
|
797 | + $search_criteria = isset( $criteria[ 'search_criteria' ] ) ? $criteria[ 'search_criteria' ] : array( 'field_filters' => array() ); |
|
798 | 798 | |
799 | 799 | /** |
800 | 800 | * @filter `gravityview_fe_search_criteria` Modify the search criteria |
@@ -810,29 +810,29 @@ discard block |
||
810 | 810 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after hook gravityview_fe_search_criteria: ', array( 'data' =>$search_criteria ) ); |
811 | 811 | |
812 | 812 | // implicity search |
813 | - if ( ! empty( $args['search_value'] ) ) { |
|
813 | + if ( ! empty( $args[ 'search_value' ] ) ) { |
|
814 | 814 | |
815 | 815 | // Search operator options. Options: `is` or `contains` |
816 | - $operator = ! empty( $args['search_operator'] ) && in_array( $args['search_operator'], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args['search_operator'] : 'contains'; |
|
816 | + $operator = ! empty( $args[ 'search_operator' ] ) && in_array( $args[ 'search_operator' ], array( 'is', 'isnot', '>', '<', 'contains' ) ) ? $args[ 'search_operator' ] : 'contains'; |
|
817 | 817 | |
818 | - $search_criteria['field_filters'][] = array( |
|
818 | + $search_criteria[ 'field_filters' ][ ] = array( |
|
819 | 819 | 'key' => \GV\Utils::_GET( 'search_field', \GV\Utils::get( $args, 'search_field' ) ), // The field ID to search |
820 | - 'value' => _wp_specialchars( $args['search_value'] ), // The value to search. Encode ampersands but not quotes. |
|
820 | + 'value' => _wp_specialchars( $args[ 'search_value' ] ), // The value to search. Encode ampersands but not quotes. |
|
821 | 821 | 'operator' => $operator, |
822 | 822 | ); |
823 | 823 | |
824 | 824 | // Lock search mode to "all" with implicit presearch filter. |
825 | - $search_criteria['field_filters']['mode'] = 'all'; |
|
825 | + $search_criteria[ 'field_filters' ][ 'mode' ] = 'all'; |
|
826 | 826 | } |
827 | 827 | |
828 | - if( $search_criteria !== $original_search_criteria ) { |
|
828 | + if ( $search_criteria !== $original_search_criteria ) { |
|
829 | 829 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after implicity search: ', array( 'data' => $search_criteria ) ); |
830 | 830 | } |
831 | 831 | |
832 | 832 | // Handle setting date range |
833 | 833 | $search_criteria = self::process_search_dates( $args, $search_criteria ); |
834 | 834 | |
835 | - if( $search_criteria !== $original_search_criteria ) { |
|
835 | + if ( $search_criteria !== $original_search_criteria ) { |
|
836 | 836 | gravityview()->log->debug( '[get_search_criteria] Search Criteria after date params: ', array( 'data' => $search_criteria ) ); |
837 | 837 | } |
838 | 838 | |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | * @filter `gravityview_status` Modify entry status requirements to be included in search results. |
844 | 844 | * @param string $status Default: `active`. Accepts all Gravity Forms entry statuses, including `spam` and `trash` |
845 | 845 | */ |
846 | - $search_criteria['status'] = apply_filters( 'gravityview_status', 'active', $args ); |
|
846 | + $search_criteria[ 'status' ] = apply_filters( 'gravityview_status', 'active', $args ); |
|
847 | 847 | |
848 | 848 | return $search_criteria; |
849 | 849 | } |
@@ -956,7 +956,7 @@ discard block |
||
956 | 956 | 'search_criteria' => $search_criteria, |
957 | 957 | 'sorting' => self::updateViewSorting( $args, $form_id ), |
958 | 958 | 'paging' => $paging, |
959 | - 'cache' => isset( $args['cache'] ) ? $args['cache'] : true, |
|
959 | + 'cache' => isset( $args[ 'cache' ] ) ? $args[ 'cache' ] : true, |
|
960 | 960 | ); |
961 | 961 | |
962 | 962 | /** |
@@ -981,7 +981,7 @@ discard block |
||
981 | 981 | * @param array $parameters Array with `search_criteria`, `sorting` and `paging` keys. |
982 | 982 | * @param array $args View configuration args. |
983 | 983 | */ |
984 | - $parameters = apply_filters( 'gravityview_get_entries_'.\GV\Utils::get( $args, 'id' ), $parameters, $args, $form_id ); |
|
984 | + $parameters = apply_filters( 'gravityview_get_entries_' . \GV\Utils::get( $args, 'id' ), $parameters, $args, $form_id ); |
|
985 | 985 | |
986 | 986 | gravityview()->log->debug( '$parameters passed to gravityview_get_entries(): ', array( 'data' => $parameters ) ); |
987 | 987 | |
@@ -1006,17 +1006,17 @@ discard block |
||
1006 | 1006 | $default_page_size = apply_filters( 'gravityview_default_page_size', 25 ); |
1007 | 1007 | |
1008 | 1008 | // Paging & offset |
1009 | - $page_size = ! empty( $args['page_size'] ) ? intval( $args['page_size'] ) : $default_page_size; |
|
1009 | + $page_size = ! empty( $args[ 'page_size' ] ) ? intval( $args[ 'page_size' ] ) : $default_page_size; |
|
1010 | 1010 | |
1011 | 1011 | if ( -1 === $page_size ) { |
1012 | 1012 | $page_size = PHP_INT_MAX; |
1013 | 1013 | } |
1014 | 1014 | |
1015 | - $curr_page = empty( $_GET['pagenum'] ) ? 1 : intval( $_GET['pagenum'] ); |
|
1015 | + $curr_page = empty( $_GET[ 'pagenum' ] ) ? 1 : intval( $_GET[ 'pagenum' ] ); |
|
1016 | 1016 | $offset = ( $curr_page - 1 ) * $page_size; |
1017 | 1017 | |
1018 | - if ( ! empty( $args['offset'] ) ) { |
|
1019 | - $offset += intval( $args['offset'] ); |
|
1018 | + if ( ! empty( $args[ 'offset' ] ) ) { |
|
1019 | + $offset += intval( $args[ 'offset' ] ); |
|
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | $paging = array( |
@@ -1041,14 +1041,14 @@ discard block |
||
1041 | 1041 | public static function updateViewSorting( $args, $form_id ) { |
1042 | 1042 | $sorting = array(); |
1043 | 1043 | |
1044 | - $has_values = isset( $_GET['sort'] ); |
|
1044 | + $has_values = isset( $_GET[ 'sort' ] ); |
|
1045 | 1045 | |
1046 | - if ( $has_values && is_array( $_GET['sort'] ) ) { |
|
1047 | - $has_values = array_filter( array_values( $_GET['sort'] ) ); |
|
1046 | + if ( $has_values && is_array( $_GET[ 'sort' ] ) ) { |
|
1047 | + $has_values = array_filter( array_values( $_GET[ 'sort' ] ) ); |
|
1048 | 1048 | } |
1049 | 1049 | |
1050 | - $sort_field_id = $has_values ? $_GET['sort'] : \GV\Utils::get( $args, 'sort_field' ); |
|
1051 | - $sort_direction = isset( $_GET['dir'] ) ? $_GET['dir'] : \GV\Utils::get( $args, 'sort_direction' ); |
|
1050 | + $sort_field_id = $has_values ? $_GET[ 'sort' ] : \GV\Utils::get( $args, 'sort_field' ); |
|
1051 | + $sort_direction = isset( $_GET[ 'dir' ] ) ? $_GET[ 'dir' ] : \GV\Utils::get( $args, 'sort_direction' ); |
|
1052 | 1052 | |
1053 | 1053 | if ( is_array( $sort_field_id ) ) { |
1054 | 1054 | $sort_field_id = array_pop( $sort_field_id ); |
@@ -1079,10 +1079,10 @@ discard block |
||
1079 | 1079 | $form = GFAPI::get_form( $form_id ); |
1080 | 1080 | |
1081 | 1081 | // Get the first GF_Field field ID, set as the key for entry randomization |
1082 | - if ( ! empty( $form['fields'] ) ) { |
|
1082 | + if ( ! empty( $form[ 'fields' ] ) ) { |
|
1083 | 1083 | |
1084 | 1084 | /** @var GF_Field $field */ |
1085 | - foreach ( $form['fields'] as $field ) { |
|
1085 | + foreach ( $form[ 'fields' ] as $field ) { |
|
1086 | 1086 | if ( ! is_a( $field, 'GF_Field' ) ) { |
1087 | 1087 | continue; |
1088 | 1088 | } |
@@ -1127,7 +1127,7 @@ discard block |
||
1127 | 1127 | if ( is_array( $sort_field_id ) ) { |
1128 | 1128 | $modified_ids = array(); |
1129 | 1129 | foreach ( $sort_field_id as $_sort_field_id ) { |
1130 | - $modified_ids []= self::_override_sorting_id_by_field_type( $_sort_field_id, $form_id ); |
|
1130 | + $modified_ids [ ] = self::_override_sorting_id_by_field_type( $_sort_field_id, $form_id ); |
|
1131 | 1131 | } |
1132 | 1132 | return $modified_ids; |
1133 | 1133 | } |
@@ -1136,11 +1136,11 @@ discard block |
||
1136 | 1136 | |
1137 | 1137 | $sort_field = GFFormsModel::get_field( $form, $sort_field_id ); |
1138 | 1138 | |
1139 | - if( ! $sort_field ) { |
|
1139 | + if ( ! $sort_field ) { |
|
1140 | 1140 | return $sort_field_id; |
1141 | 1141 | } |
1142 | 1142 | |
1143 | - switch ( $sort_field['type'] ) { |
|
1143 | + switch ( $sort_field[ 'type' ] ) { |
|
1144 | 1144 | |
1145 | 1145 | case 'address': |
1146 | 1146 | // Sorting by full address |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | */ |
1158 | 1158 | $address_part = apply_filters( 'gravityview/sorting/address', 'city', $sort_field_id, $form_id ); |
1159 | 1159 | |
1160 | - switch( strtolower( $address_part ) ){ |
|
1160 | + switch ( strtolower( $address_part ) ) { |
|
1161 | 1161 | case 'street': |
1162 | 1162 | $sort_field_id .= '.1'; |
1163 | 1163 | break; |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | if ( ! class_exists( '\GV\Entry' ) ) { |
1231 | 1231 | |
1232 | 1232 | // Not using gravityview()->log->error(), since that may not exist yet either! |
1233 | - do_action( 'gravityview_log_error', '\GV\Entry not defined yet. Backtrace: ' . wp_debug_backtrace_summary() ); |
|
1233 | + do_action( 'gravityview_log_error', '\GV\Entry not defined yet. Backtrace: ' . wp_debug_backtrace_summary() ); |
|
1234 | 1234 | |
1235 | 1235 | return null; |
1236 | 1236 | } |
@@ -1247,7 +1247,7 @@ discard block |
||
1247 | 1247 | */ |
1248 | 1248 | $single_entry = apply_filters( 'gravityview/is_single_entry', $single_entry ); |
1249 | 1249 | |
1250 | - if ( empty( $single_entry ) ){ |
|
1250 | + if ( empty( $single_entry ) ) { |
|
1251 | 1251 | return false; |
1252 | 1252 | } else { |
1253 | 1253 | return $single_entry; |
@@ -1269,7 +1269,7 @@ discard block |
||
1269 | 1269 | $views = $this->getGvOutputData()->get_views(); |
1270 | 1270 | |
1271 | 1271 | foreach ( $views as $view_id => $data ) { |
1272 | - $view = \GV\View::by_id( $data['id'] ); |
|
1272 | + $view = \GV\View::by_id( $data[ 'id' ] ); |
|
1273 | 1273 | $view_id = $view->ID; |
1274 | 1274 | $template_id = gravityview_get_template_id( $view->ID ); |
1275 | 1275 | $data = $view->as_data(); |
@@ -1278,7 +1278,7 @@ discard block |
||
1278 | 1278 | * Don't enqueue the scripts or styles if it's not going to be displayed. |
1279 | 1279 | * @since 1.15 |
1280 | 1280 | */ |
1281 | - if( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1281 | + if ( is_user_logged_in() && false === GVCommon::has_cap( 'read_gravityview', $view_id ) ) { |
|
1282 | 1282 | continue; |
1283 | 1283 | } |
1284 | 1284 | |
@@ -1295,13 +1295,13 @@ discard block |
||
1295 | 1295 | * @filter `gravity_view_lightbox_script` Override the lightbox script to enqueue. Default: `thickbox` |
1296 | 1296 | * @param string $script_slug If you want to use a different lightbox script, return the name of it here. |
1297 | 1297 | */ |
1298 | - $js_dependencies[] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
1298 | + $js_dependencies[ ] = apply_filters( 'gravity_view_lightbox_script', 'thickbox' ); |
|
1299 | 1299 | |
1300 | 1300 | /** |
1301 | 1301 | * @filter `gravity_view_lightbox_style` Modify the lightbox CSS slug. Default: `thickbox` |
1302 | 1302 | * @param string $script_slug If you want to use a different lightbox script, return the name of its CSS file here. |
1303 | 1303 | */ |
1304 | - $css_dependencies[] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
1304 | + $css_dependencies[ ] = apply_filters( 'gravity_view_lightbox_style', 'thickbox' ); |
|
1305 | 1305 | } |
1306 | 1306 | |
1307 | 1307 | /** |
@@ -1309,19 +1309,19 @@ discard block |
||
1309 | 1309 | * @see https://github.com/katzwebservices/GravityView/issues/536 |
1310 | 1310 | * @since 1.15 |
1311 | 1311 | */ |
1312 | - if( gravityview_view_has_single_checkbox_or_radio( $data['form'], $data['fields'] ) ) { |
|
1313 | - $css_dependencies[] = 'dashicons'; |
|
1312 | + if ( gravityview_view_has_single_checkbox_or_radio( $data[ 'form' ], $data[ 'fields' ] ) ) { |
|
1313 | + $css_dependencies[ ] = 'dashicons'; |
|
1314 | 1314 | } |
1315 | 1315 | |
1316 | 1316 | wp_register_script( 'gravityview-jquery-cookie', plugins_url( 'assets/lib/jquery.cookie/jquery.cookie.min.js', GRAVITYVIEW_FILE ), array( 'jquery' ), GravityView_Plugin::version, true ); |
1317 | 1317 | |
1318 | 1318 | $script_debug = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
1319 | 1319 | |
1320 | - wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ) , GravityView_Plugin::version, true ); |
|
1320 | + wp_register_script( 'gravityview-fe-view', plugins_url( 'assets/js/fe-views' . $script_debug . '.js', GRAVITYVIEW_FILE ), apply_filters( 'gravityview_js_dependencies', $js_dependencies ), GravityView_Plugin::version, true ); |
|
1321 | 1321 | |
1322 | 1322 | wp_enqueue_script( 'gravityview-fe-view' ); |
1323 | 1323 | |
1324 | - if ( ! empty( $data['atts']['sort_columns'] ) ) { |
|
1324 | + if ( ! empty( $data[ 'atts' ][ 'sort_columns' ] ) ) { |
|
1325 | 1325 | wp_enqueue_style( 'gravityview_font', plugins_url( 'assets/css/font.css', GRAVITYVIEW_FILE ), $css_dependencies, GravityView_Plugin::version, 'all' ); |
1326 | 1326 | } |
1327 | 1327 | |
@@ -1384,7 +1384,7 @@ discard block |
||
1384 | 1384 | public static function add_style( $template_id ) { |
1385 | 1385 | |
1386 | 1386 | if ( ! empty( $template_id ) && wp_style_is( 'gravityview_style_' . $template_id, 'registered' ) ) { |
1387 | - gravityview()->log->debug( 'Adding extra template style for {template_id}', array( 'template_id' => $template_id ) ); |
|
1387 | + gravityview()->log->debug( 'Adding extra template style for {template_id}', array( 'template_id' => $template_id ) ); |
|
1388 | 1388 | wp_enqueue_style( 'gravityview_style_' . $template_id ); |
1389 | 1389 | } elseif ( empty( $template_id ) ) { |
1390 | 1390 | gravityview()->log->error( 'Cannot add template style; template_id is empty' ); |
@@ -1415,11 +1415,11 @@ discard block |
||
1415 | 1415 | * Not a table-based template; don't add sort icons |
1416 | 1416 | * @since 1.12 |
1417 | 1417 | */ |
1418 | - if( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1418 | + if ( ! preg_match( '/table/ism', GravityView_View::getInstance()->getTemplatePartSlug() ) ) { |
|
1419 | 1419 | return $label; |
1420 | 1420 | } |
1421 | 1421 | |
1422 | - if ( ! $this->is_field_sortable( $field['id'], $form ) ) { |
|
1422 | + if ( ! $this->is_field_sortable( $field[ 'id' ], $form ) ) { |
|
1423 | 1423 | return $label; |
1424 | 1424 | } |
1425 | 1425 | |
@@ -1427,29 +1427,29 @@ discard block |
||
1427 | 1427 | |
1428 | 1428 | $class = 'gv-sort'; |
1429 | 1429 | |
1430 | - $sort_field_id = self::_override_sorting_id_by_field_type( $field['id'], $form['id'] ); |
|
1430 | + $sort_field_id = self::_override_sorting_id_by_field_type( $field[ 'id' ], $form[ 'id' ] ); |
|
1431 | 1431 | |
1432 | 1432 | $sort_args = array( |
1433 | - 'sort' => $field['id'], |
|
1433 | + 'sort' => $field[ 'id' ], |
|
1434 | 1434 | 'dir' => 'asc', |
1435 | 1435 | ); |
1436 | 1436 | |
1437 | - if ( ! empty( $sorting['key'] ) && (string) $sort_field_id === (string) $sorting['key'] ) { |
|
1437 | + if ( ! empty( $sorting[ 'key' ] ) && (string)$sort_field_id === (string)$sorting[ 'key' ] ) { |
|
1438 | 1438 | //toggle sorting direction. |
1439 | - if ( 'asc' === $sorting['direction'] ) { |
|
1440 | - $sort_args['dir'] = 'desc'; |
|
1439 | + if ( 'asc' === $sorting[ 'direction' ] ) { |
|
1440 | + $sort_args[ 'dir' ] = 'desc'; |
|
1441 | 1441 | $class .= ' gv-icon-sort-desc'; |
1442 | 1442 | } else { |
1443 | - $sort_args['dir'] = 'asc'; |
|
1443 | + $sort_args[ 'dir' ] = 'asc'; |
|
1444 | 1444 | $class .= ' gv-icon-sort-asc'; |
1445 | 1445 | } |
1446 | 1446 | } else { |
1447 | 1447 | $class .= ' gv-icon-caret-up-down'; |
1448 | 1448 | } |
1449 | 1449 | |
1450 | - $url = add_query_arg( $sort_args, remove_query_arg( array('pagenum') ) ); |
|
1450 | + $url = add_query_arg( $sort_args, remove_query_arg( array( 'pagenum' ) ) ); |
|
1451 | 1451 | |
1452 | - return '<a href="'. esc_url_raw( $url ) .'" class="'. $class .'" ></a> '. $label; |
|
1452 | + return '<a href="' . esc_url_raw( $url ) . '" class="' . $class . '" ></a> ' . $label; |
|
1453 | 1453 | |
1454 | 1454 | } |
1455 | 1455 | |
@@ -1467,7 +1467,7 @@ discard block |
||
1467 | 1467 | |
1468 | 1468 | $field_type = $field_id; |
1469 | 1469 | |
1470 | - if( is_numeric( $field_id ) ) { |
|
1470 | + if ( is_numeric( $field_id ) ) { |
|
1471 | 1471 | $field = GFFormsModel::get_field( $form, $field_id ); |
1472 | 1472 | $field_type = $field ? $field->type : $field_id; |
1473 | 1473 | } |
@@ -1490,7 +1490,7 @@ discard block |
||
1490 | 1490 | return false; |
1491 | 1491 | } |
1492 | 1492 | |
1493 | - return apply_filters( "gravityview/sortable/formfield_{$form['id']}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1493 | + return apply_filters( "gravityview/sortable/formfield_{$form[ 'id' ]}_{$field_id}", apply_filters( "gravityview/sortable/field_{$field_id}", true, $form ) ); |
|
1494 | 1494 | |
1495 | 1495 | } |
1496 | 1496 |