GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
field-textarea-html.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The default textarea 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 $entry = $gravityview->entry->as_entry();
16 $field_settings = $gravityview->field->as_configuration();
17 
18 /**
19  * @filter `gravityview/fields/textarea/allow_html` Allow the following HTML tags and strip everything else.
20  * @since 2.8
21  * @param bool $allow_html Whether to allow rendering HTML submitted in the textarea field. If disabled, output will be escaped with esc_html(). Default: true.
22  * @param \GV\Template_Context $gravityview The context
23  */
24 $allow_html = apply_filters( 'gravityview/fields/textarea/allow_html', \GV\Utils::get( $field_settings, 'allow_html', true ), $gravityview );
25 
26 if( $allow_html ) {
27 
28  /**
29  * @filter `gravityview/fields/textarea/allowed_kses` Allow the following HTML tags and strip everything else.
30  * @since 1.21.5.1
31  * @since 2.0
32  * @see wp_kses_allowed_html() For allowed contexts
33  * @see $allowedposttags global in kses.php for an example of the format for passing an array of allowed tags and atts
34  *
35  * @param array|string $allowed_html Context string (allowed strings are post, strip, data, entities, or the name of a field filter such as pre_user_description) or allowed tags array (see above). [Default: 'post']
36  * @param \GV\Template_Context $gravityview The context
37  */
38  $allowed_html = apply_filters( 'gravityview/fields/textarea/allowed_kses', 'post', $gravityview );
39 
40  $value = wp_kses( $value, $allowed_html );
41 
42 } else {
43  $value = esc_html( $value );
44 }
45 
46 if ( ! empty( $field_settings['trim_words'] ) ) {
47 
48  /**
49  * @filter `gravityview_excerpt_more` Modify the "Read more" link used when "Maximum Words" setting is enabled and the output is truncated
50  * @since 1.16.1
51  * @param string $excerpt_more Default: ` ...`
52  */
53  $excerpt_more = apply_filters( 'gravityview_excerpt_more', ' ' . '&hellip;' );
54 
55  global $post;
56 
57  $entry_link = GravityView_API::entry_link_html( $entry, $excerpt_more, array(), $field_settings, $post ? $post->ID : $gravityview->view->ID );
58  $value = wp_trim_words( $value, $field_settings['trim_words'], $entry_link );
59  unset( $entry_link, $excerpt_more );
60 }
61 
62 if ( ! empty( $field_settings['make_clickable'] ) ) {
63  $value = make_clickable( $value );
64 }
65 
66 if ( ! empty( $field_settings['new_window'] ) ) {
67  $value = links_add_target( $value );
68 }
69 
70 echo wpautop( $value );
global $post
Definition: delete-entry.php:7
static entry_link_html( $entry=array(), $anchor_text='', $passed_tag_atts=array(), $field_settings=array(), $base_id=null)
Generate an anchor tag that links to an entry.
Definition: class-api.php:259
$allowed_html
Definition: textarea.php:27
gravityview()
The main GravityView wrapper function.
if(! isset( $gravityview)||empty( $gravityview->template)) $value
The default textarea field output template.