GravityView  2.1.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 Attributes
GravityView_frontend Class Reference

Public Member Functions

 add_columns_sort_links ( $label='', $field, $form)
 Inject the sorting links on the table columns. More...
 
 add_scripts_and_styles ()
 Register styles and scripts. More...
 
 comments_open ( $open, $post_id)
 Disable comments on GravityView post types. More...
 
 context_not_configured_warning ( $view_id=0)
 Display a warning when a View has not been configured. More...
 
 get_context_view_id ()
 Returns the the view_id context when page contains multiple embedded views or displaying single entry view. More...
 
 getEntry ()
 
 getGvOutputData ()
 
 getPostId ()
 
 getSingleEntry ()
 
 is_field_sortable ( $field_id='', $form=array())
 Checks if field (column) is sortable. More...
 
 is_searching ()
 Checks if the current View is presenting search results. More...
 
 isGravityviewPostType ()
 
 isPostHasShortcode ()
 
 isSearch ()
 
 parse_content ( $wp=array())
 Read the $post and process the View data inside. More...
 
 parse_query_fix_frontpage (&$query)
 Allow GravityView entry endpoints on the front page of a site. More...
 
 set_context_view_id ( $view_id=null)
 Set the context view ID used when page contains multiple embedded views or displaying the single entry view. More...
 
 set_entry_data ()
 Set the entry. More...
 
 setEntry ( $entry)
 Set the current entry. More...
 
 setGvOutputData ( $gv_output_data)
 
 setIsGravityviewPostType ( $is_gravityview_post_type)
 
 setIsSearch ( $is_search)
 
 setPostHasShortcode ( $post_has_shortcode)
 
 setPostId ( $post_id)
 
 setSingleEntry ( $single_entry)
 Sets the single entry ID and also the entry. More...
 
 single_entry_title ( $title, $passed_post_id=null)
 Filter the title for the single entry view. More...
 

Static Public Member Functions

static _override_sorting_id_by_field_type ( $sort_field_id, $form_id)
 Override sorting per field. More...
 
static add_style ( $template_id)
 Add template extra style if exists. More...
 
static get_search_criteria ( $args, $form_id)
 Parse search criteria for a entries search. More...
 
static get_search_criteria_paging ( $args)
 Get the paging array for the View. More...
 
static getInstance ()
 Get the one true instantiated self. More...
 
 insert_view_in_content ( $content)
 In case View post is called directly, insert the view in the post content. More...
 
static is_entry_approved ( $entry, $args=array())
 Check if a certain entry is approved. More...
 
static is_single_entry ()
 Verify if user requested a single entry view. More...
 
static process_search_dates ( $args, $search_criteria=array())
 Process the start and end dates for a view - overrides values defined in shortcode (if needed) More...
 
static process_search_only_approved ( $args, $search_criteria)
 Process the approved only search criteria according to the View settings. More...
 
 render_view ( $passed_args)
 Core function to render a View based on a set of arguments. More...
 

Data Fields

 $context_view_id = null
 
 $entry = false
 
 $gv_output_data = null
 
 $is_gravityview_post_type = false
 
 $is_search = false
 
 $post_has_shortcode = false
 
 $post_id = null
 
 $single_entry = false
 

Static Public Attributes

static $instance
 

Private Member Functions

 __construct ()
 Class constructor, enforce Singleton pattern. More...
 
 enqueue_default_style ( $css_dependencies=array())
 Handle enqueuing the gravityview_default_style stylesheet. More...
 
 initialize ()
 

Static Private Attributes

static $search_parameters = array( 'gv_search', 'gv_start', 'gv_end', 'gv_id', 'gv_by', 'filter_*' )
 

Detailed Description

Definition at line 15 of file class-frontend-views.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )
private

Class constructor, enforce Singleton pattern.

Definition at line 85 of file class-frontend-views.php.

Member Function Documentation

◆ _override_sorting_id_by_field_type()

static _override_sorting_id_by_field_type (   $sort_field_id,
  $form_id 
)
static

Override sorting per field.

Currently only modifies sorting ID when sorting by the full name. Sorts by first name. Use the gravityview/sorting/full-name filter to override.

Since
1.7.4

Override how to sort when sorting address

Since
1.8
Parameters
string$address_partstreet, street2, city, state, zip, or country (default: city)
string$sort_field_idField used for sorting
int$form_idGF Form ID
Runs Filter:
gravityview/sorting/full-name Override how to sort when sorting full name.
Since
1.7.4
Parameters
[in,out]string$name_partSort by first or last (default: first)
[in]string$sort_field_idField used for sorting
[in]int$form_idGF Form ID
Runs Filter:
gravityview/sorting/time Override how to sort when sorting time
See also
GravityView_Field_Time
Since
1.14
Parameters
[in,out]string$name_partField used for sorting
[in]int$form_idGF Form ID

Definition at line 1104 of file class-frontend-views.php.

References GV\$form, $form_id, and gravityview_get_form().

Referenced by View_Table_Template\add_columns_sort_links().

◆ add_columns_sort_links()

add_columns_sort_links (   $label = '',
  $field,
  $form 
)

Inject the sorting links on the table columns.

Callback function for hook 'gravityview/template/field_label'

See also
GravityView_API::field_label() (in includes/class-api.php)
Since
1.7
Parameters
string$labelField label
array$fieldField settings
array$formForm object
Returns
string Field Label

Not a table-based template; don't add sort icons

Since
1.12

Definition at line 1373 of file class-frontend-views.php.

References $class, $field, GV\$form, $label, $url, GravityView_View\getInstance(), and is_field_sortable().

◆ add_scripts_and_styles()

add_scripts_and_styles ( )

Register styles and scripts.

public

Returns
void

Don't enqueue the scripts or styles if it's not going to be displayed.

Since
1.15
Runs Filter:
gravity_view_lightbox_script Override the lightbox script to enqueue. Default: thickbox
Parameters
string$script_slugIf you want to use a different lightbox script, return the name of it here.
Runs Filter:
gravity_view_lightbox_style Modify the lightbox CSS slug. Default: thickbox
Parameters
string$script_slugIf you want to use a different lightbox script, return the name of its CSS file here.

If the form has checkbox fields, enqueue dashicons

See also
https://github.com/katzwebservices/GravityView/issues/536
Since
1.15
Runs Filter:
gravityview_js_localization Modify the array passed to wp_localize_script()
Parameters
array$js_localizationThe data padded to the Javascript file
array$viewsArray of View data arrays with View settings

Definition at line 1225 of file class-frontend-views.php.

References $post, $view_id, View\by_id(), enqueue_default_style(), getGvOutputData(), GRAVITYVIEW_FILE, gravityview_get_template_id(), GVCommon\has_cap(), and GravityView_Plugin\version.

◆ add_style()

static add_style (   $template_id)
static

Add template extra style if exists.

Parameters
string$template_id

Definition at line 1345 of file class-frontend-views.php.

References gravityview().

◆ comments_open()

comments_open (   $open,
  $post_id 
)

Disable comments on GravityView post types.

Parameters
boolean$openexisting status
int$post_idPost ID
Returns
boolean
Runs Filter:
gravityview/comments_open Whether to set comments to open or closed.
Since
1.5.4
Parameters
boolean$openOpen or closed status
int$post_idPost ID to set comment status for

Definition at line 515 of file class-frontend-views.php.

References isGravityviewPostType().

◆ context_not_configured_warning()

context_not_configured_warning (   $view_id = 0)

Display a warning when a View has not been configured.

Since
1.19.2
Parameters
int$view_idThe ID of the View currently being displayed
Returns
void

Definition at line 541 of file class-frontend-views.php.

References $image, $output, $title, $view_id, GVCommon\generate_notice(), GravityView_View\getInstance(), and GRAVITYVIEW_FILE.

◆ enqueue_default_style()

enqueue_default_style (   $css_dependencies = array())
private

Handle enqueuing the gravityview_default_style stylesheet.

Since
1.17
Parameters
array$css_dependenciesDependencies for the gravityview_default_style stylesheet
Returns
void
Runs Filter:
gravityview_use_legacy_search_css Should GravityView use the legacy Search Bar stylesheet (from before Version 1.17)?
Since
1.17
Parameters
bool$use_legacy_search_styleIf true, loads gv-legacy-search(-rtl).css. If false, loads gv-default-styles(-rtl).css. -rtl is added on RTL websites. Default: false

Definition at line 1323 of file class-frontend-views.php.

References gravityview_css_url(), and GravityView_Plugin\version.

Referenced by add_scripts_and_styles().

◆ get_context_view_id()

get_context_view_id ( )

Returns the the view_id context when page contains multiple embedded views or displaying single entry view.

Since
1.5.4
Returns
string

Definition at line 261 of file class-frontend-views.php.

References $context_view_id.

Referenced by single_entry_title().

◆ get_search_criteria()

static get_search_criteria (   $args,
  $form_id 
)
static

Parse search criteria for a entries search.

array( 'search_field' => 1, // ID of the field 'search_value' => '', // Value of the field to search 'search_operator' => 'contains', // 'is', 'isnot', '>', '<', 'contains' 'show_only_approved' => 0 or 1 // Boolean )

Parameters
array$argsArray of args
int$form_idGravity Forms form ID
Returns
array Array of search parameters, formatted in Gravity Forms mode, using status key set to "active" by default, field_filters array with key, value and operator keys.

Compatibility with filters hooking in gravityview_search_criteria instead of gravityview_fe_search_criteria.

Runs Filter:
gravityview_fe_search_criteria Modify the search criteria
See also
GravityView_Widget_Search::filter_entries Adds the default search criteria
Parameters
array$search_criteriaEmpty field_filters key
int$form_idID of the Gravity Forms form that is being searched
array$argsThe View settings.
Runs Filter:
gravityview_status Modify entry status requirements to be included in search results.
Parameters
string$statusDefault: active. Accepts all Gravity Forms entry statuses, including spam and trash

Definition at line 792 of file class-frontend-views.php.

References $criteria, $entries, $form_id, $search_criteria, GV\get(), gravityview(), and GV\Mocks\GravityView_frontend_get_view_entries().

Referenced by GravityView_Admin_ApproveEntries\process_bulk_action().

◆ get_search_criteria_paging()

static get_search_criteria_paging (   $args)
static

Get the paging array for the View.

Since
1.19.5
Parameters
$args
int$form_id
Runs Filter:
gravityview_default_page_size The default number of entries displayed in a View
Since
1.1.6
Parameters
int$default_page_sizeDefault: 25

Definition at line 999 of file class-frontend-views.php.

References $field, GV\$form, $form_id, Utils\get(), GravityView_View\getInstance(), gravityview(), and GVCommon\is_field_numeric().

◆ getEntry()

getEntry ( )
Returns
array

Definition at line 166 of file class-frontend-views.php.

References $entry.

Referenced by single_entry_title().

◆ getGvOutputData()

getGvOutputData ( )

◆ getInstance()

static getInstance ( )
static

◆ getPostId()

getPostId ( )
Returns
int

Definition at line 186 of file class-frontend-views.php.

References $post_id.

Referenced by parse_content().

◆ getSingleEntry()

getSingleEntry ( )
Returns
bool|int

Definition at line 149 of file class-frontend-views.php.

References $single_entry.

Referenced by is_searching(), and single_entry_title().

◆ initialize()

initialize ( )
private

Definition at line 87 of file class-frontend-views.php.

◆ insert_view_in_content()

insert_view_in_content (   $content)
static

In case View post is called directly, insert the view in the post content.

public

Parameters
mixed$content
Returns
string Add the View output into View CPT content

Definition at line 504 of file class-frontend-views.php.

References $content, and gravityview().

◆ is_entry_approved()

static is_entry_approved (   $entry,
  $args = array() 
)
static

Check if a certain entry is approved.

If we pass the View settings ($args) it will check the 'show_only_approved' setting before checking the entry approved field, returning true if show_only_approved = false.

Since
1.7
1.18 Converted check to use GravityView_Entry_Approval_Status::is_approved

GravityView_Entry_Approval_Status::is_approved

Parameters
array$entryEntry object
array$argsView settings (optional)
Returns
bool
Since
1.19

Definition at line 760 of file class-frontend-views.php.

References gravityview(), GVCommon\has_cap(), GravityView_Entry_Approval_Status\is_approved(), and GravityView_Entry_Approval\meta_key.

◆ is_field_sortable()

is_field_sortable (   $field_id = '',
  $form = array() 
)

Checks if field (column) is sortable.

Parameters
string$fieldField settings
array$formGravity Forms form array
Since
1.7
Returns
bool True: Yes, field is sortable; False: not sortable
Runs Filter:
gravityview/sortable/field_blacklist Modify what fields should never be sortable.
Since
1.7
Parameters
[in,out]array$not_sortableArray of field types that aren't sortable
string$field_typeField type to check whether the field is sortable
array$formGravity Forms form

Definition at line 1427 of file class-frontend-views.php.

References $field, $field_id, GV\$form, and getInstance().

Referenced by add_columns_sort_links().

◆ is_searching()

is_searching ( )

Checks if the current View is presenting search results.

Since
1.5.4
Returns
boolean True: Yes, it's a search; False: No, not a search.

Definition at line 380 of file class-frontend-views.php.

References $search_method, GravityView_Widget_Search\getInstance(), and getSingleEntry().

Referenced by parse_content().

◆ is_single_entry()

static is_single_entry ( )
static

Verify if user requested a single entry view.

Returns
boolean|string false if not, single entry slug if true

Modify the entry that is being displayed.

Definition at line 1197 of file class-frontend-views.php.

References $single_entry, and Entry\get_endpoint_name().

Referenced by GravityView_Edit_Entry_Render\get_entry(), gravityview_is_single_entry(), and GravityView_Edit_Entry_Render\is_edit_entry().

◆ isGravityviewPostType()

isGravityviewPostType ( )
Returns
boolean

Definition at line 214 of file class-frontend-views.php.

References $is_gravityview_post_type.

Referenced by comments_open(), and parse_content().

◆ isPostHasShortcode()

isPostHasShortcode ( )
Returns
boolean

Definition at line 200 of file class-frontend-views.php.

References $post_has_shortcode.

◆ isSearch()

isSearch ( )
Returns
boolean

Definition at line 135 of file class-frontend-views.php.

References $is_search.

◆ parse_content()

parse_content (   $wp = array())

Read the $post and process the View data inside.

Parameters
array$wpPassed in the wp hook. Not used.
Returns
void

Definition at line 337 of file class-frontend-views.php.

References $post, GravityView_View_Data\getInstance(), getPostId(), gravityview(), gravityview_has_shortcode_r(), is_searching(), isGravityviewPostType(), set_context_view_id(), setGvOutputData(), setIsGravityviewPostType(), setIsSearch(), setPostHasShortcode(), and setPostId().

◆ parse_query_fix_frontpage()

parse_query_fix_frontpage ( $query)

Allow GravityView entry endpoints on the front page of a site.

Fixes this core issue https://wordpress.org/plugins/cpt-on-front-page/ Code is based on this 1.17.3 WP_Query &$query (passed by reference) void

Definition at line 277 of file class-frontend-views.php.

References Utils\get().

◆ process_search_dates()

static process_search_dates (   $args,
  $search_criteria = array() 
)
static

Process the start and end dates for a view - overrides values defined in shortcode (if needed)

The start_date and end_date keys need to be in a format processable by GFFormsModel::get_date_range_where(), which uses () format.

You can set the start_date or end_date to any value allowed by strtotime(), including strings like "now" or "-1 year" or "-3 days".

See also
GFFormsModel::get_date_range_where
Parameters
array$argsView settings
array$search_criteriaSearch being performed, if any
Returns
array Modified $search_criteria array

If the end date is formatted as 'Y-m-d', it should be formatted without hours and seconds so that Gravity Forms can convert the day to 23:59:59 the previous day.

If it's a relative date ("now" or "-1 day"), then it should use the precise date format

See also
GFFormsModel::get_date_range_where

Definition at line 645 of file class-frontend-views.php.

References $search_criteria, and gravityview().

◆ process_search_only_approved()

static process_search_only_approved (   $args,
  $search_criteria 
)
static

Process the approved only search criteria according to the View settings.

Parameters
array$argsView settings
array$search_criteriaSearch being performed, if any
Returns
array Modified $search_criteria array
Since
1.19

Definition at line 720 of file class-frontend-views.php.

References $search_criteria, GravityView_Entry_Approval_Status\APPROVED, gravityview(), GVCommon\has_cap(), and GravityView_Entry_Approval\meta_key.

Referenced by GravityView_Recent_Entries_Widget\get_entries().

◆ render_view()

render_view (   $passed_args)
static

Core function to render a View based on a set of arguments.

public

Parameters
array$passed_args{
 Settings for rendering the View

 @type int $id View id
 @type int $page_size Number of entries to show per page
 @type string $sort_field Form field id to sort
 @type string $sort_direction Sorting direction ('ASC', 'DESC', or 'RAND')
 @type string $start_date - Ymd
 @type string $end_date - Ymd
 @type string $class - assign a html class to the view
 @type string $offset (optional) - This is the start point in the current data set (0 index based).
}
Returns
string|null HTML output of a View, NULL if View isn't found

We can use a shortcode here, since it's pretty much the same.

But we do need to check embed permissions, since shortcodes don't do this.

Definition at line 604 of file class-frontend-views.php.

References gravityview(), and GVCommon\has_cap().

◆ set_context_view_id()

set_context_view_id (   $view_id = null)

Set the context view ID used when page contains multiple embedded views or displaying the single entry view.

Parameters
null$view_id

used on a has_multiple_views context

See also
GravityView_API::entry_link

Definition at line 232 of file class-frontend-views.php.

References $view_id, and getGvOutputData().

Referenced by parse_content().

◆ set_entry_data()

set_entry_data ( )

Set the entry.

Definition at line 367 of file class-frontend-views.php.

References setEntry(), and setSingleEntry().

◆ setEntry()

setEntry (   $entry)

Set the current entry.

Parameters
array | int$entryEntry array or entry slug or ID

Definition at line 174 of file class-frontend-views.php.

References $entry, and GVCommon\get_entry().

Referenced by set_entry_data().

◆ setGvOutputData()

setGvOutputData (   $gv_output_data)
Parameters
\GravityView_View_Data$gv_output_data

Definition at line 128 of file class-frontend-views.php.

References $gv_output_data.

Referenced by parse_content().

◆ setIsGravityviewPostType()

setIsGravityviewPostType (   $is_gravityview_post_type)
Parameters
boolean$is_gravityview_post_type

Definition at line 221 of file class-frontend-views.php.

References $is_gravityview_post_type.

Referenced by parse_content().

◆ setIsSearch()

setIsSearch (   $is_search)
Parameters
boolean$is_search

Definition at line 142 of file class-frontend-views.php.

References $is_search.

Referenced by parse_content().

◆ setPostHasShortcode()

setPostHasShortcode (   $post_has_shortcode)
Parameters
boolean$post_has_shortcode

Definition at line 207 of file class-frontend-views.php.

References $post_has_shortcode.

Referenced by parse_content().

◆ setPostId()

setPostId (   $post_id)
Parameters
int$post_id

Definition at line 193 of file class-frontend-views.php.

References $post_id.

Referenced by parse_content().

◆ setSingleEntry()

setSingleEntry (   $single_entry)

Sets the single entry ID and also the entry.

Parameters
bool | int | string$single_entry

Definition at line 157 of file class-frontend-views.php.

References $single_entry.

Referenced by set_entry_data().

◆ single_entry_title()

single_entry_title (   $title,
  $passed_post_id = null 
)

Filter the title for the single entry view.

Parameters
string$titlecurrent title
int$passed_post_idPost ID
Returns
string (modified) title
Runs Filter:
gravityview/single/title/out_loop Apply the Single Entry Title filter outside the WordPress loop?
Parameters
boolean$in_the_loopWhether to apply the filter to the menu title and the meta tag <title> - outside the loop
array$entryCurrent entry

Deprecated stuff in the future. See the branch above.

Definition at line 431 of file class-frontend-views.php.

References $post, $title, $view_id, get_context_view_id(), getEntry(), getGvOutputData(), getSingleEntry(), and GravityView_API\replace_variables().

Field Documentation

◆ $context_view_id

$context_view_id = null

Definition at line 60 of file class-frontend-views.php.

Referenced by get_context_view_id().

◆ $entry

$entry = false

Definition at line 54 of file class-frontend-views.php.

Referenced by getEntry(), and setEntry().

◆ $gv_output_data

$gv_output_data = null

Definition at line 75 of file class-frontend-views.php.

Referenced by getGvOutputData(), and setGvOutputData().

◆ $instance

$instance
static

Definition at line 80 of file class-frontend-views.php.

Referenced by Legacy_Context\reset().

◆ $is_gravityview_post_type

$is_gravityview_post_type = false

Definition at line 29 of file class-frontend-views.php.

Referenced by isGravityviewPostType(), and setIsGravityviewPostType().

◆ $is_search

$is_search = false

Definition at line 67 of file class-frontend-views.php.

Referenced by isSearch(), and setIsSearch().

◆ $post_has_shortcode

$post_has_shortcode = false

Definition at line 35 of file class-frontend-views.php.

Referenced by isPostHasShortcode(), and setPostHasShortcode().

◆ $post_id

$post_id = null

Definition at line 41 of file class-frontend-views.php.

Referenced by getPostId(), and setPostId().

◆ $search_parameters

$search_parameters = array( 'gv_search', 'gv_start', 'gv_end', 'gv_id', 'gv_by', 'filter_*' )
staticprivate

Definition at line 23 of file class-frontend-views.php.

◆ $single_entry

$single_entry = false

Definition at line 48 of file class-frontend-views.php.

Referenced by getSingleEntry(), is_single_entry(), and setSingleEntry().


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