|
@@ -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
|
} |
|
@@ -323,7 +323,7 @@ discard block |
|
|
block discarded – undo |
|
323
|
323
|
|
|
324
|
324
|
foreach ( $entryset as $e ) { |
|
325
|
325
|
|
|
326
|
|
- if ( 'active' !== $e['status'] ) { |
|
|
326
|
+ if ( 'active' !== $e[ 'status' ] ) { |
|
327
|
327
|
gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $e->ID ) ); |
|
328
|
328
|
return __( 'You are not allowed to view this content.', 'gravityview' ); |
|
329
|
329
|
} |
|
@@ -334,7 +334,7 @@ discard block |
|
|
block discarded – undo |
|
334
|
334
|
} |
|
335
|
335
|
|
|
336
|
336
|
if ( $show_only_approved && ! $is_admin_and_can_view ) { |
|
337
|
|
- if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
|
337
|
+ if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $e->ID, \GravityView_Entry_Approval::meta_key ) ) ) { |
|
338
|
338
|
gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $e->ID ) ); |
|
339
|
339
|
return __( 'You are not allowed to view this content.', 'gravityview' ); |
|
340
|
340
|
} |
|
@@ -509,7 +509,7 @@ discard block |
|
|
block discarded – undo |
|
509
|
509
|
$join_column = is_numeric( $join_column ) ? GF_Field::by_id( $join, $join_column ) : Internal_Field::by_id( $join_column ); |
|
510
|
510
|
$join_on_column = is_numeric( $join_on_column ) ? GF_Field::by_id( $join_on, $join_on_column ) : Internal_Field::by_id( $join_on_column ); |
|
511
|
511
|
|
|
512
|
|
- $joins [] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
|
512
|
+ $joins [ ] = new Join( $join, $join_column, $join_on, $join_on_column ); |
|
513
|
513
|
} |
|
514
|
514
|
|
|
515
|
515
|
return $joins; |
|
@@ -604,7 +604,7 @@ discard block |
|
|
block discarded – undo |
|
604
|
604
|
if ( ! $view->form ) { |
|
605
|
605
|
gravityview()->log->error( 'View #{view_id} tried attaching non-existent Form #{form_id} to it.', array( |
|
606
|
606
|
'view_id' => $view->ID, |
|
607
|
|
- 'form_id' => $view->_gravityview_form_id ? : 0, |
|
|
607
|
+ 'form_id' => $view->_gravityview_form_id ?: 0, |
|
608
|
608
|
) ); |
|
609
|
609
|
} |
|
610
|
610
|
|
|
@@ -837,43 +837,42 @@ discard block |
|
|
block discarded – undo |
|
837
|
837
|
* @todo: Stop using _frontend and use something like $request->get_search_criteria() instead |
|
838
|
838
|
*/ |
|
839
|
839
|
$parameters = \GravityView_frontend::get_view_entries_parameters( $this->settings->as_atts(), $this->form->ID ); |
|
840
|
|
- $parameters['context_view_id'] = $this->ID; |
|
|
840
|
+ $parameters[ 'context_view_id' ] = $this->ID; |
|
841
|
841
|
$parameters = \GVCommon::calculate_get_entries_criteria( $parameters, $this->form->ID ); |
|
842
|
842
|
|
|
843
|
843
|
if ( $request instanceof REST\Request ) { |
|
844
|
844
|
$atts = $this->settings->as_atts(); |
|
845
|
845
|
$paging_parameters = wp_parse_args( $request->get_paging(), array( |
|
846
|
|
- 'paging' => array( 'page_size' => $atts['page_size'] ), |
|
|
846
|
+ 'paging' => array( 'page_size' => $atts[ 'page_size' ] ), |
|
847
|
847
|
) ); |
|
848
|
|
- $parameters['paging'] = $paging_parameters['paging']; |
|
|
848
|
+ $parameters[ 'paging' ] = $paging_parameters[ 'paging' ]; |
|
849
|
849
|
} |
|
850
|
850
|
|
|
851
|
|
- $page = Utils::get( $parameters['paging'], 'current_page' ) ? |
|
852
|
|
- : ( ( ( $parameters['paging']['offset'] - $this->settings->get( 'offset' ) ) / $parameters['paging']['page_size'] ) + 1 ); |
|
|
851
|
+ $page = Utils::get( $parameters[ 'paging' ], 'current_page' ) ?: ( ( ( $parameters[ 'paging' ][ 'offset' ] - $this->settings->get( 'offset' ) ) / $parameters[ 'paging' ][ 'page_size' ] ) + 1 ); |
|
853
|
852
|
|
|
854
|
853
|
/** |
|
855
|
854
|
* Cleanup duplicate field_filter parameters to simplify the query. |
|
856
|
855
|
*/ |
|
857
|
856
|
$unique_field_filters = array(); |
|
858
|
|
- foreach ( $parameters['search_criteria']['field_filters'] as $key => $filter ) { |
|
|
857
|
+ foreach ( $parameters[ 'search_criteria' ][ 'field_filters' ] as $key => $filter ) { |
|
859
|
858
|
if ( 'mode' === $key ) { |
|
860
|
|
- $unique_field_filters['mode'] = $filter; |
|
|
859
|
+ $unique_field_filters[ 'mode' ] = $filter; |
|
861
|
860
|
} else if ( ! in_array( $filter, $unique_field_filters ) ) { |
|
862
|
|
- $unique_field_filters[] = $filter; |
|
|
861
|
+ $unique_field_filters[ ] = $filter; |
|
863
|
862
|
} |
|
864
|
863
|
} |
|
865
|
|
- $parameters['search_criteria']['field_filters'] = $unique_field_filters; |
|
|
864
|
+ $parameters[ 'search_criteria' ][ 'field_filters' ] = $unique_field_filters; |
|
866
|
865
|
|
|
867
|
|
- if ( ! empty( $parameters['search_criteria']['field_filters'] ) ) { |
|
|
866
|
+ if ( ! empty( $parameters[ 'search_criteria' ][ 'field_filters' ] ) ) { |
|
868
|
867
|
gravityview()->log->notice( 'search_criteria/field_filters is not empty, third-party code may be using legacy search_criteria filters.' ); |
|
869
|
868
|
} |
|
870
|
869
|
|
|
871
|
870
|
if ( gravityview()->plugin->supports( Plugin::FEATURE_GFQUERY ) ) { |
|
872
|
871
|
$query_class = $this->get_query_class(); |
|
873
|
|
- $query = new $query_class( $this->form->ID, $parameters['search_criteria'], $parameters['sorting'] ); |
|
|
872
|
+ $query = new $query_class( $this->form->ID, $parameters[ 'search_criteria' ], $parameters[ 'sorting' ] ); |
|
874
|
873
|
|
|
875
|
|
- $query->limit( $parameters['paging']['page_size'] ) |
|
876
|
|
- ->offset( ( ( $page - 1 ) * $parameters['paging']['page_size'] ) + $this->settings->get( 'offset' ) ); |
|
|
874
|
+ $query->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
|
875
|
+ ->offset( ( ( $page - 1 ) * $parameters[ 'paging' ][ 'page_size' ] ) + $this->settings->get( 'offset' ) ); |
|
877
|
876
|
|
|
878
|
877
|
/** |
|
879
|
878
|
* Any joins? |
|
@@ -896,7 +895,7 @@ discard block |
|
|
block discarded – undo |
|
896
|
895
|
|
|
897
|
896
|
$query_parameters = $query->_introspect(); |
|
898
|
897
|
|
|
899
|
|
- $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
|
898
|
+ $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
900
|
899
|
} |
|
901
|
900
|
|
|
902
|
901
|
|
|
@@ -911,7 +910,7 @@ discard block |
|
|
block discarded – undo |
|
911
|
910
|
|
|
912
|
911
|
$query_parameters = $query->_introspect(); |
|
913
|
912
|
|
|
914
|
|
- $query->where( \GF_Query_Condition::_and( $query_parameters['where'], $condition ) ); |
|
|
913
|
+ $query->where( \GF_Query_Condition::_and( $query_parameters[ 'where' ], $condition ) ); |
|
915
|
914
|
} |
|
916
|
915
|
} |
|
917
|
916
|
} |
|
@@ -947,15 +946,15 @@ discard block |
|
|
block discarded – undo |
|
947
|
946
|
} ); |
|
948
|
947
|
} else { |
|
949
|
948
|
$entries = $this->form->entries |
|
950
|
|
- ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters['search_criteria'] ) ) |
|
|
949
|
+ ->filter( \GV\GF_Entry_Filter::from_search_criteria( $parameters[ 'search_criteria' ] ) ) |
|
951
|
950
|
->offset( $this->settings->get( 'offset' ) ) |
|
952
|
|
- ->limit( $parameters['paging']['page_size'] ) |
|
|
951
|
+ ->limit( $parameters[ 'paging' ][ 'page_size' ] ) |
|
953
|
952
|
->page( $page ); |
|
954
|
953
|
|
|
955
|
|
- if ( ! empty( $parameters['sorting'] ) && ! empty( $parameters['sorting']['key'] ) ) { |
|
|
954
|
+ if ( ! empty( $parameters[ 'sorting' ] ) && ! empty( $parameters[ 'sorting' ][ 'key' ] ) ) { |
|
956
|
955
|
$field = new \GV\Field(); |
|
957
|
|
- $field->ID = $parameters['sorting']['key']; |
|
958
|
|
- $direction = strtolower( $parameters['sorting']['direction'] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
|
956
|
+ $field->ID = $parameters[ 'sorting' ][ 'key' ]; |
|
|
957
|
+ $direction = strtolower( $parameters[ 'sorting' ][ 'direction' ] ) == 'asc' ? \GV\Entry_Sort::ASC : \GV\Entry_Sort::DESC; |
|
959
|
958
|
$entries = $entries->sort( new \GV\Entry_Sort( $field, $direction ) ); |
|
960
|
959
|
} |
|
961
|
960
|
} |