GravityView
2.17
The best, easiest way to display Gravity Forms entries on your website.
|
Go to the source code of this file.
Functions | |
_gravityview_process_posted_fields () | |
Maybe convert jQuery-serialized fields into array, otherwise return $_POST['fields'] array. More... | |
_gravityview_strip_subdomain ( $string_maybe_has_subdomain) | |
Do a very basic match for second-level TLD domains, like .co.uk More... | |
gravityview_css_url ( $css_file='', $dir_path='') | |
Functions that don't require GravityView or Gravity Forms API access but are used in the plugin to extend PHP and WP functions. More... | |
gravityview_format_link ( $value=null) | |
Convert a whole link into a shorter link for display. More... | |
gravityview_get_floaty ( $height=87, $css_class=null) | |
Get an image of our intrepid explorer friend. More... | |
gravityview_get_input_id_from_id ( $field_id='') | |
Very commonly needed: get the # of the input based on a full field ID. More... | |
gravityview_get_permalink_query_args ( $id=0) | |
Get get_permalink() without the home_url() prepended to it. More... | |
gravityview_get_terms_choices ( $args=array()) | |
Get categories formatted in a way used by GravityView and Gravity Forms input choices. More... | |
gravityview_is_not_empty_string ( $mixed='') | |
Check whether a variable is not an empty string. More... | |
gravityview_maybe_convert_date_string_to_timestamp ( $value='') | |
Convert a string to a timestamp if it's a valid date or a relative date prefixed with "relative:". More... | |
gravityview_number_format ( $number, $decimals='', $separator=true) | |
Intelligently format a number. More... | |
gravityview_ob_include ( $file_path, $object=NULL) | |
Get the contents of a file using include() and ob_start() More... | |
if(! function_exists( 'gravityview_sanitize_html_class')) | gravityview_strip_whitespace ( $string) |
Replace multiple newlines, tabs, and spaces with a single space. More... | |
gv_empty ( $value, $zero_is_empty=true, $allow_string_booleans=true) | |
Is the value empty? More... | |
gv_map_deep ( $value, $callback) | |
Maps a function to all non-iterable elements of an array or an object. More... | |
gv_maybe_json_decode ( $value, $assoc=false, $depth=512, $options=0) | |
If content is JSON, decode it. More... | |
gv_not_empty ( $value, $zero_is_empty=false, $allow_string_booleans=false) | |
The inverse of gv_empty() More... | |
gv_selected ( $value, $current, $echo=true, $type='selected') | |
Similar to the WordPress selected() , checked() , and disabled() functions, except it allows arrays to be passed as current value. More... | |
_gravityview_process_posted_fields | ( | ) |
Maybe convert jQuery-serialized fields into array, otherwise return $_POST['fields'] array.
Fields are passed as a jQuery-serialized array, created in admin-views.js in the serializeForm method.
Definition at line 627 of file helper-functions.php.
References gravityview(), and GVCommon\gv_parse_str().
Referenced by GravityView_Plugin_Hooks_ACF\fix_posted_fields(), and GravityView_Admin_Views\save_postdata().
_gravityview_strip_subdomain | ( | $string_maybe_has_subdomain | ) |
Do a very basic match for second-level TLD domains, like .co.uk
Ideally, we'd use https://github.com/jeremykendall/php-domain-parser to check for this, but it's too much work for such a basic functionality. Maybe if it's needed more in the future. So instead, we use Basic matching regex.
string | $domain | Domain to check if it's a TLD or subdomain |
Definition at line 375 of file helper-functions.php.
Referenced by gravityview_format_link().
gravityview_css_url | ( | $css_file = '' , |
|
$dir_path = '' |
|||
) |
Functions that don't require GravityView or Gravity Forms API access but are used in the plugin to extend PHP and WP functions.
If there's a CSS file with the same name as a GravityView CSS file in the current theme directory, it will be used. Place the CSS file in a /gravityview/css/
sub-directory.
Example: /twentysixteen/gravityview/css/gv-default-styles.css
Will use, in order: 1) [theme directory]/gravityview/css/ 2) [gravityview plugin]/css/ (no check performed)
get_stylesheet_directory() get_stylesheet_directory_uri()
string | $css_file | Filename of the CSS file (like gv-default-styles.css) |
string | $dir_path | Absolute path to the directory where the CSS file is stored. If empty, uses default GravityView templates CSS folder. |
Definition at line 30 of file helper-functions.php.
References gravityview(), and GRAVITYVIEW_DIR.
Referenced by GravityView_Default_Template_List\__construct(), GravityView_frontend\enqueue_default_style(), and GravityView_Field_Notes\register_scripts().
gravityview_format_link | ( | $value = null | ) |
Convert a whole link into a shorter link for display.
string | $value | Existing URL |
gravityview_anchor_text_striphttp
Strip scheme from the displayed URL? boolean | $enable | Whether to strip the scheme. Return false to show scheme. (default: true) If true: http://example.com => example.com |
gravityview_anchor_text_stripwww
Strip www from the domain? boolean | $enable | Whether to strip www. Return false to show www. (default: true) If true: www.example.com => example.com |
gravityview_anchor_text_nosubdomain
Strip subdomains from the domain? boolean | $enable | Whether to strip subdomains. Return false to show subdomains. (default: true) If true: http://demo.example.com => example.com If false: http://demo.example.com => demo.example.com |
gravityview_anchor_text_rootonly
Display link path going only to the base directory, not a sub-directory or file? boolean | $enable | Whether to enable "root only". Return false to show full path. (default: true) If true: http://example.com/sub/directory/page.html => example.com If false: http://example.com/sub/directory/page.html => example.com/sub/directory/page.html |
gravityview_anchor_text_noquerystring
Strip the query string from the end of the URL? boolean | $enable | Whether to enable "root only". Return false to show full path. (default: true) If true: http://example.com/?query=example => example.com |
Definition at line 273 of file helper-functions.php.
References $value, and _gravityview_strip_subdomain().
gravityview_get_floaty | ( | $height = 87 , |
|
$css_class = null |
|||
) |
Get an image of our intrepid explorer friend.
int | $height | Height of the cutie in pixels |
null | string | $css_class | If defined, use the passed CSS class (can be empty string). Otherwise, use default alignleft (or alignright, based on RTL). |
Definition at line 208 of file helper-functions.php.
References GRAVITYVIEW_FILE.
Referenced by GravityView_Admin_Notices\admin_notice(), GravityView_Admin\connected_form_warning(), GravityView_Admin\get_floaty(), and GravityView_Welcome\tabs().
gravityview_get_input_id_from_id | ( | $field_id = '' | ) |
Very commonly needed: get the # of the input based on a full field ID.
Example: 12.3 => field #12, input #3. Returns: 3 Example: 7 => field #7, no input. Returns: 0
string | $field_id | Full ID of field, with or without input ID, like "12.3" or "7". |
Definition at line 550 of file helper-functions.php.
References $field_id, and gravityview().
Referenced by GravityView_Field_List\_filter_field_label(), GravityView_Field_Date\date_display(), GravityView_Field_Time\date_format(), GravityView_Field_Survey\field_options(), GravityView_Widget_Search\prepare_field_filter(), GravityView_Field_Address\search_bar_input_type(), and GravityView_Field_Address\search_field_filter().
gravityview_get_permalink_query_args | ( | $id = 0 | ) |
Get get_permalink()
without the home_url() prepended to it.
get_permalink() does a lot of good stuff: it gets the correct permalink structure for custom post types, pages, posts, etc. Instead of using ?p={id}
, ?page_id={id}
, or ?p={id}&post_type={post_type}
, by using get_permalink(), we can use ?p=slug
or ?gravityview={slug}
We could do this in a cleaner fashion, but this prevents a lot of code duplication, checking for URL structure, etc.
int | WP_Post | $id | Optional. Post ID or post object. Default current post. |
Definition at line 81 of file helper-functions.php.
References $args.
Referenced by GravityView_Widget_Search\add_no_permalink_fields().
gravityview_get_terms_choices | ( | $args = array() | ) |
Get categories formatted in a way used by GravityView and Gravity Forms input choices.
array | $args | Arguments array as used by the get_terms() function. Filtered using gravityview_get_terms_choices_args filter. Defaults: { string $taxonomy Used as first argument in get_terms(). Default: "category" string $fields Default: 'id=>name' to only fetch term ID and Name int $number Limit the total number of terms to fetch. Default: 1000 } |
text
(Category Name) and value
(Category ID) keys. gravityview_get_terms_choices_args
Modify the arguments passed to get_terms()
Definition at line 577 of file helper-functions.php.
References $args.
Referenced by GravityView_Widget_Search\get_search_filter_details().
gravityview_is_not_empty_string | ( | $mixed = '' | ) |
Check whether a variable is not an empty string.
mixed | $mixed | Variable to check |
Definition at line 64 of file helper-functions.php.
gravityview_maybe_convert_date_string_to_timestamp | ( | $value = '' | ) |
Convert a string to a timestamp if it's a valid date or a relative date prefixed with "relative:".
For example: "relative:-1 week" or "relative:tomorrow" will be converted to a timestamp.
Note: This assumes the date is using a Gregorian calendar.
GFCommon::parse_date() DateTimeImmutable::createFromFormat()
strtotime()
string | $value | The string to convert to a timestamp. Supports relative dates and different date formats. Does its best to figure out the date format. |
Definition at line 669 of file helper-functions.php.
References $value.
Referenced by GVCommon\matches_operation().
gravityview_number_format | ( | $number, | |
$decimals = '' , |
|||
$separator = true |
|||
) |
Intelligently format a number.
If you don't define the number of decimal places, then it will use the existing number of decimal places. This is done in a way that respects the localization of the site.
If you do define decimals, it uses number_format_i18n()
int | float | string | double | $number | A number to format |
int | string | $decimals | Optional. Precision of the number of decimal places. Default '' (use existing number of decimals) |
boolean | $separator | Separate with dots or commas, etc. Default: true. |
Calculate the position of the decimal point in the number
Definition at line 241 of file helper-functions.php.
gravityview_ob_include | ( | $file_path, | |
$object = NULL |
|||
) |
Get the contents of a file using include()
and ob_start()
string | $file_path | Full path to a file |
mixed | $object | Pass pseudo-global to the included file |
Definition at line 187 of file helper-functions.php.
References gravityview().
Referenced by GravityView_Edit_Entry_Render\edit_entry_form(), and GravityView_Edit_Entry_Render\render_form_buttons().
if (! function_exists('gravityview_sanitize_html_class')) gravityview_strip_whitespace | ( | $string | ) |
Replace multiple newlines, tabs, and spaces with a single space.
First, runs normalize_whitespace() on a string. This replaces multiple lines with a single line, and tabs with spaces. We then strip any tabs or newlines and replace those with a single space.
string | $string | String to strip whitespace from |
Definition at line 172 of file helper-functions.php.
Referenced by GravityView_Field_Notes\display_note(), GravityView_Edit_Entry_Render\edit_entry_form(), GravityView_Field_Notes\get_add_note_part(), GravityView_Ajax\get_field_options(), and GravityView_Ajax\get_sortable_fields().
gv_empty | ( | $value, | |
$zero_is_empty = true , |
|||
$allow_string_booleans = true |
|||
) |
Is the value empty?
Allows you to pass a function instead of just a variable, like the empty() function insists upon (until PHP 5.5)
Checks whether false
, null
, empty string, empty array, object with no vars defined
mixed | $value | Check whether this is empty |
boolean | $zero_is_empty | Should the number zero be treated as an empty value? |
boolean | $allow_string_booleans | Whether to check if 'yes', 'true' => true and 'no', 'false' => false |
Arrays with empty values are empty.
Consider the a missing product field.
Definition at line 412 of file helper-functions.php.
References $value.
Referenced by GravityView_Widget_Search\filter_entries(), GravityView_Edit_Entry_Render\get_field_value(), gv_not_empty(), GravityView_Shortcode\parse_and_sanitize_atts(), gravityview\parse_and_sanitize_atts(), and Field_Template\render().
gv_map_deep | ( | $value, | |
$callback | |||
) |
Maps a function to all non-iterable elements of an array or an object.
map_deep()
, added in 4.4. Here for legacy purposes. mixed | $value | The array, object, or scalar. |
callable | $callback | The function to map onto $value. |
Definition at line 511 of file helper-functions.php.
References $value.
Referenced by gvfield\callback(), gvlogic\callback(), GravityView_Widget_Search\filter_entries(), GVCommon\get_directory_widgets(), GravityView_Widget_Search\rgget_or_rgpost(), GravityView_Field_Post_Category\set_post_categories(), and GravityView_Field_Notes\strings().
gv_maybe_json_decode | ( | $value, | |
$assoc = false , |
|||
$depth = 512 , |
|||
$options = 0 |
|||
) |
If content is JSON, decode it.
Otherwise, return the passed value
string | $value | The string that may be decoded |
bool | $assoc | [optional] When true , returned objects will be converted into associative arrays |
int | $depth | [optional] User specified recursion depth. |
int | $options | [optional] Bitmask of JSON decode options. Used only on sites running PHP 5.4+ |
json_decode()
. Otherwise, returns original value. Definition at line 474 of file helper-functions.php.
References $value.
Referenced by View_Collection\merge_deep().
gv_not_empty | ( | $value, | |
$zero_is_empty = false , |
|||
$allow_string_booleans = false |
|||
) |
The inverse of gv_empty()
mixed | $value | Check whether this is not empty |
bool | $zero_is_empty | Should the number zero be treated as an empty value? Default: false |
bool | $allow_string_booleans | Whether to check if 'yes', 'true' => true and 'no', 'false' => false . Default: false |
Definition at line 395 of file helper-functions.php.
References $value, and gv_empty().
gv_selected | ( | $value, | |
$current, | |||
$echo = true , |
|||
$type = 'selected' |
|||
) |
Similar to the WordPress selected()
, checked()
, and disabled()
functions, except it allows arrays to be passed as current value.
string | $value | One of the values to compare |
mixed | $current | (true) The other value to compare if not just true |
bool | $echo | Whether to echo or just return the string |
string | $type | The type of checked|selected|disabled we are doing |
sanitize_html_class doesn't handle spaces (multiple classes). We remedy that.
sanitize_html_class
string | array | $classes | Text or array of classes to sanitize |
Definition at line 109 of file helper-functions.php.
References $output, and $value.
Referenced by Page_Size\render_frontend().