/**
  * Load the necessary assets for the confirmation message.
  *
  * @since 1.1.2
  */
 public function assets_confirmation()
 {
     // Base CSS only
     if (wpforms_setting('disable-css', '1') == '1') {
         wp_enqueue_style('wpforms-full', WPFORMS_PLUGIN_URL . 'assets/css/wpforms-full.css', array(), WPFORMS_VERSION);
     }
     // Special confirmation JS
     wp_enqueue_script('wpforms-confirmation', WPFORMS_PLUGIN_URL . 'assets/js/wpforms-confirmation.js', array('jquery'), WPFORMS_VERSION, true);
     do_action('wpforms_frontend_confirmation');
 }
Exemplo n.º 2
0
/**
 * Email Header
 *
 * @package    WPForms
 * @author     WPForms
 * @since      1.1.3
 * @license    GPL-2.0+
 * @copyright  Copyright (c) 2016, WPForms LLC
*/
// Exit if accessed directly
if (!defined('ABSPATH')) {
    exit;
}
$header_image = wpforms_setting('email-header-image', false);
$background_color = wpforms_setting('email-background-color', '#e9eaec');
$text_direction = is_rtl() ? 'rtl' : 'ltr';
?>
<!doctype html>
<html dir="<?php 
echo $text_direction;
?>
" xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
	<!--[if gte mso 15]>
	<xml>
		<o:OfficeDocumentSettings>
		<o:AllowPNG/>
		<o:PixelsPerInch>96</o:PixelsPerInch>
		</o:OfficeDocumentSettings>
	</xml>
 /**
  * Process the form entry.
  *
  * @since 1.0.0
  * @param array $form $_POST object
  */
 public function process($entry)
 {
     $this->errors = array();
     $this->fields = array();
     $form_id = absint($entry['id']);
     $form = wpforms()->form->get($form_id);
     $honeypot = false;
     // Validate form is real and active (published)
     if (!$form || 'publish' != $form->post_status) {
         $this->errors[$form_id]['header'] = __('Invalid form.', 'wpforms');
         return;
     }
     // Formatted form data for hooks
     $form_data = wpforms_decode($form->post_content);
     // Pre-process/validate hooks and filter. Data is not validated or
     // cleaned yet so use with caution.
     $entry = apply_filters('wpforms_process_before_filter', $entry, $form_data);
     do_action('wpforms_process_before', $entry, $form_data);
     do_action("wpforms_process_before_{$form_id}", $entry, $form_data);
     // Validate fields
     foreach ($form_data['fields'] as $field) {
         $field_id = $field['id'];
         $field_type = $field['type'];
         $field_submit = isset($entry['fields'][$field_id]) ? $entry['fields'][$field_id] : '';
         do_action("wpforms_process_validate_{$field_type}", $field_id, $field_submit, $form_data);
     }
     // reCAPTCHA check
     $site_key = wpforms_setting('recaptcha-site-key', '');
     $secret_key = wpforms_setting('recaptcha-secret-key', '');
     if (!empty($site_key) || !empty($secret_key)) {
         if (isset($form_data['settings']['recaptcha']) && '1' == $form_data['settings']['recaptcha']) {
             // We should have a reCAPTCHA so let's process
             $response = $_POST['g-recaptcha-response'];
             $secret = wpforms_setting('recaptcha-secret-key');
             $data = wp_remote_get('https://www.google.com/recaptcha/api/siteverify?secret=' . $secret . '&response=' . $response);
             $data = json_decode(wp_remote_retrieve_body($data));
             if (empty($data->success)) {
                 $this->errors[$form_id]['recaptcha'] = __('Incorrect reCAPTCHA, please try again.', 'wpforms');
             }
         }
     }
     // One last error check - don't proceed if there are any errors
     if (!empty($this->errors[$form_id])) {
         $this->errors[$form_id]['header'] = __('Form has not been submitted, please see the errors below.', 'wpforms');
         return;
     }
     // Validate honeypot
     if (!empty($form_data['settings']['honeypot']) && '1' == $form_data['settings']['honeypot']) {
         if (isset($entry['hp']) && !empty($entry['hp'])) {
             $honeypot = __('WPForms honeypot field triggered.', 'wpforms');
         }
     }
     $honeypot = apply_filters('wpforms_process_honeypot', $honeypot, $this->fields, $entry, $form_data);
     // Only trigger the processing (saving/sending entries, etc) if the entry
     // is not spam.
     if (!$honeypot) {
         // Pass the form created date into the form data
         $form_data['created'] = $form->post_date;
         // Format fields
         foreach ($form_data['fields'] as $field) {
             $field_id = $field['id'];
             $field_type = $field['type'];
             $field_submit = isset($entry['fields'][$field_id]) ? $entry['fields'][$field_id] : '';
             do_action("wpforms_process_format_{$field_type}", $field_id, $field_submit, $form_data);
         }
         // Process hooks/filter - this is where most add-ons should hook
         // because at this point we have completed all field validation and
         // formatted the data.
         $this->fields = apply_filters('wpforms_process_filter', $this->fields, $entry, $form_data);
         do_action('wpforms_process', $this->fields, $entry, $form_data);
         do_action("wpforms_process_{$form_id}", $this->fields, $entry, $form_data);
         $this->fields = apply_filters('wpforms_process_after_filter', $this->fields, $entry, $form_data);
         // One last error check - don't proceed if there are any errors
         if (!empty($this->errors[$form_id])) {
             if (empty($this->errors[$form_id]['header'])) {
                 $this->errors[$form_id]['header'] = __('Form has not been submitted, please see the errors below.', 'wpforms');
             }
             return;
         }
         // Success - add entry to database
         $entry_id = $this->entry_save($this->fields, $entry, $form_data['id'], $form_data);
         // Success - send email notification
         $this->entry_email($this->fields, $entry, $form_data, $entry_id);
         // Pass completed and formatted fields in POST
         $_POST['wpforms']['complete'] = $this->fields;
         // Pass entry ID in POST
         $_POST['wpforms']['entry_id'] = $entry_id;
         // Logs entry depending on log levels set
         wpforms_log('Entry', $this->fields, array('type' => array('entry'), 'parent' => $entry_id, 'form_id' => $form_data['id']));
         // Post-process hooks
         do_action('wpforms_process_complete', $this->fields, $entry, $form_data, $entry_id);
         do_action("wpforms_process_complete_{$form_id}", $this->fields, $entry, $form_data, $entry_id);
     } else {
         // Logs spam entry depending on log levels set
         wpforms_log('Spam Entry', array($honeypot, $entry), array('type' => array('spam'), 'form_id' => $form_data['id']));
     }
     $this->entry_confirmation_redirect($form_data);
 }
Exemplo n.º 4
0
 /**
  * Get the enabled email template
  *
  * @since 1.1.3
  * @return string|null
  */
 public function get_template()
 {
     if (!$this->template) {
         $this->template = wpforms_setting('email-template', 'default');
     }
     return apply_filters('wpforms_email_template', $this->template);
 }
Exemplo n.º 5
0
 /**
  * Outputs the Settings panel primary content.
  *
  * @since 1.0.0
  */
 public function panel_content()
 {
     // Check if there is a form created
     if (!$this->form) {
         echo '<div class="wpforms-alert wpforms-alert-info">';
         _e('You need to <a href="#" class="wpforms-panel-switch" data-panel="setup">setup your form</a> before you can manage the settings.', 'wpforms');
         echo '</div>';
         return;
     }
     //--------------------------------------------------------------------//
     // General
     //--------------------------------------------------------------------//
     echo '<div class="wpforms-panel-content-section wpforms-panel-content-section-general">';
     echo '<div class="wpforms-panel-content-section-title">';
     _e('General', 'wpforms');
     echo '</div>';
     wpforms_panel_field('text', 'settings', 'form_title', $this->form_data, __('Form Title', 'wpforms'), array('default' => $this->form->post_title));
     wpforms_panel_field('textarea', 'settings', 'form_desc', $this->form_data, __('Form Description', 'wpforms'));
     wpforms_panel_field('checkbox', 'settings', 'hide_title_desc', $this->form_data, __('Hide form title and description area', 'wpforms'));
     wpforms_panel_field('text', 'settings', 'form_class', $this->form_data, __('Form CSS Class', 'wpforms'), array('tooltip' => __('Enter CSS class names for the form wrapper. Multiple class names should be seperated with spaces.', 'wpforms')));
     wpforms_panel_field('text', 'settings', 'submit_text', $this->form_data, __('Submit Button Text', 'wpforms'), array('default' => __('Submit', 'wpforms')));
     wpforms_panel_field('text', 'settings', 'submit_text_processing', $this->form_data, __('Submit Button Processing Text', 'wpforms'), array('tooltip' => __('Enter the submit button text you would like the button display while the form submit is processing.', 'wpforms')));
     wpforms_panel_field('text', 'settings', 'submit_class', $this->form_data, __('Submit Button CSS Class', 'wpforms'), array('tooltip' => __('Enter CSS class names for the form submit button. Multiple names should be seperated with spaces.', 'wpforms')));
     wpforms_panel_field('checkbox', 'settings', 'honeypot', $this->form_data, __('Enable anti-spam honeypot', 'wpforms'));
     $recaptcha_key = wpforms_setting('recaptcha-site-key', false);
     $recaptcha_secret = wpforms_setting('recaptcha-secret-key', false);
     if (!empty($recaptcha_key) && !empty($recaptcha_secret)) {
         wpforms_panel_field('checkbox', 'settings', 'recaptcha', $this->form_data, __('Enable reCAPTCHA', 'wpforms'));
     }
     do_action('wpforms_form_settings_general', $this);
     echo '</div>';
     //--------------------------------------------------------------------//
     // Notifications
     //--------------------------------------------------------------------//
     echo '<div class="wpforms-panel-content-section wpforms-panel-content-section-notifications">';
     // echo '<div class="wpforms-panel-content-section-title">';
     // 	_e( 'Notifications', 'wpforms' );
     // echo '</div>';
     // wpforms_panel_field(
     // 	'select',
     // 	'settings',
     // 	'notification_enable',
     // 	$this->form_data,
     // 	__( 'Notifications', 'wpforms' ),
     // 	array(
     // 		'default' => '1',
     // 		'options' => array(
     // 			'1' => __( 'On', 'wpforms' ),
     // 			'0' => __( 'Off', 'wpforms' ),
     // 		),
     // 	)
     // );
     // wpforms_panel_field(
     // 	'text',
     // 	'settings',
     // 	'notification_email',
     // 	$this->form_data,
     // 	__( 'Send To Email Address', 'wpforms' ),
     // 	array(
     // 		'default' => '{admin_email}',
     // 		'tooltip' => __( 'Enter the email address to receive form entry notifications. For multiple notifications, seperate email addresses with a comma.', 'wpforms' ),
     // 		'smarttags' => array(
     // 			'type'   => 'fields',
     // 			'fields' => 'name,email,text',
     // 		),
     // 	)
     // );
     // wpforms_panel_field(
     // 	'text',
     // 	'settings',
     // 	'notification_subject',
     // 	$this->form_data,
     // 	__( 'Email Subject', 'wpforms' ),
     // 	array(
     // 		'default' => __( 'New Entry: ' , 'wpforms' ) . $this->form->post_title,
     // 		'smarttags' => array(
     // 			'type'   => 'fields',
     // 			'fields' => 'name,email,text',
     // 		),
     // 	)
     // );
     // wpforms_panel_field(
     // 	'text',
     // 	'settings',
     // 	'notification_fromname',
     // 	$this->form_data,
     // 	__( 'From Name', 'wpforms' ),
     // 	array(
     // 		'default' => sanitize_text_field( get_option( 'blogname' ) ),
     // 		'smarttags' => array(
     // 			'type'   => 'fields',
     // 			'fields' => 'name,email,text',
     // 		),
     // 	)
     // );
     // wpforms_panel_field(
     // 	'text',
     // 	'settings',
     // 	'notification_fromaddress',
     // 	$this->form_data,
     // 	__( 'From Email', 'wpforms' ),
     // 	array(
     // 		'default' => '{admin_email}',
     // 		'smarttags' => array(
     // 			'type'   => 'fields',
     // 			'fields' => 'name,email,text',
     // 		),
     // 	)
     // );
     // wpforms_panel_field(
     // 	'text',
     // 	'settings',
     // 	'notification_replyto',
     // 	$this->form_data,
     // 	__( 'Reply-To', 'wpforms' ),
     // 	array(
     // 		'smarttags' => array(
     // 			'type'   => 'fields',
     // 			'fields' => 'name,email,text',
     // 		),
     // 	)
     // );
     do_action('wpforms_form_settings_notifications', $this);
     echo '</div>';
     //--------------------------------------------------------------------//
     // Confirmation
     //--------------------------------------------------------------------//
     echo '<div class="wpforms-panel-content-section wpforms-panel-content-section-confirmation">';
     echo '<div class="wpforms-panel-content-section-title">';
     _e('Confirmation', 'wpforms');
     echo '</div>';
     wpforms_panel_field('select', 'settings', 'confirmation_type', $this->form_data, __('Confirmation Type', 'wpforms'), array('default' => 'message', 'options' => array('message' => __('Message', 'wpforms'), 'page' => __('Show Page', 'wpforms'), 'redirect' => __('Go to URL (Redirect)', 'wpforms'))));
     wpforms_panel_field('tinymce', 'settings', 'confirmation_message', $this->form_data, __('Confirmation Message', 'wpforms'), array('default' => __('Thanks for contacting us! We will be in touch with you shortly.', 'wpforms'), 'tinymce' => array('editor_height' => '200')));
     wpforms_panel_field('checkbox', 'settings', 'confirmation_message_scroll', $this->form_data, __('Automatically scroll to the confirmation message', 'wpforms'));
     $p = array();
     $pages = get_pages();
     foreach ($pages as $page) {
         $depth = sizeof($page->ancestors);
         $p[$page->ID] = str_repeat('-', $depth) . ' ' . $page->post_title;
     }
     wpforms_panel_field('select', 'settings', 'confirmation_page', $this->form_data, __('Confirmation Page', 'wpforms'), array('options' => $p));
     wpforms_panel_field('text', 'settings', 'confirmation_redirect', $this->form_data, __('Confirmation Redirect URL', 'wpforms'));
     do_action('wpforms_form_settings_confirmation', $this);
     echo '</div>';
     do_action('wpforms_form_settings_panel_content', $this);
 }
Exemplo n.º 6
0
 * Default email template.
 *
 * Don't forget to run final template through 
 * http://templates.mailchimp.com/resources/inline-css/
 *
 * @package    WPForms
 * @author     WPForms
 * @since      1.1.3
 * @license    GPL-2.0+
 * @copyright  Copyright (c) 2016, WPForms LLC
*/
// Exit if accessed directly
if (!defined('ABSPATH')) {
    exit;
}
$header_image = wpforms_setting('email-header-image', false);
?>
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
	<!--[if gte mso 15]>
	<xml>
		<o:OfficeDocumentSettings>
		<o:AllowPNG/>
		<o:PixelsPerInch>96</o:PixelsPerInch>
		</o:OfficeDocumentSettings>
	</xml>
	<![endif]-->
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">