GravityView  2.10.1
The best, easiest way to display Gravity Forms entries on your website.
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes
GravityView_Widget_Search Class Reference
Inheritance diagram for GravityView_Widget_Search:
Widget

Public Member Functions

 __construct ()
 
 add_datepicker_js_dependency ( $js_dependencies)
 Require the datepicker script for the frontend GV script. More...
 
 add_datepicker_localization ( $localizations=array(), $view_data=array())
 Modify the array passed to wp_localize_script() More...
 
 add_no_permalink_fields ( $search_fields, $object, $widget_args=array())
 Display hidden fields to add support for sites using Default permalink structure. More...
 
 add_preview_inputs ()
 If previewing a View or page with embedded Views, make the search work properly by adding hidden fields with query vars. More...
 
 add_reserved_args ( $args)
 
 add_scripts_and_styles ( $hook)
 Add script to Views edit screen (admin) More...
 
 add_template_path ( $file_paths)
 Include this extension templates path. More...
 
 enqueue_datepicker ()
 Enqueue the datepicker script. More...
 
 filter_entries ( $search_criteria, $form_id=null, $args=array(), $force_search_criteria=false)
 — Frontend — More...
 
 get_search_method ()
 Returns the search method. More...
 
 gf_query_filter (&$query, $view, $request)
 Filters the with advanced logic. More...
 
 prepare_field_filter ( $filter_key, $value, $view, $searchable_fields, $get=array())
 Prepare the field filters to GFAPI. More...
 
 register_no_conflict ( $allowed)
 Add admin script to the no-conflict scripts whitelist. More...
 
 register_scripts ()
 Register search widget scripts, including Flexibility. More...
 
 render_frontend ( $widget_args, $content='', $context='')
 Renders the Search Widget. More...
 
- Public Member Functions inherited from Widget
 add_shortcode ()
 Add $this->shortcode_name shortcode to output self::render_frontend() More...
 
 as_configuration ()
 Return an array of the old format. More...
 
 assign_widget_options ( $options=array(), $template='', $widget='')
 Assign template specific widget options. More...
 
 get_setting ( $key)
 Get a setting by the setting key. More...
 
 get_settings ()
 Get the widget settings. More...
 
 get_widget_id ()
 Get the Widget ID. More...
 
 is_registered ()
 Whether this Widget's been registered already or not. More...
 
 maybe_do_shortcode ( $text, $widget=null)
 Do shortcode if the Widget's shortcode exists. More...
 
 pre_render_frontend ()
 General validations when rendering the widget. More...
 
 register_widget ( $widgets)
 Register widget to become available in admin. More...
 
 render_frontend ( $widget_args, $content='', $context='')
 Frontend logic. More...
 
 render_shortcode ( $atts, $content='', $context='')
 Shortcode. More...
 

Static Public Member Functions

static get_date_field_format (GF_Field_Date $field)
 Get the Field Format form GravityForms. More...
 
static get_formatted_date ( $value='', $format='Y-m-d', $value_format='Y-m-d')
 Format a date value. More...
 
static get_input_types_by_field_type ()
 Get the input types available for different field types. More...
 
static get_search_class ( $custom_class='')
 Get the search class for a search form. More...
 
static get_search_form_action ()
 Calculate the search form action. More...
 
static get_search_input_label ( $input_type)
 
static get_search_input_labels ()
 Get labels for different types of search bar inputs. More...
 
static get_search_input_types ( $field_id='', $field_type=null)
 Assign an input type according to the form field type. More...
 
static get_searchable_fields ()
 Ajax Returns the form fields ( only the searchable ones ) More...
 
static getInstance ()
 
static render_searchable_fields ( $form_id=null, $current='')
 Generates html for the available Search Fields dropdown. More...
 
static the_clear_search_button ()
 Output the Clear Search Results button. More...
 
- Static Public Member Functions inherited from Widget
static from_configuration ( $configuration)
 Create the needed widget from a configuration array. More...
 
static get_default_widget_areas ()
 Default widget areas. More...
 
static registered ()
 Return all registered widgets. More...
 

Data Fields

 $icon = 'dashicons-search'
 
- Data Fields inherited from Widget
 $configuration
 
 $icon
 
 $position = ''
 
 $UID = ''
 

Static Public Attributes

static $file
 
static $instance
 

Private Member Functions

 convert_request_key_to_filter_key ( $key)
 Convert $_GET/$_POST key to the field/meta ID. More...
 
 get_datepicker_format ( $date_format=false)
 Retrieve the datepicker format. More...
 
 get_operator ( $get, $key, $allowed, $default)
 Get an operator URL override. More...
 
 get_search_filter_details ( $field, $context)
 Prepare search fields to frontend render with other details (label, field type, searched values) More...
 
 get_view_searchable_fields ( $view, $with_full_field=false)
 Get the fields that are searchable for a View. More...
 
 has_date_field ( $search_fields)
 Check whether the configured search fields have a date field. More...
 
 maybe_enqueue_flexibility ()
 If the current visitor is running IE 8 or 9, enqueue Flexibility. More...
 
 rgget_or_rgpost ( $name)
 Based on the search method, fetch the value for a specific key. More...
 
 set_search_method ()
 Sets the search method to GET (default) or POST. More...
 
 sieve_filter_choices ( $filter, $context)
 Sieve filter choices to only ones that are used. More...
 

Static Private Member Functions

static get_created_by_choices ( $view)
 Calculate the search choices for the users. More...
 
static get_field_label ( $field, $form_field=array())
 Get the label for a search form field. More...
 
static get_is_approved_choices ()
 Calculate the search checkbox choices for approval status. More...
 

Private Attributes

 $search_filters = array()
 
 $search_method = 'get'
 whether search method is GET or POST ( default: GET ) More...
 

Additional Inherited Members

- Protected Member Functions inherited from Widget
 get_default_settings ()
 Define general widget settings. More...
 
- Protected Attributes inherited from Widget
 $defaults = array()
 
 $settings = array()
 
 $shortcode_name
 
 $widget_description = ''
 
 $widget_id = ''
 
 $widget_label = ''
 
 $widget_subtitle = ''
 

Detailed Description

Definition at line 16 of file class-search-widget.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

Member Function Documentation

◆ add_datepicker_js_dependency()

add_datepicker_js_dependency (   $js_dependencies)

Require the datepicker script for the frontend GV script.

Parameters
array$js_dependenciesArray of existing required scripts for the fe-views.js script
Returns
array Array required scripts, with jquery-ui-datepicker added

Definition at line 1785 of file class-search-widget.php.

◆ add_datepicker_localization()

add_datepicker_localization (   $localizations = array(),
  $view_data = array() 
)

Modify the array passed to wp_localize_script()

Parameters
array$js_localizationThe data padded to the Javascript file
array$view_dataView data array with View settings
Returns
array
Runs Filter:
gravityview_datepicker_settings Modify the datepicker settings
See also
http://api.jqueryui.com/datepicker/ Learn what settings are available
http://www.renegadetechconsulting.com/tutorials/jquery-datepicker-and-wordpress-i18n Thanks for the helpful information on $wp_locale
Parameters
array$js_localizationThe data padded to the Javascript file
array$view_dataView data array with View settings

Definition at line 1800 of file class-search-widget.php.

◆ add_no_permalink_fields()

add_no_permalink_fields (   $search_fields,
  $object,
  $widget_args = array() 
)

Display hidden fields to add support for sites using Default permalink structure.

Since
1.8
Returns
array Search fields, modified if not using permalinks

WP_Rewrite $wp_rewrite

Definition at line 456 of file class-search-widget.php.

References $args, $value, and gravityview_get_permalink_query_args().

Referenced by render_frontend().

◆ add_preview_inputs()

add_preview_inputs ( )

If previewing a View or page with embedded Views, make the search work properly by adding hidden fields with query vars.

Since
2.2.1
Returns
void

Definition at line 1956 of file class-search-widget.php.

References $value.

◆ add_reserved_args()

add_reserved_args (   $args)
Since
2.10
Parameters
$args
Returns
mixed

Definition at line 124 of file class-search-widget.php.

References $args, $value, and convert_request_key_to_filter_key().

◆ add_scripts_and_styles()

add_scripts_and_styles (   $hook)

Add script to Views edit screen (admin)

Parameters
mixed$hook

Definition at line 251 of file class-search-widget.php.

References gravityview().

◆ add_template_path()

add_template_path (   $file_paths)

Include this extension templates path.

Parameters
array$file_pathsList of template paths ordered

Definition at line 1301 of file class-search-widget.php.

◆ convert_request_key_to_filter_key()

convert_request_key_to_filter_key (   $key)
private

Convert $_GET/$_POST key to the field/meta ID.

Examples:

  • filter_is_starred => is_starred
  • filter_1_2 => 1.2
  • filter_5 => 5
Since
2.0
Parameters
string$key$_GET/_$_POST search key
Returns
string

Definition at line 987 of file class-search-widget.php.

References $field_id.

Referenced by add_reserved_args(), and filter_entries().

◆ enqueue_datepicker()

enqueue_datepicker ( )

Enqueue the datepicker script.

It sets the $gravityview->datepicker_class parameter

Returns
void
Runs Filter:
gravityview_search_datepicker_class Modify the CSS class for the datepicker, used by the CSS class is used by Gravity Forms' javascript to determine the format for the date picker. The gv-datepicker class is required by the GravityView datepicker javascript.
Parameters
string$css_classCSS class to use. Default: gv-datepicker datepicker mdy
Options are:
  • mdy (mm/dd/yyyy)
  • dmy (dd/mm/yyyy)
  • dmy_dash (dd-mm-yyyy)
  • dmy_dot (dd.mm.yyyy)
  • ymd_slash (yyyy/mm/dd)
  • ymd_dash (yyyy-mm-dd)
  • ymd_dot (yyyy.mm.dd)

Definition at line 1871 of file class-search-widget.php.

References $gravityview_view, get_datepicker_format(), and GravityView_View\getInstance().

Referenced by render_frontend().

◆ filter_entries()

filter_entries (   $search_criteria,
  $form_id = null,
  $args = array(),
  $force_search_criteria = false 
)

— Frontend —

Calculate the search criteria to filter entries

Parameters
array$search_criteriaThe search criteria
int$form_idThe form ID
array$argsSome args
bool$force_search_criteriaWhether to suppress GF_Query filter, internally used in self::gf_query_filter
Returns
array

If GF_Query is available, we can construct custom conditions with nested booleans on the query, giving up the old ways of flat search_criteria field_filters.

Runs Filter:
gravityview/search-all-split-words Search for each word separately or the whole phrase?
Since
1.20.2
Parameters
bool$split_wordsTrue: split a phrase into words; False: search whole word only [Default: true]
Runs Filter:
gravityview/search-trim-input Remove leading/trailing whitespaces from search value
Since
2.9.3
Parameters
bool$trim_search_valueTrue: remove whitespace; False: keep as is [Default: true]

Get and normalize the dates according to the input format.

Override start and end dates if View is limited to some already.

Runs Filter:
gravityview_date_created_adjust_timezone Whether to adjust the timezone for entries.
date_created is stored in UTC format. Convert search date into UTC (also used on templates/fields/date_created.php).
This is for backward compatibility before started to automatically apply the timezone offset.
Since
1.12
Parameters
[in,out]boolean$adjust_tzUse timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default is false.
[in]string$contextWhere the filter is being called from. search in this case.

Don't set $search_criteria['start_date'] if start_date is empty as it may lead to bad query results (GFAPI::get_entries)

Runs Filter:
gravityview/search/mode Set the Search Mode (all or any)
Since
1.5.1
Parameters
[in,out]string$modeSearch mode (any vs all)

Definition at line 567 of file class-search-widget.php.

References $args, $value, View\by_id(), convert_request_key_to_filter_key(), Utils\get(), GV\get(), get_datepicker_format(), get_operator(), get_view_searchable_fields(), gravityview(), gv_empty(), gv_map_deep(), and prepare_field_filter().

Referenced by gf_query_filter().

◆ get_created_by_choices()

static get_created_by_choices (   $view)
staticprivate

Calculate the search choices for the users.

Parameters
\GV\View$viewThe view
Since
develop
1.8
Returns
array Array of user choices (value = ID, text = display name)

filter gravityview/get_users/search_widget

See also
::get_users
Runs Filter:
gravityview/search/created_by/text Filter the display text in created by search choices
Since
develop
Parameters
string[in,out]The text. Default: $user->display_name
\WP_User$userThe user.
\GV\View$viewThe view.

Definition at line 1695 of file class-search-widget.php.

References $user, and GVCommon\get_users().

◆ get_date_field_format()

static get_date_field_format ( GF_Field_Date  $field)
static

Get the Field Format form GravityForms.

Parameters
GF_Field_Date$fieldThe field object
Since
1.10
Returns
string Format of the date in the database

Definition at line 1255 of file class-search-widget.php.

References $format.

◆ get_datepicker_format()

get_datepicker_format (   $date_format = false)
private

Retrieve the datepicker format.

Parameters
bool$date_formatWhether to return the PHP date format or the datpicker class name. Default: false.
See also
https://docs.gravityview.co/article/115-changing-the-format-of-the-search-widgets-date-picker
Returns
string The datepicker format placeholder, or the PHP date format.
Runs Filter:
gravityview/widgets/search/datepicker/format
Since
2.1.1
Parameters
string$formatDefault: mdy Options are:
  • mdy (mm/dd/yyyy)
  • dmy (dd/mm/yyyy)
  • dmy_dash (dd-mm-yyyy)
  • dmy_dot (dd.mm.yyyy)
  • ymd_slash (yyyy/mm/dd)
  • ymd_dash (yyyy-mm-dd)
  • ymd_dot (yyyy.mm.dd)

Definition at line 1909 of file class-search-widget.php.

References $format, and GV\get().

Referenced by enqueue_datepicker(), filter_entries(), and prepare_field_filter().

◆ get_field_label()

static get_field_label (   $field,
  $form_field = array() 
)
staticprivate

Get the label for a search form field.

Parameters
array$fieldField setting as sent by the GV configuration - has field, input (input type), and label keys
array$form_fieldForm field data, as fetched by gravityview_get_field()
Returns
string Label for the search form
Runs Filter:
gravityview_search_field_label Modify the label for a search field. Supports returning HTML
Since
1.17.3 Added $field parameter
Parameters
[in,out]string$labelExisting label text, sanitized.
[in]array$form_fieldGravity Forms field array, as returned by GFFormsModel::get_field()
[in]array$fieldField setting as sent by the GV configuration - has field, input (input type), and label keys

Definition at line 1499 of file class-search-widget.php.

References $field, $label, $value, Utils\_GET(), and GV\get().

◆ get_formatted_date()

static get_formatted_date (   $value = '',
  $format = 'Y-m-d',
  $value_format = 'Y-m-d' 
)
static

Format a date value.

Parameters
string$valueDate value input
string$formatWanted formatted date
Since
2.1.2
Parameters
string$value_formatThe value format. Default: Y-m-d
Returns
string

Definition at line 1285 of file class-search-widget.php.

References $format, $value, and gravityview().

◆ get_input_types_by_field_type()

static get_input_types_by_field_type ( )
static

Get the input types available for different field types.

Since
1.17.5
Returns
array [field type name] => (array|string) search bar input types

Input Type groups

See also
admin-search-widget.js (getSelectInput)
Runs Filter:
gravityview/search/input_types Change the types of search fields available to a field type
See also
GravityView_Widget_Search::get_search_input_labels() for the available input types
Parameters
array$input_typesAssociative array: key is field name, value is array of GravityView input types (note: use input_text for text)

Definition at line 179 of file class-search-widget.php.

◆ get_is_approved_choices()

static get_is_approved_choices ( )
staticprivate

Calculate the search checkbox choices for approval status.

Since
develop
Returns
array Array of approval status choices (value = status, text = display name)

Definition at line 1729 of file class-search-widget.php.

References GravityView_Entry_Approval_Status\get_all().

◆ get_operator()

get_operator (   $get,
  $key,
  $allowed,
  $default 
)
private

Get an operator URL override.

Parameters
array$getWhere to look for the operator.
string$keyThe filter key to look for.
array$allowedThe allowed operators (whitelist).
string$defaultThe default operator.
Returns
string The operator.
Runs Filter:
gravityview/search/operator_whitelist An array of allowed operators for a field.
Parameters
[in,out]string[]A whitelist of allowed operators.
stringThe filter name.

Definition at line 1980 of file class-search-widget.php.

References Utils\get().

Referenced by filter_entries(), and prepare_field_filter().

◆ get_search_class()

static get_search_class (   $custom_class = '')
static

Get the search class for a search form.

Since
1.5.4
Returns
string Sanitized CSS class for the search form
Runs Filter:
gravityview_search_class Modify the CSS class for the search form
Parameters
string$search_classThe CSS class for the search form

Definition at line 1448 of file class-search-widget.php.

References $gravityview_view, GravityView_frontend\getInstance(), and GravityView_View\getInstance().

◆ get_search_filter_details()

get_search_filter_details (   $field,
  $context 
)
private

Prepare search fields to frontend render with other details (label, field type, searched values)

Parameters
array$field
\GV\Context$context
Returns
array
Runs Filter:
gravityview/search/sieve_choices Only output used choices for this field.
Parameters
[in,out]boolYes or no.
array$fieldThe field configuration.

Definition at line 1556 of file class-search-widget.php.

References $field, GV\$form, $gravityview_view, $name, $value, Utils\get(), GV\get(), GravityView_View\getInstance(), gravityview_get_field(), gravityview_get_terms_choices(), rgget_or_rgpost(), and sieve_filter_choices().

Referenced by render_frontend().

◆ get_search_form_action()

static get_search_form_action ( )
static

Calculate the search form action.

Since
1.6
Returns
string
Runs Filter:
gravityview/widget/search/form/action Override the search URL.
Parameters
[in,out]string$actionWhere the form submits to.

Further parameters will be added once adhoc context is added. Use gravityview()->request until then.

Definition at line 1476 of file class-search-widget.php.

References $gravityview_view, $url, and GravityView_View\getInstance().

◆ get_search_input_label()

static get_search_input_label (   $input_type)
static

Definition at line 241 of file class-search-widget.php.

References $labels, and GV\get().

◆ get_search_input_labels()

static get_search_input_labels ( )
static

Get labels for different types of search bar inputs.

Since
1.17.5
Returns
array [input type] => input type label

Input Type labels l10n

See also
admin-search-widget.js (getSelectInput)
Runs Filter:
gravityview/search/input_types Change the label of search field input types
Parameters
array$input_typesAssociative array: key is input type name, value is label

Definition at line 215 of file class-search-widget.php.

◆ get_search_input_types()

static get_search_input_types (   $field_id = '',
  $field_type = null 
)
static

Assign an input type according to the form field type.

See also
admin-search-widget.js
Parameters
string | int | float$field_idGravity Forms field ID
string$field_typeGravity Forms field type (also the name parameter of GravityView_Field classes)
Returns
string GV field search input type ('multi', 'boolean', 'select', 'date', 'text')
Runs Filter:
gravityview/extension/search/input_type Modify the search form input type based on field type
Since
1.2
1.19.2 Added $field_id parameter
Parameters
string$input_typeAssign an input type according to the form field type. Defaults: boolean, multi, select, date, text
string$field_typeGravity Forms field type (also the name parameter of GravityView_Field classes)
string | int | float$field_idID of the field being processed

Definition at line 418 of file class-search-widget.php.

References $field_id.

Referenced by GravityView_Migrate\get_search_fields().

◆ get_search_method()

get_search_method ( )

Returns the search method.

Since
1.16.4
Returns
string

Definition at line 168 of file class-search-widget.php.

References $search_method.

◆ get_searchable_fields()

static get_searchable_fields ( )
static

Ajax Returns the form fields ( only the searchable ones )

Returns
void

Definition at line 294 of file class-search-widget.php.

References GV\$form, gravityview_get_form_id(), and GravityView_Ajax\pre_get_form_fields().

◆ get_view_searchable_fields()

get_view_searchable_fields (   $view,
  $with_full_field = false 
)
private

Get the fields that are searchable for a View.

Since
2.0
2.0.9 Added $with_full_field parameter
Parameters
\GV\View | null$view
bool$with_full_fieldReturn full field array, or just field ID? Default: false (just field ID)

TODO: Move to , perhaps? And return a Field_Collection TODO: Use in gravityview()->request->is_search() to calculate whether a valid search

Returns
array If no View, returns empty array. Otherwise, returns array of fields configured in widgets and Search Bar for a View

Find all search widgets on the view and get the searchable fields settings.

Include the sidebar Widgets.

Runs Filter:
gravityview/search/searchable_fields/whitelist Modifies the fields able to be searched using the Search Bar
Since
2.5.1
Parameters
array$searchable_fieldsArray of GravityView-formatted fields or only the field ID? Example: [ '1.2', 'created_by' ]
\GV\View$viewObject of View being searched.
bool$with_full_fieldDoes $searchable_fields contain the full field array or just field ID? Default: false (just field ID)

Definition at line 504 of file class-search-widget.php.

References $field, and GV\all().

Referenced by filter_entries(), and prepare_field_filter().

◆ getInstance()

static getInstance ( )
static

◆ gf_query_filter()

gf_query_filter ( $query,
  $view,
  $request 
)

Filters the with advanced logic.

Dropin for the legacy flat filters when is available.

Parameters
\GF_Query$queryThe current query object reference
\GV\View$thisThe current view object
\GV\Request$requestThe request object

This is a shortcut to get all the needed search criteria. We feed these into an new GF_Query and tack them onto the current object.

force search_criteria

Call any userland filters that they might have.

Runs Filter:
gravityview_search_operator Modify the search operator for the field (contains, is, isnot, etc)
Parameters
string$operatorExisting search operator
array$filterarray with key, value, operator, type keys
Since
develop
Parameters
\GV\View$viewThe View we're operating on.

Parse the filter criteria to generate the needed WHERE condition. This is a trick to not write our own generation code by reusing what's inside GF_Query already as they take care of many small things like forcing numeric, etc.

Grab the current clauses. We'll be combining them shortly.

Combine the parts as a new WHERE clause.

Definition at line 786 of file class-search-widget.php.

References $search_field, filter_entries(), and GravityView_Entry_Approval_Status\UNAPPROVED.

◆ has_date_field()

has_date_field (   $search_fields)
private

Check whether the configured search fields have a date field.

Since
1.17.5
Parameters
array$search_fields
Returns
bool True: has a date or date_range field

Definition at line 1318 of file class-search-widget.php.

References $field.

Referenced by render_frontend().

◆ maybe_enqueue_flexibility()

maybe_enqueue_flexibility ( )
private

If the current visitor is running IE 8 or 9, enqueue Flexibility.

Since
1.17
Returns
void

Definition at line 1857 of file class-search-widget.php.

Referenced by render_frontend().

◆ prepare_field_filter()

prepare_field_filter (   $filter_key,
  $value,
  $view,
  $searchable_fields,
  $get = array() 
)

Prepare the field filters to GFAPI.

The type post_category, multiselect and checkbox support multi-select search - each value needs to be separated in an independent filter so we could apply the ANY search mode.

Format searched values

Parameters
string$filter_keyID of the field, or entry meta key
string$value$_GET/$_POST search value
\GV\View$viewThe view we're looking at
array[]$searchable_fields The searchable fields as configured by the widget.
string[]$get The $_GET/$_POST array.
Since
develop Added 5th $get parameter for operator overrides.
Returns
array|false 1 or 2 deph levels, false if not allowed
Since
1.16.3 Safeguard until GF implements '<=' operator

Definition at line 1017 of file class-search-widget.php.

References $field, $field_id, GV\$form, $form_id, $forms, $value, Internal_Field\by_id(), GF_Field\by_id(), get_datepicker_format(), get_operator(), get_view_searchable_fields(), and gravityview_get_input_id_from_id().

Referenced by filter_entries().

◆ register_no_conflict()

register_no_conflict (   $allowed)

Add admin script to the no-conflict scripts whitelist.

Parameters
array$allowedScripts allowed in no-conflict mode
Returns
array Scripts allowed in no-conflict mode, plus the search widget script

Definition at line 283 of file class-search-widget.php.

◆ register_scripts()

register_scripts ( )

Register search widget scripts, including Flexibility.

See also
https://github.com/10up/flexibility
Since
1.17
Returns
void

Definition at line 1846 of file class-search-widget.php.

References GRAVITYVIEW_FILE.

◆ render_frontend()

render_frontend (   $widget_args,
  $content = '',
  $context = '' 
)

Renders the Search Widget.

Parameters
array$widget_args
string$content
string | \GV\Template_Context$context
Returns
void
Runs Filter:
gravityview_widget_search_filters Modify what fields are shown. The order of the fields in the $search_filters array controls the order as displayed in the search bar widget.
Parameters
array$search_fieldsArray of search filters with key, label, value, type, choices keys
GravityView_Widget_Search$thisCurrent widget object
array$widget_argsArgs passed to this method. {
Since
1.8}
Parameters
\GV\Template_Context$context{
Since
2.0}
Parameters
array
Since
1.14

Definition at line 1340 of file class-search-widget.php.

References $field, $gravityview_view, add_no_permalink_fields(), View\by_id(), enqueue_datepicker(), get_search_filter_details(), GravityView_View\getInstance(), gravityview(), has_date_field(), maybe_enqueue_flexibility(), and rgget_or_rgpost().

◆ render_searchable_fields()

static render_searchable_fields (   $form_id = null,
  $current = '' 
)
static

Generates html for the available Search Fields dropdown.

Parameters
int$form_id
string$current(for future use)
Returns
string
Runs Filter:
gravityview/search/searchable_fields Modify the fields that are displayed as searchable in the Search Bar dropdown
Since
1.17
See also
gravityview_get_form_fields() Used to fetch the fields
GravityView_Widget_Search::get_search_input_types See this method to modify the type of input types allowed for a field
Parameters
array$fieldsArray of searchable fields, as fetched by gravityview_get_form_fields()
int$form_id

Definition at line 329 of file class-search-widget.php.

References $field, $form_id, $output, gravityview(), and gravityview_get_form_fields().

◆ rgget_or_rgpost()

rgget_or_rgpost (   $name)
private

Based on the search method, fetch the value for a specific key.

Since
1.16.4
Parameters
string$nameName of the request key to fetch the value for
Returns
mixed|string Value of request at $name key. Empty string if empty.

Definition at line 1767 of file class-search-widget.php.

References $name, $value, Utils\_REQUEST(), and gv_map_deep().

Referenced by get_search_filter_details(), and render_frontend().

◆ set_search_method()

set_search_method ( )
private

Sets the search method to GET (default) or POST.

Since
1.16.4
Runs Filter:
gravityview/search/method Modify the search form method (GET / POST)
Since
1.16.4
Parameters
string$search_methodAssign an input type according to the form field type. Defaults: boolean, multi, select, date, text
string$field_typeGravity Forms field type (also the name parameter of GravityView_Field classes)

Definition at line 149 of file class-search-widget.php.

Referenced by __construct().

◆ sieve_filter_choices()

sieve_filter_choices (   $filter,
  $context 
)
private

Sieve filter choices to only ones that are used.

Parameters
array$filterThe filter configuration.
\GV\Context$contextThe context
Since
develop

Definition at line 1629 of file class-search-widget.php.

References $field, $form_id, endswitch, GV\get(), and gravityview_get_field().

Referenced by get_search_filter_details().

◆ the_clear_search_button()

static the_clear_search_button ( )
static

Output the Clear Search Results button.

Since
1.5.4

Definition at line 1746 of file class-search-widget.php.

References $gravityview_view, $url, GravityView_View\getInstance(), and gravityview_get_link().

Field Documentation

◆ $file

$file
static

Definition at line 20 of file class-search-widget.php.

◆ $icon

$icon = 'dashicons-search'

Definition at line 18 of file class-search-widget.php.

◆ $instance

$instance
static

Definition at line 21 of file class-search-widget.php.

◆ $search_filters

$search_filters = array()
private

Definition at line 23 of file class-search-widget.php.

◆ $search_method

string $search_method = 'get'
private

whether search method is GET or POST ( default: GET )

Since
1.16.4

Definition at line 30 of file class-search-widget.php.

Referenced by get_search_method().


The documentation for this class was generated from the following file: