GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
sort-filter.php
Go to the documentation of this file.
1 <?php
2 /**
3  * @package GravityView
4  * @subpackage Gravityview/admin/metaboxes/partials
5  * @global WP_Post $post
6  */
7 global $post;
8 
10 
11 // View template settings
13 
14 ?>
15 <table class="form-table">
16 
17  <?php
18 
19  do_action( 'gravityview_metabox_sort_filter_before', $current_settings );
20 
21  // Begin Sort fields
22  do_action( 'gravityview_metabox_sort_before', $current_settings );
23 
24  /**
25  * @since 1.7
26  */
28 
29  $sort_fields_input = '<select name="template_settings[sort_field][]" class="gravityview_sort_field" id="gravityview_sort_field_%d">%s</select>';
30 
31  if ( is_array( $current_settings['sort_field'] ) ) {
32  $primary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings['sort_field'][0] );
33  $secondary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings['sort_field'][1] );
34  } else {
35  $primary_sort_fields = $secondary_sort_fields = gravityview_get_sortable_fields( $curr_form, $current_settings['sort_field'] );
36  }
37 
38  // Splice the sort direction
39  $_directions = array();
40  foreach ( (array)\GV\Utils::get( $current_settings, 'sort_direction', array() ) as $i => $direction ) {
41  if ( ! $i ) {
42  $_directions['sort_direction'] = $direction;
43  } else {
44  $_directions[ sprintf( 'sort_direction_%d', $i + 1 ) ] = $direction;
45  }
46  }
48 
49  $sort_directions_input = '<select name="template_settings[sort_direction][]" class="gravityview_sort_direction" id="gravityview_sort_direction_%d">%s</select>';
50 
51  GravityView_Render_Settings::render_setting_row( 'sort_field', $current_settings, sprintf( $sort_fields_input, 1, $primary_sort_fields ) );
52 
53  GravityView_Render_Settings::render_setting_row( 'sort_direction', $current_settings, null, 'template_settings[sort_direction][]' );
54 
55  GravityView_Render_Settings::render_setting_row( 'sort_field_2', $current_settings, sprintf( $sort_fields_input, 2, $secondary_sort_fields ) );
56 
57  GravityView_Render_Settings::render_setting_row( 'sort_direction_2', $current_settings, null, 'template_settings[sort_direction][]' );
58 
59 
60  // End Sort fields
61  do_action( 'gravityview_metabox_sort_after', $current_settings );
62 
63  // Begin Filter fields
64  do_action( 'gravityview_metabox_filter_before', $current_settings );
65 
67 
69 
70  // End Filter fields
71  do_action( 'gravityview_metabox_filter_after', $current_settings );
72 
73  do_action( 'gravityview_metabox_sort_filter_after', $current_settings );
74 
75  ?>
76 
77 </table>
global $post
Definition: sort-filter.php:7
$sort_fields_input
Definition: sort-filter.php:29
$_directions
Definition: sort-filter.php:39
static render_setting_row( $key='', $current_settings=array(), $override_input=null, $name='template_settings[%s]', $id='gravityview_se_%s')
Output a table row for view settings.
gravityview_get_template_settings( $post_id)
Get all the settings for a View.
gravityview_get_form_id( $view_id)
Get the connected form ID from a View ID.
$curr_form
Definition: sort-filter.php:9
gravityview_get_sortable_fields( $formid, $current='')
Render dropdown (select) with the list of sortable fields from a form ID.
$current_settings
Definition: sort-filter.php:12
$sort_directions_input
Definition: sort-filter.php:49