GravityView  1.19.4
The best, easiest way to display Gravity Forms entries on your website.
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes
GravityView_Widget_Search Class Reference
Inheritance diagram for GravityView_Widget_Search:
GravityView_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_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)
 — Frontend — More...
 
 get_search_method ()
 Returns the search method. More...
 
 prepare_field_filter ($key, $value)
 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...
 
- Public Member Functions inherited from GravityView_Widget
 add_shortcode ($run_on_singular=true)
 Add $this->shortcode_name shortcode to output self::render_frontend() More...
 
 assign_widget_options ($options=array(), $template= '', $widget= '')
 Assign template specific field options. More...
 
 get_setting ($key)
 Get a setting by the setting key. More...
 
 get_settings ()
 Get the widget settings. More...
 
 get_widget_id ()
 
 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= '')
 

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')
 Format a date value. 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_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 Attributes

static $file
 
static $instance
 

Private Member Functions

 get_search_filter_details ($field)
 Prepare search fields to frontend render with other details (label, field type, searched values) 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...
 

Static Private Member Functions

static get_created_by_choices ()
 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...
 

Private Attributes

 $search_filters = array()
 
 $search_method = 'get'
 

Additional Inherited Members

- Protected Member Functions inherited from GravityView_Widget
 get_default_settings ()
 Define general widget settings. More...
 
- Protected Attributes inherited from GravityView_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 ( )

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

References GravityView_Widget\$settings, and set_search_method().

Member Function Documentation

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 1111 of file class-search-widget.php.

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 1126 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.

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

WP_Rewrite $wp_rewrite

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

References $value, and gravityview_get_permalink_query_args().

add_scripts_and_styles (   $hook)

Add script to Views edit screen (admin)

Parameters
mixed$hook

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

References gravityview_is_admin_page(), and GravityView_Plugin\version.

add_template_path (   $file_paths)

Include this extension templates path.

Parameters
array$file_pathsList of template paths ordered

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

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)
  • ymp_slash (yyyy/mm/dd)
  • ymd_dash (yyyy-mm-dd)
  • ymp_dot (yyyy.mm.dd)

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

References $gravityview_view, and GravityView_View\getInstance().

Referenced by has_date_field().

filter_entries (   $search_criteria)

— Frontend —

Calculate the search criteria to filter entries

Parameters
array$search_criteria
Returns
array
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)
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: true
[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 439 of file class-search-widget.php.

References $value, gv_map_deep(), and prepare_field_filter().

static get_created_by_choices ( )
staticprivate

Calculate the search choices for the users.

Since
1.8
Returns
array Array of user choices (value = ID, text = display name)

filter gravityview/get_users/search_widget

See also
::get_users

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

References GVCommon\get_users().

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 726 of file class-search-widget.php.

References $format.

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 947 of file class-search-widget.php.

References $field, $label, and $value.

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

Format a date value.

Parameters
string$valueDate value input
string$formatWanted formatted date
Returns
string

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

References $format, and $value.

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 903 of file class-search-widget.php.

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

get_search_filter_details (   $field)
private

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

Parameters
array$field
Returns
array

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

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

Referenced by has_date_field().

static get_search_form_action ( )
static

Calculate the search form action.

Since
1.6
Returns
string

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

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

static get_search_input_label (   $input_type)
static

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

References $labels.

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 361 of file class-search-widget.php.

References $field_id.

Referenced by GravityView_Migrate\get_search_fields().

get_search_method ( )

Returns the search method.

Since
1.16.4
Returns
string

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

References $search_method.

static get_searchable_fields ( )
static

Ajax Returns the form fields ( only the searchable ones )

public

Returns
void

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

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

static getInstance ( )
static
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 783 of file class-search-widget.php.

References $content, $field, $gravityview_view, enqueue_datepicker(), get_search_filter_details(), GravityView_View\getInstance(), maybe_enqueue_flexibility(), GravityView_Widget\render_frontend(), and rgget_or_rgpost().

maybe_enqueue_flexibility ( )
private

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

Since
1.17
Returns
void

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

Referenced by has_date_field().

prepare_field_filter (   $key,
  $value 
)

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$key$_GET/$_POST search key
string$value$_GET/$_POST search value
Returns
array 1 or 2 deph levels
Since
1.16.3 Safeguard until GF implements '<=' operator

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

References $field_id, $form, $gravityview_view, $value, GravityView_View\getInstance(), and gravityview_get_field().

Referenced by filter_entries().

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 236 of file class-search-widget.php.

register_scripts ( )

Register search widget scripts, including Flexibility.

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

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

References GRAVITYVIEW_FILE, and GravityView_Plugin\version.

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 283 of file class-search-widget.php.

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

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 1093 of file class-search-widget.php.

References $name, $value, and gv_map_deep().

Referenced by get_search_filter_details(), and has_date_field().

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 113 of file class-search-widget.php.

Referenced by __construct().

static the_clear_search_button ( )
static

Output the Clear Search Results button.

Since
1.5.4

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

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

Field Documentation

$file
static

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

$instance
static

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

$search_filters = array()
private

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

$search_method = 'get'
private

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

Referenced by get_search_method().


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