GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
search-field-link.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Display the search LINK input field
4  *
5  * @file class-search-widget.php See for usage
6  */
7 
9 $view_id = $gravityview_view->getViewId();
11 
12 // base url to calculate the final full link
14 
15 // Make sure that there are choices to display
16 if ( empty( $search_field['choices'] ) ) {
17  gravityview()->log->debug( 'search-field-link.php - No choices for field' );
18  return;
19 }
20 
21 $links_label = empty( $search_field['label'] ) ? __( 'Show only:', 'gk-gravityview' ) : $search_field['label'];
22 
23 /**
24  * @filter `gravityview/extension/search/links_label` Change the label for the "Link" search bar input type
25  * @since 1.17 Use search field label as default value, if set. Before that, it was hard-coded to "Show only:"
26  * @param string $links_label Default: `Show only:` if search field label is not set. Otherwise, search field label.
27  */
28 $links_label = apply_filters( 'gravityview/extension/search/links_label', $links_label );
29 
30 /**
31  * @filter `gravityview/extension/search/links_sep` Change what separates search bar "Link" input type links
32  * @param string $links_sep Default: `&nbsp;|&nbsp;` Used to connect multiple links
33  */
34 $links_sep = apply_filters( 'gravityview/extension/search/links_sep', '&nbsp;|&nbsp;' );
35 
36 ?>
37 
38 <div class="gv-search-box gv-search-field-link gv-search-box-links">
39  <p>
40  <?php echo esc_html( $links_label ); ?>
41 
42  <?php
43 
45 
46  foreach ( $search_field['choices'] as $k => $choice ) {
47 
48  if ( 0 != $k ) {
49  echo esc_html( $links_sep );
50  }
51 
52  $active = ( '' !== $search_value && in_array( $search_value, array( $choice['text'], $choice['value'] ) ) ) ? ' class="active"' : false;
53 
54  if ( $active ) {
55  $link = remove_query_arg( array( 'pagenum', $search_field['name'] ), $base_url );
56  } else {
57  $link = add_query_arg( array( $search_field['name'] => urlencode( $choice['value'] ) ), remove_query_arg( array('pagenum'), $base_url ) );
58  }
59  ?>
60 
61  <a href="<?php echo esc_url_raw( $link ); ?>" <?php echo $active; ?>><?php echo esc_html( $choice['text'] ); ?></a>
62 
63  <?php } ?>
64  </p>
65 </div>
static _GET( $name, $default=null)
Grab a value from the _GET superglobal or default.
static getInstance( $passed_post=NULL)
static get_search_form_action()
Calculate the search form action.
if( $add_query_args) $link
gravityview()
The main GravityView wrapper function.