GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
Static Public Member Functions | Static Private Member Functions
GravityView_API Class Reference

Static Public Member Functions

static directory_link ( $post_id=NULL, $add_query_args=true, $context=null)
 Generate a URL to the Directory context. More...
 
static entry_create_custom_slug ( $entry, $form)
 If using the entry custom slug feature, make sure the new entries have the custom slug created and saved as meta. More...
 
static entry_link ( $entry, $post_id=NULL, $add_directory_args=true, $view_id=0)
 return href for single entry More...
 
static entry_link_html ( $entry=array(), $anchor_text='', $passed_tag_atts=array(), $field_settings=array(), $base_id=null)
 Generate an anchor tag that links to an entry. More...
 
static field_class ( $field, $form=NULL, $entry=NULL)
 Fetch Field class. More...
 
static field_html_attr_id ( $field, $form=array(), $entry=array())
 Fetch Field HTML ID. More...
 
static field_label ( $field, $entry=array(), $force_show_label=false)
 Fetch Field Label. More...
 
static field_value ( $entry, $field_settings, $format='html')
 Given an entry and a form field id, calculate the entry value for that field. More...
 
static field_width ( $field, $format='%d%%')
 Get column width from the field setting. More...
 
static get_entry_slug ( $id_or_string, $entry=array())
 Get the entry slug for the entry. More...
 
static no_results ( $wpautop=true, $context=null)
 Get the "No Results" text depending on whether there were results. More...
 
static replace_variables ( $text, $form=array(), $entry=array(), $url_encode=false, $esc_html=true, $nl2br=true, $format='html', $aux_data=array())
 Alias for GravityView_Merge_Tags::replace_variables() More...
 

Static Private Member Functions

static get_custom_entry_slug ( $id, $entry=array())
 Calculate an unique hash for an entry based on the entry ID. More...
 

Detailed Description

Definition at line 14 of file class-api.php.

Member Function Documentation

◆ directory_link()

static directory_link (   $post_id = NULL,
  $add_query_args = true,
  $context = null 
)
static

Generate a URL to the Directory context.

Uses local static variable to speed up repeated requests to get permalink, which improves load time. Since we may be doing this hundreds of times per request, it adds up!

Parameters
int$post_idPost ID
boolean$add_query_argsAdd pagination and sorting arguments
Since
2.0
Parameters
\GV\Template_Context$contextThe context this is being used in.
Returns
string Permalink to multiple entries view

If we've saved the permalink, use it. Reduces time spent on get_permalink(), which is heavy.

Since
1.3
2.17 Changed from using wp_cache_set() to using a static variable.
Runs Filter:
gravityview_directory_link Modify the URL to the View "directory" context
Since
1.19.4
Parameters
string$linkURL to the View's "directory" context (Multiple Entries screen)
int$post_idID of the post to link to. If the View is embedded, it is the post or page ID
Runs Filter:
gravityview/view/links/directory Modify the URL to the View "directory" context
Since
2.0
Parameters
string$linkURL to the View's "directory" context (Multiple Entries screen)
\GV\Template_Context$context

Definition at line 399 of file class-api.php.

References $add_query_args, $args, $gravityview_view, $link, $post, Utils\_GET(), Utils\_POST(), GravityView_frontend\getInstance(), GravityView_View\getInstance(), and gravityview().

Referenced by GravityView_Delete_Entry\get_delete_link(), GravityView_Duplicate_Entry\get_duplicate_link(), gv_directory_link(), and GravityView_Edit_Entry_Render\maybe_print_message().

◆ entry_create_custom_slug()

static entry_create_custom_slug (   $entry,
  $form 
)
static

If using the entry custom slug feature, make sure the new entries have the custom slug created and saved as meta.

Triggered by add_action( 'gform_entry_created', array( 'GravityView_API', 'entry_create_custom_slug' ), 10, 2 );

Parameters
$entryarray Gravity Forms entry object
$formarray Gravity Forms form object
Runs Filter:
gravityview_custom_entry_slug On entry creation, check if we are using the custom entry slug feature and update the meta
Parameters
boolean$customShould we process the custom entry slug?

Definition at line 620 of file class-api.php.

References $entry, and gravityview().

◆ entry_link()

static entry_link (   $entry,
  $post_id = NULL,
  $add_directory_args = true,
  $view_id = 0 
)
static

return href for single entry

Since
1.7.3 Added $add_directory_args parameter
2.7.2 Added $view_id parameter
2.10 Added $_GET args to links by default. Use gravityview/entry_link/add_query_args filter to override.
Parameters
array | int$entryEntry array or entry ID.
int | null$post_idIf wanting to define the parent post, pass a post ID.
boolean$add_directory_argsTrue: Add args to help return to directory; False: only include args required to get to entry.
int$view_id
Returns
string Link to the entry with the directory parent slug, or empty string if embedded post or View doesn't exist
Runs Filter:
gravityview/entry_link/add_query_args Modify whether to include passed $_GET parameters to the end of the url
Since
2.10
Parameters
bool$add_query_paramsWhether to include passed $_GET parameters to the end of the Entry Link URL. Default: true.

Make sure the $directory_link doesn't contain any query otherwise it will break when adding the entry slug.

Since
1.16.5
1.7.3
1.7

Definition at line 656 of file class-api.php.

References $add_query_args, $args, $entry, $entry_slug, $forms, $view_id, Utils\_GET(), View_Collection\from_post(), Entry\get_endpoint_name(), GVCommon\get_entry(), get_entry_slug(), GravityView_frontend\getInstance(), GravityView_View_Data\getInstance(), gravityview_get_view_id(), and gv_get_query_args().

Referenced by GravityView_Entry_List\get_item_output(), GravityView_Entry_Link_Shortcode\get_url(), gv_entry_link(), and GravityView_Theme_Hooks_WPML\wpml_ls_filter().

◆ entry_link_html()

static entry_link_html (   $entry = array(),
  $anchor_text = '',
  $passed_tag_atts = array(),
  $field_settings = array(),
  $base_id = null 
)
static

Generate an anchor tag that links to an entry.

Since
1.6
See also
GVCommon::get_link_html()
Parameters
string$anchor_textThe text or HTML inside the link
array$entryGravity Forms entry array
array | string$passed_tag_attsAttributes to be added to the anchor tag, such as title or rel.
array$field_settingsArray of field settings. Optional, but passed to the gravityview_field_entry_link filter
Since
2.0
Parameters
int$base_idThe post or the view that this entry is linked from.
Returns
string|null Returns HTML for an anchor link. Null if $entry isn't defined or is missing an ID.
Runs Filter:
gravityview_field_entry_link Modify the link HTML
Parameters
string$linkHTML output of the link
string$hrefURL of the link
array$entryThe GF entry array
array$field_settingsSettings for the particular GV field

Definition at line 259 of file class-api.php.

References $entry, $field_settings, $href, $link, $output, gravityview(), and gravityview_get_link().

◆ field_class()

static field_class (   $field,
  $form = NULL,
  $entry = NULL 
)
static

Fetch Field class.

Parameters
mixed$field
Returns
string

Definition at line 157 of file class-api.php.

References $entry, $field, GV\$form, $form_id, $gravityview_view, GravityView_View\getInstance(), and gravityview().

Referenced by gv_class().

◆ field_html_attr_id()

static field_html_attr_id (   $field,
  $form = array(),
  $entry = array() 
)
static

Fetch Field HTML ID.

Since
1.11
Parameters
array$fieldGravityView field array passed to gravityview_field_output()
array$formGravity Forms form array, if set.
array$entryGravity Forms entry array
Returns
string Sanitized unique HTML id attribute for the field

Definition at line 209 of file class-api.php.

References $field, GV\$form, $form_id, $gravityview_view, GravityView_View\getInstance(), and gravityview().

Referenced by gravityview_field_output().

◆ field_label()

static field_label (   $field,
  $entry = array(),
  $force_show_label = false 
)
static

Fetch Field Label.

Parameters
array$fieldGravityView field array
array$entryGravity Forms entry array
boolean$force_show_labelWhether to always show the label, regardless of field settings
Returns
string

Allow to fall through for back compatibility testing purposes.

Runs Filter:
gravityview_render_after_label Append content to a field label
Parameters
string$appended_contentContent you can add after a label. Empty by default.
array$fieldGravityView field array
Runs Filter:
gravityview/template/field_label Modify field label output
Since
1.7
Parameters
string$labelField label HTML
array$fieldGravityView field array
array$formGravity Forms form array
array$entryGravity Forms entry array

Definition at line 27 of file class-api.php.

References $entry, $field, GV\$form, $gravityview_view, $label, GravityView_View\getInstance(), and GV\Mocks\GravityView_API_field_label().

Referenced by gv_label().

◆ field_value()

static field_value (   $entry,
  $field_settings,
  $format = 'html' 
)
static

Given an entry and a form field id, calculate the entry value for that field.

Parameters
array$entry
array$field
Returns
null|string

Definition at line 238 of file class-api.php.

References $entry, $field_settings, $format, gravityview(), and GV\Mocks\GravityView_API_field_value().

Referenced by gv_value().

◆ field_width()

static field_width (   $field,
  $format = '%d%%' 
)
static

Get column width from the field setting.

Since
1.9
Parameters
array$fieldArray of settings for the field
string$formatFormat for width. "%" (default) will return
Returns
string|null If not empty, string in $format format. Otherwise, null.

Definition at line 132 of file class-api.php.

References $field, and $format.

Referenced by gravityview_field_output().

◆ get_custom_entry_slug()

static get_custom_entry_slug (   $id,
  $entry = array() 
)
staticprivate

Calculate an unique hash for an entry based on the entry ID.

This allows you to be more discrete as to the number of the entry - if you don't want users to know that you have made a certain number of sales, for example, or that their entry in the giveaway is entry #3.

The hashed value MUST be unique, otherwise multiple entries will share the same URL, which leads to obvious problems.

Parameters
int | string$idEntry ID to generate the hash for.
array$entryEntry data passed to provide additional information when generating the hash. Optional - don't rely on it being available.
Returns
string Hashed unique value for entry
Runs Filter:
gravityview_entry_slug Modify the unique hash ID generated, if you want to improve usability or change the format. This will allow for custom URLs, such as {entryid}-{first-name} or even, if unique, {first-name}-{last-name}
Parameters
string$hashExisting hash generated by GravityView
string$idThe entry ID
array$entryEntry data array. May be empty.

Definition at line 518 of file class-api.php.

References $entry.

◆ get_entry_slug()

static get_entry_slug (   $id_or_string,
  $entry = array() 
)
static

Get the entry slug for the entry.

By default, it is the entry ID.

See also
gravityview_get_entry() GravityView_API::get_custom_entry_slug() If using custom slug, gets the custom slug value
Since
1.4
Parameters
int | string$id_or_stringID of the entry, or custom slug string
array$entryGravity Forms Entry array, optional. Used only to provide data to customize the gravityview_entry_slug filter
Returns
string Unique slug ID, passed through sanitize_title()

Default: use the entry ID as the unique identifier

Runs Filter:
gravityview_custom_entry_slug Whether to enable and use custom entry slugs.
Parameters
booleanTrue: Allow for slugs based on entry values. False: always use entry IDs (default)

Definition at line 550 of file class-api.php.

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

Referenced by entry_link(), and Entry\get_slug().

◆ no_results()

static no_results (   $wpautop = true,
  $context = null 
)
static

Get the "No Results" text depending on whether there were results.

Since
2.0
Parameters
boolean$wpautopApply wpautop() to the output?
\GV\Template_Context | null$contextThe context
Returns
string HTML of "no results" text

Added now that users are able to modify via View settings

Since
2.8.2
Runs Filter:
gravitview_no_entries_text Modify the text displayed when there are no entries. Note: this filter is, and always has been, misspelled. This will not be fixed, since the filter is deprecated.
Parameters
string$outputThe existing "No Entries" text
boolean$is_searchIs the current page a search result, or just a multiple entries screen?
Returns
string The modified text.
Runs Filter:
gravityview/template/text/no_entries Modify the text displayed when there are no entries.
Since
2.0
2.17 Added $wpautop parameter.
Parameters
string$outputThe existing "No Entries" text.
boolean$is_searchIs the current page a search result, or just a multiple entries screen?
\GV\Template_Context$contextThe context.
string$unformatted_outputOutput without wpautop().
Returns
string The modified text.

Definition at line 296 of file class-api.php.

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

Referenced by gv_no_results().

◆ replace_variables()

static replace_variables (   $text,
  $form = array(),
  $entry = array(),
  $url_encode = false,
  $esc_html = true,
  $nl2br = true,
  $format = 'html',
  $aux_data = array() 
)
static

Alias for GravityView_Merge_Tags::replace_variables()

See also
GravityView_Merge_Tags::replace_variables() Moved in 1.8.4
Since
1.22.4 - Added $nl2br, $format, $aux_data args
Parameters
string$textText to replace variables in
array$formGF Form array
array$entryGF Entry array
bool$url_encodePass return value through url_encode()
bool$esc_htmlPass return value through esc_html()
bool$nl2brConvert newlines to
HTML tags
string$formatThe format requested for the location the merge is being used. Possible values: html, text or url.
array$aux_dataAdditional data to be used to replace merge tags {
See also
https://www.gravityhelp.com/documentation/article/gform_merge_tag_data/}
Returns
string Text with variables maybe replaced

Definition at line 118 of file class-api.php.

References $entry, GV\$form, $format, and GravityView_Merge_Tags\replace_variables().

Referenced by GravityView_frontend\_get_single_entry_title(), Entry_Template\get_back_label(), GravityView_Entry_List\get_item_output(), GravityView_View\getBackLinkLabel(), GV\Mocks\GravityView_API_field_label(), and Field_Template\render().


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