GravityView
2.17
The best, easiest way to display Gravity Forms entries on your website.
|
Enhance Gravity Forms' merge tag functionality by adding additional merge tags. More...
Public Member Functions | |
__construct () | |
Static Public Member Functions | |
static | format_date ( $date_created='', $property='') |
Format Merge Tags using GVCommon::format_date() More... | |
static | process_modifiers ( $value, $merge_tag, $modifier, $field, $raw_value) |
Process custom GravityView modifiers for Merge Tags. More... | |
static | replace_current_post ( $original_text, $form=array(), $entry=array(), $url_encode=false, $esc_html=false) |
Add a {current_post} Merge Tag for information about the current post (in the loop or singular) More... | |
static | replace_entry_link ( $original_text, $form=array(), $entry=array(), $url_encode=false, $esc_html=false) |
Add a {gv_entry_link} Merge Tag, alias of [gv_entry_link] shortcode in {gv_entry_link:[post id]:[action]} format. More... | |
static | replace_get_variables ( $text, $form=array(), $entry=array(), $url_encode=false) |
Allow passing variables via URL to be displayed in Merge Tags. More... | |
static | replace_gv_merge_tags ( $text, $form=array(), $entry=array(), $url_encode=false, $esc_html=false) |
Run GravityView filters when using GFCommon::replace_variables() More... | |
static | replace_is_starred ( $original_text, $form=array(), $entry=array(), $url_encode=false, $esc_html=false) |
Add a {is_starred} Merge Tag. More... | |
static | replace_site_url ( $original_text, $form=array(), $entry=array(), $url_encode=false, $esc_html=false) |
Add a {site_url} Merge Tag. More... | |
static | replace_variables ( $text, $form=array(), $entry=array(), $url_encode=false, $esc_html=true, $nl2br=true, $format='html', $aux_data=array()) |
Alias for GFCommon::replace_variables() More... | |
Private Member Functions | |
add_hooks () | |
Tap in to gform_replace_merge_tags to add merge tags. More... | |
Static Private Member Functions | |
static | get_format_from_modifiers ( $exploded, $backup='') |
If there is a :format modifier in a merge tag, grab the formatting. More... | |
static | maybe_urlencode ( $field=false, $value='') |
GF 2.3 adds GF_Field::get_modifers(), which allows us to check if a field has urlencode applied to it. More... | |
static | modifier_explode ( $raw_value, $matches, $value, $field=null) |
Convert JSON or CSV values into space-separated string. More... | |
static | modifier_maxwords ( $raw_value, $matches, $field=null) |
Trim the Merge Tag's length in words. More... | |
static | modifier_strings ( $raw_value, $matches, $value='', $field=null) |
Process strings with common PHP string manipulations. More... | |
static | modifier_timestamp ( $raw_value, $matches) |
Convert Date field values to timestamp int. More... | |
Enhance Gravity Forms' merge tag functionality by adding additional merge tags.
Definition at line 7 of file class-gravityview-merge-tags.php.
__construct | ( | ) |
|
private |
Tap in to gform_replace_merge_tags to add merge tags.
Definition at line 20 of file class-gravityview-merge-tags.php.
Referenced by __construct().
|
static |
Format Merge Tags using GVCommon::format_date()
string | $date_created | The Gravity Forms date created format |
string | $property | Any modifiers for the merge tag (human , format:m/d/Y ) |
Definition at line 531 of file class-gravityview-merge-tags.php.
References GVCommon\format_date().
Referenced by GravityView_Field_Date\apply_format_date_modifiers(), and GravityView_Field_Date_Created\replace_merge_tag().
|
staticprivate |
If there is a :format
modifier in a merge tag, grab the formatting.
The :format
modifier should always have the format follow it; it's the next item in the array In foo:format:bar
, "bar" will be the returned format
array | $exploded | Array of modifiers with a possible format value |
string | $backup | The backup value to use, if not found |
Definition at line 563 of file class-gravityview-merge-tags.php.
|
staticprivate |
GF 2.3 adds GF_Field::get_modifers(), which allows us to check if a field has urlencode applied to it.
Here's the relevant code:
$modifier = strtolower( rgar( $match, $i ) ); $modifiers = array_map( 'trim', explode( ',', $modifier ) ); $field->set_modifiers( $modifiers );
GF_Field | false | $field | |
string | $value |
Definition at line 203 of file class-gravityview-merge-tags.php.
|
staticprivate |
Convert JSON or CSV values into space-separated string.
Useful for Multiple Select field data, like categories
mixed | $raw_value | The raw value submitted for this field. May be CSV or JSON-encoded. |
array | $matches | Regex matches group |
string | $value | The value as passed by Gravity Forms |
GF_Field | false | $field | Gravity Forms field, if any |
Definition at line 234 of file class-gravityview-merge-tags.php.
|
staticprivate |
Trim the Merge Tag's length in words.
Notes:
string | $raw_value | Value to filter |
array | $matches | Regex matches group |
GF_Field | false | $field |
maxwords
modifier Use htmlentities instead, so that entities are double-encoded, and decoding restores original values.
Definition at line 162 of file class-gravityview-merge-tags.php.
References $field.
|
staticprivate |
Process strings with common PHP string manipulations.
mixed | $raw_value | The raw value submitted for this field. May be CSV or JSON-encoded. |
array | $matches | Regex matches group |
string | $value | The value as passed by Gravity Forms |
GF_Field | false | $field | Gravity Forms field, if any |
Definition at line 256 of file class-gravityview-merge-tags.php.
|
staticprivate |
Convert Date field values to timestamp int.
strtotime()
string | $raw_value | Value to filter |
array | $matches | Regex matches group |
-1
if not a valid timestamp. Definition at line 133 of file class-gravityview-merge-tags.php.
|
static |
Process custom GravityView modifiers for Merge Tags.
Is not processed on {all_fields}
Merge Tag.
string | $value | The current merge tag value to be filtered. |
string | $merge_tag | If the merge tag being executed is an individual field merge tag (i.e. {Name:3}), this variable will contain the field's ID. If not, this variable will contain the name of the merge tag (i.e. all_fields). |
string | $modifier | The string containing any modifiers for this merge tag. For example, "maxwords:10" would be the modifiers for the following merge tag: {Text:2:maxwords:10} . |
GF_Field | $field | The current field. |
mixed | $raw_value | The raw value submitted for this field. |
gravityview/merge_tags/modifiers/value
Modify the merge tag modifier output string | $return | The current merge tag value to be filtered. |
string | $raw_value | The raw value submitted for this field. May be CSV or JSON-encoded. |
string | $value | The original merge tag value, passed from Gravity Forms |
string | $merge_tag | If the merge tag being executed is an individual field merge tag (i.e. {Name:3}), this variable will contain the field's ID. If not, this variable will contain the name of the merge tag (i.e. all_fields). |
string | $modifier | The string containing any modifiers for this merge tag. For example, "maxwords:10" would be the modifiers for the following merge tag: {Text:2:maxwords:10} . |
GF_Field | $field | The current field. |
Definition at line 45 of file class-gravityview-merge-tags.php.
|
static |
Add a {current_post} Merge Tag for information about the current post (in the loop or singular)
{current_post} is replaced with the current post's permalink by default, when no modifiers are passed. Pass WP_Post properties as :modifiers to access.
{current_post} is the same as {embed_post}, except:
string | $original_text | Text to replace |
array | $form | Gravity Forms form array |
array | $entry | Entry array |
bool | $url_encode | Whether to URL-encode output |
bool | $esc_html | Indicates if the esc_html function should be applied. |
Definition at line 600 of file class-gravityview-merge-tags.php.
References Utils\get().
|
static |
Add a {gv_entry_link} Merge Tag, alias of [gv_entry_link] shortcode in {gv_entry_link:[post id]:[action]} format.
string | $original_text | Text to replace |
array | $form | Gravity Forms form array |
array | $entry | Entry array |
bool | $url_encode | Whether to URL-encode output |
bool | $esc_html | Indicates if the esc_html function should be applied. |
array | $match | { $match[0] Full tag $match[1] Post ID (optional) $match[2] Action (optional) } |
Definition at line 467 of file class-gravityview-merge-tags.php.
References $entry, gravityview(), and GravityView_Entry_Link_Shortcode.
|
static |
Allow passing variables via URL to be displayed in Merge Tags.
Works with [gvlogic]
: [gvlogic if="{get:example}" is="false"] ?example=false [else] ?example wasn't "false". It's {get:example}! [/gvlogic]
Supports passing arrays: URL: example[]=Example+One&example[]=Example+(with+comma)%2C+Two
Merge Tag: {get:example}
Output: Example One, Example (with comma), Two
string | $text | Text to replace |
array | $form | Gravity Forms form array |
array | $entry | Entry array |
bool | $url_encode | Whether to URL-encode output |
gravityview/merge_tags/get/glue/
Modify the glue used to convert an array of {get}
values from an array to string string | $glue | String used to implode() $_GET values Default: ', ' |
string | $property | The current name of the $_GET parameter being combined |
gravityview/merge_tags/get/esc_html/{url parameter name}
Disable esc_html() from running on {get}
merge tag By default, all values passed through URLs will be escaped for security reasons. If for some reason you want to pass HTML in the URL, for example, you will need to return false on this filter. It is strongly recommended that you do not disable this filter. bool | $esc_html | Whether to esc_html() the value. Default: true |
gravityview/merge_tags/get/esc_html/{url parameter name}
Modify the value of the {get}
replacement before being used string | $value | Value that will replace {get} |
string | $text | Text that contains {get} (before replacement) |
array | $form | Gravity Forms form array |
array | $entry | Entry array |
Definition at line 672 of file class-gravityview-merge-tags.php.
References $entry, GV\$form, $glue, and $value.
Referenced by gvlogic\callback().
|
static |
Run GravityView filters when using GFCommon::replace_variables()
Instead of adding multiple hooks, add all hooks into this one method to improve speed
string | $text | Text to replace |
array | bool | $form | Gravity Forms form array. When called inside { |
false
array | bool | $entry | Entry array. When called inside { |
false
bool | $url_encode | Whether to URL-encode output |
bool | $esc_html | Whether to apply esc_html() to output |
This prevents the gform_replace_merge_tags filter from being called twice, as defined in:
Definition at line 373 of file class-gravityview-merge-tags.php.
|
static |
Add a {is_starred} Merge Tag.
string | $original_text | Text to replace |
array | $form | Gravity Forms form array |
array | $entry | Entry array |
bool | $url_encode | Whether to URL-encode output |
bool | $esc_html | Indicates if the esc_html function should be applied. |
Definition at line 415 of file class-gravityview-merge-tags.php.
References $entry.
|
static |
Add a {site_url} Merge Tag.
string | $original_text | Text to replace |
array | $form | Gravity Forms form array |
array | $entry | Entry array |
bool | $url_encode | Whether to URL-encode output |
bool | $esc_html | Indicates if the esc_html function should be applied. |
Definition at line 437 of file class-gravityview-merge-tags.php.
|
static |
Alias for GFCommon::replace_variables()
Before 1.15.3, it would check for merge tags before passing to Gravity Forms to improve speed.
string | $text | Text to replace variables in. |
array | $form | GF Form array |
array | $entry | GF Entry array |
bool | $url_encode | Pass return value through url_encode() |
bool | $esc_html | Pass return value through esc_html() |
bool | $nl2br | Convert newlines to HTML tags |
string | $format | The format requested for the location the merge is being used. Possible values: html, text or url. |
array | $aux_data | Additional data to be used to replace merge tags { |
gravityview_do_replace_variables
Turn off merge tag variable replacements.boolean | $do_replace_variables | True: yes, replace variables for this text; False: do not replace variables. |
string | $text | Text to replace variables in |
array | $form | GF Form array |
array | $entry | GF Entry array |
Make sure the required keys are set for GFCommon::replace_variables
Definition at line 321 of file class-gravityview-merge-tags.php.
References $entry, GV\$form, $format, and gravityview().
Referenced by GravityView_Shortcode\parse_and_sanitize_atts(), gravityview\parse_and_sanitize_atts(), GravityView_Widget_Custom_Content\render_frontend(), GravityView_API\replace_variables(), and GravityView_Field_Custom\show_field_in_edit_entry().