|
@@ -108,7 +108,7 @@ discard block |
|
|
block discarded – undo |
|
108
|
108
|
$supports = array( 'title', 'revisions' ); |
|
109
|
109
|
|
|
110
|
110
|
if ( $is_hierarchical ) { |
|
111
|
|
- $supports[] = 'page-attributes'; |
|
|
111
|
+ $supports[ ] = 'page-attributes'; |
|
112
|
112
|
} |
|
113
|
113
|
|
|
114
|
114
|
/** |
|
@@ -210,11 +210,11 @@ discard block |
|
|
block discarded – undo |
|
210
|
210
|
$rule = array( sprintf( '%s/([^/]+)/csv/?', $slug ), 'index.php?gravityview=$matches[1]&csv=1', 'top' ); |
|
211
|
211
|
|
|
212
|
212
|
add_filter( 'query_vars', function( $query_vars ) { |
|
213
|
|
- $query_vars[] = 'csv'; |
|
|
213
|
+ $query_vars[ ] = 'csv'; |
|
214
|
214
|
return $query_vars; |
|
215
|
215
|
} ); |
|
216
|
216
|
|
|
217
|
|
- if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[0] ] ) ) { |
|
|
217
|
+ if ( ! isset( $wp_rewrite->extra_rules_top[ $rule[ 0 ] ] ) ) { |
|
218
|
218
|
call_user_func_array( 'add_rewrite_rule', $rule ); |
|
219
|
219
|
} |
|
220
|
220
|
} |
|
@@ -283,13 +283,13 @@ discard block |
|
|
block discarded – undo |
|
283
|
283
|
return $content; |
|
284
|
284
|
} |
|
285
|
285
|
|
|
286
|
|
- $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap('gravityview_moderate_entries', $view->ID ); |
|
|
286
|
+ $is_admin_and_can_view = $view->settings->get( 'admin_show_all_statuses' ) && \GVCommon::has_cap( 'gravityview_moderate_entries', $view->ID ); |
|
287
|
287
|
|
|
288
|
288
|
/** |
|
289
|
289
|
* Editing a single entry. |
|
290
|
290
|
*/ |
|
291
|
291
|
if ( $entry = $request->is_edit_entry( $view->form ? $view->form->ID : 0 ) ) { |
|
292
|
|
- if ( $entry['status'] != 'active' ) { |
|
|
292
|
+ if ( $entry[ 'status' ] != 'active' ) { |
|
293
|
293
|
gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
|
294
|
294
|
return __( 'You are not allowed to view this content.', 'gravityview' ); |
|
295
|
295
|
} |
|
@@ -300,7 +300,7 @@ discard block |
|
|
block discarded – undo |
|
300
|
300
|
} |
|
301
|
301
|
|
|
302
|
302
|
if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
|
303
|
|
- if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
|
303
|
+ if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
304
|
304
|
gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
|
305
|
305
|
return __( 'You are not allowed to view this content.', 'gravityview' ); |
|
306
|
306
|
} |
|
@@ -313,7 +313,7 @@ discard block |
|
|
block discarded – undo |
|
313
|
313
|
* Viewing a single entry. |
|
314
|
314
|
*/ |
|
315
|
315
|
} else if ( $entry = $request->is_entry( $view->form ? $view->form->ID : 0 ) ) { |
|
316
|
|
- if ( $entry['status'] != 'active' ) { |
|
|
316
|
+ if ( $entry[ 'status' ] != 'active' ) { |
|
317
|
317
|
gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) ); |
|
318
|
318
|
return __( 'You are not allowed to view this content.', 'gravityview' ); |
|
319
|
319
|
} |
|
@@ -324,7 +324,7 @@ discard block |
|
|
block discarded – undo |
|
324
|
324
|
} |
|
325
|
325
|
|
|
326
|
326
|
if ( $view->settings->get( 'show_only_approved' ) && ! $is_admin_and_can_view ) { |
|
327
|
|
- if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
|
327
|
+ if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
328
|
328
|
gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) ); |
|
329
|
329
|
return __( 'You are not allowed to view this content.', 'gravityview' ); |
|
330
|
330
|
} |
|
@@ -498,7 +498,7 @@ discard block |
|
|
block discarded – undo |
|
498
|
498
|
$join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field( $join_column ); |
|
499
|
499
|
$join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field( $join_on_column ); |
|
500
|
500
|
|
|
501
|
|
- $joins [] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
|
501
|
+ $joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
502
|
502
|
} |
|
503
|
503
|
|
|
504
|
504
|
return $joins; |
|
@@ -540,10 +540,10 @@ discard block |
|
|
block discarded – undo |
|
540
|
540
|
|
|
541
|
541
|
list( $join, $join_column, $join_on, $join_on_column ) = $meta; |
|
542
|
542
|
|
|
543
|
|
- $forms_ids [] = GF_Form::by_id( $join_on ); |
|
|
543
|
+ $forms_ids [ ] = GF_Form::by_id( $join_on ); |
|
544
|
544
|
} |
|
545
|
545
|
|
|
546
|
|
- return ( !empty( $forms_ids) ) ? $forms_ids : null; |
|
|
546
|
+ return ( ! empty( $forms_ids ) ) ? $forms_ids : null; |
|
547
|
547
|
} |
|
548
|
548
|
|
|
549
|
549
|
/** |
|
@@ -581,7 +581,7 @@ discard block |
|
|
block discarded – undo |
|
581
|
581
|
if ( ! $view->form ) { |
|
582
|
582
|
gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
|
583
|
583
|
'view_id' => $view->ID, |
|
584
|
|
- 'form_id' => $view->_gravityview_form_id ? : 0, |
|
|
584
|
+ 'form_id' => $view->_gravityview_form_id ?: 0, |
|
585
|
585
|
) ); |
|
586
|
586
|
} |
|
587
|
587
|
|
|
@@ -814,34 +814,33 @@ discard block |
|
|
block discarded – undo |
|
814
|
814
|
* @todo: Stop using _frontend and use something like $request->get_search_criteria() instead |
|
815
|
815
|
*/ |
|
816
|
816
|
$parameters = \GravityView_frontend::get_view_entries_parameters( $this->settings->as_atts(), $this->form->ID ); |
|
817
|
|
- $parameters['context_view_id'] = $this->ID; |
|
|
817
|
+ $parameters[ 'context_view_id' ] = $this->ID; |
|
818
|
818
|
$parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
|
819
|
819
|
|
|
820
|
820
|
if ( $request instanceof REST\Request ) { |
|
821
|
821
|
$atts = $this->settings->as_atts(); |
|
822
|
822
|
$paging_parameters = wp_parse_args( $request->get_paging(), array( |
|
823
|
|
- 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
|
823
|
+ 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
824
|
824
|
) ); |
|
825
|
|
- $parameters['paging'] = $paging_parameters['paging']; |
|
|
825
|
+ $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
826
|
826
|
} |
|
827
|
827
|
|
|
828
|
|
- $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
829
|
|
- : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 ); |
|
|
828
|
+ $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 ); |
|
830
|
829
|
|
|
831
|
830
|
/** |
|
832
|
831
|
* Cleanup duplicate field_filter parameters to simplify the query. |
|
833
|
832
|
*/ |
|
834
|
833
|
$unique_field_filters = array(); |
|
835
|
|
- foreach ( $parameters['search_criteria']['field_filters'] as $key => $filter ) { |
|
|
834
|
+ foreach ( $parameters[ 'search_criteria' ][ 'field_filters' ] as $key => $filter ) { |
|
836
|
835
|
if ( 'mode' === $key ) { |
|
837
|
|
- $unique_field_filters['mode'] = $filter; |
|
|
836
|
+ $unique_field_filters[ 'mode' ] = $filter; |
|
838
|
837
|
} else if ( ! in_array( $filter, $unique_field_filters ) ) { |
|
839
|
|
- $unique_field_filters[] = $filter; |
|
|
838
|
+ $unique_field_filters[ ] = $filter; |
|
840
|
839
|
} |
|
841
|
840
|
} |
|
842
|
|
- $parameters['search_criteria']['field_filters'] = $unique_field_filters; |
|
|
841
|
+ $parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters; |
|
843
|
842
|
|
|
844
|
|
- if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) { |
|
|
843
|
+ if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
845
|
844
|
gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' ); |
|
846
|
845
|
} |
|
847
|
846
|
|
|
@@ -849,10 +848,10 @@ discard block |
|
|
block discarded – undo |
|
849
|
848
|
/** |
|
850
|
849
|
* New \GF_Query stuff :) |
|
851
|
850
|
*/ |
|
852
|
|
- $query = new \GF_Query( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] ); |
|
|
851
|
+ $query = new \GF_Query( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] ); |
|
853
|
852
|
|
|
854
|
|
- $query->limit( $parameters['paging']['page_size'] ) |
|
855
|
|
- ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
|
853
|
+ $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
|
854
|
+ ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
856
|
855
|
|
|
857
|
856
|
/** |
|
858
|
857
|
* Any joins? |
|
@@ -894,15 +893,15 @@ discard block |
|
|
block discarded – undo |
|
894
|
893
|
} ); |
|
895
|
894
|
} else { |
|
896
|
895
|
$entries = $this->form->entries |
|
897
|
|
- ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
|
896
|
+ ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
898
|
897
|
->offset( $this->settings->get( 'offset' ) ) |
|
899
|
|
- ->limit( $parameters['paging']['page_size'] ) |
|
|
898
|
+ ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
900
|
899
|
->page( $page ); |
|
901
|
900
|
|
|
902
|
|
- if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
|
901
|
+ if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
903
|
902
|
$field = new \GV\Field(); |
|
904
|
|
- $field->ID = $parameters['sorting']['key']; |
|
905
|
|
- $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
|
903
|
+ $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
|
904
|
+ $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
906
|
905
|
$entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
|
907
|
906
|
} |
|
908
|
907
|
} |