GravityView_Widget_Search
Source: includes/widgets/search-widget/class-search-widget.php:27
Details
- Kind:
class - Namespace:
(global) - Extends: GV\Widget
Methods
| Method | Description |
|---|---|
getInstance() | |
add_reserved_args() | |
get_search_method() | Returns the search method |
get_input_types_by_field_type() | Get the input types available for different field types |
get_search_input_labels() | Get labels for different types of search bar inputs |
add_scripts_and_styles() | Add script to Views edit screen (admin) |
register_no_conflict() | Add admin script to the no-conflict scripts allowlist |
get_searchable_fields() | Ajax |
render_searchable_fields() | Generates html for the available Search Fields dropdown |
get_search_input_types() | Assign an input type according to the form field type |
add_no_permalink_fields() | Display hidden fields to add support for sites using Default permalink structure |
filter_entries() | Calculate the search criteria to filter entries |
gf_query_filter() | Filters the \GF_Query with advanced logic. |
prepare_field_filter() | Prepares the field filters to GFAPI. |
get_date_field_format() | Get the Field Format form GravityForms |
get_formatted_date() | Format a date value |
add_template_path() | Include this extension templates path |
render_frontend() | Renders the Search Widget |
get_search_class() | Get the search class for a search form. |
get_search_form_action() | Calculate the search form action |
the_clear_search_button() | Output the Clear Search Results button |
add_datepicker_js_dependency() | Require the datepicker script for the frontend GV script |
add_datepicker_localization() | Modify the array passed to wp_localize_script() |
enqueue_datepicker() | Enqueue the datepicker script |
add_preview_inputs() | If previewing a View or page with embedded Views, make the search work properly by adding hidden fields with |
add_form_search_fields() | Adds search fields for a specific form. |
set_search_field_options() | Add the settings for this field. |
render_search_active_areas() | Render the search areas. |
render_available_search_fields() | Render html for displaying available search fields. |
record_search_field_context() | Records the rendering context of a search field about to be rendered. |
reset_area_recording() | Resets the recorded areas for the next row. |
add_search_area_settings_button() | Renders a "Clear all fields" button in the View configuration. |
add_search_area_settings() | Registers the area settings for the search fields. |
render_area_settings() | Renders the settings for a search area. |
Method Reference
getInstance()
public static function getInstance()
Returns
Source: includes/widgets/search-widget/class-search-widget.php:117
add_reserved_args()
public function add_reserved_args( $args )
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$args |
Returns
mixed
Since: 2.10
Source: includes/widgets/search-widget/class-search-widget.php:132
get_search_method()
public function get_search_method()
Returns the search method
Returns
string
Since: 1.16.4
Source: includes/widgets/search-widget/class-search-widget.php:190
get_input_types_by_field_type()
public static function get_input_types_by_field_type()
Get the input types available for different field types
Returns
array— [field type name] => (array|string) search bar input types
Since: 1.17.5
Source: includes/widgets/search-widget/class-search-widget.php:201
get_search_input_labels()
public static function get_search_input_labels()
Get labels for different types of search bar inputs
Returns
array— [input type] => input type label
Since: 1.17.5
Source: includes/widgets/search-widget/class-search-widget.php:263
add_scripts_and_styles()
public function add_scripts_and_styles( $hook )
Add script to Views edit screen (admin)
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$hook | mixed |
Source: includes/widgets/search-widget/class-search-widget.php:305
register_no_conflict()
public function register_no_conflict( $allowed )
Add admin script to the no-conflict scripts allowlist
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$allowed | array | Scripts allowed in no-conflict mode |
Returns
array— Scripts allowed in no-conflict mode, plus the search widget script
Source: includes/widgets/search-widget/class-search-widget.php:346
get_searchable_fields()
public static function get_searchable_fields()
Ajax
Returns the form fields ( only the searchable ones )
Returns
void
Source: includes/widgets/search-widget/class-search-widget.php:358
render_searchable_fields()
public static function render_searchable_fields( $form=null, $current='' )
Generates html for the available Search Fields dropdown
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | int | array | null | |
$current | string | '' | (for future use) |
Returns
string
Source: includes/widgets/search-widget/class-search-widget.php:388
get_search_input_types()
public static function get_search_input_types( $field_id='', $field_type=null )
Assign an input type according to the form field type
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$field_id | string | int | float | '' | Gravity Forms field ID |
$field_type | string | null | Gravity Forms field type (also the name parameter of GravityView_Field classes) |
Returns
string— GV field search input type ('multi', 'boolean', 'select', 'date', 'text')
See Also
admin-search-widget.js
Source: includes/widgets/search-widget/class-search-widget.php:435
add_no_permalink_fields()
public function add_no_permalink_fields( $search_fields, $object, $widget_args=[] )
Display hidden fields to add support for sites using Default permalink structure
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$search_fields | |||
$object | |||
$widget_args | [] |
Returns
array— Search fields, modified if not using permalinks
Since: 1.8
Source: includes/widgets/search-widget/class-search-widget.php:479
filter_entries()
public function filter_entries( $search_criteria, $form_id=null, $args=[], $force_search_criteria=false )
Calculate the search criteria to filter entries
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$search_criteria | array | The search criteria | |
$form_id | int | null | The form ID |
$args | array | [] | Some args |
$force_search_criteria | bool | false | Whether to suppress GF_Query filter, internally used in self::gf_query_filter |
Returns
array
Source: includes/widgets/search-widget/class-search-widget.php:655
gf_query_filter()
public function gf_query_filter( &$query, $view, $request )
Filters the \GF_Query with advanced logic.
Drop-in for the legacy flat filters when \GF_Query is available.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
&$query | \GF_Query | The current query object reference | |
$view | |||
$request | \GV\Request | The request object | |
$this | \GV\View | The current view object |
Source: includes/widgets/search-widget/class-search-widget.php:977
prepare_field_filter()
public function prepare_field_filter( $filter_key, $value, $view, $searchable_fields, $get=[] )
Prepares 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
| Name | Type | Default | Description |
|---|---|---|---|
$filter_key | string | ID of the field, or entry meta key | |
$value | string | $_GET/$_POST search value | |
$view | \GV\View | The view we're looking at | |
$searchable_fields | array[] | The searchable fields as configured by the widget. | |
$get | string[] | [] | The $_GET/$_POST array. |
Returns
array|false— 1 or 2 deph levels, false if not allowed
Since: 2.42
Source: includes/widgets/search-widget/class-search-widget.php:1478
get_date_field_format()
public static function get_date_field_format( GF_Field_Date $field )
Get the Field Format form GravityForms
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$field | GF_Field_Date | The field object |
Returns
string— Format of the date in the database
Since: 1.10
Source: includes/widgets/search-widget/class-search-widget.php:1739
get_formatted_date()
public static function get_formatted_date( $value='', $format='Y-m-d', $value_format='Y-m-d' )
Format a date value
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$value | string | '' | Date value input |
$format | string | 'Y-m-d' | Wanted formatted date |
$value_format | string | 'Y-m-d' | The value format. Default: Y-m-d |
Returns
string
Since: 2.1.2
Source: includes/widgets/search-widget/class-search-widget.php:1770
add_template_path()
public function add_template_path( $file_paths )
Include this extension templates path
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$file_paths | array | List of template paths ordered |
Source: includes/widgets/search-widget/class-search-widget.php:1787
render_frontend()
public function render_frontend( $widget_args, $content='', $context='' )
Renders the Search Widget
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$widget_args | array | ||
$content | string | '' | |
$context | string | \GV\Template_Context | '' |
Returns
void
Source: includes/widgets/search-widget/class-search-widget.php:1833
get_search_class()
public static function get_search_class( $custom_class='', $search_layout='horizontal' )
Get the search class for a search form.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$custom_class | string | '' | Custom class to add to the search form |
$search_layout | string | 'horizontal' | Search layout ("horizontal" or "vertical"). Default: "horizontal". |
Returns
string— Sanitized CSS class for the search form
Since:
Source: includes/widgets/search-widget/class-search-widget.php:1905
get_search_form_action()
public static function get_search_form_action( $post_id=0 )
Calculate the search form action
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$post_id | 0 |
Returns
string
Since:
Source: includes/widgets/search-widget/class-search-widget.php:1933
the_clear_search_button()
public static function the_clear_search_button()
Output the Clear Search Results button
Since: 1.5.4
Source: includes/widgets/search-widget/class-search-widget.php:1958
add_datepicker_js_dependency()
public function add_datepicker_js_dependency( $js_dependencies )
Require the datepicker script for the frontend GV script
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$js_dependencies | array | Array of existing required scripts for the fe-views.js script |
Returns
array— Array required scripts, withjquery-ui-datepickeradded
Source: includes/widgets/search-widget/class-search-widget.php:1971
add_datepicker_localization()
public function add_datepicker_localization( $localizations=[], $view_data=[] )
Modify the array passed to wp_localize_script()
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$localizations | [] | ||
$view_data | array | [] | View data array with View settings |
$js_localization | array | The data padded to the Javascript file |
Returns
array
Source: includes/widgets/search-widget/class-search-widget.php:1985
enqueue_datepicker()
public function enqueue_datepicker()
Enqueue the datepicker script
Returns
void
Source: includes/widgets/search-widget/class-search-widget.php:2034
add_preview_inputs()
public function add_preview_inputs()
If previewing a View or page with embedded Views, make the search work properly by adding hidden fields with
query vars
Returns
void
Since: 2.2.1
Source: includes/widgets/search-widget/class-search-widget.php:2129
add_form_search_fields()
public function add_form_search_fields( array $search_fields, int $form_id ): array
Adds search fields for a specific form.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$search_fields | Search_Field[] | The fields. | |
$form_id | int | The form ID. |
Returns
Search_Field[]— The update fields.
Since: 2.42
Source: includes/widgets/search-widget/class-search-widget.php:2262
set_search_field_options()
final public function set_search_field_options( $options=[], $template_id='', $field_id='', $context='', $input_type='', $form_id=0 ): array
Add the settings for this field.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$options | array | [] | The original options. |
$template_id | string | '' | The template ID. |
$field_id | string | '' | The field ID. |
$context | string | '' | The area ID. |
$input_type | string | '' | The (optional) input type. |
$form_id | string | int | 0 | The form ID. |
Returns
array— The updated options.
Since: 2.42
Source: includes/widgets/search-widget/class-search-widget.php:2346
render_search_active_areas()
public function render_search_active_areas( string $template_id, string $zone, array $data ): void
Render the search areas.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$template_id | string | The current slug of the selected View template. | |
$zone | string | Either 'search-general' or 'search-advanced'. | |
$data | array |
Returns
void
Since: 2.42
Source: includes/widgets/search-widget/class-search-widget.php:2445
render_available_search_fields()
public function render_available_search_fields( ?int $form_id=0, ?string $section=null ): void
Render html for displaying available search fields.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | ?int | 0 | |
$section | ?string | null |
Returns
void
Since: 2.42
Source: includes/widgets/search-widget/class-search-widget.php:2512
record_search_field_context()
public function record_search_field_context( string $field_type, string $key, array $option, array $settings, array $rendering ): void
Records the rendering context of a search field about to be rendered.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$field_type | string | Either 'widget', 'field' or 'search'. | |
$key | string | The key of the settings field. | |
$option | array | The configuration of the settings field. | |
$settings | array | All the values for the current item being rendered. | |
$rendering | array | Extra rendering context added to the action. |
Returns
void
Since: 2.42
Source: includes/widgets/search-widget/class-search-widget.php:2544
reset_area_recording()
public function reset_area_recording( $is_dynamic, $template_id, $type, $zone ): void
Resets the recorded areas for the next row.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$is_dynamic | bool | Whether the area is dynamic. | |
$template_id | string | The template ID. | |
$type | string | The object type (widget or field). | |
$zone | string | The render zone. |
Returns
void
Since: 2.44
Source: includes/widgets/search-widget/class-search-widget.php:2568
add_search_area_settings_button()
public function add_search_area_settings_button( $area, $type, $values, $is_dynamic, $template_id, $zone ): void
Renders a "Clear all fields" button in the View configuration.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$area | array | The area. | |
$type | string | The type. | |
$values | array | The values in the area. | |
$is_dynamic | bool | Whether the zone is dynamic. | |
$template_id | string | The template ID. | |
$zone | string | The zone. |
Returns
void
Since: 2.44
Source: includes/widgets/search-widget/class-search-widget.php:2588
add_search_area_settings()
public function add_search_area_settings( $settings, $template_id, $field_id ): array
Registers the area settings for the search fields.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$settings | array | The area settings. | |
$template_id | string | The template ID. | |
$field_id | string | The Field ID. |
Returns
array
Since: 2.44
Source: includes/widgets/search-widget/class-search-widget.php:2615
render_area_settings()
public function render_area_settings( $is_dynamic, $view, $template_id, $type, $zone ): void
Renders the settings for a search area.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$is_dynamic | bool | Whether the area is dynamic. | |
$view | View | The View. | |
$template_id | string | The template ID. | |
$type | string | The object type (widget or field). | |
$zone | string | The render zone. |
Returns
void
Since: 2.44
Source: includes/widgets/search-widget/class-search-widget.php:2648