GravityView  2.1.1
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)
 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 wp_cache_get and wp_cache_get (since 1.3) 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
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 356 of file class-api.php.

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

Referenced by GravityView_Delete_Entry\get_delete_link(), and gv_directory_link().

◆ 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 567 of file class-api.php.

References $entry, GV\get(), and gravityview().

◆ entry_link()

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

return href for single entry

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 {
Since
1.7.3}
Returns
string Link to the entry with the directory parent slug, or empty string if embedded post or View doesn't exist

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 596 of file class-api.php.

References $entry, $entry_slug, Utils\_GET(), Entry\get_endpoint_name(), GVCommon\get_entry(), GravityView_frontend\getInstance(), GravityView_View_Data\getInstance(), and gravityview_get_view_id().

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 263 of file class-api.php.

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

◆ field_class()

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

Fetch Field class.

public

Parameters
mixed$field
Returns
string

Definition at line 159 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

public

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

public

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
[in,out]string$appended_contentContent you can add after a label. Empty by default.
[in]array$fieldGravityView field array
Runs Filter:
gravityview/template/field_label Modify field label output
Since
1.7
Parameters
[in,out]string$labelField label HTML
[in]array$fieldGravityView field array
[in]array$formGravity Forms form array
[in]array$entryGravity Forms entry array

Definition at line 28 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.

public

Parameters
array$entry
array$field
Returns
null|string

Definition at line 242 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 133 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 465 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 497 of file class-api.php.

References $entry, $value, GV\get(), and gravityview().

Referenced by GravityView_Admin_Bar\add_floaty_icon(), GF_Entry\from_entry(), GravityView_Field_Notes\get_add_note_part(), GravityView_Delete_Entry\get_delete_link(), GravityView_Field_FileUpload\get_field_input(), and Entry\get_permalink().

◆ no_results()

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

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

Parameters
boolean$wpautopApply wpautop() to the output?
Since
2.0
Parameters
\GV\Template_Context$contextThe context
Returns
string HTML of "no results" text
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
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.
Returns
string The modified text.

Definition at line 299 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 119 of file class-api.php.

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

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


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