33 $template_css_path = trailingslashit( get_stylesheet_directory() ) .
'gravityview/css/' . $css_file;
35 if( file_exists( $template_css_path ) ) {
36 $path = trailingslashit( get_stylesheet_directory_uri() ) .
'gravityview/css/' . $css_file;
37 gravityview()->log->debug(
'Stylesheet override ({css_file})', array(
'css_file' => esc_attr( $css_file ) ) );
42 if(
'' === $dir_path ) {
47 $path = plugins_url( $css_file, trailingslashit( $dir_path ) .
'stripped-by-plugin_basename.php' );
65 return ( $mixed !==
'' );
83 $parsed_permalink = parse_url( get_permalink( $id ) );
85 $permalink_args = isset( $parsed_permalink[
'query'] ) ? $parsed_permalink[
'query'] :
false;
87 if( empty( $permalink_args ) ) {
91 parse_str( $permalink_args,
$args );
112 if( is_array( $current ) ) {
113 if( in_array(
$value, $current ) ) {
114 $output = __checked_selected_helper(
true,
true,
false, $type );
117 $output = __checked_selected_helper(
$value, $current,
false, $type );
128 if( ! function_exists(
'gravityview_sanitize_html_class' ) ) {
139 function gravityview_sanitize_html_class( $classes ) {
141 if ( is_string( $classes ) ) {
142 $classes = explode(
' ', $classes );
146 if ( ! is_array( $classes ) ) {
150 $classes = array_map(
'trim', $classes );
151 $classes = array_map(
'sanitize_html_class', $classes );
152 $classes = array_filter( $classes );
154 return implode(
' ', $classes );
173 $string = normalize_whitespace( $string );
174 return preg_replace(
'/[\r\n\t ]+/',
' ', $string );
188 if( ! file_exists( $file_path ) ) {
189 gravityview()->log->error(
'File path does not exist. {path}', array(
'path' => $file_path ) );
193 include( $file_path );
194 return ob_get_clean();
210 $width = $height * 0.7586206897;
212 if( function_exists(
'is_rtl') && is_rtl() ) {
213 $style =
'margin:10px 10px 10px 0; height='. $height .
'px; width: '. $width .
'px;';
214 $css_class = is_string( $css_class ) ? $css_class :
'alignright';
216 $style =
'margin:10px 10px 10px 0; height='. $height .
'px; width: '. $width .
'px;';
217 $css_class = is_string( $css_class ) ? $css_class :
'alignleft';
220 return '<img src="'. esc_url( plugins_url(
'assets/images/astronaut-200x263.png',
GRAVITYVIEW_FILE ) ) .
'" class="'. gravityview_sanitize_html_class( $css_class ).
'" height="'.intval( $height ).
'" width="'.round( $width, 2 ).
'" alt="The GravityView Astronaut Says:" style="'.$style.
'" />';
244 if(
'' === $decimals ) {
246 $decimal_point = isset( $wp_locale ) ? $wp_locale->number_format[
'decimal_point'] :
'.';
252 $decimals = strlen( substr( strrchr( $number, $decimal_point ), 1 ) );
256 $number = number_format_i18n( $number, (
int)$decimals );
258 $number = sprintf(
"%.{$decimals}f", $number );
276 $parts = parse_url(
$value );
279 if( empty( $parts[
'host'] ) ) {
292 if(
false === apply_filters(
'gravityview_anchor_text_striphttp',
true) ) {
294 if( isset( $parts[
'scheme'] ) ) {
295 $return .= $parts[
'scheme'];
301 $domain = $parts[
'host'];
309 $strip_www = apply_filters(
'gravityview_anchor_text_stripwww',
true );
312 $domain = str_replace(
'www.',
'', $domain );
322 $strip_subdomains = apply_filters(
'gravityview_anchor_text_nosubdomain',
true);
324 if( $strip_subdomains ) {
340 $root_only = apply_filters(
'gravityview_anchor_text_rootonly',
true);
342 if( empty( $root_only ) ) {
344 if( isset( $parts[
'path'] ) ) {
345 $return .= $parts[
'path'];
355 $strip_query_string = apply_filters(
'gravityview_anchor_text_noquerystring',
true );
357 if( empty( $strip_query_string ) ) {
359 if( isset( $parts[
'query'] ) ) {
360 $return .=
'?'.$parts[
'query'];
377 if( preg_match(
"/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches ) ) {
378 return $matches[
'domain'];
380 return $string_maybe_has_subdomain;
396 return !
gv_empty(
$value, $zero_is_empty, $allow_string_booleans );
412 function gv_empty(
$value, $zero_is_empty =
true, $allow_string_booleans =
true ) {
419 if ( is_array(
$value ) ) {
421 foreach (
$value as $v ) {
422 if ( !
gv_empty( $v, $zero_is_empty, $allow_string_booleans ) ) {
435 || ( is_object(
$value ) && ! get_object_vars(
$value ) )
440 if ( is_string(
$value ) && $allow_string_booleans ) {
445 if ( in_array(
$value, array(
'yes',
'true' ),
true ) ) {
447 }
else if( in_array(
$value, array(
'no',
'false' ),
true ) ) {
453 if ( ! $zero_is_empty && is_numeric(
$value ) && empty(
$value ) ) {
476 if( ! is_string(
$value ) ) {
480 if ( version_compare( phpversion(),
'5.4.0',
'>=' ) ) {
481 $decoded = json_decode(
$value, $assoc, $depth, $options );
483 $decoded = json_decode(
$value, $assoc, $depth );
487 if( function_exists(
'json_last_error') && JSON_ERROR_NONE !== json_last_error() ) {
492 if( is_null( $decoded ) ) {
512 return map_deep(
$value, $callback );
525 function gravityview_is_valid_datetime( $datetime, $expected_format =
'Y-m-d' ) {
530 $formatted_date = DateTime::createFromFormat( $expected_format, $datetime );
535 return ( $formatted_date && $formatted_date->format( $expected_format ) === $datetime );
557 $exploded = explode(
'.',
"{$field_id}" );
559 return isset( $exploded[1] ) ? intval( $exploded[1] ) :
false;
587 'taxonomy' =>
'category',
588 'fields' =>
'id=>name',
598 $args = apply_filters(
'gravityview_get_terms_choices_args',
$args );
600 $terms = get_terms(
$args[
'taxonomy'],
$args );
604 if ( is_array( $terms ) ) {
605 foreach ( $terms as $term_id => $term_name ) {
607 'text' => $term_name,
630 if( !empty( $_POST[
'gv_fields'] ) ) {
631 if ( ! is_array( $_POST[
'gv_fields'] ) ) {
634 $fields_holder = array();
637 if ( isset( $fields_holder[
'fields'] ) ) {
638 $fields = $fields_holder[
'fields'];
640 gravityview()->log->error(
'No `fields` key was found after parsing $fields string', array(
'data' => $fields_holder ) );
644 $fields = $_POST[
'gv_fields'];
671 if ( ! is_string(
$value ) ) {
675 if(
false !== strpos( strtolower(
$value ),
"relative:") ) {
678 $timestamp = strtotime(
$value );
687 $parsed_date = array_filter( \GFCommon::parse_date(
$value ) );
690 if ( 3 !==
sizeof( $parsed_date ) ) {
694 $year = (int) rgar( $parsed_date,
'year' );
695 $month = (int) rgar( $parsed_date,
'month' );
696 $day = (int) rgar( $parsed_date,
'day' );
700 if ( ! checkdate( $month, $day, $year ) ) {
701 $day = (int) rgar( $parsed_date,
'month' );
702 $month = (int) rgar( $parsed_date,
'day' );
706 if ( ! checkdate( $month, $day, $year ) ) {
711 $date = DateTimeImmutable::createFromFormat(
'Y-m-d H:i:s',
"$year-$month-$day 00:00:00" );
717 return $date->getTimestamp();
const GRAVITYVIEW_DIR
"GRAVITYVIEW_DIR" "./" The absolute path to the plugin directory, with trailing slash ...
_gravityview_strip_subdomain( $string_maybe_has_subdomain)
Do a very basic match for second-level TLD domains, like .co.uk
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:"...
gravityview_is_not_empty_string( $mixed='')
Check whether a variable is not an empty string.
gravityview_get_floaty( $height=87, $css_class=null)
Get an image of our intrepid explorer friend.
if(! function_exists( 'gravityview_sanitize_html_class')) gravityview_strip_whitespace( $string)
Replace multiple newlines, tabs, and spaces with a single space.
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 ...
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 ex...
gravityview_format_link( $value=null)
Convert a whole link into a shorter link for display.
gravityview_get_input_id_from_id( $field_id='')
Very commonly needed: get the # of the input based on a full field ID.
gravityview_ob_include( $file_path, $object=NULL)
Get the contents of a file using include() and ob_start()
gv_map_deep( $value, $callback)
Maps a function to all non-iterable elements of an array or an object.
gv_maybe_json_decode( $value, $assoc=false, $depth=512, $options=0)
If content is JSON, decode it.
const GRAVITYVIEW_FILE
Full path to the GravityView file "GRAVITYVIEW_FILE" "./gravityview.php".
gv_not_empty( $value, $zero_is_empty=false, $allow_string_booleans=false)
The inverse of gv_empty()
gravityview_get_terms_choices( $args=array())
Get categories formatted in a way used by GravityView and Gravity Forms input choices.
_gravityview_process_posted_fields()
Maybe convert jQuery-serialized fields into array, otherwise return $_POST['fields'] array...
gravityview()
The main GravityView wrapper function.
gv_empty( $value, $zero_is_empty=true, $allow_string_booleans=true)
Is the value empty?
gravityview_number_format( $number, $decimals='', $separator=true)
Intelligently format a number.
if(false !==strpos( $value, '00:00')) $field_id
string $field_id ID of the field being displayed
gv_selected( $value, $current, $echo=true, $type='selected')
Similar to the WordPress selected(), checked(), and disabled() functions, except it allows arrays to ...
gravityview_get_permalink_query_args( $id=0)
Get get_permalink() without the home_url() prepended to it.