33 if ( defined(
'DOING_GRAVITYVIEW_TESTS' ) && ! empty( $GLOBALS[
'GravityView_API_field_label_override'] ) ) {
41 if( !empty(
$field[
'show_label'] ) || $force_show_label ) {
46 if( class_exists(
'GF_Field' ) ) {
48 $field_object = RGFormsModel::get_field(
$form,
$field[
'id'] );
52 $input = GFFormsModel::get_input( $field_object,
$field[
'id'] );
58 $label = ! empty( $input[
'customLabel'] ) ? $input[
'customLabel'] : $input[
'label'];
63 $label = $field_object->get_field_label(
true,
$field[
'label'] );
72 if ( !empty(
$field[
'custom_label'] ) ) {
83 $label .= apply_filters(
'gravityview_render_after_label',
'',
$field );
136 if( !empty(
$field[
'width'] ) ) {
137 $width = absint(
$field[
'width'] );
140 if(
'%d%%' ===
$format && $width > 100 ) {
144 $width = sprintf(
$format, $width );
160 if( !empty(
$field[
'custom_class'] ) ) {
162 $custom_class =
$field[
'custom_class'];
169 add_filter(
'gform_merge_tag_filter',
'sanitize_html_class');
171 $custom_class = self::replace_variables( $custom_class,
$form,
$entry);
174 remove_filter(
'gform_merge_tag_filter',
'sanitize_html_class');
178 $classes[] = gravityview_sanitize_html_class( $custom_class );
182 if(!empty(
$field[
'id'])) {
183 if( !empty(
$form ) && !empty(
$form[
'id'] ) ) {
187 gravityview()->log->warning(
'GravityView_View::getInstance() legacy API called' );
192 $classes[] =
'gv-field'.$form_id.
'-'.
$field[
'id'];
195 return esc_attr(implode(
' ', $classes));
212 if ( ! empty( $id ) ) {
213 if ( ! empty(
$form ) && ! empty(
$form[
'id'] ) ) {
217 gravityview()->log->warning(
'GravityView_View::getInstance() legacy API called' );
225 return esc_attr( $id );
239 gravityview()->log->notice(
'\GravityView_API::field_value is deprecated. Use \GV\Field_Template::render() or \GV\Field::get_value()' );
262 gravityview()->log->debug(
'Entry not defined; returning null', array(
'data' =>
$entry ) );
296 public static function no_results( $wpautop =
true, $context = null ) {
299 if ( $context instanceof \
GV\Template_Context ) {
300 if ( $context->request->is_search() ) {
315 $output = esc_html__(
'This search returned no results.',
'gk-gravityview' );
318 $setting = $context->view->settings->get(
'no_search_results_text',
$output );
323 $output = esc_html__(
'No entries match your request.',
'gk-gravityview' );
326 $setting = $context->view->settings->get(
'no_results_text',
$output );
330 if (
'' !== $setting ) {
341 'p' => array(
'class' => array(),
'id' => array() ),
342 'h1' => array(
'class' => array(),
'id' => array() ),
343 'h2' => array(
'class' => array(),
'id' => array() ),
344 'h3' => array(
'class' => array(),
'id' => array() ),
345 'h4' => array(
'class' => array(),
'id' => array() ),
346 'h5' => array(
'class' => array(),
'id' => array() ),
347 'strong' => array(
'class' => array(),
'id' => array() ),
348 'span' => array(
'class' => array(),
'id' => array() ),
349 'b' => array(
'class' => array(),
'id' => array() ),
350 'em' => array(
'class' => array(),
'id' => array() ),
351 'a' => array(
'class' => array(),
'id' => array(),
'href' => array(),
'title' => array(),
'rel' => array(),
'target' => array() ),
352 'div' => array(
'class' => array(),
'id' => array() ),
369 $output = apply_filters(
'gravitview_no_entries_text',
$output, $is_search );
381 $output = apply_filters(
'gravityview/template/text/no_entries',
$output, $is_search, $context, $unformatted_output );
402 if ( empty( $post_id ) ) {
404 if ( defined(
'DOING_AJAX' ) && DOING_AJAX ) {
407 if ( $context instanceof \
GV\Template_Context ) {
409 if ( is_a( $post,
'WP_Post' ) ) {
410 $post_id = $post->ID;
414 $post_id = $context->view ? $context->view->ID :
false;
418 if ( ! class_exists(
'GravityView_View' ) ) {
419 gravityview()->plugin->include_legacy_frontend(
true );
435 $post_id = $post->ID;
448 if ( empty( $post_id ) ) {
452 static $directory_links = array();
459 if ( isset( $directory_links[
'gv_directory_link_' . $post_id ] ) ) {
460 $link = $directory_links[
'gv_directory_link_' . $post_id ];
463 if ( (
int) $post_id === (
int) get_option(
'page_on_front' ) ) {
467 if ( empty(
$link ) ) {
468 $link = get_permalink( $post_id );
470 $directory_links[
'gv_directory_link_' . $post_id ] =
$link;
478 if( $pagenum = \
GV\Utils::_GET(
'pagenum' ) ) {
479 $args[
'pagenum'] = intval( $pagenum );
482 if( $sort = \
GV\Utils::_GET(
'sort' ) ) {
483 $args[
'sort'] = $sort;
496 $link = apply_filters(
'gravityview_directory_link',
$link, $post_id );
504 return apply_filters(
'gravityview/view/links/directory',
$link, $context );
521 $slug = substr( wp_hash( $id,
'gravityview'.$id ), 0, 8 );
529 $slug = apply_filters(
'gravityview_entry_slug', $slug, $id,
$entry );
532 if( empty( $slug ) ) {
536 return sanitize_title( $slug );
555 $slug = $id_or_string;
561 $custom = apply_filters(
'gravityview_custom_entry_slug',
false );
567 $hash = self::get_custom_entry_slug( $id_or_string,
$entry );
570 static $cache = array();
572 if ( ! isset( $cache[ $id_or_string ] ) ) {
575 if ( version_compare( GFFormsModel::get_database_version(),
'2.3-dev-1',
'>=' ) ) {
576 $table = GFFormsModel::get_entry_meta_table_name();
577 $column =
'entry_id';
579 $table = RGFormsModel::get_lead_meta_table_name();
583 $results = $wpdb->get_results( $wpdb->prepare(
"SELECT $column, meta_value FROM $table WHERE form_id = (SELECT form_id FROM $table WHERE $column = %d LIMIT 1) AND meta_key = 'gravityview_unique_id'", $id_or_string ) );
586 $cache = array_replace( $cache, array_combine( wp_list_pluck( $results, $column ), wp_list_pluck( $results,
'meta_value' ) ) );
589 if ( ! isset( $cache[ $id_or_string ] ) ) {
590 $cache[ $id_or_string ] =
false;
594 $value = $cache[ $id_or_string ];
600 gravityview()->log->debug(
'Setting hash for entry {entry}: {hash}', array(
'entry' => $id_or_string,
'hash' => $hash ) );
601 gform_update_meta( $id_or_string,
'gravityview_unique_id', $hash, \
GV\Utils::get(
$entry,
'form_id' ) );
609 return sanitize_title( $slug );
625 $custom = apply_filters(
'gravityview_custom_entry_slug',
false );
630 $hash = self::get_custom_entry_slug(
$entry[
'id'],
$entry );
632 gravityview()->log->debug(
'Setting hash for entry {entry_id}: {hash}', array(
'entry_id' =>
$entry[
'id'],
'hash' => $hash ) );
634 gform_update_meta(
$entry[
'id'],
'gravityview_unique_id', $hash, \
GV\Utils::get(
$entry,
'form_id' ) );
660 }
else if( empty(
$entry ) ) {
666 if ( ! is_numeric( $post_id ) ) {
671 $directory_link = self::directory_link( $post_id,
false );
674 if ( empty( $directory_link ) ) {
680 if ( ! empty(
$entry[
'_multi'] ) ) {
681 $entry_slugs = array();
683 foreach (
$entry[
'_multi'] as $_multi ) {
685 if( $gv_multi = \
GV\GF_Entry::from_entry( $_multi ) ) {
686 $entry_slugs[] = $gv_multi->get_slug();
694 $forms[] = $_multi[
'form_id'];
701 if( $gv_entry = \
GV\GF_Entry::from_entry(
$entry ) ) {
718 $add_query_args = apply_filters(
'gravityview/entry_link/add_query_args',
true );
724 if ( get_option(
'permalink_structure') && ! is_preview() ) {
730 $link_parts = explode(
'?', $directory_link );
732 $query = !empty( $link_parts[1] ) ?
'?'.$link_parts[1] :
'';
734 $directory_link = trailingslashit( $link_parts[0] ) . $query_arg_name .
'/'.
$entry_slug .
'/' . $query;
744 if ( $add_directory_args ) {
746 if ( ! empty( $_GET[
'pagenum'] ) ) {
747 $args[
'pagenum'] = intval( $_GET[
'pagenum'] );
753 if ( $sort = \
GV\Utils::_GET(
'sort' ) ) {
754 $args[
'sort'] = $sort;
761 $passed_post = get_post( $post_id );
763 $has_multiple_views = $views->count() > 1;
768 if ( $has_multiple_views ) {
772 return add_query_arg(
$args, $directory_link );
795 $passed_get = isset( $_GET ) ? $_GET : array();
797 $passed_get = stripslashes_deep( $passed_get );
798 $passed_get = urldecode_deep( $passed_get );
800 if ( empty( $passed_get ) ) {
804 $query_args = $passed_get;
806 $reserved_args = array(
821 $reserved_args = apply_filters(
'gravityview/api/reserved_query_args', $reserved_args );
823 foreach ( $reserved_args as $reserved_arg ) {
824 unset( $query_args[ $reserved_arg ] );
858 if ( $context instanceof \
GV\Template_Context ) {
859 $hide_until_searched =
false;
862 if ( $context->view ) {
864 if( $context->view->settings->get(
'hide_until_searched' ) ) {
865 $hide_until_searched = ( empty( $context->entry ) && ! $context->request->is_search() );
868 if ( $context->entries ) {
869 $total_entries = $context->entries->total();
870 }
else if ( $context->entry ) {
880 $passed_css_class = trim( $passed_css_class );
882 $default_css_class = ! empty(
$view_id ) ? sprintf(
'gv-container gv-container-%d',
$view_id ) :
'gv-container';
884 if ( $hide_until_searched ) {
885 $default_css_class .=
' hidden';
888 if ( 0 === $total_entries ) {
889 $default_css_class .=
' gv-container-no-results';
892 if ( $context instanceof \
GV\Template_Context && $context->view ) {
893 $default_css_class .=
' ' . $context->view->settings->get(
'class',
'' );
896 $css_class = trim( $passed_css_class .
' '. $default_css_class );
905 $css_class = apply_filters(
'gravityview/render/container/class', $css_class, $context );
907 $css_class = gravityview_sanitize_html_class( $css_class );
928 $value = apply_filters(
'gravityview_empty_value',
'' );
964 $href = apply_filters(
'gravityview_go_back_url',
$href );
973 $href = apply_filters(
'gravityview/template/links/back/url',
$href, $context );
975 if ( empty(
$href ) ) {
979 if ( $context instanceof \
GV\Template_Context ) {
981 $view_label = $context->template->get_back_label();
990 $label = $view_label ? $view_label : __(
'← Go back',
'gk-gravityview' );
998 $label = apply_filters(
'gravityview_go_back_label',
$label );
1007 $label = apply_filters(
'gravityview/template/links/back/label',
$label, $context );
1015 $atts = apply_filters(
'gravityview/template/links/back/atts', array(
'data-viewid' =>
$view_id ), $context );
1064 if ( is_array(
$value ) ) {
1065 $terms = array_filter( array_values(
$value ),
'strlen' );
1067 $terms = explode(
', ',
$value );
1070 foreach ($terms as $term_name ) {
1073 if( $taxonomy ===
'category' ) {
1076 list( $term_name, $term_id ) = rgexplode(
':', $term_name, 2 );
1079 if( !empty( $term_id )) {
1080 $term = get_term_by(
'id', $term_id, $taxonomy );
1083 $term = get_term_by(
'name', $term_name, $taxonomy );
1088 $term = get_term_by(
'name', $term_name, $taxonomy );
1094 $term_link = get_term_link( $term, $taxonomy );
1097 if ( is_wp_error( $term_link ) ) {
1105 return implode(
', ',
$output );
1117 $output = get_the_term_list( $post_id, $taxonomy, NULL,
', ' );
1119 if( empty(
$link ) ) {
1139 if( ! $fe->getGvOutputData() ) {
1141 gravityview()->log->debug(
'gv_output_data not defined; parsing content.' );
1143 $fe->parse_content();
1147 if( !is_a( $fe->getGvOutputData(),
'GravityView_View_Data' ) ) {
1149 gravityview()->log->debug(
'gv_output_data not an object or get_view not callable.', array(
'data' => $fe->getGvOutputData() ) );
1154 return $fe->getGvOutputData()->get_views();
1178 $view_id = $fe->get_context_view_id();
1181 if ( ! $fe->getGvOutputData() ) {
return array(); }
1183 return $fe->getGvOutputData()->get_view(
$view_id );
1192 if ( count(
$args = func_get_args() ) ) {
1193 $gravityview = reset(
$args );
1194 if ( $gravityview instanceof \
GV\Template_Context ) {
1199 do_action(
'gravityview/template/before', $gravityview );
1204 return do_action(
'gravityview_before', $gravityview->view->ID );
1221 if ( count(
$args = func_get_args() ) ) {
1222 $gravityview = reset(
$args );
1223 if ( $gravityview instanceof \
GV\Template_Context ) {
1228 do_action(
'gravityview/template/header', $gravityview );
1233 return do_action(
'gravityview_header', $gravityview->view->ID );
1250 if ( count(
$args = func_get_args() ) ) {
1251 $gravityview = reset(
$args );
1252 if ( $gravityview instanceof \
GV\Template_Context ) {
1257 do_action(
'gravityview/template/footer', $gravityview );
1262 return do_action(
'gravityview_footer', $gravityview->view->ID );
1275 if ( count(
$args = func_get_args() ) ) {
1276 $gravityview = reset(
$args );
1277 if ( $gravityview instanceof \
GV\Template_Context ) {
1282 do_action(
'gravityview/template/after', $gravityview );
1287 do_action(
'gravityview_after', $gravityview->view->ID );
1310 if ( ! class_exists(
'GravityView_View' ) ) {
1333 if ( isset( $wp_query ) && $wp_query->post_count > 1 ) {
1342 $is_edit_entry = apply_filters(
'gravityview_is_edit_entry',
false );
1344 if ( $is_edit_entry ) {
1346 }
else if (
gravityview()->request->is_entry() ) {
1348 }
else if (
gravityview()->request->is_view(
false ) ) {
1378 if( !class_exists(
'GravityView_Field' ) ) {
1379 include_once(
GRAVITYVIEW_DIR .
'includes/fields/class-gravityview-field.php' );
1382 if( !class_exists(
'GravityView_Field_FileUpload' ) ) {
1383 include_once(
GRAVITYVIEW_DIR .
'includes/fields/class-gravityview-field-fileupload.php' );
1386 if ( is_null( $context ) ) {
1387 _doing_it_wrong( __FUNCTION__,
'2.0',
'Please pass an \GV\Template_Context object as the 3rd parameter' );
1407 $address_qs = str_replace( array(
'<br />',
"\n" ),
' ', $address );
1408 $address_qs = urlencode( $address_qs );
1410 $url =
"https://maps.google.com/maps?q={$address_qs}";
1412 $link_text = esc_html__(
'Map It',
'gk-gravityview' );
1414 $atts = array_merge(
1416 'class' =>
'map-it-link' 1429 $link = apply_filters(
'gravityview_map_link',
$link, $address,
$url );
1457 'hide_empty' =>
true,
1458 'markup' =>
'<div id="{{ field_id }}" class="{{ class }}">{{ label }}{{ value }}</div>',
1459 'label_markup' =>
'',
1464 $args = wp_parse_args( $passed_args, $defaults );
1475 $args = apply_filters(
'gravityview/field_output/args',
$args, $passed_args, $context );
1484 $context = apply_filters(
'gravityview/template/field_output/context', $context,
$args, $passed_args );
1486 if ( $context instanceof \
GV\Template_Context ) {
1487 if ( ! $context->field || ! $context->view || ! $context->view->form ) {
1488 gravityview()->log->error(
'Field or form are empty.', array(
'data' => array( $context->field, $context->view->form ) ) );
1494 if ( empty(
$args[
'field'] ) || empty(
$args[
'form'] ) ) {
1495 gravityview()->log->error(
'Field or form are empty.', array(
'data' =>
$args ) );
1500 if ( $context instanceof \
GV\Template_Context ) {
1501 $entry =
$args[
'entry'] ? : ( $context->entry ? $context->entry->as_entry() : array() );
1502 $field =
$args[
'field'] ? : ( $context->field ? $context->field->as_configuration() : array() );
1503 $form =
$args[
'form'] ? : ( $context->view->form ? $context->view->form->form : array() );
1515 $placeholders = array(
1518 'width:style' =>
'',
1520 'label_value' =>
'',
1521 'label_value:esc_attr' =>
'',
1522 'label_value:data-label' =>
'',
1527 if ( $context instanceof \
GV\Template_Context ) {
1535 if ( $placeholders[
'value'] ===
'' && ! empty(
$args[
'hide_empty'] ) ) {
1539 if ( $placeholders[
'value'] !==
'' && ! empty(
$args[
'wpautop'] ) ) {
1540 $placeholders[
'value'] = wpautop( $placeholders[
'value'] );
1553 if ( $context instanceof \
GV\Template_Context ) {
1560 $placeholders[
'label_value:data-label'] = trim( esc_attr( strip_tags( str_replace(
'> ',
'>', $placeholders[
'label_value'] ) ) ) );
1561 $placeholders[
'label_value:esc_attr'] = esc_attr( $placeholders[
'label_value'] );
1563 if ( empty( $placeholders[
'label'] ) && ! empty( $placeholders[
'label_value'] ) ){
1564 $placeholders[
'label'] =
'<span class="gv-field-label">{{ label_value }}</span>';
1575 $html = apply_filters(
'gravityview/field_output/pre_html',
$args[
'markup'],
$args, $context );
1584 $open_tag = apply_filters(
'gravityview/field_output/open_tag',
'{{',
$args, $context );
1593 $close_tag = apply_filters(
'gravityview/field_output/close_tag',
'}}',
$args, $context );
1599 foreach ( $placeholders as $tag =>
$value ) {
1602 if (
false === strpos( $html, $open_tag . $tag . $close_tag ) &&
false === strpos( $html, $open_tag .
' ' . $tag .
' ' . $close_tag ) ){
1608 $open_tag . $tag . $close_tag,
1609 $open_tag .
' ' . $tag .
' ' . $close_tag,
1620 $value = apply_filters(
'gravityview/field_output/context/' . $tag,
$value,
$args, $context );
1623 $html = str_replace( $search, (
string)
$value, $html );
1633 $html = apply_filters(
'gravityview_field_output', $html,
$args, $context );
1642 $html = apply_filters(
'gravityview/field_output/html', $html,
$args, $context );
1645 $html = str_replace( array(
' style=""',
' class=""',
' id=""' ),
'', $html );
gravityview_get_view_id()
Get the current View ID being rendered.
const GRAVITYVIEW_DIR
"GRAVITYVIEW_DIR" "./" The absolute path to the plugin directory, with trailing slash ...
gv_value( $entry, $field)
gv_no_results( $wpautop=true, $context=null)
static no_results( $wpautop=true, $context=null)
Get the "No Results" text depending on whether there were results.
if(!GravityView_Delete_Entry::check_user_cap_delete_entry( $entry, $field_settings)) $link_text
static _GET( $name, $default=null)
Grab a value from the _GET superglobal or default.
gravityview_get_field_value( $entry, $field_id, $display_value)
Handle getting values for complex Gravity Forms fields.
static getInstance( $passed_post=NULL)
gravityview_get_files_array( $value, $gv_class='', $context=null)
Return an array of files prepared for output.
gv_directory_link( $post=NULL, $add_pagination=true, $context=null)
gravityview_get_the_term_list( $post_id, $link=true, $taxonomy='post_tag')
Get the links for post_tags and post_category output based on post ID.
static getInstance( $passed_post=NULL)
$gravityview_view
array $entry array $form array $field_settings
if(gv_empty( $field['value'], false, false)) $format
gravityview_get_map_link( $address, $atts=array())
Generate a mapping link from an address.
gravityview_get_current_view_data( $view_id=0)
Get data for a specific view.
$field_settings['content']
gravityview_get_link( $href='', $anchor_text='', $atts=array())
Generate an HTML anchor tag with a list of supported attributes.
if( $add_query_args) $link
static from_post(\WP_Post $post)
Get a list of objects inside the supplied .
GravityView_API_field_value( $entry, $field_settings, $format)
The old function does a bit too much, not only does it retrieve the value for a field, but it also renders some output.
static get_custom_entry_slug( $id, $entry=array())
Calculate an unique hash for an entry based on the entry ID.
if(gravityview() ->plugin->is_GF_25()) $form
static entry_create_custom_slug( $entry, $form)
If using the entry custom slug feature, make sure the new entries have the custom slug created and sa...
gravityview_back_link( $context=null)
Generate HTML for the back link from single entry view.
static directory_link( $post_id=NULL, $add_query_args=true, $context=null)
Generate a URL to the Directory context.
gv_container_class( $passed_css_class='', $echo=true, $context=null)
Generate a CSS class to be added to the wrapper of a View.
static get_endpoint_name()
Return the endpoint name for a single Entry.
static get_files_array( $value, $gv_class, $context=null)
Return an array of files prepared for output.
static field_html_attr_id( $field, $form=array(), $entry=array())
Fetch Field HTML ID.
static entry_link_html( $entry=array(), $anchor_text='', $passed_tag_atts=array(), $field_settings=array(), $base_id=null)
Generate an anchor tag that links to an entry.
static field_value( $entry, $field_settings, $format='html')
Given an entry and a form field id, calculate the entry value for that field.
gravityview_convert_value_to_term_list( $value, $taxonomy='post_tag')
Take a passed CSV of terms and generate a linked list of terms.
static field_width( $field, $format='%d%%')
Get column width from the field setting.
gv_label( $field, $entry=NULL)
static replace_variables( $text, $form=array(), $entry=array(), $url_encode=false, $esc_html=true, $nl2br=true, $format='html', $aux_data=array())
Alias for GravityView_Merge_Tags::replace_variables()
gv_class( $field, $form=NULL, $entry=array())
if(empty( $created_by)) $form_id
GravityView_API_field_label( $form, $field_settings, $entry, $force_show_label=false)
Mock out the ::field_label method.
static get_entry_slug( $id_or_string, $entry=array())
Get the entry slug for the entry.
static get( $array, $key, $default=null)
Grab a value from an array or an object or default.
gravityview()
The main GravityView wrapper function.
gv_entry_link( $entry, $post_id=NULL)
gv_get_query_args()
Returns query parameters from $_GET with reserved internal GravityView keys removed.
gravityview_get_context()
Returns the current GravityView context, or empty string if not GravityView.
static field_class( $field, $form=NULL, $entry=NULL)
Fetch Field class.
static get_entry( $entry_slug, $force_allow_ids=false, $check_entry_display=true, $view=null)
Return a single entry object.
gravityview_field_output( $passed_args, $context=null)
Output field based on a certain html markup.
if(false !==strpos( $value, '00:00')) $field_id
string $field_id ID of the field being displayed
static entry_link( $entry, $post_id=NULL, $add_directory_args=true, $view_id=0)
return href for single entry
static _POST( $name, $default=null)
Grab a value from the _POST superglobal or default.
static field_label( $field, $entry=array(), $force_show_label=false)
Fetch Field Label.
static getInstance()
Get the one true instantiated self.
gravityview_get_current_views()
Get all views processed so far for the current page load.