body-default.php
1 year ago
default.php
2 years ago
email-preview.php
1 year ago
field-default.php
2 years ago
footer-default.php
2 years ago
header-default.php
2 years ago
email-preview.php
155 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Everest Form email preview template. |
| 4 | * |
| 5 | * @since 2.0.5 |
| 6 | * |
| 7 | * @package Everest form email preview template. |
| 8 | */ |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | ?> |
| 12 | <!DOCTYPE html> |
| 13 | <html <?php language_attributes(); ?> style="background-color: #E9EAEC;"> |
| 14 | <head> |
| 15 | <meta name="viewport" content="width=device-width"/> |
| 16 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> |
| 17 | <title> |
| 18 | <?php get_bloginfo( 'name' ); ?> |
| 19 | </title> |
| 20 | </head> |
| 21 | <body <?php body_class(); ?> > |
| 22 | <?php |
| 23 | $connection_id = isset( $_GET['evf_email_preview'] ) ? $_GET['evf_email_preview'] : ''; |
| 24 | /** |
| 25 | * Get email message from the specific email connection |
| 26 | * |
| 27 | * @return array email preview message. |
| 28 | */ |
| 29 | function form_data() { |
| 30 | $form_data = array(); |
| 31 | |
| 32 | if ( ! empty( $_GET['form_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 33 | $connection_id = isset( $_GET['evf_email_preview'] ) ? $_GET['evf_email_preview'] : ''; |
| 34 | $form_data = evf()->form->get( absint( $_GET['form_id'] ), array( 'content_only' => true ) ); // phpcs:ignore WordPress.Security.NonceVerification |
| 35 | |
| 36 | if ( isset( $form_data['settings']['email'][ "$connection_id" ] ) && isset( $form_data['settings']['email'][ "$connection_id" ]['evf_email_message'] ) ) { |
| 37 | $email_preview_message = $form_data['settings']['email'][ "$connection_id" ]['evf_email_message']; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | return $form_data; |
| 42 | } |
| 43 | |
| 44 | |
| 45 | // Email data of the specific connection. |
| 46 | $email_form_data = form_data(); |
| 47 | |
| 48 | if ( isset( $email_form_data['settings']['email'] ) && isset( $email_form_data['settings']['email'][ $connection_id ] ) ) { |
| 49 | $email_content = $email_form_data['settings']['email'][ $connection_id ]['evf_email_message']; |
| 50 | $email_template_included = isset( $email_form_data['settings']['email'][ $connection_id ]['choose_template'] ) ? $email_form_data['settings']['email'][ $connection_id ]['choose_template'] : 0; |
| 51 | } |
| 52 | |
| 53 | // Initializing the EVF_Emails class to import the email template. |
| 54 | $evf_emails_obj = new EVF_Emails(); |
| 55 | $evf_emails_obj->form_data = $email_form_data; |
| 56 | |
| 57 | if ( empty( $email_content ) ) { |
| 58 | $email_content = esc_html__( '{all_fields}', 'everest-forms' ); |
| 59 | } |
| 60 | |
| 61 | $email_content = str_replace( '{all_fields}', evf_process_all_fields_smart_tag( $email_content ), $email_content ); |
| 62 | |
| 63 | // Email Template Enabled or not checked. |
| 64 | $email_template_included = ! empty( $email_form_data['settings']['email'][ $connection_id ]['choose_template'] ) ? $email_content : 0; |
| 65 | |
| 66 | if ( $email_template_included ) { |
| 67 | $email_content = apply_filters( 'everest_forms_email_template_message', $email_content, $evf_emails_obj, $connection_id ); |
| 68 | $allowed_tags = array( |
| 69 | 'p' => array( |
| 70 | 'style' => array(), |
| 71 | ), |
| 72 | 'table' => array( |
| 73 | 'border' => array(), |
| 74 | 'cellpadding' => array(), |
| 75 | 'cellspacing' => array(), |
| 76 | 'style' => array(), |
| 77 | ), |
| 78 | 'tr' => array( |
| 79 | 'style' => array(), |
| 80 | ), |
| 81 | 'td' => array( |
| 82 | 'style' => array(), |
| 83 | ), |
| 84 | 'img' => array( |
| 85 | 'src' => array(), |
| 86 | 'alt' => array(), |
| 87 | 'height' => array(), |
| 88 | 'width' => array(), |
| 89 | 'style' => array(), |
| 90 | ), |
| 91 | 'a' => array( |
| 92 | 'href' => array(), |
| 93 | 'title' => array(), |
| 94 | 'style' => array(), |
| 95 | ), |
| 96 | 'h1' => array( 'style' => array() ), |
| 97 | 'h2' => array( 'style' => array() ), |
| 98 | 'h3' => array( 'style' => array() ), |
| 99 | 'h4' => array( 'style' => array() ), |
| 100 | 'h5' => array( 'style' => array() ), |
| 101 | 'h6' => array( 'style' => array() ), |
| 102 | 'br' => array(), |
| 103 | 'strong' => array(), |
| 104 | 'em' => array(), |
| 105 | 'style' => array(), |
| 106 | ); |
| 107 | echo wp_kses( $email_content, $allowed_tags ); |
| 108 | } else { |
| 109 | $email_content = $evf_emails_obj->build_email( $email_content ); |
| 110 | $allowed_tags = array( |
| 111 | 'p' => array( |
| 112 | 'style' => array(), |
| 113 | ), |
| 114 | 'table' => array( |
| 115 | 'border' => array(), |
| 116 | 'cellpadding' => array(), |
| 117 | 'cellspacing' => array(), |
| 118 | 'style' => array(), |
| 119 | ), |
| 120 | 'tr' => array( |
| 121 | 'style' => array(), |
| 122 | ), |
| 123 | 'td' => array( |
| 124 | 'style' => array(), |
| 125 | ), |
| 126 | 'img' => array( |
| 127 | 'src' => array(), |
| 128 | 'alt' => array(), |
| 129 | 'height' => array(), |
| 130 | 'width' => array(), |
| 131 | 'style' => array(), |
| 132 | ), |
| 133 | 'a' => array( |
| 134 | 'href' => array(), |
| 135 | 'title' => array(), |
| 136 | 'style' => array(), |
| 137 | ), |
| 138 | 'h1' => array( 'style' => array() ), |
| 139 | 'h2' => array( 'style' => array() ), |
| 140 | 'h3' => array( 'style' => array() ), |
| 141 | 'h4' => array( 'style' => array() ), |
| 142 | 'h5' => array( 'style' => array() ), |
| 143 | 'h6' => array( 'style' => array() ), |
| 144 | 'br' => array(), |
| 145 | 'strong' => array(), |
| 146 | 'em' => array(), |
| 147 | 'style' => array(), |
| 148 | ); |
| 149 | echo wp_kses( $email_content, $allowed_tags ); |
| 150 | } |
| 151 | |
| 152 | ?> |
| 153 | </body> |
| 154 | </html> |
| 155 |