GravityView  2.1.1
The best, easiest way to display Gravity Forms entries on your website.
Data Structures | Namespaces | Functions
class-api.php File Reference

Go to the source code of this file.

Data Structures

class  GravityView_API
 

Namespaces

 GravityView
 GPL2+
 

Functions

 gravityview_after ()
 
 gravityview_back_link ( $context=null)
 Generate HTML for the back link from single entry view. More...
 
 gravityview_before ()
 
 gravityview_convert_value_to_term_list ( $value, $taxonomy='post_tag')
 Take a passed CSV of terms and generate a linked list of terms. More...
 
 gravityview_field_output ( $passed_args, $context=null)
 Output field based on a certain html markup. More...
 
 gravityview_footer ()
 
 gravityview_get_context ()
 Returns the current GravityView context, or empty string if not GravityView. More...
 
 gravityview_get_current_view_data ( $view_id=0)
 Get data for a specific view. More...
 
 gravityview_get_current_views ()
 Get all views processed so far for the current page load. More...
 
 gravityview_get_field_value ( $entry, $field_id, $display_value)
 Handle getting values for complex Gravity Forms fields. More...
 
 gravityview_get_files_array ( $value, $gv_class='', $context=null)
 Return an array of files prepared for output. More...
 
 gravityview_get_map_link ( $address)
 Generate a mapping link from an address. More...
 
 gravityview_get_the_term_list ( $post_id, $link=true, $taxonomy='post_tag')
 Get the links for post_tags and post_category output based on post ID. More...
 
 gravityview_get_view_id ()
 Get the current View ID being rendered. More...
 
 gravityview_header ()
 
 gv_class ( $field, $form=NULL, $entry=array())
 
 gv_container_class ( $passed_css_class='', $echo=true, $context=null)
 Generate a CSS class to be added to the wrapper

of a View.
More...
 
 gv_directory_link ( $post=NULL, $add_pagination=true, $context=null)
 
 gv_entry_link ( $entry, $post_id=NULL)
 
 gv_label ( $field, $entry=NULL)
 
 gv_no_results ( $wpautop=true, $context=null)
 
 gv_value ( $entry, $field)
 

Function Documentation

◆ gravityview_after()

gravityview_after ( )
Runs Actions:
gravityview/template/after Append content to the view.
Parameters
\GV\Template_Context$gravityviewThe $gravityview object available in templates.
Runs Actions:
gravityview_after Append content to the View container <div>
Parameters
int$view_idThe ID of the View being displayed

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

References gravityview_get_view_id().

◆ gravityview_back_link()

gravityview_back_link (   $context = null)

Generate HTML for the back link from single entry view.

Since
1.0.1
2.0
Parameters
\GV\Template_Context$contextThe context this link is being displayed from.
Returns
string|null If no GV post exists, null. Otherwise, HTML string of back link.
Runs Filter:
gravityview_go_back_url Modify the back link URL
Since
1.17.5
See also
gv_directory_link() Generated the original back link
Parameters
string$hrefExisting label URL
Runs Filter:
gravityview/template/links/back/url Modify the back link URL
Since
2.0
See also
gv_directory_link() Generated the original back link
Parameters
string$hrefExisting label URL

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

References $gravityview_view, $href, $label, $view_id, GravityView_View\getInstance(), gravityview_get_link(), and gv_directory_link().

◆ gravityview_before()

gravityview_before ( )
Runs Actions:
gravityview/template/before Append content to the view.
Parameters
object$gravityviewThe $gravityview object available in templates.
Runs Actions:
gravityview/template/before Prepend content to the view.
Parameters
\GV\Template_Context$gravityviewThe $gravityview object available in templates.
Runs Actions:
gravityview_before Prepend content to the View container <div>
Parameters
int$view_idThe ID of the View being displayed

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

References gravityview_get_view_id().

◆ gravityview_convert_value_to_term_list()

gravityview_convert_value_to_term_list (   $value,
  $taxonomy = 'post_tag' 
)

Take a passed CSV of terms and generate a linked list of terms.

Gravity Forms passes categories as "Name:ID" so we handle that using the ID, which is more accurate than checking the name, which is more likely to change.

Parameters
string$valueExisting value
string$taxonomyType of term (post_tag or category)
Returns
string CSV of linked terms

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

References $output, $value, and gravityview_get_link().

◆ gravityview_field_output()

gravityview_field_output (   $passed_args,
  $context = null 
)

Output field based on a certain html markup.

markup - string to be used on a sprintf statement. Use: {{label}} - field label {{value}} - entry field value {{class}} - field class

wpautop - true will filter the value using wpautop function

Since
1.1.5
Parameters
array$passed_argsAssociative array with field data. field and form are required.
Since
2.0
Parameters
Runs Filter:
gravityview/field_output/args Modify the args before generation begins
Since
1.7
Parameters
array$argsAssociative array; field and form is required.
array$passed_argsOriginal associative array with field data. field and form are required.
Since
2.0
Parameters
\GV\Template_Context$contextThe context.
Runs Filter:
gravityview/template/field_output/context Modify the context before generation begins.
Since
2.0
Parameters
[in,out]\GV\Template_Context$contextThe context.
array$argsThe sanitized arguments, these should not be trusted any longer.
array$passed_argsThe passed arguments, these should not be trusted any longer.

Create the content variables for replacing.

Since
1.11
Runs Filter:
gravityview/field_output/pre_html Allow Pre filtering of the HTML
Since
1.11
Parameters
string$markupThe HTML for the markup
array$argsAll args for the field output
Since
2.0
Parameters
\GV\Template_Context$contextThe context.
Runs Filter:
gravityview/field_output/open_tag Modify the opening tags for the template content placeholders
Since
1.11
Parameters
string$open_tagOpen tag for template content placeholders. Default: {{
Since
2.0
Parameters
\GV\Template_Context$contextThe context.
Runs Filter:
gravityview/field_output/close_tag Modify the closing tags for the template content placeholders
Since
1.11
Parameters
string$close_tagClose tag for template content placeholders. Default: }}
Since
2.0
Parameters
\GV\Template_Context$contextThe context.

Loop through each of the tags to replace and replace both {{tag}} and {{ tag }} with the values

Since
1.11

gravityview/field_output/context/{$tag} Allow users to filter content on context

Since
1.11
Parameters
string$valueThe content to be shown instead of the {{tag}} placeholder
array$argsArguments passed to the function
Since
2.0
Parameters
\GV\Template_Context$contextThe context.
Runs Filter:
gravityview_field_output Modify field HTML output
Parameters
string$htmlExisting HTML output
array$argsArguments passed to the function
Since
2.0
Parameters
\GV\Template_Context$contextThe context.
Runs Filter:
gravityview/field_output/html Modify field HTML output
Parameters
string$htmlExisting HTML output
array$argsArguments passed to the function
Since
2.0
Parameters
\GV\Template_Context$contextThe context.
Since
2.0.8 Remove unused atts

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

References $entry, $field, GV\$form, $value, GravityView_API\field_html_attr_id(), GravityView_API\field_width(), Utils\get(), gravityview(), gv_class(), gv_label(), and gv_value().

Referenced by GravityView_View\renderZone(), View_Table_Template\the_columns(), Entry_Table_Template\the_field(), Entry_List_Template\the_field(), View_List_Template\the_field(), and View_Table_Template\the_field().

◆ gravityview_footer()

gravityview_footer ( )
Runs Actions:
gravityview/template/footer Append content to the view.
Parameters
object$gravityviewThe $gravityview object available in templates.
Runs Actions:
gravityview/template/footer Prepend outside of the view container
.
Parameters
\GV\Template_Context$gravityviewThe $gravityview object available in templates.
Runs Actions:
gravityview_after Display content after a View. Used to render footer widget areas. Rendered outside the View container <div>
Parameters
int$view_idThe ID of the View being displayed

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

References gravityview_get_view_id().

◆ gravityview_get_context()

gravityview_get_context ( )

Returns the current GravityView context, or empty string if not GravityView.

  • Returns empty string on GravityView archive pages
  • Returns empty string on archive pages containing embedded Views
  • Returns empty string for embedded Views, not 'directory'
  • Returns empty string for embedded entries (oEmbed or [gventry]), not 'single'
  • Returns 'single' when viewing a [gravityview] shortcode-embedded single entry

GravityView_View $gravityview_view

Returns
string View context "directory", "single", "edit", or empty string if not GravityView
Runs Filter:
gravityview_is_edit_entry Whether we're currently on the Edit Entry screen
The Edit Entry functionality overrides this value.
Parameters
boolean$is_edit_entry

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

References gravityview().

Referenced by GravityView_Plugin_Hooks_Gravity_Forms_Signature\edit_entry_field_input(), GravityView_Field_FileUpload\get_field_input(), GVCommon\matches_operation(), and GravityView_View\render_widget_hooks().

◆ gravityview_get_current_view_data()

gravityview_get_current_view_data (   $view_id = 0)

Get data for a specific view.

See also
GravityView_View_Data::get_view()
Returns
array View data with id, view_id, form_id, template_id, atts, fields, widgets, form keys.

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

References $view_id, and GravityView_frontend\getInstance().

Referenced by GravityView_Delete_Entry\check_user_cap_delete_entry().

◆ gravityview_get_current_views()

gravityview_get_current_views ( )

Get all views processed so far for the current page load.

See also
GravityView_View_Data::add_view()
Returns
array Array of View data, each View data with id, view_id, form_id, template_id, atts, fields, widgets, form keys.

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

References GravityView_frontend\getInstance(), and gravityview().

◆ gravityview_get_field_value()

gravityview_get_field_value (   $entry,
  $field_id,
  $display_value 
)

Handle getting values for complex Gravity Forms fields.

If the field is complex, like a product, the field ID, for example, 11, won't exist. Instead, it will be 11.1, 11.2, and 11.3. This handles being passed 11 and 11.2 with the same function.

Since
1.0.4
Parameters
array$entryGF entry array
string$field_id[description]
string$display_valueThe value generated by Gravity Forms
Returns
string Value

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

References $display_value, $entry, and $field_id.

◆ gravityview_get_files_array()

gravityview_get_files_array (   $value,
  $gv_class = '',
  $context = null 
)

Return an array of files prepared for output.

Wrapper for GravityView_Field_FileUpload::get_files_array()

Processes files by file type and generates unique output for each.

Returns array for each file, with the following keys:

file_path => The file path of the file, with a line break html => The file output HTML formatted

See also
GravityView_Field_FileUpload::get_files_array()
Since
1.2
Parameters
string$valueField value passed by Gravity Forms. String of file URL, or serialized string of file URL array
string$gv_classField class to add to the output HTML
Since
2.0
Parameters
\GV\Template_Context$contextThe context
Returns
array Array of file output, with file_path and html keys (see comments above)

"GRAVITYVIEW_DIR" "../"

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

References $value, and GRAVITYVIEW_DIR.

◆ gravityview_get_map_link()

gravityview_get_map_link (   $address)

Generate a mapping link from an address.

The address should be plain text with new line (\n) or <br /> line breaks separating sections

See also
https://gravityview.co/support/documentation/201608159 Read how to modify the link
Parameters
string$addressAddress
Returns
string URL of link to map of address
Runs Filter:
gravityview_map_link Modify the map link generated. You can use a different mapping service, for example.
Parameters
[in,out]string$linkMap link
[in]string$addressAddress to generate link for
[in]string$urlURL generated by the function

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

References $link_text, $url, and gravityview_get_link().

◆ gravityview_get_the_term_list()

gravityview_get_the_term_list (   $post_id,
  $link = true,
  $taxonomy = 'post_tag' 
)

Get the links for post_tags and post_category output based on post ID.

Parameters
int$post_idThe ID of the post
boolean$linkAdd links or no?
string$taxonomyTaxonomy of term to fetch.
Returns
string String with terms

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

References $output.

◆ gravityview_get_view_id()

gravityview_get_view_id ( )

Get the current View ID being rendered.

GravityView_View $gravityview_view

Returns
int View ID, if exists. 0 if GravityView_View doesn't exist, like in the admin, or no View is set.

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

References GravityView_View\getInstance().

Referenced by GravityView_API\entry_link(), GravityView_Delete_Entry\get_delete_link(), gravityview_after(), gravityview_before(), gravityview_footer(), gravityview_header(), and Renderer\maybe_print_notices().

◆ gravityview_header()

gravityview_header ( )
Runs Actions:
gravityview/template/header Append content to the view.
Parameters
object$gravityviewThe $gravityview object available in templates.
Runs Actions:
gravityview/template/header Prepend content to the view container
.
Parameters
\GV\Template_Context$gravityviewThe $gravityview object available in templates.
Runs Actions:
gravityview_header Prepend content to the View container <div>
Parameters
int$view_idThe ID of the View being displayed

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

References gravityview_get_view_id().

◆ gv_class()

gv_class (   $field,
  $form = NULL,
  $entry = array() 
)

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

References $entry, $field, GV\$form, and GravityView_API\field_class().

Referenced by gravityview_field_output().

◆ gv_container_class()

gv_container_class (   $passed_css_class = '',
  $echo = true,
  $context = null 
)

Generate a CSS class to be added to the wrapper

of a View.

Since
1.5.4
1.16 Added $echo parameter.
2.0 Added $context parameter.
Parameters
string$passed_css_classDefault: gv-container gv-container-{view id}. If View is hidden until search, adds hidden
boolean$echoWhether to echo the output. Default: true
\GV\Template_Context$contextThe template context.
Returns
string CSS class, sanitized by gravityview_sanitize_html_class()
Runs Filter:
gravityview/render/container/class Modify the CSS class to be added to the wrapper
of a View
Since
1.5.4
Parameters
[in,out]string$css_classDefault: gv-container gv-container-{view id}. If View is hidden until search, adds hidden. If the View has no results, adds gv-container-no-results
Since
2.0
Parameters
\GV\Template_Context$contextThe context.

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

References $view_id, and GravityView_View\getInstance().

◆ gv_directory_link()

gv_directory_link (   $post = NULL,
  $add_pagination = true,
  $context = null 
)

◆ gv_entry_link()

gv_entry_link (   $entry,
  $post_id = NULL 
)

◆ gv_label()

gv_label (   $field,
  $entry = NULL 
)

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

References $entry, $field, and GravityView_API\field_label().

Referenced by gravityview_field_output().

◆ gv_no_results()

gv_no_results (   $wpautop = true,
  $context = null 
)

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

References GravityView_API\no_results().

Referenced by GravityView_Entry_List\__construct().

◆ gv_value()

gv_value (   $entry,
  $field 
)
Runs Filter:
gravityview_empty_value What to display when a field is empty
Parameters
string$value(empty string)

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

References $entry, $field, $value, and GravityView_API\field_value().

Referenced by gravityview_field_output().