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

If this file is called directly, abort. More...

Static Public Member Functions

static array_merge_recursive_distinct (array &$array1, array &$array2)
 array_merge_recursive does indeed merge arrays, but it converts values with duplicate keys to arrays rather than overwriting the value in the first array with the duplicate value in the second array, as array_merge does. More...
 
static calculate_get_entries_criteria ( $passed_criteria=array(), $form_ids=array())
 Calculates the Search Criteria used on the self::get_entries / self::get_entry methods. More...
 
static check_entry_display ( $entry, $view=null)
 Checks if a certain entry is valid according to the View search filters (specially the Adv Filters) More...
 
static decode_shortcodes ( $string)
 Inspired on ::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets. More...
 
static entry_has_transaction_data ( $entry=array())
 Check if an entry has transaction data. More...
 
static format_date ( $date_string='', $args=array())
 Allow formatting date and time based on GravityView standards. More...
 
static generate_notice ( $notice, $class='', $cap='', $object_id=null)
 Display updated/error notice. More...
 
static get_all_views ( $args=array())
 Get all existing Views. More...
 
static get_connected_views ( $form_id, $args=array())
 Get the views for a particular form. More...
 
static get_directory_fields ( $post_id, $apply_filter=true, $form_id=0)
 Get the field configuration for the View. More...
 
static get_directory_widgets ( $view_id, $json_decode=false)
 Get the widget configuration for a View. More...
 
static get_entries ( $form_ids=null, $passed_criteria=null, &$total=null)
 Retrieve entries given search, sort, paging criteria. More...
 
static get_entry ( $entry_slug, $force_allow_ids=false, $check_entry_display=true, $view=null)
 Return a single entry object. More...
 
static get_entry_id ( $entry_id_or_slug='', $force_allow_ids=false)
 Get the entry ID from a string that may be the Entry ID or the Entry Slug. More...
 
static get_entry_id_from_slug ( $slug)
 Get the entry ID from the entry slug, which may or may not be the entry ID. More...
 
static get_entry_ids ( $form_id, $search_criteria=array())
 Wrapper for the Gravity Forms GFFormsModel::search_lead_ids() method. More...
 
static get_entry_meta ( $form_id, $only_default_column=true)
 get extra fields from entry meta More...
 
static get_field ( $form, $field_id)
 Returns the field details array of a specific form given the field id. More...
 
static get_field_array ( $field)
 Return a Gravity Forms field array, whether using GF 1.9 or not. More...
 
static get_field_label ( $form=array(), $field_id='', $field_value='')
 Retrieve the label of a given field id (for a specific form) More...
 
static get_field_type ( $form=null, $field_id='')
 Returns the GF Form field type for a certain field(id) of a form. More...
 
static get_form ( $form_id)
 Returns the form object for a given Form ID. More...
 
static get_form_fields ( $form='', $add_default_properties=false, $include_parent_field=true)
 Return array of fields' id and label, for a given Form ID. More...
 
static get_form_from_entry_id ( $entry_slug)
 Get the form array for an entry based only on the entry ID. More...
 
static get_form_or_form_template ( $form_id=0)
 Returns form object for existing form or a form template. More...
 
static get_forms ( $active=true, $trash=false, $order_by='id', $order='ASC')
 Alias of GFAPI::get_forms() More...
 
static get_forms_as_options ( $active=true, $trash=false, $sort_column='id', $sort_dir='ASC')
 Get all forms to use as options in View settings. More...
 
static get_link_html ( $href='', $anchor_text='', $atts=array())
 Generate an HTML anchor tag with a list of supported attributes. More...
 
static get_meta_form_id ( $view_id)
 Get the Gravity Forms form ID connected to a View. More...
 
static get_meta_template_id ( $view_id)
 Get the template ID (list, table, datatables, map) for a View. More...
 
static get_product_field_types ()
 Return array of product field types. More...
 
static get_sortable_fields ( $formid, $current='')
 Render dropdown (select) with the list of sortable fields from a form ID. More...
 
static get_sortable_fields_array ( $formid, $blocklist=array( 'list', 'textarea'))
 
static get_template_setting ( $post_id, $key)
 Get the setting for a View. More...
 
static get_template_settings ( $post_id)
 Get all the settings for a View. More...
 
static get_users ( $context='change_entry_creator', $args=array())
 Get WordPress users with reasonable limits set. More...
 
static gv_parse_str ( $string, &$result)
 Do the same than parse_str without max_input_vars limitation: Parses $string as if it were the query string passed via a URL and sets variables in the current scope. More...
 
static has_cap ( $caps='', $object_id=null, $user_id=null)
 Alias of GravityView_Roles_Capabilities::has_cap() More...
 
static has_gravityview_shortcode ( $post=null)
 Check whether the post is GravityView. More...
 
static has_product_field ( $form=array())
 Check whether a form has product fields. More...
 
static has_shortcode_r ( $content, $tag='gravityview')
 Placeholder until the recursive has_shortcode() patch is merged. More...
 
static is_field_numeric ( $form=null, $field='')
 Checks if the field type is a 'numeric' field type (e.g. More...
 
static js_encrypt ( $content, $message='')
 Encrypt content using Javascript so that it's hidden when JS is disabled. More...
 
static matches_operation ( $val1, $val2, $operation)
 Wrapper for the GFFormsModel::matches_operation() method that adds additional comparisons, including: 'equals', 'greater_than_or_is', 'greater_than_or_equals', 'less_than_or_is', 'less_than_or_equals', 'not_contains', 'in', and 'not_in'. More...
 
static send_email ( $from, $to, $bcc, $reply_to, $subject, $message, $from_name='', $message_format='html', $attachments='', $entry=false, $notification=false)
 Send email using GFCommon::send_email() More...
 

Detailed Description

If this file is called directly, abort.

Definition at line 19 of file class-common.php.

Member Function Documentation

◆ array_merge_recursive_distinct()

static array_merge_recursive_distinct ( array &  $array1,
array &  $array2 
)
static

array_merge_recursive does indeed merge arrays, but it converts values with duplicate keys to arrays rather than overwriting the value in the first array with the duplicate value in the second array, as array_merge does.

See also
http://php.net/manual/en/function.array-merge-recursive.php
Since
1.5.3
Parameters
array$array1
array$array2
Returns
array
Author
Daniel danie.nosp@m.l@da.nosp@m.niels.nosp@m.mede.nosp@m.gaard.nosp@m.buus.nosp@m..dk
Gabriel Sobrinho gabri.nosp@m.el.s.nosp@m.obrin.nosp@m.ho@g.nosp@m.mail..nosp@m.com

Definition at line 1801 of file class-common.php.

References $value.

◆ calculate_get_entries_criteria()

static calculate_get_entries_criteria (   $passed_criteria = array(),
  $form_ids = array() 
)
static

Calculates the Search Criteria used on the self::get_entries / self::get_entry methods.

Since
1.7.4
Parameters
array$passed_criteriaarray Input Criteria (search_criteria, sorting, paging)
array$form_idsarray Gravity Forms form IDs
Returns
array
Runs Filter:
gravityview_search_operator Modify the search operator for the field (contains, is, isnot, etc)
Parameters
string$operatorExisting search operator
array$filterarray with key, value, operator, type keys

Prepare date formats to be in Gravity Forms DB format; $passed_criteria may include date formats incompatible with Gravity Forms.

Runs Filter:
gravityview_search_criteria Apply final criteria filter (Used by the Advanced Filter extension)
Parameters
array$criteriaSearch criteria used by GravityView
array$form_idsForms to search
int$view_idID of the view being used to search

Definition at line 494 of file class-common.php.

References $criteria, GravityView_frontend\getInstance(), GravityView_View_Data\getInstance(), and gravityview().

Referenced by View\get_entries(), and GV\Mocks\GravityView_frontend_get_view_entries().

◆ check_entry_display()

static check_entry_display (   $entry,
  $view = null 
)
static

Checks if a certain entry is valid according to the View search filters (specially the Adv Filters)

GVCommon::calculate_get_entries_criteria();

See also
GFFormsModel::is_value_match()
Since
1.7.4
2.1 Added $view parameter
Parameters
array$entryGravity Forms Entry object
\GV\View | \GV\View_Collection$viewThe View or a View Collection
Returns
WP_Error|array Returns WP_Error if entry is not valid according to the view search filters (Adv Filter). Returns original $entry value if passes.

Check whether the entry is in the entries subset by running a modified query.

$query

Definition at line 936 of file class-common.php.

References $criteria, $entries, $entry, Utils\_GET(), and gravityview().

Referenced by GravityView_frontend\_get_single_entry_title(), gravityview\callback(), and View\content().

◆ decode_shortcodes()

static decode_shortcodes (   $string)
static

Inspired on ::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets.

Since
1.16.5
Parameters
string$stringInput string to decode
Returns
string $string Output string

Definition at line 1874 of file class-common.php.

◆ entry_has_transaction_data()

static entry_has_transaction_data (   $entry = array())
static

Check if an entry has transaction data.

Checks the following keys to see if they are set: 'payment_status', 'payment_date', 'transaction_id', 'payment_amount', 'payment_method'

Since
1.20
Parameters
array$entryGravity Forms entry array
Returns
bool True: Entry has metadata suggesting it has communicated with a payment gateway; False: it does not have that data.

Definition at line 201 of file class-common.php.

References $entry, and Utils\get().

Referenced by GravityView_Plugin_Hooks_Gravity_Forms_Coupon\should_hide_coupon_fields(), and GravityView_Field_Product\should_hide_product_fields().

◆ format_date()

static format_date (   $date_string = '',
  $args = array() 
)
static

Allow formatting date and time based on GravityView standards.

Since
1.16
See also
GVCommon_Test::test_format_date for examples
Parameters
string$date_stringThe date as stored by Gravity Forms (Y-m-d h:i:s GMT)
string | array$argsArray or string of settings for output parsed by wp_parse_args(); Can use raw=1 or `array('raw' => true)\n -rawUn-formatted date string in originalY-m-d h:i:sformat -timestampInteger timestamp returned by GFCommon::get_local_timestamp() -diff"%s ago" format, unless otherformatis defined -humanSet $is_human parameter to true forGFCommon::format_date(). Showsdiffwithin 24 hours or date after. Format based on blog setting, unlessformatis defined. -timeInclude time in theGFCommon::format_date()output -formatDefine your own date format, ordiff` format
Returns
int|null|string Formatted date based on the original date

Gravity Forms code to adjust date to locally-configured Time Zone

See also
GFCommon::format_date() for original code

Definition at line 1070 of file class-common.php.

References $args, $format, and Utils\get().

Referenced by GravityView_Merge_Tags\format_date(), GravityView_Field_Date_Created\get_content(), GravityView_Field_Date_Updated\get_content(), and GravityView_Field_Workflow_Current_Status_Timestamp\modify_entry_value_workflow_current_status_timestamp().

◆ generate_notice()

static generate_notice (   $notice,
  $class = '',
  $cap = '',
  $object_id = null 
)
static

Display updated/error notice.

Since
1.19.2 Added $cap and $object_id parameters
Parameters
string$noticetext/HTML of notice
string$classCSS class for notice (updated or error)
string$cap[Optional] Define a capability required to show a notice. If not set, displays to all caps.
Returns
string

Definition at line 1857 of file class-common.php.

References $class.

Referenced by GravityView_frontend\context_not_configured_warning(), GravityView_Delete_Entry\display_message(), GravityView_Edit_Entry_Render\maybe_print_message(), GravityView_Entry_Approval_Merge_Tags\maybe_show_approval_notice(), GravityView_Edit_Entry_Render\user_can_edit_entry(), and GravityView_Edit_Entry_Render\user_can_edit_field().

◆ get_all_views()

static get_all_views (   $args = array())
static

Get all existing Views.

Since
1.5.4 Added $args array
Parameters
array$argsPass custom array of args, formatted as if for get_posts()
Returns
WP_Post[] Array of Views as WP_Post. Empty array if none found.
Runs Filter:
gravityview/get_all_views/params Modify the parameters sent to get all views.
Parameters
array$paramsArray of parameters to pass to get_posts()

Definition at line 114 of file class-common.php.

References $args.

Referenced by GravityView_Search_WP_Widget\form(), Views_Route\get_items(), and Blocks\get_views().

◆ get_connected_views()

static get_connected_views (   $form_id,
  $args = array() 
)
static

Get the views for a particular form.

Since
1.15.2 Add $args array and limit posts_per_page to 500

get_posts()

Parameters
int$form_idGravity Forms form ID
array$argsPass args sent to get_posts()
Returns
array Array with view details, as returned by get_posts()

Definition at line 1245 of file class-common.php.

References $args, and $form_id.

Referenced by gravityview_get_connected_views().

◆ get_directory_fields()

static get_directory_fields (   $post_id,
  $apply_filter = true,
  $form_id = 0 
)
static

Get the field configuration for the View.

array(

[other zones]

'directory_list-title' => array(

[other fields]

'5372653f25d44' => array(
    'id' => string '9' (length=1)
    'label' => string 'Screenshots' (length=11)
    'show_label' => string '1' (length=1)
    'custom_label' => string '' (length=0)
    'custom_class' => string 'gv-gallery' (length=10)
    'only_loggedin' => string '0' (length=1)
    'only_loggedin_cap' => string 'read' (length=4)
)

[other fields]

)

[other zones] )

Since
1.17.4 Added $apply_filter parameter.
2.17 Added $form_id parameter.
Parameters
int$post_idView ID.
bool$apply_filterWhether to apply the gravityview/configuration/fields filter [Default: true]
Returns
array Multi-array of fields with first level being the field zones. See code comment.
Runs Filter:
gravityview/configuration/fields Filter the View fields' configuration array
Since
1.6.5
2.16.3 Added the $form_id parameter.
Parameters
$fieldsarray Multi-array of fields with first level being the field zones
$post_idint Post ID
int$form_idThe main form ID for the View.
Runs Filter:
gravityview/view/configuration/fields Filter the View fields' configuration array.
Since
2.0
2.16.3 Added the $form_id parameter.
Parameters
array$fieldsMulti-array of fields with first level being the field zones.
\GV\View$viewThe View the fields are being pulled for.
int$form_idThe main form ID for the View.

Definition at line 1388 of file class-common.php.

References $form_id.

Referenced by GravityView_Welcome\getting_started_screen(), and gravityview_get_directory_fields().

◆ get_directory_widgets()

static get_directory_widgets (   $view_id,
  $json_decode = false 
)
static

Get the widget configuration for a View.

Parameters
int$view_idView ID
bool$json_decodeWhether to JSON-decode the widget values. Default: false
Returns
array Multi-array of widgets, with the slug of each widget "zone" being the key ("header_top"), and each widget having their own "id"

Definition at line 1426 of file class-common.php.

References $view_id, and gv_map_deep().

◆ get_entries()

static get_entries (   $form_ids = null,
  $passed_criteria = null,
$total = null 
)
static

Retrieve entries given search, sort, paging criteria.

See also
GFAPI::get_entries()
GFFormsModel::get_field_filters_where()
Parameters
int | array$form_idsThe ID of the form or an array IDs of the Forms. Zero for all forms.
mixed$passed_criteria(default: null)
mixed&$totalOptional. An output parameter containing the total number of entries. Pass a non-null value to generate the total count. (default: null)
Returns
mixed False: Error fetching entries. Array: Multi-dimensional array of Gravity Forms entry arrays

Reduce # of database calls

Runs Filter:
gravityview_pre_get_entries Define entries to be used before GFAPI::get_entries() is called
Since
1.14
Parameters
null$returnIf you want to override GFAPI::get_entries() and define entries yourself, tap in here.
array$criteriaThe final search criteria used to generate the request to GFAPI::get_entries()
array$passed_criteriaThe original search criteria passed to GVCommon::get_entries()
int | null$totalOptional. An output parameter containing the total number of entries. Pass a non-null value to generate
Since
2.1 The $total parameter can now be overriden by reference.

Remove filter added above

Remove filter added above

Runs Filter:
gravityview_entries Modify the array of entries returned to GravityView after it has been fetched from the cache or from GFAPI::get_entries().
Parameters
array | null$entriesArray of entries as returned by the cache or by GFAPI::get_entries()
array$criteriaThe final search criteria used to generate the request to GFAPI::get_entries()
array$passed_criteriaThe original search criteria passed to GVCommon::get_entries()
int | null$totalOptional. An output parameter containing the total number of entries. Pass a non-null value to generate
Since
2.1 The $total parameter can now be overriden by reference.

Definition at line 595 of file class-common.php.

References $criteria, $entries, gravityview(), and GravityView_Cache.

Referenced by gravityview_get_entries().

◆ get_entry()

static get_entry (   $entry_slug,
  $force_allow_ids = false,
  $check_entry_display = true,
  $view = null 
)
static

Return a single entry object.

Since 1.4, supports custom entry slugs. The way that GravityView fetches an entry based on the custom slug is by searching gravityview_unique_id meta. The $entry_slug is fetched by getting the current query var set by is_single_entry()

Parameters
string | int$entry_slugEither entry ID or entry slug string
boolean$force_allow_idsForce the get_entry() method to allow passed entry IDs, even if the gravityview_custom_entry_slug_allow_id filter returns false.
boolean$check_entry_displayCheck whether the entry is visible for the current View configuration. Default: true. {
Since
1.14}
Parameters
\GV\View | null$viewThe View if $check_entry_display is set to true. In legacy context mocks, can be null. {
Since
develop}
Returns
array|boolean
Runs Filter:
gravityview/common/get_entry/check_entry_display Override whether to check entry display rules against filters
Since
1.16.2
2.6 Added $view parameter
Parameters
bool$check_entry_displayCheck whether the entry is visible for the current View configuration. Default: true.
array$entryGravity Forms entry array
\GV\View | null$viewThe View

Definition at line 749 of file class-common.php.

References $entry, $entry_slug, Utils\_GET(), View\by_id(), and gravityview().

Referenced by GravityView_API\entry_link(), GravityView_Entry_Link_Shortcode\get_entry(), gravityview_get_entry(), and GravityView_frontend\setEntry().

◆ get_entry_id()

static get_entry_id (   $entry_id_or_slug = '',
  $force_allow_ids = false 
)
static

Get the entry ID from a string that may be the Entry ID or the Entry Slug.

Since
1.18
Parameters
string$entry_id_or_slugThe ID or slug of an entry.
bool$force_allow_idsWhether to force allowing getting the ID of an entry, even if custom slugs are enabled
Returns
false|int|null Returns the ID of the entry found, if custom slugs is enabled. Returns original value if custom slugs is disabled. Returns false if not allowed to convert slug to ID. Returns NULL if entry not found for the passed slug.
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)
Runs Filter:
gravityview_custom_entry_slug_allow_id When using a custom slug, allow access to the entry using the original slug (the Entry ID).
  • If disabled (default), only allow access to an entry using the custom slug value. (example: /entry/custom-slug/ NOT /entry/123/)
  • If enabled, you could access using the custom slug OR the entry id (example: /entry/custom-slug/ OR /entry/123/)
Parameters
boolean$custom_slug_id_accessTrue: allow accessing the slug by ID; False: only use the slug passed to the method.

If we're using custom entry slugs, we do a meta value search instead of doing a straight-up ID search.

Definition at line 697 of file class-common.php.

Referenced by GravityView_Entry_Approval\ajax_update_approved(), and GravityView_Entry_Approval\get_entry_status().

◆ get_entry_id_from_slug()

static get_entry_id_from_slug (   $slug)
static

Get the entry ID from the entry slug, which may or may not be the entry ID.

Since
1.5.2
Parameters
string$slugThe entry slug, as returned by GravityView_API::get_entry_slug()
Returns
int|null The entry ID, if exists; NULL if not
Runs Filter:
gravityview/common/get_entry_id_from_slug/form_id The form ID used to get the custom entry ID. Change this to avoid collisions with data from other forms with the same values and the same field ID.
Since
1.17.2
Parameters
int$form_idID of the form to search. Default: 0 (searches all forms)

Definition at line 235 of file class-common.php.

References $form_id.

◆ get_entry_ids()

static get_entry_ids (   $form_id,
  $search_criteria = array() 
)
static

Wrapper for the Gravity Forms GFFormsModel::search_lead_ids() method.

See also
GFEntryList::leads_page()
Parameters
int$form_idID of the Gravity Forms form
Since
1.1.6
Returns
array|void Array of entry IDs. Void if Gravity Forms isn't active.

Definition at line 476 of file class-common.php.

References $form_id.

Referenced by gravityview_get_entry_ids().

◆ get_entry_meta()

static get_entry_meta (   $form_id,
  $only_default_column = true 
)
static

get extra fields from entry meta

Parameters
string$form_id(default: '')
Returns
array

Definition at line 449 of file class-common.php.

References $field, and $form_id.

Referenced by gravityview_get_entry_meta().

◆ get_field()

static get_field (   $form,
  $field_id 
)
static

Returns the field details array of a specific form given the field id.

Alias of GFFormsModel::get_field

Since
1.19 Allow passing form ID as well as form array

GFFormsModel::get_field

See also
GFFormsModel::get_field
Parameters
array | int$formForm array or ID
string | int$field_id
Returns
GF_Field|null Gravity Forms field object, or NULL: Gravity Forms GFFormsModel does not exist or field at $field_id doesn't exist.

Definition at line 1161 of file class-common.php.

References $field, $field_id, and GV\$form.

Referenced by gravityview_get_field().

◆ get_field_array()

static get_field_array (   $field)
static

Return a Gravity Forms field array, whether using GF 1.9 or not.

Since
1.7
Parameters
array | GF_Fields$fieldGravity Forms field or array
Returns
array Array version of $field

Definition at line 89 of file class-common.php.

References $field.

◆ get_field_label()

static get_field_label (   $form = array(),
  $field_id = '',
  $field_value = '' 
)
static

Retrieve the label of a given field id (for a specific form)

Since
1.17 Added $field_value parameter
Parameters
array$formGravity Forms form array
string$field_idID of the field. If an input, full input ID (like 1.3)
string | array$field_valueRaw value of the field.
Returns
string

Definition at line 1130 of file class-common.php.

References $field, $field_id, $field_value, GV\$form, $label, and Utils\get().

Referenced by GravityView_Field_Gravatar\_get_email_field_choices(), and gravityview_get_field_label().

◆ get_field_type()

static get_field_type (   $form = null,
  $field_id = '' 
)
static

Returns the GF Form field type for a certain field(id) of a form.

Parameters
object$formGravity Forms form
mixed$field_idField ID or Field array
Returns
string field type

Definition at line 1559 of file class-common.php.

References $field, $field_id, and GV\$form.

Referenced by gravityview_get_field_type().

◆ get_form()

static get_form (   $form_id)
static

Returns the form object for a given Form ID.

Parameters
mixed$form_id
Returns
array|false Array: Form object returned from Gravity Forms; False: no form ID specified or Gravity Forms isn't active.

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

References $form_id.

Referenced by GravityView_Field\_filter_gform_custom_merge_tags(), GravityView_frontend\_get_single_entry_title(), GravityView_Admin_View_Item\getOutput(), gravityview_get_form(), GravityView_Entry_Approval\update_approved_meta(), and GravityView_Search_WP_Widget\widget().

◆ get_form_fields()

static get_form_fields (   $form = '',
  $add_default_properties = false,
  $include_parent_field = true 
)
static

Return array of fields' id and label, for a given Form ID.

Parameters
string | array$form_id(default: '') or $form object
bool$add_default_properties
bool$include_parent_field
Returns
array

In case of email/email confirmation, the input for email has the same id as the parent field

Since
1.7
Runs Filter:
gravityview/common/get_form_fields Modify the form fields shown in the Add Field field picker.
Since
1.17
Parameters
array$fieldsAssociative array of fields, with keys as field type, values an array with the following keys: (string) label (required), (string) type (required), desc, (string) customLabel, (GF_Field) parent, (string) adminLabel, (bool)adminOnly
array$formGF Form array
bool$include_parent_fieldWhether to include the parent field when getting a field with inputs

Definition at line 344 of file class-common.php.

References $field, GV\$form, and GravityView_Fields\get_all().

Referenced by gravityview_get_form_fields().

◆ get_form_from_entry_id()

static get_form_from_entry_id (   $entry_slug)
static

Get the form array for an entry based only on the entry ID.

Parameters
int | string$entry_slugEntry slug
Returns
array|false Array: Form object returned from Gravity Forms; False: form doesn't exist, or $entry didn't exist or $entry didn't specify form ID

Definition at line 142 of file class-common.php.

References $entry, $entry_slug, and GV\$form.

Referenced by gravityview_get_form_from_entry_id().

◆ get_form_or_form_template()

static get_form_or_form_template (   $form_id = 0)
static

Returns form object for existing form or a form template.

Since
2.16
Parameters
int | string$form_idGravity Forms form ID. Default: 0.
Returns
array|false

Definition at line 53 of file class-common.php.

References GV\$form, $form_id, and GravityView_Ajax\pre_get_form_fields().

Referenced by GravityView_Admin_Views\render_additional_fields(), GravityView_Admin_Views\render_available_fields(), and GravityView_Render_Settings\render_field_options().

◆ get_forms()

static get_forms (   $active = true,
  $trash = false,
  $order_by = 'id',
  $order = 'ASC' 
)
static

Alias of GFAPI::get_forms()

See also
GFAPI::get_forms()
Since
1.19 Allow "any" $active status option
2.7.2 Allow sorting forms using wp_list_sort()
Parameters
bool | string$activeStatus of forms. Use any to get array of forms with any status. Default: true
bool$trashInclude forms in trash? Default: false
string | array$order_byOptional. Either the field name to order by or an array of multiple orderby fields as $orderby => $order.
string$orderOptional. Either 'ASC' or 'DESC'. Only used if $orderby is a string.
Returns
array Empty array if GFAPI class isn't available or no forms. Otherwise, the array of Forms

Definition at line 317 of file class-common.php.

References $forms.

Referenced by gravityview_get_forms().

◆ get_forms_as_options()

static get_forms_as_options (   $active = true,
  $trash = false,
  $sort_column = 'id',
  $sort_dir = 'ASC' 
)
static

Get all forms to use as options in View settings.

Since
2.17

GFAPI::get_form() -by ::defaults()

Parameters
bool$activeTrue if active forms are returned. False to get inactive forms. Defaults to true.
bool$trashTrue if trashed forms are returned. False to exclude trash. Defaults to false.
string$sort_columnThe column to sort the results on.
string$sort_dirThe sort direction, ASC or DESC.
Returns
array

Definition at line 283 of file class-common.php.

References GV\$form, and $forms.

Referenced by View_Settings\defaults().

◆ get_link_html()

static get_link_html (   $href = '',
  $anchor_text = '',
  $atts = array() 
)
static

Generate an HTML anchor tag with a list of supported attributes.

See also
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a Supported attributes defined here esc_url_raw() to sanitize $href esc_attr() to sanitize $atts
Since
1.6
Parameters
string$hrefURL of the link. Sanitized using esc_url_raw()
string$anchor_textThe text or HTML inside the anchor. This is not sanitized in the function.
array | string$attsAttributes to be added to the anchor tag. Parsed by wp_parse_args(), sanitized using esc_attr()
Returns
string HTML output of anchor link. If empty $href, returns NULL
Runs Filter:
gravityview/get_link/allowed_atts Modify the attributes that are allowed to be used in generating links
Since
1.6
Parameters
array$allowed_attsArray of attributes allowed

Fix potential security issue with target=_blank

See also
https://dev.to/ben/the-targetblank-vulnerability-by-example

Definition at line 1705 of file class-common.php.

References $href, $output, and $value.

Referenced by gravityview_get_link().

◆ get_meta_form_id()

static get_meta_form_id (   $view_id)
static

Get the Gravity Forms form ID connected to a View.

Parameters
int$view_idThe ID of the View to get the connected form of
Returns
false|string ID of the connected Form, if exists. Empty string if not. False if not the View ID isn't valid.

Definition at line 1295 of file class-common.php.

References $view_id.

Referenced by gravityview_get_form_id(), and GravityView_Search_WP_Widget\widget().

◆ get_meta_template_id()

static get_meta_template_id (   $view_id)
static

Get the template ID (list, table, datatables, map) for a View.

See also
GravityView_Template::template_id
Parameters
int$view_idThe ID of the View to get the layout of
Returns
string GravityView_Template::template_id value. Empty string if not.

Definition at line 1308 of file class-common.php.

References $view_id.

Referenced by gravityview_get_template_id().

◆ get_product_field_types()

static get_product_field_types ( )
static

Return array of product field types.

Modify the value using the gform_product_field_types filter

Since
1.20
Returns
array

Definition at line 183 of file class-common.php.

Referenced by GravityView_Field_Product\edit_entry_field_blocklist().

◆ get_sortable_fields()

static get_sortable_fields (   $formid,
  $current = '' 
)
static

Render dropdown (select) with the list of sortable fields from a form ID.

Parameters
int$formidForm ID
Returns
string html

Definition at line 1454 of file class-common.php.

References $field, and $output.

Referenced by gravityview_get_sortable_fields().

◆ get_sortable_fields_array()

static get_sortable_fields_array (   $formid,
  $blocklist = array( 'list', 'textarea' ) 
)
static
Parameters
int$formidGravity Forms form ID
array$blocklistField types to exclude
Since
1.8
Returns
array

Merge date and time subfields.

Runs Filter:
gravityview/common/sortable_fields Filter the sortable fields
Since
1.12
Parameters
array$fieldsSub-set of GF form fields that are sortable
int$formidThe Gravity Forms form ID that the fields are from

Definition at line 1494 of file class-common.php.

References $field.

Referenced by GravityView_HTML_Elements\field_dropdown().

◆ get_template_setting()

static get_template_setting (   $post_id,
  $key 
)
static

Get the setting for a View.

If the setting isn't set by the View, it returns the plugin default.

Parameters
int$post_idView ID
string$keyKey for the setting
Returns
mixed|null Setting value, or NULL if not set.

Definition at line 1343 of file class-common.php.

References $settings.

Referenced by GravityView_Edit_Entry\check_user_cap_edit_entry(), and gravityview_get_template_setting().

◆ get_template_settings()

static get_template_settings (   $post_id)
static

Get all the settings for a View.

::defaults() Parses the settings with the plugin defaults as backups.

Parameters
int$post_idView ID
Returns
array Associative array of settings with plugin defaults used if not set by the View

Definition at line 1320 of file class-common.php.

References $settings.

Referenced by gravityview_get_template_settings(), and oEmbed\render_frontend().

◆ get_users()

static get_users (   $context = 'change_entry_creator',
  $args = array() 
)
static

Get WordPress users with reasonable limits set.

Parameters
string$contextWhere are we using this information (e.g. change_entry_creator, search_widget ..)
array$argsArguments to modify the user query. See get_users() {
Since
1.14}
Returns
array Array of WP_User objects.
Runs Filter:
gravityview/get_users/{$context} There are issues with too many users using get_users() where it breaks the select. We try to keep it at a reasonable number.
$context is where are we using this information (e.g. change_entry_creator, search_widget ..)
Parameters
array$settingsSettings array, with number key defining the # of users to display

Definition at line 1823 of file class-common.php.

References $args.

Referenced by GravityView_Change_Entry_Creator\add_select(), GravityView_Change_Entry_Creator\entry_creator_get_users(), and GravityView_Widget_Search\get_created_by_choices().

◆ gv_parse_str()

static gv_parse_str (   $string,
$result 
)
static

Do the same than parse_str without max_input_vars limitation: Parses $string as if it were the query string passed via a URL and sets variables in the current scope.

Parameters
$stringstring string to parse (not altered like in the original parse_str(), use the second parameter!)
$resultarray If the second parameter is present, variables are stored in this variable as array elements
Returns
bool true or false if $string is an empty string
Since
1.5.3
See also
https://gist.github.com/rubo77/6821632

Definition at line 1665 of file class-common.php.

Referenced by _gravityview_process_posted_fields().

◆ has_cap()

static has_cap (   $caps = '',
  $object_id = null,
  $user_id = null 
)
static

Alias of GravityView_Roles_Capabilities::has_cap()

Since
1.15
See also
GravityView_Roles_Capabilities::has_cap()
Parameters
string | array$capsSingle capability or array of capabilities
int$object_id(optional) Parameter can be used to check for capabilities against a specific object, such as a post or user
int | null$user_id(optional) Check the capabilities for a user who is not necessarily the currently logged-in user
Returns
bool True: user has at least one passed capability; False: user does not have any defined capabilities

Definition at line 77 of file class-common.php.

References GravityView_Roles_Capabilities\has_cap().

Referenced by GravityView_Compatibility\_shortcode_gf_notice(), GravityView_Admin_ApproveEntries\add_entry_approved_hidden_input(), GravityView_Admin_Bar\add_floaty_icon(), GravityView_Admin_Bar\add_hooks(), GravityView_Admin_Views\add_post_type_columns(), GravityView_Admin_ApproveEntries\add_scripts_and_styles(), GravityView_Admin_Add_Shortcode\add_shortcode_button(), Plugin\add_to_gravitykit_admin_menu(), GravityView_Admin_Notices\admin_notice(), GravityView_Entry_Approval\ajax_update_approved(), GravityView_Entry_Approval\autounapprove(), gvfield\callback(), gravityview\callback(), View\can_render(), GravityView_Delete_Entry\check_user_cap_delete_entry(), GravityView_Duplicate_Entry\check_user_cap_duplicate_entry(), GravityView_Edit_Entry\check_user_cap_edit_entry(), GravityView_Edit_Entry_Render\check_user_cap_edit_field(), View\content(), GravityView_Admin_Duplicate_View\current_user_can_copy(), GravityView_Field_Notes\display_note(), GravityView_Edit_Entry_Render\filter_admin_only_fields(), GravityView_Field_Notes\get_add_note_part(), GravityView_Admin_Views\get_connected_form_links(), View\get_entries(), GravityView_Edit_Entry_Locking\get_lock_ui(), GravityView_Field_Notes\get_note_email_fields(), Views_Route\get_sub_item_permissions_check(), GravityView_Admin_Views\gform_toolbar_menu(), GravityView_frontend\is_entry_approved(), Field\is_visible(), GravityView_Change_Entry_Creator\load(), GravityView_Field_Notes\maybe_add_note(), GravityView_Field_Notes\maybe_delete_notes(), GravityView_Duplicate_Entry\maybe_duplicate_list(), GravityView_Field_Entry_Approval\maybe_not_visible(), GravityView_Field_Entry_Approval\maybe_prevent_field_render(), Plugin_Settings\maybe_save_app_settings(), GravityView_Field_Notes\maybe_send_entry_notes(), GravityView_Entry_Approval_Merge_Tags\maybe_update_approved(), GravityView_Edit_Entry_Render\maybe_update_post_fields(), GravityView_Field_Unsubscribe\modify_entry_value_unsubscribe(), GravityView_Admin\no_views_text(), Views_Route\prepare_view_for_response(), GravityView_Field_Notes\process_add_note(), GravityView_Field_Notes\process_delete_notes(), GravityView_frontend\process_search_only_approved(), oEmbed\render_frontend(), GravityView_frontend\render_view(), GravityView_Edit_Entry_Locking\request_lock(), GravityView_Admin_Views\save_postdata(), Plugin\setup_gravitykit_admin_menu_redirects(), GravityView_Admin_ApproveEntries\show_approve_entry_column(), GravityView_Support_Port\show_for_user(), GravityView_Entry_Approval\update_bulk(), GravityView_Cache\use_cache(), and GravityView_Support_Port\user_field().

◆ has_gravityview_shortcode()

static has_gravityview_shortcode (   $post = null)
static

Check whether the post is GravityView.

  • Check post type. Is it gravityview?
  • Check shortcode
Parameters
WP_Post$postWordPress post object
Returns
boolean True: yep, GravityView; No: not!

Definition at line 1178 of file class-common.php.

References $post.

Referenced by has_gravityview_shortcode().

◆ has_product_field()

static has_product_field (   $form = array())
static

Check whether a form has product fields.

Since
1.16
1.20 Refactored the field types to get_product_field_types() method
Parameters
array$formGravity Forms form array
Returns
bool|GF_Field[]

Definition at line 165 of file class-common.php.

References GV\$form.

Referenced by GravityView_Field_Product\clear_product_info_cache().

◆ has_shortcode_r()

static has_shortcode_r (   $content,
  $tag = 'gravityview' 
)
static

Placeholder until the recursive has_shortcode() patch is merged.

See also
https://core.trac.wordpress.org/ticket/26343#comment:10
Parameters
string$contentContent to check whether there's a shortcode
string$tagCurrent shortcode tag

Definition at line 1199 of file class-common.php.

References $content.

Referenced by gravityview_has_shortcode_r().

◆ is_field_numeric()

static is_field_numeric (   $form = null,
  $field = '' 
)
static

Checks if the field type is a 'numeric' field type (e.g.

to be used when sorting)

Parameters
int | array$formform ID or form array
int | array$fieldfield key or field array
Returns
boolean
Runs Filter:
gravityview/common/numeric_types What types of fields are numeric?
Since
1.5.2
Parameters
array$numeric_typesFields that are numeric. Default: [ number, time ]

Definition at line 1579 of file class-common.php.

References $field, GV\$form, $gv_field, and GravityView_Fields\get().

Referenced by View\get_entries(), and GravityView_frontend\get_search_criteria_paging().

◆ js_encrypt()

static js_encrypt (   $content,
  $message = '' 
)
static

Encrypt content using Javascript so that it's hidden when JS is disabled.

This is mostly used to hide email addresses from scraper bots.

Parameters
string$contentContent to encrypt
string$messageMessage shown if Javascript is disabled
See also
https://github.com/katzwebservices/standalone-phpenkoder StandalonePHPEnkoder on Github
Since
1.7
Returns
string Content, encrypted
Runs Filter:
gravityview/phpenkoder/msg Modify the message shown when Javascript is disabled and an encrypted email field is displayed
Since
1.7
Parameters
string$messageExisting message
string$contentContent to encrypt

Definition at line 1625 of file class-common.php.

References $content, $output, and GRAVITYVIEW_DIR.

◆ matches_operation()

static matches_operation (   $val1,
  $val2,
  $operation 
)
static

Wrapper for the GFFormsModel::matches_operation() method that adds additional comparisons, including: 'equals', 'greater_than_or_is', 'greater_than_or_equals', 'less_than_or_is', 'less_than_or_equals', 'not_contains', 'in', and 'not_in'.

Since
1.13 You can define context, which displays/hides based on what's being displayed (single, multiple, edit)
1.22.1 Added 'in' and 'not_in' for JSON-encoded array values, serialized non-strings
See also
https://docs.gravityview.co/article/252-gvlogic-shortcode GFFormsModel::matches_operation
Since
1.7.5
Parameters
mixed$val1Left side of comparison
mixed$val2Right side of comparison
string$operationType of comparison
Returns
bool True: matches, false: not matches
Since
1.22.1 Handle JSON-encoded comparisons

Definition at line 812 of file class-common.php.

References $value, gravityview_get_context(), and gravityview_maybe_convert_date_string_to_timestamp().

Referenced by gvlogic\callback(), and GravityView_GFFormsModel\is_value_match().

◆ send_email()

static send_email (   $from,
  $to,
  $bcc,
  $reply_to,
  $subject,
  $message,
  $from_name = '',
  $message_format = 'html',
  $attachments = '',
  $entry = false,
  $notification = false 
)
static

Send email using GFCommon::send_email()

Since
1.17
See also
GFCommon::send_email This just makes the method public
Parameters
string$fromSender address (required)
string$toRecipient address (required)
string$bccBCC recipients (required)
string$reply_toReply-to address (required)
string$subjectSubject line (required)
string$messageMessage body (required)
string$from_nameDisplayed name of the sender
string$message_formatIf "html", sent text as text/html. Otherwise, text/plain. Default: "html".
string | array$attachmentsOptional. Files to attach. {
See also
wp_mail()} for usage. Default: "".
Parameters
array | false$entryGravity Forms entry array, related to the email. Default: false.
array | false$notificationGravity Forms notification that triggered the email. {
See also
GFCommon::send_notification}. Default:false.

Definition at line 1902 of file class-common.php.

References $entry.

Referenced by GravityView_Field_Notes\maybe_send_entry_notes().


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