GVCommon
Source: includes/class-common.php:19
Details
- Kind:
class - Namespace:
(global)
Methods
| Method | Description |
|---|---|
clear_cache() | Clears the internal microcache. |
get_form() | Returns the form object for a given Form ID. |
get_form_or_form_template() | Returns form object for existing form or a form template. |
has_cap() | Alias of GravityView_Roles_Capabilities::has_cap() |
get_field_array() | Return a Gravity Forms field array, whether using GF 1.9 or not |
get_all_views() | Get all existing Views |
get_form_from_entry_id() | Get the form array for an entry based only on the entry ID |
has_product_field() | Check whether a form has product fields |
get_product_field_types() | Return array of product field types |
entry_has_transaction_data() | Check if an entry has transaction data |
get_entry_id_from_slug() | Get the entry ID from the entry slug, which may or may not be the entry ID |
get_forms_columns() | Alias of GFFormsModel::get_form_ids(), but allows for fetching other columns as well. |
get_forms_as_options() | Get all forms to use as options in View settings. |
get_forms() | Alias of GFAPI::get_forms() |
get_form_fields() | Return array of fields' id and label, for a given Form ID |
get_entry_meta() | get extra fields from entry meta |
get_entry_ids() | Wrapper for the Gravity Forms GFFormsModel::search_lead_ids() method |
calculate_get_entries_criteria() | Calculates the Search Criteria used on the self::get_entries / self::get_entry methods |
get_entries() | Retrieve entries given search, sort, paging criteria |
get_entry_id() | Get the entry ID from a string that may be the Entry ID or the Entry Slug |
get_entry() | Return a single entry object |
matches_operation() | Wrapper for the GFFormsModel::matches_conditional_operation() method that adds additional comparisons, including: |
check_entry_display() | Checks if a certain entry is valid according to the View search filters (specially the Adv Filters) |
format_date_without_timezone_offset() | Formats date without applying site's timezone. This is a copy of {@see GFCommon::format_date()}. |
format_date() | Allow formatting date and time based on GravityView standards |
get_field_label() | Retrieve the label of a given field id (for a specific form) |
get_field() | Returns the field details array of a specific form given the field id |
has_gravityview_shortcode() | Check whether the post is GravityView |
has_shortcode_r() | Placeholder until the recursive has_shortcode() patch is merged |
get_connected_views() | Get the views for a particular form |
get_meta_form_id() | Get the Gravity Forms form ID connected to a View |
get_meta_template_id() | Get the template ID (list, table, datatables, map) for a View |
get_template_settings() | Get all the settings for a View |
get_template_setting() | Get the setting for a View |
get_directory_fields() | Get the field configuration for the View |
get_directory_widgets() | Get the widget configuration for a View |
get_sortable_fields() | Render dropdown (select) with the list of sortable fields from a form ID |
get_sortable_fields_array() | |
get_field_type() | Returns the GF Form field type for a certain field(id) of a form |
is_field_numeric() | Checks if the field type is a 'numeric' field type (e.g. to be used when sorting) |
js_encrypt() | Encrypt content using Javascript so that it's hidden when JS is disabled. |
gv_parse_str() | Do the same than parse_str without max_input_vars limitation: |
get_link_html() | Generate an HTML anchor tag with a list of supported attributes |
array_merge_recursive_distinct() | array_merge_recursive does indeed merge arrays, but it converts values with duplicate |
get_users() | Get WordPress users with reasonable limits set |
generate_notice() | Display updated/error notice |
decode_shortcodes() | Inspired on \GFCommon::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets |
send_email() | Send email using GFCommon::send_email() |
is_rest_request() | Check if the current request is a REST request. |
Method Reference
clear_cache()
public static function clear_cache(): void
Clears the internal microcache.
Returns
void
Since: 2.42
Source: includes/class-common.php:34
get_form()
public static function get_form( $form_id )
Returns the form object for a given Form ID.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | string | The Form ID. |
Returns
array|false— Array: Form object returned from Gravity Forms; False: no form ID specified or Gravity Forms isn't active.
Source: includes/class-common.php:45
get_form_or_form_template()
public static function get_form_or_form_template( $form_id=0 )
Returns form object for existing form or a form template.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | string | 0 | Gravity Forms form ID. Default: 0. |
Returns
array|false
Since: 2.16
Source: includes/class-common.php:75
has_cap()
public static function has_cap( $caps='', $object_id=null, $user_id=null )
Alias of GravityView_Roles_Capabilities::has_cap()
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$caps | string | array | '' | Single capability or array of capabilities |
$object_id | int | null | (optional) Parameter can be used to check for capabilities against a specific object, such as a post or user |
$user_id | int | null | null | (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
See Also
Since: 1.15
Source: includes/class-common.php:99
get_field_array()
public static function get_field_array( $field )
Return a Gravity Forms field array, whether using GF 1.9 or not
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$field | array | GF_Fields | Gravity Forms field or array |
Returns
array— Array version of $field
Since: 1.7
Source: includes/class-common.php:111
get_all_views()
public static function get_all_views( $args=[] )
Get all existing Views
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$args | array | [] | Pass custom array of args, formatted as if for get_posts() |
Returns
- WP_Post[] — Array of Views as
WP_Post. Empty array if none found.
Since: 1.5.4 (Added $args array)
Source: includes/class-common.php:136
get_form_from_entry_id()
public static function get_form_from_entry_id( $entry_slug )
Get the form array for an entry based only on the entry ID
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$entry_slug | int | string | Entry 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
Source: includes/class-common.php:168
has_product_field()
public static function has_product_field( $form=[] )
Check whether a form has product fields
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | [] | Gravity Forms form array |
Returns
bool| GF_Field[]
Since:
Source: includes/class-common.php:191
get_product_field_types()
public static function get_product_field_types()
Return array of product field types
Modify the value using the gform_product_field_types filter
Returns
array
Since: 1.20
Source: includes/class-common.php:209
entry_has_transaction_data()
public static function entry_has_transaction_data( $entry=[] )
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'
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$entry | array | [] | Gravity Forms entry array |
Returns
bool— True: Entry has metadata suggesting it has communicated with a payment gateway; False: it does not have that data.
Since: 1.20
Source: includes/class-common.php:227
get_entry_id_from_slug()
public static function get_entry_id_from_slug( $slug )
Get the entry ID from the entry slug, which may or may not be the entry ID
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$slug | string | The entry slug, as returned by GravityView_API::get_entry_slug() |
Returns
int|null— The entry ID, if exists;NULLif not
Since: 1.5.2
Source: includes/class-common.php:261
get_forms_columns()
public static function get_forms_columns( $active=true, $trash=false, $sort_column='id', $sort_dir='ASC', $columns=['id'] )
Alias of GFFormsModel::get_form_ids(), but allows for fetching other columns as well.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$active | bool | true | True if active forms are returned. False to get inactive forms. Defaults to true. |
$trash | bool | false | True if trashed forms are returned. False to exclude trash. Defaults to false. |
$sort_column | string | 'id' | The column to sort the results on. |
$sort_dir | string | 'ASC' | The sort direction, ASC or DESC. |
$columns | array | ['id'] | The columns to return. Defaults to ['id']. Other options are 'title', 'date_created', 'is_active', 'is_trash'. 'date_updated' may be supported, depending on the Gravity Forms version. |
Returns
array— Forms indexed from 0 by SQL result row number. Each row is an associative array (column => value).
See Also
Since: 2.17.2
Source: includes/class-common.php:310
get_forms_as_options()
public static function get_forms_as_options( $active=true, $trash=false, $sort_column='id', $sort_dir='ASC' )
Get all forms to use as options in View settings.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$active | bool | true | True if active forms are returned. False to get inactive forms. Defaults to true. |
$trash | bool | false | True if trashed forms are returned. False to exclude trash. Defaults to false. |
$sort_column | string | 'id' | The column to sort the results on. |
$sort_dir | string | 'ASC' | The sort direction, ASC or DESC. |
Returns
array
Since: 2.17
Source: includes/class-common.php:356
get_forms()
public static function get_forms( $active=true, $trash=false, $order_by='id', $order='ASC' )
Alias of GFAPI::get_forms()
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$active | bool | string | true | Status of forms. Use any to get array of forms with any status. Default: true. |
$trash | bool | false | Include forms in trash? Default: false. |
$order_by | string | array | 'id' | Optional. Either the field name to order by or an array of multiple orderby fields as $orderby => $order. |
$order | string | 'ASC' | Optional. 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.
See Also
Since:
1.19(Allow "any" $active status option.)2.7.2(Allow sorting forms using wp_list_sort().)2.17.6(Addedgravityview/common/get_formsfilter.)
Source: includes/class-common.php:418
get_form_fields()
public static function get_form_fields( $form='', $add_default_properties=false, $include_parent_field=true )
Return array of fields' id and label, for a given Form ID
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | '' | ||
$add_default_properties | bool | false | |
$include_parent_field | bool | true | |
$form_id | string | array | '' | (default: '') or $form object |
Returns
array
Source: includes/class-common.php:469
get_entry_meta()
public static function get_entry_meta( $form_id, $only_default_column=true )
get extra fields from entry meta
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | string | '' | (default: '') |
$only_default_column | true |
Returns
array
Source: includes/class-common.php:593
get_entry_ids()
public static function get_entry_ids( $form_id, $search_criteria=[] )
Wrapper for the Gravity Forms GFFormsModel::search_lead_ids() method
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | ID of the Gravity Forms form | |
$search_criteria | [] |
Returns
array|void— Array of entry IDs. Void if Gravity Forms isn't active.
See Also
\GFEntryList::leads_page()
Since: 1.1.6
Source: includes/class-common.php:620
calculate_get_entries_criteria()
public static function calculate_get_entries_criteria( $passed_criteria=[], $form_ids=[] )
Calculates the Search Criteria used on the self::get_entries / self::get_entry methods
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$passed_criteria | array | [] | array Input Criteria (search_criteria, sorting, paging) |
$form_ids | array | [] | array Gravity Forms form IDs |
Returns
array
Since: 1.7.4
Source: includes/class-common.php:638
get_entries()
public static function get_entries( $form_ids=null, $passed_criteria=null, &$total=null )
Retrieve entries given search, sort, paging criteria
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_ids | int | array | null | The ID of the form or an array IDs of the Forms. Zero for all forms. |
$passed_criteria | mixed | null | (default: null) |
&$total | mixed | null | Optional. 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
See Also
Deprecated: \GV\View::get_entries()
Source: includes/class-common.php:745
get_entry_id()
public static function 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
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$entry_id_or_slug | string | '' | The ID or slug of an entry. |
$force_allow_ids | bool | false | Whether 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.
Since: 1.18
Source: includes/class-common.php:852
get_entry()
public static function get_entry( $entry_slug, $force_allow_ids=false, $check_entry_display=true, $view=null )
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
| Name | Type | Default | Description |
|---|---|---|---|
$entry_slug | string | int | Either entry ID or entry slug string | |
$force_allow_ids | boolean | false | Force the get_entry() method to allow passed entry IDs, even if the gravityview_custom_entry_slug_allow_id filter returns false. |
$check_entry_display | boolean | true | Check whether the entry is visible for the current View configuration. Default: true. {@since 1.14} |
$view | \GV\View | null | null | The View if $check_entry_display is set to true. In legacy context mocks, can be null. {@since develop} |
Returns
array|boolean
Source: includes/class-common.php:910
matches_operation()
public static function matches_operation( $val1, $val2, $operation )
Wrapper for the GFFormsModel::matches_conditional_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'
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$val1 | mixed | Left side of comparison | |
$val2 | mixed | Right side of comparison | |
$operation | string | Type of comparison |
Returns
bool— True: matches, false: not matches
See Also
Since:
1.7.51.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)2.33(Uses GFFormsModel::matches_operation or GFFormsModel::matches_conditional_operation depending on the Gravity Forms version.)
Source: includes/class-common.php:983
check_entry_display()
public static function check_entry_display( $entry, $view=null )
Checks if a certain entry is valid according to the View search filters (specially the Adv Filters)
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$entry | array | Gravity Forms Entry object | |
$view | \GV\View | \GV\View_Collection | null | The 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.
See Also
Since:
Source: includes/class-common.php:1108
format_date_without_timezone_offset()
public static function format_date_without_timezone_offset( $gmt_datetime, $is_human=true, $date_format='', $include_time=true )
Formats date without applying site's timezone. This is a copy of {@see GFCommon::format_date()}.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$gmt_datetime | string | The UTC date/time value to be formatted. | |
$is_human | bool | true | Indicates if a human-readable time difference such as "1 hour ago" should be returned when within 24hrs of the current time. Defaults to true. |
$date_format | string | '' | The format the value should be returned in. Defaults to an empty string; the date format from the WordPress general settings, if configured, or Y-m-d. |
$include_time | bool | true | Indicates if the time should be included in the returned string. Defaults to true; the time format from the WordPress general settings, if configured, or H:i. |
Returns
string
Since: 2.33
Source: includes/class-common.php:1240
format_date()
public static function format_date( $date_string='', $args=[] )
Allow formatting date and time based on GravityView standards
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$date_string | string | '' | The date as stored by Gravity Forms (Y-m-d h:i:s GMT) |
$args | string | array | [] | { Settings to define how you want the date to be formatted. |
Returns
int|null|string— Formatted date based on the original date
See Also
GVCommon_Test::test_format_date for examples
Since: 1.16
Source: includes/class-common.php:1289
get_field_label()
public static function get_field_label( $form=[], $field_id='', $field_value='' )
Retrieve the label of a given field id (for a specific form)
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | [] | Gravity Forms form array |
$field_id | string | '' | ID of the field. If an input, full input ID (like 1.3) |
$field_value | string | array | '' | Raw value of the field. |
Returns
string
Since: 1.17 (Added $field_value parameter)
Source: includes/class-common.php:1355
get_field()
public static function get_field( $form, $field_id )
Returns the field details array of a specific form given the field id
Alias of \GFFormsModel::get_field()
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | array | int | Form array or ID | |
$field_id | string | int |
Returns
- GF_Field |
null— Gravity Forms field object, or NULL: Gravity Forms GFFormsModel does not exist or field at $field_id doesn't exist.
See Also
GFFormsModel::get_field
Since: 1.19 (Allow passing form ID as well as form array)
Source: includes/class-common.php:1386
has_gravityview_shortcode()
public static function has_gravityview_shortcode( $post=null )
Check whether the post is GravityView
- Check post type. Is it
gravityview? - Check shortcode
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$post | WP_Post | null | WordPress post object |
Returns
boolean— True: yep, GravityView; No: not!
Source: includes/class-common.php:1403
has_shortcode_r()
public static function has_shortcode_r( $content, $tag='gravityview' )
Placeholder until the recursive has_shortcode() patch is merged
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$content | string | Content to check whether there's a shortcode | |
$tag | string | 'gravityview' | Current shortcode tag |
See Also
Source: includes/class-common.php:1423
get_connected_views()
public static function get_connected_views( $form_id, $args=[], $include_joins=true )
Get the views for a particular form
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form_id | int | Gravity Forms form ID | |
$args | array | [] | Pass args sent to get_posts() |
$include_joins | bool | true | Whether to include forms that are joined to the View |
Returns
array— Array with view details, as returned by get_posts()
Since:
Source: includes/class-common.php:1471
get_meta_form_id()
public static function get_meta_form_id( $view_id )
Get the Gravity Forms form ID connected to a View
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$view_id | int | The 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.
Source: includes/class-common.php:1528
get_meta_template_id()
public static function get_meta_template_id( $view_id, string $section='directory' )
Get the template ID (list, table, datatables, map) for a View
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$view_id | int | The ID of the View to get the layout of. | |
$section | string | 'directory' | The view section. |
Returns
string— GravityView_Template::template_id value. Empty string if not.
See Also
GravityView_Template::template_id
Source: includes/class-common.php:1542
get_template_settings()
public static function get_template_settings( $post_id )
Get all the settings for a View
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$post_id | int | View ID |
Returns
array— Associative array of settings with plugin defaults used if not set by the View
Source: includes/class-common.php:1575
get_template_setting()
public static function get_template_setting( $post_id, $key )
Get the setting for a View
If the setting isn't set by the View, it returns the plugin default.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$post_id | int | View ID | |
$key | string | Key for the setting |
Returns
mixed|null— Setting value, or NULL if not set.
Source: includes/class-common.php:1602
get_directory_fields()
public static function get_directory_fields( $post_id, $apply_filter=true, $form_id=0 )
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]
)
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$post_id | int | View ID. | |
$apply_filter | bool | true | Whether to apply the gravityview/configuration/fields filter [Default: true] |
$form_id | 0 |
Returns
array— Multi-array of fields with first level being the field zones. See code comment.
Since:
Source: includes/class-common.php:1649
get_directory_widgets()
public static function get_directory_widgets( $view_id, $json_decode=false )
Get the widget configuration for a View
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$view_id | int | View ID | |
$json_decode | bool | false | Whether 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"
Source: includes/class-common.php:1689
get_sortable_fields()
public static function get_sortable_fields( $formid, $current='id' )
Render dropdown (select) with the list of sortable fields from a form ID
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$formid | int | Form ID | |
$current | string | 'id' | Current selected field ID |
Returns
string— html
Source: includes/class-common.php:1719
get_sortable_fields_array()
public static function get_sortable_fields_array( $formid, $blocklist=['list', 'textarea'] )
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$formid | int | Gravity Forms form ID | |
$blocklist | array | ['list', 'textarea'] | Field types to exclude |
Returns
array
Since: 1.8
Source: includes/class-common.php:1767
get_field_type()
public static function get_field_type( $form=null, $field_id='' )
Returns the GF Form field type for a certain field(id) of a form
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | object | null | Gravity Forms form |
$field_id | mixed | '' | Field ID or Field array |
Returns
string— field type
Source: includes/class-common.php:1834
is_field_numeric()
public static function is_field_numeric( $form=null, $field='' )
Checks if the field type is a 'numeric' field type (e.g. to be used when sorting)
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$form | int | array | null | form ID or form array |
$field | int | array | '' | field key or field array |
Returns
boolean
Source: includes/class-common.php:1853
js_encrypt()
public static function js_encrypt( $content, $message='' )
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
| Name | Type | Default | Description |
|---|---|---|---|
$content | string | Content to encrypt | |
$message | string | '' | Message shown if Javascript is disabled |
Returns
string— Content, encrypted
See Also
- https://github.com/katzwebservices/standalone-phpenkoder StandalonePHPEnkoder on Github
Since: 1.7
Source: includes/class-common.php:1901
gv_parse_str()
public static function 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.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$string | string string to parse (not altered like in the original parse_str(), use the second parameter!) | ||
&$result | array 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
See Also
Since: 1.5.3
Source: includes/class-common.php:1943
get_link_html()
public static function get_link_html( $href='', $anchor_text='', $atts=[] )
Generate an HTML anchor tag with a list of supported attributes
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$href | string | '' | URL of the link. Sanitized using esc_url_raw() |
$anchor_text | string | '' | The text or HTML inside the anchor. This is not sanitized in the function. |
$atts | array | string | [] | Attributes 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
See Also
- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a Supported attributes defined here
Since: 1.6
Source: includes/class-common.php:1983
array_merge_recursive_distinct()
public static function 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.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
&$array1 | array | ||
&$array2 | array |
Returns
array
See Also
Since: 1.5.3
Source: includes/class-common.php:2081
get_users()
public static function get_users( $context='change_entry_creator', $args=[] )
Get WordPress users with reasonable limits set
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$context | string | 'change_entry_creator' | Where are we using this information (e.g. change_entry_creator, search_widget ..) |
$args | array | [] | Arguments to modify the user query. See get_users() {@since 1.14} |
Returns
array— Array of WP_User objects.
Source: includes/class-common.php:2103
generate_notice()
public static function generate_notice( $notice, $class='', $cap='', $object_id=null )
Display updated/error notice
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$notice | string | text/HTML of notice | |
$class | string | '' | CSS class for notice (updated or error) |
$cap | string | '' | [Optional] Define a capability required to show a notice. If not set, displays to all caps. |
$object_id | null |
Returns
string
Since: 1.19.2 (Added $cap and $object_id parameters)
Source: includes/class-common.php:2143
decode_shortcodes()
public static function decode_shortcodes( $string )
Inspired on \GFCommon::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortcode brackets
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$string | string | Input string to decode |
Returns
string— $string Output string
Since: 1.16.5
Source: includes/class-common.php:2160
send_email()
public static function 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()
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$from | string | Sender address (required) | |
$to | string | Recipient address (required) | |
$bcc | string | BCC recipients (required) | |
$reply_to | string | Reply-to address (required) | |
$subject | string | Subject line (required) | |
$message | string | Message body (required) | |
$from_name | string | '' | Displayed name of the sender |
$message_format | string | 'html' | If "html", sent text as text/html. Otherwise, text/plain. Default: "html". |
$attachments | string | array | '' | Optional. Files to attach. \wp_mail for usage. Default: "". |
$entry | array | false | false | Gravity Forms entry array, related to the email. Default: false. |
$notification | array | false | false | Gravity Forms notification that triggered the email. \GFCommon::send_notification(). Default:false. |
See Also
GFCommon::send_email This just makes the method public
Since: 1.17
Source: includes/class-common.php:2188
is_rest_request()
public static function is_rest_request()
Check if the current request is a REST request.
Returns
bool— True if the request is a REST request, false otherwise.
Since: 2.41
Source: includes/class-common.php:2207