GravityView  2.10.1
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 if ( ! $gravityview->field->form_id || ! ( $form = GFAPI::get_form( $gravityview->field->form_id ) ) ) {
15  $form = $gravityview->view->form->form;
16 }
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', '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
$add_query_args
$href
if(! empty( $field_settings['new_window'])) global $post
gravityview_get_link( $href='', $anchor_text='', $atts=array())
Generate an HTML anchor tag with a list of supported attributes.
if( $add_query_args) $link
gravityview()
Definition: _stubs.php:26
if(gravityview() ->plugin->is_GF_25()) $form
$tag_atts
$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
gv_get_query_args()
Returns query parameters from $_GET with reserved internal GravityView keys removed.
Definition: class-api.php:781
$entry
Definition: notes.php:27