GravityView
2.17
The best, easiest way to display Gravity Forms entries on your website.
|
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... | |
maybe_sieve_filter_choices ( $search_fields, $widget, $widget_args, $context) | |
If sieve choices is enabled, run it for each of the fields with choices. 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 allowlist. 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, $widget_args) | |
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 = '' | |
Definition at line 16 of file class-search-widget.php.
__construct | ( | ) |
Definition at line 32 of file class-search-widget.php.
References Widget\$settings, Widget\is_registered(), and set_search_method().
add_datepicker_js_dependency | ( | $js_dependencies | ) |
Require the datepicker script for the frontend GV script.
array | $js_dependencies | Array of existing required scripts for the fe-views.js script |
jquery-ui-datepicker
added Definition at line 1932 of file class-search-widget.php.
add_datepicker_localization | ( | $localizations = array() , |
|
$view_data = array() |
|||
) |
Modify the array passed to wp_localize_script()
array | $js_localization | The data padded to the Javascript file |
array | $view_data | View data array with View settings |
gravityview_datepicker_settings
Modify the datepicker settings array | $js_localization | The data padded to the Javascript file |
array | $view_data | View data array with View settings |
Definition at line 1947 of file class-search-widget.php.
add_no_permalink_fields | ( | $search_fields, | |
$object, | |||
$widget_args = array() |
|||
) |
Display hidden fields to add support for sites using Default permalink structure.
WP_Rewrite $wp_rewrite
Definition at line 481 of file class-search-widget.php.
References $args, $value, and gravityview_get_permalink_query_args().
Referenced by render_frontend().
add_preview_inputs | ( | ) |
If previewing a View or page with embedded Views, make the search work properly by adding hidden fields with query vars.
Definition at line 2103 of file class-search-widget.php.
References $value.
add_reserved_args | ( | $args | ) |
$args |
Definition at line 149 of file class-search-widget.php.
References $args, $value, and convert_request_key_to_filter_key().
add_scripts_and_styles | ( | $hook | ) |
Add script to Views edit screen (admin)
mixed | $hook |
Definition at line 276 of file class-search-widget.php.
References gravityview().
add_template_path | ( | $file_paths | ) |
Include this extension templates path.
array | $file_paths | List of template paths ordered |
Definition at line 1387 of file class-search-widget.php.
|
private |
Convert $_GET/$_POST key to the field/meta ID.
Examples:
filter_is_starred
=> is_starred
filter_1_2
=> 1.2
filter_5
=> 5
string | $key | $_GET/_$_POST search key |
Definition at line 1073 of file class-search-widget.php.
References $field_id.
Referenced by add_reserved_args(), and filter_entries().
enqueue_datepicker | ( | ) |
Enqueue the datepicker script.
It sets the $gravityview->datepicker_class parameter
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. string | $css_class | CSS class to use. Default: gv-datepicker datepicker mdy Options are:
|
Definition at line 2018 of file class-search-widget.php.
References $gravityview_view, get_datepicker_format(), and GravityView_View\getInstance().
Referenced by render_frontend().
filter_entries | ( | $search_criteria, | |
$form_id = null , |
|||
$args = array() , |
|||
$force_search_criteria = false |
|||
) |
— Frontend —
Calculate the search criteria to filter entries
array | $search_criteria | The search criteria |
int | $form_id | The form ID |
array | $args | Some args |
bool | $force_search_criteria | Whether to suppress GF_Query filter, internally used in self::gf_query_filter |
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.
gravityview/search-all-split-words
Search for each word separately or the whole phrase? bool | $split_words | True: split a phrase into words; False: search whole word only [Default: true] |
gravityview/search-trim-input
Remove leading/trailing whitespaces from search value bool | $trim_search_value | True: 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.
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). boolean | $adjust_tz | Use timezone-adjusted datetime? If true, adjusts date based on blog's timezone setting. If false, uses UTC setting. Default is false . |
string | $context | Where 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)
gravityview/search/ignore-empty-values
Filter to control if empty field values should be ignored or strictly matched (default: true) bool | $ignore_empty_values | |
int | null | $filter_key | |
int | null | $view_id | |
int | null | $form_id |
gravityview/search/mode
Set the Search Mode (all
or any
) string | $mode | Search mode (any vs all ) |
Definition at line 600 of file class-search-widget.php.
References $args, $field, $form_id, $value, $view_id, View\by_id(), convert_request_key_to_filter_key(), Utils\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().
|
staticprivate |
Calculate the search choices for the users.
\GV\View | null | $view | The View, if set. |
filter gravityview/get_users/search_widget
gravityview/search/created_by/text
Filter the display text in created by search choices string[in,out] | The text. Default: $user->display_name | |
\WP_User | $user | The user. |
\GV\View | null | $view | The view. |
Definition at line 1840 of file class-search-widget.php.
References $user, and GVCommon\get_users().
|
static |
Get the Field Format form GravityForms.
GF_Field_Date | $field | The field object |
Definition at line 1341 of file class-search-widget.php.
References $format.
|
private |
Retrieve the datepicker format.
bool | $date_format | Whether to return the PHP date format or the datpicker class name. Default: false. |
gravityview/widgets/search/datepicker/format
string | $format | Default: mdy Options are:
|
Definition at line 2056 of file class-search-widget.php.
References $format.
Referenced by enqueue_datepicker(), filter_entries(), and prepare_field_filter().
|
staticprivate |
Get the label for a search form field.
array | $field | Field setting as sent by the GV configuration - has field , input (input type), and label keys |
array | $form_field | Form field data, as fetched by gravityview_get_field() |
gravityview_search_field_label
Modify the label for a search field. Supports returning HTML string | $label | Existing label text, sanitized. |
array | $form_field | Gravity Forms field array, as returned by GFFormsModel::get_field() |
array | $field | Field setting as sent by the GV configuration - has field , input (input type), and label keys |
Definition at line 1584 of file class-search-widget.php.
References $field, $label, $value, and Utils\_GET().
|
static |
Format a date value.
string | $value | Date value input |
string | $format | Wanted formatted date |
string | $value_format | The value format. Default: Y-m-d |
Definition at line 1371 of file class-search-widget.php.
References $format, $value, and gravityview().
|
static |
Get the input types available for different field types.
Input Type groups
gravityview/search/input_types
Change the types of search fields available to a field type array | $input_types | Associative array: key is field name , value is array of GravityView input types (note: use input_text for text ) |
Definition at line 204 of file class-search-widget.php.
|
staticprivate |
Calculate the search checkbox choices for approval status.
Definition at line 1874 of file class-search-widget.php.
References GravityView_Entry_Approval_Status\get_all().
|
private |
Get an operator URL override.
array | $get | Where to look for the operator. |
string | $key | The filter key to look for. |
array | $allowed | The allowed operators (allowlist). |
string | $default | The default operator. |
2.14
gravityview/search/operator_allowlist
An array of allowed operators for a field. string[] | An allowlist of operators. |
string | The filter name. |
Definition at line 2127 of file class-search-widget.php.
References Utils\get().
Referenced by filter_entries(), and prepare_field_filter().
|
static |
Get the search class for a search form.
gravityview_search_class
Modify the CSS class for the search form string | $search_class | The CSS class for the search form |
Definition at line 1533 of file class-search-widget.php.
References $gravityview_view, GravityView_frontend\getInstance(), GravityView_View\getInstance(), and gravityview().
|
private |
Prepare search fields to frontend render with other details (label, field type, searched values)
array | $field | |
\GV\Context | $context | |
array | $widget_args |
gravityview/search/filter_details
Filter the output filter details for the Search widget. array | $filter | The filter details |
array | $field | The search field configuration |
Definition at line 1644 of file class-search-widget.php.
References $field, GV\$form, $gravityview_view, $name, $value, Utils\get(), GravityView_View\getInstance(), gravityview_get_field(), gravityview_get_terms_choices(), and rgget_or_rgpost().
Referenced by render_frontend().
|
static |
Calculate the search form action.
gravityview/widget/search/form/action
Override the search URL. string | $action | Where the form submits to. |
Further parameters will be added once adhoc context is added. Use gravityview()->request until then.
Definition at line 1561 of file class-search-widget.php.
References $gravityview_view, $url, and GravityView_View\getInstance().
|
static |
Definition at line 266 of file class-search-widget.php.
References $labels.
|
static |
Get labels for different types of search bar inputs.
Input Type labels l10n
gravityview/search/input_types
Change the label of search field input types array | $input_types | Associative array: key is input type name, value is label |
Definition at line 240 of file class-search-widget.php.
|
static |
Assign an input type according to the form field type.
string | int | float | $field_id | Gravity Forms field ID |
string | $field_type | Gravity Forms field type (also the name parameter of GravityView_Field classes) |
gravityview/extension/search/input_type
Modify the search form input type based on field type string | $input_type | Assign an input type according to the form field type. Defaults: boolean , multi , select , date , text |
string | $field_type | Gravity Forms field type (also the name parameter of GravityView_Field classes) |
string | int | float | $field_id | ID of the field being processed |
Definition at line 443 of file class-search-widget.php.
References $field_id.
Referenced by GravityView_Migrate\get_search_fields().
get_search_method | ( | ) |
Returns the search method.
Definition at line 193 of file class-search-widget.php.
References $search_method.
|
static |
Ajax Returns the form fields ( only the searchable ones )
Definition at line 319 of file class-search-widget.php.
References GV\$form, gravityview_get_form_id(), and GravityView_Ajax\pre_get_form_fields().
|
private |
Get the fields that are searchable for a View.
\GV\View | null | $view | |
bool | $with_full_field | Return 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
Find all search widgets on the view and get the searchable fields settings.
Include the sidebar Widgets.
gravityview/search/searchable_fields/allowlist
Modifies the fields able to be searched using the Search Bar array | $searchable_fields | Array of GravityView-formatted fields or only the field ID? Example: [ '1.2', 'created_by' ] |
\GV\View | $view | Object of View being searched. |
bool | $with_full_field | Does $searchable_fields contain the full field array or just field ID? Default: false (just field ID) |
Definition at line 529 of file class-search-widget.php.
References $field.
Referenced by filter_entries(), and prepare_field_filter().
|
static |
Definition at line 135 of file class-search-widget.php.
References GravityView_Widget_Search.
Referenced by GravityView_Search_WP_Widget\__construct(), GravityView_frontend\is_searching(), and GravityView_Search_WP_Widget\widget().
gf_query_filter | ( | & | $query, |
$view, | |||
$request | |||
) |
Filters the with advanced logic.
Dropin for the legacy flat filters when is available.
\GF_Query | $query | The current query object reference |
\GV\View | $this | The current view object |
\GV\Request | $request | The 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.
gravityview_search_operator
Modify the search operator for the field (contains, is, isnot, etc) string | $operator | Existing search operator |
array | $filter | array with key , value , operator , type keys |
\GV\View | $view | The 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 849 of file class-search-widget.php.
References $search_field, $value, filter_entries(), and GravityView_Entry_Approval_Status\UNAPPROVED.
|
private |
Check whether the configured search fields have a date field.
array | $search_fields |
date
or date_range
field Definition at line 1404 of file class-search-widget.php.
References $field.
Referenced by render_frontend().
|
private |
If the current visitor is running IE 8 or 9, enqueue Flexibility.
Definition at line 2004 of file class-search-widget.php.
Referenced by render_frontend().
maybe_sieve_filter_choices | ( | $search_fields, | |
$widget, | |||
$widget_args, | |||
$context | |||
) |
If sieve choices is enabled, run it for each of the fields with choices.
sieve_filter_choices
array | $search_fields | Array of search filters with key , label , value , type keys |
GravityView_Widget_Search | $widget | Current widget object |
array | $widget_args | Args passed to this method. { |
\GV\Template_Context | $context |
address
, and there are choices to add, adds them and changes the input type. Otherwise, sets the input to text. gravityview/search/sieve_choices
Only output used choices for this field. sieve_choices
widget setting and added $widget_args parameter.bool | $sieve_choices | True: Yes, filter choices based on whether the value exists in entries. False: show all choices in the original field. Default: false. |
array | $field | The field configuration. |
Definition at line 1710 of file class-search-widget.php.
References $field, Utils\get(), gravityview_get_field(), and sieve_filter_choices().
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
string | $filter_key | ID of the field, or entry meta key |
string | $value | $_GET/$_POST search value |
\GV\View | $view | The view we're looking at |
array[] | $searchable_fields The searchable fields as configured by the widget. | |
string[] | $get The $_GET/$_POST array. |
Definition at line 1103 of file class-search-widget.php.
References $field, $field_id, GV\$form, $form_id, $forms, $input_id, $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 | ( | $allowed | ) |
Add admin script to the no-conflict scripts allowlist.
array | $allowed | Scripts allowed in no-conflict mode |
Definition at line 308 of file class-search-widget.php.
register_scripts | ( | ) |
Register search widget scripts, including Flexibility.
Definition at line 1993 of file class-search-widget.php.
References GRAVITYVIEW_FILE.
render_frontend | ( | $widget_args, | |
$content = '' , |
|||
$context = '' |
|||
) |
Renders the Search Widget.
array | $widget_args | |
string | $content | |
string | \GV\Template_Context | $context |
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. array | $search_fields | Array of search filters with key , label , value , type , choices keys |
GravityView_Widget_Search | $this | Current widget object |
array | $widget_args | Args passed to this method. { |
\GV\Template_Context | $context | { |
Definition at line 1426 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().
|
static |
Generates html for the available Search Fields dropdown.
int | $form_id | |
string | $current | (for future use) |
gravityview/search/searchable_fields
Modify the fields that are displayed as searchable in the Search Bar dropdownarray | $fields | Array of searchable fields, as fetched by gravityview_get_form_fields() |
int | $form_id |
Definition at line 354 of file class-search-widget.php.
References $field, $form_id, $output, gravityview(), and gravityview_get_form_fields().
|
private |
Based on the search method, fetch the value for a specific key.
string | $name | Name of the request key to fetch the value for |
Definition at line 1912 of file class-search-widget.php.
References $name, $value, Utils\_REQUEST(), and gv_map_deep().
Referenced by get_search_filter_details(), and render_frontend().
|
private |
Sets the search method to GET (default) or POST.
gravityview/search/method
Modify the search form method (GET / POST) string | $search_method | Assign an input type according to the form field type. Defaults: boolean , multi , select , date , text |
string | $field_type | Gravity Forms field type (also the name parameter of GravityView_Field classes) |
Definition at line 174 of file class-search-widget.php.
Referenced by __construct().
|
private |
Sieve filter choices to only ones that are used.
array | $filter | The filter configuration. |
\GV\Context | $context | The context |
Definition at line 1752 of file class-search-widget.php.
References $field, $form_id, GravityView_Cache, and gravityview_get_field().
Referenced by maybe_sieve_filter_choices().
|
static |
Output the Clear Search Results button.
Definition at line 1891 of file class-search-widget.php.
References $gravityview_view, $url, GravityView_View\getInstance(), and gravityview_get_link().
|
static |
Definition at line 20 of file class-search-widget.php.
$icon = 'dashicons-search' |
Definition at line 18 of file class-search-widget.php.
|
static |
Definition at line 21 of file class-search-widget.php.
|
private |
Definition at line 23 of file class-search-widget.php.
|
private |
whether search method is GET or POST ( default: GET )
Definition at line 30 of file class-search-widget.php.
Referenced by get_search_method().