GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
field-address-html.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The default address field output template.
4  *
5  * @global \GV\Template_Context $gravityview
6  * @since 2.0
7  */
8 
9 if ( ! isset( $gravityview ) || empty( $gravityview->template ) ) {
10  gravityview()->log->error( '{file} template loaded without context', array( 'file' => __FILE__ ) );
11  return;
12 }
13 
14 $field_id = $gravityview->field->ID;
15 $field = $gravityview->field->field;
16 $value = $gravityview->value;
17 $display_value = $gravityview->display_value;
18 $entry = $gravityview->entry->as_entry();
19 $field_settings = $gravityview->field->as_configuration();
20 $is_single_input = floor( $field_id ) !== floatval( $field_id );
21 
22 // If it's the full address
23 if ( ! $is_single_input ) {
24 
25  /**
26  * Make sure we're only showing enabled inputs.
27  */
28  foreach ( $field->inputs as $input ) {
29  if ( ! empty( $input['isHidden'] ) ) {
30  unset( $value["{$input['id']}"] );
31  }
32  }
33 
34  /**
35  * Disable internal Gravity Forms map link.
36  * Use our own legacy code and filter.
37  */
38  add_filter( 'gform_disable_address_map_link', '__return_true' );
39 
40  /**
41  * Use Gravity Forms' method to get the full address.
42  */
43  $value_with_newline = GFCommon::get_lead_field_display( $field, $value, "", false, 'html' );
44 
45  remove_filter( 'gform_disable_address_map_link', '__return_true' );
46 
47  if ( empty( $value_with_newline ) ) { return; }
48 
49  /**
50  * Add map link if it's not set (default, back compat) or if it's set to yes
51  */
52  if ( $gravityview->field->show_map_link ) {
53  $atts = array();
54 
55  if ( $gravityview->field->show_map_link_new_window ) {
56  $atts['target'] = '_blank';
57  }
58 
59  /** Add the map link as another line. */
60  $value_with_newline = "$value_with_newline\n" . gravityview_get_map_link( $value_with_newline, $atts );
61  }
62 
63  echo str_replace( "\n", '<br />', $value_with_newline );
64 
65 } else {
67 }
gravityview_get_field_value( $entry, $field_id, $display_value)
Handle getting values for complex Gravity Forms fields.
Definition: class-api.php:1034
gravityview_get_map_link( $address, $atts=array())
Generate a mapping link from an address.
Definition: class-api.php:1406
if(! isset( $gravityview)||empty( $gravityview->template)) $field_id
The default address field output template.
$field_settings
$display_value
gravityview()
The main GravityView wrapper function.
$is_single_input