示例#1
0
 protected function _mailpoet($data)
 {
     if (!class_exists('WYSIJA')) {
         return array('success' => false, 'message' => __('MailPoet Newsletters not exists!.', DHVC_FORM));
     }
     $form_id = $_REQUEST['dhvc_form'];
     $list_submit['user_list']['list_ids'] = dhvc_get_post_meta($form_id, '_mailpoet', array());
     $list_submit['user']['firstname'] = isset($data['firstname']) ? trim(preg_replace('/\\s*\\[[^)]*\\]/', '', $data['firstname'])) : '';
     $list_submit['user']['lastname'] = isset($data['lastname']) ? trim(preg_replace('/\\s*\\[[^)]*\\]/', '', $data['lastname'])) : '';
     $list_submit['user']['email'] = isset($data['email']) ? $data['email'] : '';
     if (!is_email($list_submit['user']['email'])) {
         return array('success' => false, 'message' => __('The email address isn\'t correct.', DHVC_FORM));
     }
     //WYSIJA_help_user
     $helper_user = WYSIJA::get('user', 'helper');
     $result = $helper_user->addSubscriber($list_submit);
     if (!$result) {
         $message = $helper_user->getMsgs();
         return array('success' => false, 'message' => implode('<br>', $message['error']));
     } else {
         return array('success' => true, 'message' => sprintf(__('MailPoet Added: %s to list <strong>%s</strong>', DHVC_FORM), $list_submit['user']['email'], implode(', ', dhvc_form_get_mailpoet_subscribers_list($list_submit['user']['list_ids']))));
     }
 }
示例#2
0
 public function init()
 {
     register_setting('dhvc_form', 'dhvc_form');
     if (post_type_exists('dhvcform')) {
         if (class_exists('WPBakeryVisualComposer') && method_exists('WPBakeryVisualComposer', 'isTheme') && WPBakeryVisualComposer::getInstance()->isTheme()) {
             $wpb_js_content_types = 'wpb_js_theme_content_types';
         } else {
             $wpb_js_content_types = 'wpb_js_content_types';
         }
         $pt_array = ($pt_array = get_option($wpb_js_content_types)) ? $pt_array : array('page');
         if (!in_array('dhvcform', $pt_array)) {
             array_push($pt_array, 'dhvcform');
             update_option($wpb_js_content_types, $pt_array);
         }
     }
     $this->setting_fields = array('general' => array('type' => 'heading', 'label' => __('General settings', DHVC_FORM)), 'allowed_file_extension' => array('type' => 'textarea', 'default' => 'zip,rar,tar,7z,jpg,jpeg,png,gif,pdf,doc,docx,ppt,pptx,xls,xlsx', 'label' => __('Allowed Files Upload Types', DHVC_FORM), 'help' => __('Which files are allowed in the attachments? (Separate the extensions by a comma)', DHVC_FORM)), 'date_format' => array('type' => 'text', 'label' => __('Date Format', DHVC_FORM), 'default' => 'Y/m/d'), 'time_format' => array('type' => 'text', 'label' => __('Time Format', DHVC_FORM), 'default' => 'H:i', 'help' => sprintf('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">%s</a>', __('Documentation on date and time formatting', DHVC_FORM))), 'time_picker_step' => array('type' => 'select', 'label' => __('Time picker step', DHVC_FORM), 'default' => '60', 'options' => array('5' => 5, '10' => 10, '15' => 15, '30' => 30, '60' => 60)), 'datetimepicker_lang' => array('type' => 'select', 'label' => __('Datetime Picker Language', DHVC_FORM), 'default' => 'en', 'options' => array('ar' => 'Arabic', 'az' => 'Azerbaijanian (Azeri)', 'bg' => 'Bulgarian', 'bs' => 'Bosanski', 'ca' => 'Català', 'ch' => 'Simplified Chinese', 'cs' => 'Čeština', 'da' => 'Dansk', 'de' => 'German', 'el' => 'Ελληνικά', 'en' => 'English', 'en-GB' => 'English (British)', 'es' => 'Spanish', 'et' => '"Eesti"', 'eu' => 'Euskara', 'fa' => 'Persian', 'fi' => 'Finnish (Suomi)', 'fr' => 'French', 'gl' => 'Galego', 'he' => 'Hebrew (עברית)', 'hr' => 'Hrvatski', 'hu' => 'Hungarian', 'id' => 'Indonesian', 'it' => 'Italian', 'ja' => 'Japanese', 'ko' => 'Korean (한국어)', 'kr' => 'Korean', 'lt' => 'Lithuanian (lietuvių)', 'lv' => 'Latvian (Latviešu)', 'mk' => 'Macedonian (Македонски)', 'mn' => 'Mongolian (Монгол)', 'nl' => 'Dutch', 'no' => 'Norwegian', 'pl' => 'Polish', 'pt' => 'Portuguese', 'pt-BR' => 'Português(Brasil)', 'ro' => 'Romanian', 'ru' => 'Russian', 'se' => 'Swedish', 'sk' => 'Slovenčina', 'sl' => 'Slovenščina', 'sq' => 'Albanian (Shqip)', 'sr' => 'Serbian Cyrillic (Српски)', 'sr-YU' => 'Serbian (Srpski)', 'sv' => 'Svenska', 'th' => 'Thai', 'tr' => 'Turkish', 'uk' => 'Ukrainian', 'vi' => 'Vietnamese', 'zh' => 'Simplified Chinese (简体中文)', 'zh-TW' => 'Traditional Chinese (繁體中文)')), 'container_class' => array('type' => 'text', 'label' => __('Conditional Container Element', DHVC_FORM), 'default' => '.vc_row-fluid'), 'user' => array('type' => 'heading', 'label' => __('Users page settings', DHVC_FORM)), 'user_login' => array("type" => "select", "label" => __("Login page", DHVC_FORM), "options" => dhvc_form_get_pages(true)), 'user_logout_redirect_to' => array("type" => "select", "label" => __("Logout redirect to page", DHVC_FORM), "options" => dhvc_form_get_pages(true)), 'user_regiter' => array("type" => "select", "label" => __("Register page", DHVC_FORM), "options" => dhvc_form_get_pages(true)), 'user_forgotten' => array("type" => "select", "label" => __("Lost password page", DHVC_FORM), "options" => dhvc_form_get_pages(true)), 'email' => array('type' => 'heading', 'label' => __('Email settings', DHVC_FORM)), 'email_method' => array('type' => 'select', 'label' => __('Sender method', DHVC_FORM), 'default' => 'default', 'options' => array('default' => __('PHP Mailer', DHVC_FORM), 'smtp' => __('SMTP', DHVC_FORM))), 'smtp_host' => array('type' => 'text', 'label' => __('SMTP host', DHVC_FORM)), 'smtp_post' => array('type' => 'text', 'value' => 25, 'label' => __('SMTP port', DHVC_FORM)), 'smtp_encryption' => array('type' => 'select', 'label' => __('SMTP encryption', DHVC_FORM), 'options' => array('' => __('None', DHVC_FORM), 'tls' => __('TLS', DHVC_FORM), 'ssl' => __('SSL', DHVC_FORM))), 'smtp_username' => array('type' => 'text', 'label' => __('SMTP username', DHVC_FORM)), 'smtp_password' => array('type' => 'password', 'label' => __('SMTP password', DHVC_FORM)), 'recaptcha' => array('type' => 'heading', 'label' => __('reCaptcha settings', DHVC_FORM), 'help' => __('In order to use the reCAPTCHA element in your form you must <a target="_blank" href="https://www.google.com/recaptcha">sign up</a> for a free account to get your set of API keys.', DHVC_FORM)), 'recaptcha_public_key' => array('type' => 'text', 'label' => __('Public key (Site Key)', DHVC_FORM)), 'recaptcha_private_key' => array('type' => 'text', 'label' => __('Private key (Secret Key)', DHVC_FORM)), 'mailchimp' => array('type' => 'heading', 'label' => __('MailChimp settings', DHVC_FORM)), 'mailchimp_api' => array('type' => 'text', 'label' => __('MailChimp API Key', DHVC_FORM), 'help' => __('Enter your API Key. <a href="http://admin.mailchimp.com/account/api-key-popup" target="_blank">Get your API key</a>', DHVC_FORM)), 'mailchimp_list' => array('type' => 'mailchimp_list', 'label' => __('MailChimp List', DHVC_FORM), 'options' => array('' => __('Nothing Found...', DHVC_FORM)), 'help' => __('After you add your MailChimp API Key above and save it this list will be populated.', DHVC_FORM)), 'mailchimp_opt_in' => array('type' => 'checkbox', 'label' => __('Enable Double Opt-In', DHVC_FORM), 'help' => __("Learn more about <a href='http://kb.mailchimp.com/article/how-does-confirmed-optin-or-double-optin-work' target='_blank'>Double Opt-in</a>.", DHVC_FORM)), 'mailchimp_welcome_email' => array('type' => 'checkbox', 'label' => __('Send Welcome Email', DHVC_FORM), 'help' => __("If your Double Opt-in is false and this is true, MailChimp will send your lists Welcome Email if this subscribe succeeds - this will not fire if MailChimp ends up updating an existing subscriber. If Double Opt-in is true, this has no effect. Learn more about <a href='http://blog.mailchimp.com/sending-welcome-emails-with-mailchimp/' target='_blank'>Welcome Emails</a>.", DHVC_FORM)), 'mailchimp_group_name' => array('type' => 'text', 'label' => __('Group Name', DHVC_FORM), 'help' => __('Optional: Enter the name of the group. Learn more about <a href="http://mailchimp.com/features/groups/" target="_blank">Groups</a>', DHVC_FORM)), 'mailchimp_group' => array('type' => 'text', 'label' => __('Group', DHVC_FORM), 'help' => __('Optional: Comma delimited list of interest groups to add the email to.', DHVC_FORM)), 'mailchimp_replace_interests' => array('type' => 'checkbox', 'label' => __('Replace Interests', DHVC_FORM), 'help' => __("Whether MailChimp will replace the interest groups with the groups provided or add the provided groups to the member's interest groups.", DHVC_FORM)));
     $this->meta_boxs = array(array("type" => "heading", "label" => __('General', DHVC_FORM)), array("type" => "checkbox", "label" => __("Save Submitted Form to Data ?", DHVC_FORM), "name" => "save_data", "cbvalue" => 1, 'description' => __('If checked, the submitted form data will be saved to your database.', DHVC_FORM)), array("type" => "checkbox", "label" => __("Use Form AJAX ? ", DHVC_FORM), "name" => "use_ajax", 'description' => __('You can not upload file if use form AJAX', DHVC_FORM), "cbvalue" => 1), array("type" => "select", "label" => __("Action Type", DHVC_FORM), "name" => "action_type", "options" => array('default' => __('Default', DHVC_FORM), 'external_url' => __('External URL', DHVC_FORM))), array("type" => "select", "label" => __("Use form action", DHVC_FORM), "name" => "form_action", "options" => $this->_get_form_acition_options()), array("type" => "checklist", "label" => __("Mailpoet subscribers to These Lists", DHVC_FORM), "name" => "mailpoet", "options" => dhvc_form_get_mailpoet_subscribers_list()), array("type" => "checklist", "label" => __("Mymail subscribers to These Lists", DHVC_FORM), "name" => "mymail", "options" => dhvc_form_get_mymail_subscribers_list()), array("type" => "checkbox", "label" => __("Mymail Double Opt In ", DHVC_FORM), "name" => "mymail_double_opt_in", 'description' => __('Users have to confirm their subscription', DHVC_FORM), "cbvalue" => 1), array("type" => "text", "label" => __("Enter URL", DHVC_FORM), "name" => "action_url", "dependency" => array('element' => "action_type", 'value' => array('external_url')), 'description' => __('Enter a action URL.', DHVC_FORM)), array("type" => "select", "label" => __("Method", DHVC_FORM), "name" => "method", "options" => array('post' => __('Post', DHVC_FORM), 'get' => __('Get', DHVC_FORM))), array("type" => "heading", "label" => __('Successful submit settings', DHVC_FORM)), array("type" => "select", "label" => __("On successful submit", DHVC_FORM), "name" => "on_success", "options" => array('message' => __('Display a message', DHVC_FORM), 'redirect' => __('Redirect to another page', DHVC_FORM))), array("type" => "textarea_variable", "label" => __("Message", DHVC_FORM), "name" => "message", "value" => 'Your message has been sent. Thanks!', "dependency" => array('element' => "on_success", 'value' => array('message')), 'description' => __('This is the text or HTML that is displayed when the form is successfully submitted', DHVC_FORM)), array("type" => "select", "label" => __("Message Position", DHVC_FORM), "name" => "message_position", "options" => array('top' => __('Top', DHVC_FORM), 'bottom' => __('Bottom', DHVC_FORM))), array("type" => "select", "label" => __("Redirect to", DHVC_FORM), "name" => "redirect_to", "dependency" => array('element' => "on_success", 'value' => array('redirect')), "options" => array('to_page' => __('Page', DHVC_FORM), 'to_post' => __('Post', DHVC_FORM), 'to_url' => __('Url', DHVC_FORM)), "description" => __('When the form is successfully submitted you can redirect the user to post, page or URL.', DHVC_FORM)), array("type" => "select", "label" => __("Select page", DHVC_FORM), "name" => "page", "options" => dhvc_form_get_pages(), "dependency" => array('element' => "redirect_to", 'value' => array('to_page'))), array("type" => "select", "label" => __("Select post", DHVC_FORM), "name" => "post", "options" => dhvc_form_get_posts(), "dependency" => array('element' => "redirect_to", 'value' => array('to_post'))), array("type" => "text", "label" => __("Enter URL", DHVC_FORM), "name" => "url", "dependency" => array('element' => "redirect_to", 'value' => array('to_url'))), array("type" => "heading", "label" => __('Notifications email settings', DHVC_FORM)), array("type" => "checkbox", "label" => __("Send form data via email ?", DHVC_FORM), "name" => "notice", "cbvalue" => 1), array('type' => 'text', 'label' => __('Sender Name', DHVC_FORM), 'name' => 'notice_name', 'value' => get_bloginfo('name'), "dependency" => array('element' => "notice", 'not_empty' => true)), array('type' => 'select', 'label' => __('Sender Email Type', DHVC_FORM), 'name' => 'notice_email_type', 'value' => 'email_text', 'options' => array('email_text' => __('Email', DHVC_FORM), 'email_field' => __('Email Field', DHVC_FORM)), "dependency" => array('element' => "notice", 'not_empty' => true)), array('type' => 'text', 'label' => __('Sender Email', DHVC_FORM), 'name' => 'notice_email', 'value' => get_bloginfo('admin_email'), "dependency" => array('element' => "notice", 'not_empty' => true)), array('type' => 'select_recipient', 'label' => __('Sender Field', DHVC_FORM), 'name' => 'notice_variables', "description" => __('The form must have at least one Email Address element to use this feature.', DHVC_FORM)), array('type' => 'recipient', 'label' => __('Recipients', DHVC_FORM), 'name' => 'notice_recipients', 'value' => get_bloginfo('admin_email'), "dependency" => array('element' => "notice", 'not_empty' => true), "description" => __('Add email address(es) which the submitted form data will be sent to.', DHVC_FORM)), array('type' => 'input_variable', 'label' => __('Email subject', DHVC_FORM), 'name' => 'notice_subject', "dependency" => array('element' => "notice", 'not_empty' => true), 'value' => __('New form submission', DHVC_FORM)), array('type' => 'textarea_variable', 'label' => __('Email body', DHVC_FORM), 'name' => 'notice_body', 'value' => '[form_body]', "description" => __("Use the label [form_body] to insert the form data in the email body. To use form control in email. please enter form control variables <strong>[form_control_name]</strong> in email.", DHVC_FORM)), array("type" => "checkbox", "label" => __("Use HTML content type ?", DHVC_FORM), "name" => "notice_html", "cbvalue" => 1), array("type" => "heading", "label" => __('Autoreply email settings', DHVC_FORM)), array("type" => "checkbox", "label" => __("Send autoreply email ?", DHVC_FORM), "name" => "reply", "cbvalue" => 1), array('type' => 'text', 'label' => __('Sender Name', DHVC_FORM), 'name' => 'reply_name', 'value' => get_bloginfo('name'), "dependency" => array('element' => "reply", 'not_empty' => true)), array('type' => 'text', 'label' => __('Sender Email', DHVC_FORM), 'name' => 'reply_email', 'value' => get_bloginfo('admin_email'), "dependency" => array('element' => "reply", 'not_empty' => true)), array('type' => 'select_recipient', 'label' => __('Recipients', DHVC_FORM), 'name' => 'reply_recipients', "description" => __('The form must have at least one Email Address element to use this feature.', DHVC_FORM)), array('type' => 'input_variable', 'label' => __('Email subject', DHVC_FORM), 'name' => 'reply_subject', "dependency" => array('element' => "reply", 'not_empty' => true), 'value' => __('Just Confirming', DHVC_FORM)), array('type' => 'textarea_variable', 'label' => __('Email body', DHVC_FORM), 'name' => 'reply_body', "dependency" => array('element' => "reply", 'not_empty' => true), 'value' => __('This is just a confirmation message. We have received you reply.', DHVC_FORM), "description" => __("Use the label [form_body] to insert the form data in the email body. To use form control in email. please enter form control variables <strong>[form_control_name]</strong> in email.", DHVC_FORM)), array("type" => "checkbox", "label" => __("Use HTML content type ?", DHVC_FORM), "name" => "reply_html", "cbvalue" => 1), array("type" => "heading", "label" => __('Form popup settings', DHVC_FORM)), array("type" => "checkbox", "label" => __("Display the form in a popup ?", DHVC_FORM), "name" => "form_popup", "cbvalue" => 1), array("type" => "labelpopup", "name" => 'form_popup_labelpopup', "label" => __('Set data-toggle="dhvcformpopup" on a controller element, like a button, along with a data-target="#dhvcformpopup-{form_ID}" or href="#dhvcformpopup-{form_ID}" to target a specific form popup to toggle.', DHVC_FORM)), array("type" => "checkbox", "label" => __("Show popup title ?", DHVC_FORM), "name" => "form_popup_title", "cbvalue" => 1), array('type' => 'text', 'label' => __('Form popup width (px)', DHVC_FORM), 'name' => 'form_popup_width', 'value' => 600), array("type" => "checkbox", "label" => __("Auto open popup ?", DHVC_FORM), "name" => "form_popup_auto_open", "cbvalue" => 1, "description" => __('If selected, form popup will auto open when load page.', DHVC_FORM)), array('type' => 'text', 'label' => __('Popup open delay (ms)', DHVC_FORM), 'name' => 'form_popup_auto_open_delay', 'value' => 2000, "description" => __('Time delay for open popup.', DHVC_FORM)), array("type" => "checkbox", "label" => __("Auto close popup ?", DHVC_FORM), "name" => "form_popup_auto_close", "cbvalue" => 1, "description" => __('If selected, form popup will auto close.', DHVC_FORM)), array('type' => 'text', 'label' => __('Popup close delay (ms)', DHVC_FORM), 'name' => 'form_popup_auto_close_delay', 'value' => 10000, "description" => __('Time delay for close popup.', DHVC_FORM)), array("type" => "checkbox", "label" => __("Only one time ?", DHVC_FORM), "name" => "form_popup_one", "cbvalue" => 1, "description" => __('If selected,form will opens only on the first visit your site.', DHVC_FORM)), array("type" => "heading", "label" => __('Style settings', DHVC_FORM)), array("type" => "select", "label" => __("Form layout", DHVC_FORM), "name" => "form_layout", "options" => array('vertical' => __('Vertical', DHVC_FORM), 'horizontal' => __('Horizontal', DHVC_FORM))), array("type" => "select", "label" => __("Input icon position", DHVC_FORM), "name" => "input_icon_position", "options" => array('right' => __('Right', DHVC_FORM), 'left' => __('Left', DHVC_FORM))), array('type' => 'color', 'label' => __('Label Color', DHVC_FORM), 'name' => 'label_color'), array('type' => 'color', 'label' => __('Input Placeholder Text Color', DHVC_FORM), 'name' => 'placeholder_color'), array('type' => 'text', 'label' => __('Input Height (example enter:40px)', DHVC_FORM), 'name' => 'input_height'), array('type' => 'color', 'label' => __('Input Background Color', DHVC_FORM), 'name' => 'input_bg_color'), array('type' => 'color', 'label' => __('Input Text Color', DHVC_FORM), 'name' => 'input_text_color'), array('type' => 'color', 'label' => __('Input border color', DHVC_FORM), 'name' => 'input_border_color'), array('type' => 'text', 'label' => __('Input border Size (example enter:1px)', DHVC_FORM), 'name' => 'input_border_size'), array('type' => 'color', 'label' => __('Input hover border color', DHVC_FORM), 'name' => 'input_hover_border_color'), array('type' => 'color', 'label' => __('Input focus border color', DHVC_FORM), 'name' => 'input_focus_border_color'), array('type' => 'text', 'label' => __('Button Height (example enter:40px)', DHVC_FORM), 'name' => 'button_height'), array('type' => 'color', 'label' => __('Button background color', DHVC_FORM), 'name' => 'button_bg_color'), array('type' => 'textarea', 'label' => __('Additional Settings', DHVC_FORM), "description" => __('Trigger with form AJAX.', DHVC_FORM), 'name' => 'additional_setting'));
 }