GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
field-custom.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The default custom content 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;
16 $form = $gf_form->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 // Make sure the class is loaded in DataTables
26 if ( ! class_exists( 'GFFormDisplay' ) ) {
27  include_once GFCommon::get_base_path() . '/form_display.php';
28 }
29 
30 /**
31  * @filter `gravityview/fields/custom/entry` Modify entry being displayed
32  *
33  * @param array $entry The current entry being displayed.
34  * @param array $form The current form the custom content is using.
35  * @param \GV\Template_Context The GravityView template context instance.
36  */
37 $entry = apply_filters( 'gravityview/fields/custom/entry', $entry, $form, $gravityview );
38 
39 /**
40  * @filter `gravityview/fields/custom/form` Modify form that content is being pulled from
41  *
42  * @param array $form The current form the custom content is using.
43  * @param array $entry The current entry being displayed.
44  * @param \GV\Template_Context The GravityView template context instance.
45  */
46 $form = apply_filters( 'gravityview/fields/custom/form', $form, $entry, $gravityview );
47 
48 /**
49  * @filter `gravityview/fields/custom/content_before` Modify Custom Content field output before Merge Tag processing
50  * @since 1.6.2
51  * @param string $content HTML content of field
52  *
53  * @since 2.0
54  * @param \GV\Template_Context The gravityview template context instance.
55  * @since 2.0
56  * @param stdClass The gravityview template context object.
57  */
58 $content = apply_filters( 'gravityview/fields/custom/content_before', $gravityview->field->content, $gravityview );
59 $content = trim( rtrim( (string) $content ) );
60 
61 // No custom content
62 if ( empty( $content ) ) {
63  return;
64 }
65 
66 // Replace the variables
68 
69 /**
70  * @filter `gravityview/fields/custom/decode_shortcodes` Decode brackets in shortcodes, rendering them inert (escape brackets).
71  * @since 1.16.5
72  * @param boolean $decode Enable/Disable decoding of brackets in the content (default: false)
73  * @param string $content HTML content of field
74  *
75  * @since 2.0
76  * @param \GV\Template_Context The gravityview template context instance.
77  */
78 if ( apply_filters( 'gravityview/fields/custom/decode_shortcodes', false, $content, $gravityview ) ) {
80 }
81 
82 // oEmbed?
83 if ( ! empty( $gravityview->field->oembed ) ) {
84  $content = $GLOBALS['wp_embed']->autoembed( $content );
85 }
86 
87 // Add paragraphs?
88 if ( ! empty( $gravityview->field->wpautop ) ) {
89  $content = wpautop( $content );
90 }
91 
92 /**
93  * @filter `gravityview/fields/custom/content_after` Modify Custom Content field output after Merge Tag variables get replaced, before shortcodes get processed
94  * @since 1.6.2
95  * @param string $content HTML content of field
96  *
97  * @since 2.0
98  * @param \GV\Template_Context The gravityview template context instance.
99  */
100 $content = apply_filters( 'gravityview/fields/custom/content_after', $content, $gravityview );
101 
102 // Enqueue scripts needed for Gravity Form display, if form shortcode exists.
103 // Also runs `do_shortcode()`
104 echo GFCommon::gform_do_shortcode( $content );
static decode_shortcodes( $string)
Inspired on ::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortc...
$form
$gf_form
if(! class_exists( 'GFFormDisplay')) $entry
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.
$content