Exemple #1
0
 protected function _mailchimp($data)
 {
     $mailchimp_api = dhvc_form_get_option('mailchimp_api', false);
     $success = false;
     $message = '';
     if ($mailchimp_api) {
         if (!class_exists('MCAPI')) {
             require_once DHVC_FORM_DIR . '/includes/MCAPI.class.php';
         }
         $api = new MCAPI($mailchimp_api);
         $fname = isset($data['name']) ? '' : '';
         $list_id = dhvc_form_get_option('mailchimp_list', 0);
         $list_id = apply_filters('dhvc_form_mailchimp_list', $list_id, $data);
         $first_name = isset($data['first_name']) ? $data['first_name'] : (isset($data['name']) ? $data['name'] : '');
         $last_name = isset($data['last_name']) ? $data['last_name'] : (isset($data['name']) ? $data['name'] : '');
         $email_address = isset($data['email']) ? $data['email'] : '';
         $merge_vars = array('FNAME' => $first_name, 'LNAME' => $last_name);
         $mailchimp_group_name = dhvc_form_get_option('mailchimp_group_name', '');
         $mailchimp_group = dhvc_form_get_option('mailchimp_group', '');
         if (!empty($mailchimp_group) && !empty($mailchimp_group_name)) {
             $merge_vars['GROUPINGS'] = array(array('name' => $mailchimp_group_name, 'groups' => $mailchimp_group));
         }
         $merge_vars = apply_filters('dhvc_form_mailchimp_groupings', $merge_vars, $data);
         $double_optin = dhvc_form_get_option('mailchimp_opt_in', '') === '1' ? true : false;
         $replace_interests = dhvc_form_get_option('mailchimp_replace_interests', '') === '1' ? true : false;
         $send_welcome = dhvc_form_get_option('mailchimp_welcome_email', '') === '1' ? true : false;
         try {
             $retval = $api->listSubscribe($list_id, $email_address, $merge_vars, $email_type = 'html', $double_optin, false, $replace_interests, $send_welcome);
             $success = $retval;
         } catch (Exception $e) {
             if ($e->getCode() == 214) {
                 $success = true;
             } else {
                 $message = $e->getMessage();
             }
         }
     }
     // Check the results of our Subscribe and provide the needed feedback
     if (!$success) {
         return array('success' => false, 'message' => __('Not Subscribe to Mailchimp!', DHVC_FORM));
     } else {
         return array('success' => true, 'message' => __('Subscribe to Mailchimp Successful!', DHVC_FORM));
     }
 }
    wp_enqueue_script('dhvc-form-recaptcha2');
} else {
    wp_enqueue_script('dhvc-form-recaptcha');
    dhvc_form_add_js_declaration('
	jQuery( document ).ready(function(){
		Recaptcha.create("' . dhvc_form_get_option('recaptcha_public_key') . '", "' . $name . '", {theme: "' . $theme . '",lang : \'' . $language . '\',tabindex: 0});
	});
	');
}
$el_class = $this->getExtraClass($el_class);
$css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $this->settings['base'] . ' ' . $el_class, $this->settings['base'], $atts);
$output .= '<div class="dhvc-form-group dhvc-form-' . $name . '-box ' . $css_class . '">' . "\n";
if (!empty($label)) {
    $output .= '<label for="' . $name . '">' . $label . (!empty($required) ? ' <span class="required">*</span>' : '') . '</label>' . "\n";
}
if ($captcha_type == '2') {
    $site_key = dhvc_form_get_option('recaptcha_public_key');
    $secret_key = dhvc_form_get_option('recaptcha_private_key');
    if (!empty($site_key) && !empty($secret_key)) {
        $output .= '<div type="recaptcha" class="dhvc-form-group-recaptcha dhvc-form-recaptcha2" id="' . $name . '"></div>';
    } else {
        $output .= __('Plese settup site Captcha in DHVC Form Settings', DHVC_FORM);
    }
} else {
    $output .= '<div class="dhvc-form-group-recaptcha" id="' . $name . '"></div>';
}
if (!empty($help_text)) {
    $output .= '<span class="help_text">' . $help_text . '</span>' . "\n";
}
$output .= '</div>' . "\n";
echo $output;
Exemple #3
0
    public function render_seting_field($id, $params)
    {
        $params = wp_parse_args((array) $params, array('type' => '', 'help' => '', 'label' => '', 'default' => '', 'help' => '', 'options' => array()));
        extract($params, EXTR_SKIP);
        $name = 'dhvc_form[' . $id . ']';
        echo '<td scope="row">';
        switch ($type) {
            case 'text':
                echo '<input type="text" id="' . $id . '" value="' . dhvc_form_get_option($id, $default) . '" name="' . $name . '" />';
                if (!empty($help)) {
                    echo '<p>' . $help . '</p>';
                }
                break;
            case 'textarea':
                echo '<textarea id="' . $id . '" name="' . $name . '" style=" height: 99px;width: 441px;">' . esc_textarea(dhvc_form_get_option($id, $default)) . '</textarea>';
                if (!empty($help)) {
                    echo '<p>' . $help . '</p>';
                }
                break;
            case 'password':
                echo '<input type="password" id="' . $id . '" value="' . dhvc_form_get_option($id, $default) . '" name="' . $name . '" />';
                if (!empty($help)) {
                    echo '<p>' . $help . '</p>';
                }
                break;
            case 'checkbox':
                echo '<input type="checkbox" id="' . $id . '" ' . (dhvc_form_get_option($id, $default) == '1' ? ' checked="checked"' : '') . ' value="1" name="' . $name . '">';
                if (!empty($help)) {
                    echo '<p>' . $help . '</p>';
                }
                break;
            case 'color':
                echo '<input data-default-color="#336CA6" type="text" id="' . $id . '" value="' . dhvc_form_get_option($id, $default) . '" name="' . $name . '" />';
                echo '<script type="text/javascript">
								jQuery(document).ready(function($){
								    $("#' . $id . '").wpColorPicker();
								});
							 </script>
							 ';
                break;
                if (!empty($help)) {
                    echo '<p>' . $help . '</p>';
                }
            case 'select':
                echo '<select id="' . $id . '" name="' . $name . '">';
                foreach ($options as $key => $value) {
                    $selected = dhvc_form_get_option($id, $default) == $key ? ' selected="selected"' : '';
                    echo '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>';
                }
                echo '</select>';
                if (!empty($help)) {
                    echo '<p>' . $help . '</p>';
                }
                break;
            case 'mailchimp_list':
                echo '<select id="' . $id . '" name="' . $name . '">';
                if ($mailchimp_api = dhvc_form_get_option('mailchimp_api', false)) {
                    if (!class_exists('MCAPI')) {
                        require_once DHVC_FORM_DIR . '/includes/MCAPI.class.php';
                    }
                    $api = new MCAPI($mailchimp_api);
                    $lists = $api->lists();
                    if ($api->errorCode) {
                        $options = array(__("Unable to load MailChimp lists, check your API Key.", DHVC_FORM));
                    } else {
                        if ($lists['total'] == 0) {
                            $options = array(__("You have not created any lists at MailChimp", DHVC_FORM));
                        }
                        $options = array(__('Select a list', DHVC_FORM));
                        foreach ($lists['data'] as $list) {
                            $options[$list['id']] = $list['name'];
                        }
                    }
                }
                foreach ($options as $key => $value) {
                    $selected = dhvc_form_get_option($id, $default) == $key ? ' selected="selected"' : '';
                    echo '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>';
                }
                echo '</select>';
                if (!empty($help)) {
                    echo '<p>' . $help . '</p>';
                }
                break;
            default:
                break;
        }
        echo '</td>';
    }
/**
 * Retrieve get PHPMailer object
 * @return PHPMailer
 */
function dhvc_form_phpmailer()
{
    if (!class_exists('PHPMailer')) {
        require_once ABSPATH . WPINC . '/class-phpmailer.php';
        require_once ABSPATH . WPINC . '/class-smtp.php';
    }
    $mailer = new PHPMailer(true);
    $mailer->ClearAllRecipients();
    $mailer->ClearAttachments();
    $mailer->ClearCustomHeaders();
    $mailer->ClearReplyTos();
    $mailer->IsMail();
    //$mailer->Mailer = 'mail';
    $mailer->CharSet = get_bloginfo('charset');
    if (dhvc_form_get_option('email_method', 'default') == 'smtp') {
        $mailer->IsSMTP();
        $smtp_host = dhvc_form_get_option('smtp_host');
        $smtp_post = dhvc_form_get_option('smtp_post');
        $smtp_username = dhvc_form_get_option('smtp_username');
        $smtp_password = dhvc_form_get_option('smtp_password');
        $smtp_encryption = dhvc_form_get_option('smtp_encryption');
        if (!empty($smtp_host)) {
            $mailer->Host = $smtp_host;
        }
        if (!empty($smtp_post)) {
            $mailer->Port = $smtp_post;
        }
        if (!empty($smtp_username) && !empty($smtp_password)) {
            $mailer->SMTPAuth = true;
            $mailer->Username = $smtp_username;
            $mailer->Password = $smtp_password;
        }
        if (in_array($smtp_encryption, array('tls', 'ssl'))) {
            $mailer->SMTPSecure = $smtp_encryption;
        }
    }
    return $mailer;
}
Exemple #5
0
 public function loadTemplate($atts, $content = null)
 {
     $recaptcha_public_key = dhvc_form_get_option('recaptcha_public_key', false);
     if (!$recaptcha_public_key) {
         echo __('ReCaptcha plugin needs a public key to be set in its parameters. Please contact a site administrator.', DHVC_FORM);
         return;
     }
     return parent::loadTemplate($atts, $content);
 }