@@ -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 | |
@@ -911,43 +911,42 @@ discard block |
||
| 911 | 911 | * @todo: Stop using _frontend and use something like $request->get_search_criteria() instead |
| 912 | 912 | */ |
| 913 | 913 | $parameters = \GravityView_frontend::get_view_entries_parameters( $this->settings->as_atts(), $this->form->ID ); |
| 914 | - $parameters['context_view_id'] = $this->ID; |
|
| 914 | + $parameters[ 'context_view_id' ] = $this->ID; |
|
| 915 | 915 | $parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
| 916 | 916 | |
| 917 | 917 | if ( $request instanceof REST\Request ) { |
| 918 | 918 | $atts = $this->settings->as_atts(); |
| 919 | 919 | $paging_parameters = wp_parse_args( $request->get_paging(), array( |
| 920 | - 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
| 920 | + 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
| 921 | 921 | ) ); |
| 922 | - $parameters['paging'] = $paging_parameters['paging']; |
|
| 922 | + $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | - $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
| 926 | - : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 ); |
|
| 925 | + $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 ); |
|
| 927 | 926 | |
| 928 | 927 | /** |
| 929 | 928 | * Cleanup duplicate field_filter parameters to simplify the query. |
| 930 | 929 | */ |
| 931 | 930 | $unique_field_filters = array(); |
| 932 | - foreach ( $parameters['search_criteria']['field_filters'] as $key => $filter ) { |
|
| 931 | + foreach ( $parameters[ 'search_criteria' ][ 'field_filters' ] as $key => $filter ) { |
|
| 933 | 932 | if ( 'mode' === $key ) { |
| 934 | - $unique_field_filters['mode'] = $filter; |
|
| 933 | + $unique_field_filters[ 'mode' ] = $filter; |
|
| 935 | 934 | } else if ( ! in_array( $filter, $unique_field_filters ) ) { |
| 936 | - $unique_field_filters[] = $filter; |
|
| 935 | + $unique_field_filters[ ] = $filter; |
|
| 937 | 936 | } |
| 938 | 937 | } |
| 939 | - $parameters['search_criteria']['field_filters'] = $unique_field_filters; |
|
| 938 | + $parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters; |
|
| 940 | 939 | |
| 941 | - if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) { |
|
| 940 | + if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
| 942 | 941 | gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' ); |
| 943 | 942 | } |
| 944 | 943 | |
| 945 | 944 | if ( gravityview()->plugin->supports( Plugin::FEATURE_GFQUERY ) ) { |
| 946 | 945 | $query_class = $this->get_query_class(); |
| 947 | - $query = new $query_class( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] ); |
|
| 946 | + $query = new $query_class( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] ); |
|
| 948 | 947 | |
| 949 | - $query->limit( $parameters['paging']['page_size'] ) |
|
| 950 | - ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
| 948 | + $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
| 949 | + ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
| 951 | 950 | |
| 952 | 951 | /** |
| 953 | 952 | * Any joins? |
@@ -970,7 +969,7 @@ discard block |
||
| 970 | 969 | |
| 971 | 970 | $query_parameters = $query->_introspect(); |
| 972 | 971 | |
| 973 | - $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
| 972 | + $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
| 974 | 973 | } |
| 975 | 974 | |
| 976 | 975 | |
@@ -985,7 +984,7 @@ discard block |
||
| 985 | 984 | |
| 986 | 985 | $query_parameters = $query->_introspect(); |
| 987 | 986 | |
| 988 | - $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
| 987 | + $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
| 989 | 988 | } |
| 990 | 989 | } |
| 991 | 990 | |
@@ -1009,7 +1008,7 @@ discard block |
||
| 1009 | 1008 | $conditions = array(); |
| 1010 | 1009 | |
| 1011 | 1010 | foreach ( $condition->expressions as $_condition ) { |
| 1012 | - $conditions[] = $recurse( $_condition, $fields, $recurse ); |
|
| 1011 | + $conditions[ ] = $recurse( $_condition, $fields, $recurse ); |
|
| 1013 | 1012 | } |
| 1014 | 1013 | |
| 1015 | 1014 | return call_user_func_array( |
@@ -1038,10 +1037,10 @@ discard block |
||
| 1038 | 1037 | $q = new $query_class( $form_id ); |
| 1039 | 1038 | |
| 1040 | 1039 | // Copy the WHERE clauses but substitute the field_ids to the respective ones |
| 1041 | - $q->where( $where_union_substitute( $query_parameters['where'], $fields, $where_union_substitute ) ); |
|
| 1040 | + $q->where( $where_union_substitute( $query_parameters[ 'where' ], $fields, $where_union_substitute ) ); |
|
| 1042 | 1041 | |
| 1043 | 1042 | // Copy the ORDER clause and substitute the field_ids to the respective ones |
| 1044 | - foreach ( $query_parameters['order'] as $order ) { |
|
| 1043 | + foreach ( $query_parameters[ 'order' ] as $order ) { |
|
| 1045 | 1044 | list( $column, $_order ) = $order; |
| 1046 | 1045 | |
| 1047 | 1046 | if ( $column && $column instanceof \GF_Query_Column ) { |
@@ -1055,15 +1054,15 @@ discard block |
||
| 1055 | 1054 | |
| 1056 | 1055 | add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( &$unions_sql ) { |
| 1057 | 1056 | // Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
| 1058 | - $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
| 1057 | + $select = 'UNION ALL ' . str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
| 1059 | 1058 | |
| 1060 | 1059 | // Record the SQL |
| 1061 | - $unions_sql[] = array( |
|
| 1060 | + $unions_sql[ ] = array( |
|
| 1062 | 1061 | // Remove columns, we'll rebuild them |
| 1063 | 1062 | 'select' => preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $select ), |
| 1064 | - 'from' => $sql['from'], |
|
| 1065 | - 'join' => $sql['join'], |
|
| 1066 | - 'where' => $sql['where'], |
|
| 1063 | + 'from' => $sql[ 'from' ], |
|
| 1064 | + 'join' => $sql[ 'join' ], |
|
| 1065 | + 'where' => $sql[ 'where' ], |
|
| 1067 | 1066 | // Remove order and limit |
| 1068 | 1067 | ); |
| 1069 | 1068 | |
@@ -1080,11 +1079,11 @@ discard block |
||
| 1080 | 1079 | |
| 1081 | 1080 | add_filter( 'gform_gf_query_sql', $gf_query_sql_callback = function( $sql ) use ( $unions_sql ) { |
| 1082 | 1081 | // Remove SQL_CALC_FOUND_ROWS as it's not needed in UNION clauses |
| 1083 | - $sql['select'] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql['select'] ); |
|
| 1082 | + $sql[ 'select' ] = str_replace( 'SQL_CALC_FOUND_ROWS ', '', $sql[ 'select' ] ); |
|
| 1084 | 1083 | |
| 1085 | 1084 | // Remove columns, we'll rebuild them |
| 1086 | - preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql['select'], $select_match ); |
|
| 1087 | - $sql['select'] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql['select'] ); |
|
| 1085 | + preg_match( '#DISTINCT (`[motc]\d+`.`.*?`)#', $sql[ 'select' ], $select_match ); |
|
| 1086 | + $sql[ 'select' ] = preg_replace( '#DISTINCT (.*)#', 'DISTINCT ', $sql[ 'select' ] ); |
|
| 1088 | 1087 | |
| 1089 | 1088 | $unions = array(); |
| 1090 | 1089 | |
@@ -1095,30 +1094,30 @@ discard block |
||
| 1095 | 1094 | }; |
| 1096 | 1095 | |
| 1097 | 1096 | // Add all the order columns into the selects, so we can order by the whole union group |
| 1098 | - preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql['order'], $order_matches ); |
|
| 1097 | + preg_match_all( '#(`[motc]\d+`.`.*?`)#', $sql[ 'order' ], $order_matches ); |
|
| 1099 | 1098 | |
| 1100 | 1099 | $columns = array( |
| 1101 | - sprintf( '%s AS %s', $select_match[1], $column_to_alias( $select_match[1] ) ) |
|
| 1100 | + sprintf( '%s AS %s', $select_match[ 1 ], $column_to_alias( $select_match[ 1 ] ) ) |
|
| 1102 | 1101 | ); |
| 1103 | 1102 | |
| 1104 | 1103 | foreach ( array_slice( $order_matches, 1 ) as $match ) { |
| 1105 | - $columns[] = sprintf( '%s AS %s', $match[0], $column_to_alias( $match[0] ) ); |
|
| 1104 | + $columns[ ] = sprintf( '%s AS %s', $match[ 0 ], $column_to_alias( $match[ 0 ] ) ); |
|
| 1106 | 1105 | |
| 1107 | 1106 | // Rewrite the order columns to the shared aliases |
| 1108 | - $sql['order'] = str_replace( $match[0], $column_to_alias( $match[0] ), $sql['order'] ); |
|
| 1107 | + $sql[ 'order' ] = str_replace( $match[ 0 ], $column_to_alias( $match[ 0 ] ), $sql[ 'order' ] ); |
|
| 1109 | 1108 | } |
| 1110 | 1109 | |
| 1111 | 1110 | $columns = array_unique( $columns ); |
| 1112 | 1111 | |
| 1113 | 1112 | // Add the columns to every UNION |
| 1114 | 1113 | foreach ( $unions_sql as $union_sql ) { |
| 1115 | - $union_sql['select'] .= implode( ', ', $columns ); |
|
| 1116 | - $unions []= implode( ' ', $union_sql ); |
|
| 1114 | + $union_sql[ 'select' ] .= implode( ', ', $columns ); |
|
| 1115 | + $unions [ ] = implode( ' ', $union_sql ); |
|
| 1117 | 1116 | } |
| 1118 | 1117 | |
| 1119 | 1118 | // Add the columns to the main SELECT, but only grab the entry id column |
| 1120 | - $sql['select'] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql['select'] . implode( ', ', $columns ); |
|
| 1121 | - $sql['order'] = implode( ' ', $unions ) . ') AS u ' . $sql['order']; |
|
| 1119 | + $sql[ 'select' ] = 'SELECT SQL_CALC_FOUND_ROWS t1_id FROM (' . $sql[ 'select' ] . implode( ', ', $columns ); |
|
| 1120 | + $sql[ 'order' ] = implode( ' ', $unions ) . ') AS u ' . $sql[ 'order' ]; |
|
| 1122 | 1121 | |
| 1123 | 1122 | return $sql; |
| 1124 | 1123 | } ); |
@@ -1159,15 +1158,15 @@ discard block |
||
| 1159 | 1158 | } ); |
| 1160 | 1159 | } else { |
| 1161 | 1160 | $entries = $this->form->entries |
| 1162 | - ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
| 1161 | + ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
| 1163 | 1162 | ->offset( $this->settings->get( 'offset' ) ) |
| 1164 | - ->limit( $parameters['paging']['page_size'] ) |
|
| 1163 | + ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
| 1165 | 1164 | ->page( $page ); |
| 1166 | 1165 | |
| 1167 | - if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
| 1166 | + if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
| 1168 | 1167 | $field = new \GV\Field(); |
| 1169 | - $field->ID = $parameters['sorting']['key']; |
|
| 1170 | - $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
| 1168 | + $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
| 1169 | + $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
| 1171 | 1170 | $entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
| 1172 | 1171 | } |
| 1173 | 1172 | } |
@@ -1238,7 +1237,7 @@ discard block |
||
| 1238 | 1237 | $allowed = $headers = array(); |
| 1239 | 1238 | |
| 1240 | 1239 | foreach ( $view->fields->by_position( "directory_*" )->by_visible()->all() as $id => $field ) { |
| 1241 | - $allowed[] = $field; |
|
| 1240 | + $allowed[ ] = $field; |
|
| 1242 | 1241 | } |
| 1243 | 1242 | |
| 1244 | 1243 | $renderer = new Field_Renderer(); |
@@ -1260,17 +1259,17 @@ discard block |
||
| 1260 | 1259 | } ); |
| 1261 | 1260 | |
| 1262 | 1261 | foreach ( array_diff( $allowed_field_ids, wp_list_pluck( $allowed, 'ID' ) ) as $field_id ) { |
| 1263 | - $allowed[] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
| 1262 | + $allowed[ ] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
| 1264 | 1263 | } |
| 1265 | 1264 | |
| 1266 | 1265 | foreach ( $allowed as $field ) { |
| 1267 | 1266 | $source = is_numeric( $field->ID ) ? $view->form : new \GV\Internal_Source(); |
| 1268 | 1267 | |
| 1269 | - $return[] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
| 1268 | + $return[ ] = $renderer->render( $field, $view, $source, $entry, gravityview()->request, '\GV\Field_CSV_Template' ); |
|
| 1270 | 1269 | |
| 1271 | 1270 | if ( ! $headers_done ) { |
| 1272 | 1271 | $label = $field->get_label( $view, $source, $entry ); |
| 1273 | - $headers[] = $label ? $label : $field->ID; |
|
| 1272 | + $headers[ ] = $label ? $label : $field->ID; |
|
| 1274 | 1273 | } |
| 1275 | 1274 | } |
| 1276 | 1275 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | 'total' => wp_count_posts( 'gravityview' )->publish, |
| 64 | 64 | ); |
| 65 | 65 | foreach ( $items as $item ) { |
| 66 | - $data['views'][] = $this->prepare_view_for_response( $item, $request ); |
|
| 66 | + $data[ 'views' ][ ] = $this->prepare_view_for_response( $item, $request ); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | return new \WP_REST_Response( $data, 200 ); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | $url = $request->get_url_params(); |
| 84 | 84 | |
| 85 | - $view_id = intval( $url['id'] ); |
|
| 85 | + $view_id = intval( $url[ 'id' ] ); |
|
| 86 | 86 | |
| 87 | 87 | $item = get_post( $view_id ); |
| 88 | 88 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | // Only output the fields that should be displayed. |
| 115 | 115 | $allowed = array(); |
| 116 | 116 | foreach ( $view->fields->by_position( "{$context}_*" )->by_visible()->all() as $field ) { |
| 117 | - $allowed[] = $field; |
|
| 117 | + $allowed[ ] = $field; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | // Tack on additional fields if needed |
| 135 | 135 | foreach ( array_diff( $allowed_field_ids, wp_list_pluck( $allowed, 'ID' ) ) as $field_id ) { |
| 136 | - $allowed[] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
| 136 | + $allowed[ ] = is_numeric( $field_id ) ? \GV\GF_Field::by_id( $view->form, $field_id ) : \GV\Internal_Field::by_id( $field_id ); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $r = new Request( $request ); |
@@ -201,10 +201,10 @@ discard block |
||
| 201 | 201 | public function get_sub_items( $request ) { |
| 202 | 202 | |
| 203 | 203 | $url = $request->get_url_params(); |
| 204 | - $view_id = intval( $url['id'] ); |
|
| 204 | + $view_id = intval( $url[ 'id' ] ); |
|
| 205 | 205 | $format = \GV\Utils::get( $url, 'format', 'json' ); |
| 206 | 206 | |
| 207 | - if( $post_id = $request->get_param('post_id') ) { |
|
| 207 | + if ( $post_id = $request->get_param( 'post_id' ) ) { |
|
| 208 | 208 | global $post; |
| 209 | 209 | |
| 210 | 210 | $post = get_post( $post_id ); |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | $data = array( 'entries' => $entries->all(), 'total' => $entries->total() ); |
| 304 | 304 | |
| 305 | - foreach ( $data['entries'] as &$entry ) { |
|
| 305 | + foreach ( $data[ 'entries' ] as &$entry ) { |
|
| 306 | 306 | $entry = $this->prepare_entry_for_response( $view, $entry, $request, 'directory' ); |
| 307 | 307 | } |
| 308 | 308 | |
@@ -321,8 +321,8 @@ discard block |
||
| 321 | 321 | */ |
| 322 | 322 | public function get_sub_item( $request ) { |
| 323 | 323 | $url = $request->get_url_params(); |
| 324 | - $view_id = intval( $url['id'] ); |
|
| 325 | - $entry_id = intval( $url['s_id'] ); |
|
| 324 | + $view_id = intval( $url[ 'id' ] ); |
|
| 325 | + $entry_id = intval( $url[ 's_id' ] ); |
|
| 326 | 326 | $format = \GV\Utils::get( $url, 'format', 'json' ); |
| 327 | 327 | |
| 328 | 328 | $view = \GV\View::by_id( $view_id ); |
@@ -357,32 +357,32 @@ discard block |
||
| 357 | 357 | // Add all the WP_Post data |
| 358 | 358 | $view_post = $view_post->to_array(); |
| 359 | 359 | |
| 360 | - unset( $view_post['to_ping'], $view_post['ping_status'], $view_post['pinged'], $view_post['post_type'], $view_post['filter'], $view_post['post_category'], $view_post['tags_input'], $view_post['post_content'], $view_post['post_content_filtered'] ); |
|
| 360 | + unset( $view_post[ 'to_ping' ], $view_post[ 'ping_status' ], $view_post[ 'pinged' ], $view_post[ 'post_type' ], $view_post[ 'filter' ], $view_post[ 'post_category' ], $view_post[ 'tags_input' ], $view_post[ 'post_content' ], $view_post[ 'post_content_filtered' ] ); |
|
| 361 | 361 | |
| 362 | 362 | $return = wp_parse_args( $item, $view_post ); |
| 363 | 363 | |
| 364 | - $return['title'] = $return['post_title']; |
|
| 364 | + $return[ 'title' ] = $return[ 'post_title' ]; |
|
| 365 | 365 | |
| 366 | - $return['settings'] = isset( $return['atts'] ) ? $return['atts'] : array(); |
|
| 367 | - unset( $return['atts'], $return['view_id'] ); |
|
| 366 | + $return[ 'settings' ] = isset( $return[ 'atts' ] ) ? $return[ 'atts' ] : array(); |
|
| 367 | + unset( $return[ 'atts' ], $return[ 'view_id' ] ); |
|
| 368 | 368 | |
| 369 | - $return['search_criteria'] = array( |
|
| 369 | + $return[ 'search_criteria' ] = array( |
|
| 370 | 370 | 'page_size' => rgars( $return, 'settings/page_size' ), |
| 371 | 371 | 'sort_field' => rgars( $return, 'settings/sort_field' ), |
| 372 | 372 | 'sort_direction' => rgars( $return, 'settings/sort_direction' ), |
| 373 | 373 | 'offset' => rgars( $return, 'settings/offset' ), |
| 374 | 374 | ); |
| 375 | 375 | |
| 376 | - unset( $return['settings']['page_size'], $return['settings']['sort_field'], $return['settings']['sort_direction'] ); |
|
| 376 | + unset( $return[ 'settings' ][ 'page_size' ], $return[ 'settings' ][ 'sort_field' ], $return[ 'settings' ][ 'sort_direction' ] ); |
|
| 377 | 377 | |
| 378 | 378 | // Redact for non-logged ins |
| 379 | 379 | if ( ! \GVCommon::has_cap( 'edit_others_gravityviews' ) ) { |
| 380 | - unset( $return['settings'] ); |
|
| 381 | - unset( $return['search_criteria'] ); |
|
| 380 | + unset( $return[ 'settings' ] ); |
|
| 381 | + unset( $return[ 'search_criteria' ] ); |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | if ( ! \GFCommon::current_user_can_any( 'gravityforms_edit_forms' ) ) { |
| 385 | - unset( $return['form'] ); |
|
| 385 | + unset( $return[ 'form' ] ); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | return $return; |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | $view_id = func_get_arg( 1 ); // $view_id override |
| 399 | 399 | } else { |
| 400 | 400 | $url = $request->get_url_params(); |
| 401 | - $view_id = intval( $url['id'] ); |
|
| 401 | + $view_id = intval( $url[ 'id' ] ); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | if ( ! $view = \GV\View::by_id( $view_id ) ) { |
@@ -444,8 +444,8 @@ discard block |
||
| 444 | 444 | } |
| 445 | 445 | |
| 446 | 446 | $url = $request->get_url_params(); |
| 447 | - $view_id = intval( $url['id'] ); |
|
| 448 | - $entry_id = intval( $url['s_id'] ); |
|
| 447 | + $view_id = intval( $url[ 'id' ] ); |
|
| 448 | + $entry_id = intval( $url[ 's_id' ] ); |
|
| 449 | 449 | |
| 450 | 450 | $view = \GV\View::by_id( $view_id ); |
| 451 | 451 | |
@@ -453,11 +453,11 @@ discard block |
||
| 453 | 453 | return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' ); |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | - if ( $entry['form_id'] != $view->form->ID ) { |
|
| 456 | + if ( $entry[ 'form_id' ] != $view->form->ID ) { |
|
| 457 | 457 | return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' ); |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | - if ( $entry['status'] != 'active' ) { |
|
| 460 | + if ( $entry[ 'status' ] != 'active' ) { |
|
| 461 | 461 | return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' ); |
| 462 | 462 | } |
| 463 | 463 | |
@@ -465,10 +465,10 @@ discard block |
||
| 465 | 465 | return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' ); |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
| 468 | + $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
| 469 | 469 | |
| 470 | 470 | if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
| 471 | - if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 471 | + if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
| 472 | 472 | return new \WP_Error( 'rest_forbidden', 'You are not allowed to view this content.', 'gravityview' ); |
| 473 | 473 | } |
| 474 | 474 | } |