GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
field-entry_link-html.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The default entry link 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 /** @var \GV\GF_Form $gf_form */
15 $gf_form = isset( $gravityview->field->form_id ) ? \GV\GF_Form::by_id( $gravityview->field->form_id ) : $gravityview->view->form->form;
16 $form = ! empty( $gf_form->form ) ? $gf_form->form : $gf_form;
17 
18 if ( $gravityview->entry->is_multi() ) {
19  $entry = $gravityview->entry[ $form['id'] ];
20  $entry = $entry->as_entry();
21 } else {
22  $entry = $gravityview->entry->as_entry();
23 }
24 
25 $field_settings = $gravityview->field->as_configuration();
26 
27 $link_text = empty( $field_settings['entry_link_text'] ) ? esc_html__( 'View Details', 'gk-gravityview' ) : $field_settings['entry_link_text'];
28 
29 $output = apply_filters( 'gravityview_entry_link', GravityView_API::replace_variables( $link_text, $form, $entry ), $gravityview );
30 
31 $tag_atts = array();
32 
33 if ( ! empty( $field_settings['new_window'] ) ) {
34  $tag_atts['target'] = '_blank';
35 }
36 
37 global $post;
38 
39 $href = $gravityview->entry->get_permalink( $gravityview->view, $gravityview->request, $tag_atts );
40 
41 /**
42  * @filter `gravityview/entry_link/add_query_args` Modify whether to include passed $_GET parameters to the end of the url
43  * @since 2.10
44  * @param bool $add_query_params Whether to include passed $_GET parameters to the end of the Entry Link URL. Default: true.
45  */
46 $add_query_args = apply_filters( 'gravityview/entry_link/add_query_args', true );
47 
48 if ( $add_query_args ) {
49  $href = add_query_arg( gv_get_query_args(), $href );
50 }
51 
53 
54 /**
55  * @filter `gravityview_field_entry_link` Modify the link HTML (here for backward compatibility)
56  * @param string $link HTML output of the link
57  * @param string $href URL of the link
58  * @param array $entry The GF entry array
59  * @param array $field_settings Settings for the particular GV field
60  */
61 $output = apply_filters( 'gravityview_field_entry_link', $link, $href, $entry, $field_settings );
62 
63 echo $output;
$output
$link_text
$gf_form
$add_query_args
$href
if(! empty( $field_settings['new_window'])) global $post
$form
gravityview_get_link( $href='', $anchor_text='', $atts=array())
Generate an HTML anchor tag with a list of supported attributes.
if( $add_query_args) $link
$tag_atts
$field_settings
static by_id( $form_id)
Construct a instance by ID.
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.
gv_get_query_args()
Returns query parameters from $_GET with reserved internal GravityView keys removed.
Definition: class-api.php:793
$entry
Definition: notes.php:27