GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
field-website-html.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The default website 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 $value = $gravityview->value;
15 $form = $gravityview->view->form->form;
16 $entry = $gravityview->entry->as_entry();
17 $field_settings = $gravityview->field->as_configuration();
18 
19 if ( ! empty( $value ) && function_exists( 'gravityview_format_link' ) ) {
20 
21  $value = esc_url_raw( $value );
22 
23  /** @since 1.8 */
24  $anchor_text = ! empty( $field_settings['anchor_text'] ) ? trim( rtrim( \GV\Utils::get( $field_settings, 'anchor_text', '' ) ) ) : false;
25 
26  // Check empty again, just in case trim removed whitespace didn't work
27  if ( ! empty( $anchor_text ) ) {
28 
29  // Replace the variables
30  $anchor_text = GravityView_API::replace_variables( $anchor_text, $form, $entry );
31 
32  } else {
33  $anchor_text = empty( $field_settings['truncatelink'] ) ? $value : gravityview_format_link( $value );
34  }
35 
36  $attributes = '';
37 
38  if ( empty( $field_settings['open_same_window'] ) && ! empty( $field_settings['new_window'] ) ) {
39  $attributes = 'target=_blank';
40  }
41 
42  echo gravityview_get_link( $value, $anchor_text, $attributes );
43 } else {
44  echo esc_html( esc_url_raw( $value ) );
45 }
if(! isset( $gravityview)||empty( $gravityview->template)) $value
The default website field output template.
gravityview_get_link( $href='', $anchor_text='', $atts=array())
Generate an HTML anchor tag with a list of supported attributes.
gravityview_format_link( $value=null)
Convert a whole link into a shorter link for display.
$field_settings
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()
Definition: class-api.php:118
gravityview()
The main GravityView wrapper function.