GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
field-email-html.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The default email 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 there's no email, don't bother continuing.
20 if ( empty( $value ) ) {
21 return;
22 }
23 
24 // Default: plain email, no link
26 
27 if ( ! isset( $field_settings['emailmailto'] ) || ! empty( $field_settings['emailmailto'] ) ) {
28 
29 $params = array();
30 
31 // The default link is a mailto link
32 $link = 'mailto:'.$value;
33 
34 // Is the subject set?
35 if ( ! empty( $field_settings['emailsubject'] ) ) {
36 
37  $subject = GravityView_API::replace_variables( $field_settings['emailsubject'], $form, $entry );
38 
39  $subject = wp_strip_all_tags( trim( do_shortcode( $subject ) ) );
40 
41  $params[] = 'subject='.str_replace( '+', '%20', urlencode( $subject ) );
42 }
43 
44 // Is the body set?
45 if ( !empty( $field_settings['emailbody'] ) ) {
46 
48 
49  $body = wp_strip_all_tags( trim( do_shortcode( $body ) ) );
50 
51  $params[] = 'body='.str_replace( '+', '%20', urlencode( $body ) );
52 }
53 
54 // If the subject and body have been set, use them
55 if ( !empty( $params) ) {
56  $link .= '?'.implode( '&', $params );
57 }
58 
59 // Generate the link HTML
61 
62 }
63 
64 /**
65 * Prevent encrypting emails no matter what - this is handy for DataTables exports, for example
66 * @since 1.1.6
67 *
68 * @since 2.0
69 * @param \GV\Template_Context The $gravityview template context object.
70 *
71 * @var boolean
72 */
73 $prevent_encrypt = apply_filters( 'gravityview_email_prevent_encrypt', false, $gravityview );
74 
75 // If encrypting the link
76 if ( ! empty( $field_settings['emailencrypt'] ) && ! $prevent_encrypt ) {
78 }
79 
80 echo $output;
static js_encrypt( $content, $message='')
Encrypt content using Javascript so that it&#39;s hidden when JS is disabled.
$field_settings
gravityview_get_link( $href='', $anchor_text='', $atts=array())
Generate an HTML anchor tag with a list of supported attributes.
if( $add_query_args) $link
if(! isset( $gravityview)||empty( $gravityview->template)) $value
The default email field output template.
$prevent_encrypt
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
if(empty( $value)) $output
gravityview()
The main GravityView wrapper function.