function mymail_form($id = 0, $tabindex = 100, $echo = true, $classes = '')
{
    require_once MYMAIL_DIR . '/classes/form.class.php';
    $mymail_form = new mymail_form();
    $form = $mymail_form->form($id, $tabindex, $classes);
    if ($echo) {
        echo $form;
    } else {
        return $form;
    }
}
 public function newsletter_unsubscribe($atts, $content)
 {
     if (isset($_REQUEST['unsubscribe'])) {
         extract(shortcode_atts(array('tabindex' => 100), $atts));
         require_once MYMAIL_DIR . '/classes/form.class.php';
         global $mymail_form;
         if (!$mymail_form) {
             $mymail_form = new mymail_form();
         }
         return do_shortcode($content) . $mymail_form->unsubscribe_form($_REQUEST['unsubscribe'], isset($_REQUEST['k']) ? $_REQUEST['k'] : '', $tabindex);
     }
 }
 public function unsubscribe_form($hash = '', $campaignid = '', $tabindex = 100, $classes = '')
 {
     self::$add_script = true;
     global $mymail_form_tabstopp;
     $tabindex = $mymail_form_tabstopp ? $mymail_form_tabstopp : $tabindex;
     $msg_id = 0;
     if (isset($_REQUEST['mymail_success'])) {
         $msg_id = intval($_REQUEST['mymail_success']);
         if ($msg_id == 1) {
             $this->message = '<p>' . mymail_text('unsubscribe') . '</p>';
         } else {
             if ($msg_id == 2) {
                 $this->message = '<p>' . mymail_text('unsubscribeerror') . '</p>';
             }
         }
     }
     $html = '';
     $html .= '<form action="' . admin_url('admin-ajax.php') . '" method="post" class="mymail-form mymail-form-unsubscribe ' . $classes . '" id="mymail-form-unsubscribe">';
     $html .= '<div class="mymail-form-info ' . ($msg_id == 2 ? 'error' : 'success') . '"' . (!empty($this->errors) || !empty($this->message) ? ' style="display:block"' : '') . '>';
     $html .= $this->get_error_html();
     $html .= $this->message;
     $html .= '</div>';
     $html .= '<input name="_wpnonce" type="hidden" value="' . wp_create_nonce('mymail_nonce') . '">';
     $html .= '<input name="_referer" type="hidden" value="' . $_SERVER['REQUEST_URI'] . '">';
     $html .= '<input name="hash" type="hidden" value="' . $hash . '">';
     $html .= '<input name="campaign" type="hidden" value="' . $campaignid . '">';
     $html .= '<input name="action" type="hidden" value="mymail_form_unsubscribe">';
     if (empty($hash)) {
         $html .= '<div class="mymail-wrapper mymail-email-wrapper"><label for="mymail-email">' . mymail_text('email', __('Email', 'mymail')) . ' <span class="required">*</span></label>';
         $html .= '<input id="mymail-email" class="input mymail-email required" name="email" type="text" value="" tabindex="' . $tabindex++ . '"></div>';
     }
     $html .= '<div class="mymail-wrapper mymail-submit-wrapper form-submit"><input name="submit" type="submit" value="' . mymail_text('unsubscribebutton', __('Unsubscribe', 'mymail')) . '" class="submit-button button" tabindex="' . $tabindex++ . '"><span class="mymail-loader"></span></div>';
     $html .= '</form>';
     //global
     $mymail_form_tabstopp = $tabindex;
     return apply_filters('mymail_unsubscribe_form', $html, $campaignid);
 }
 public function widget($args, $instance)
 {
     global $post;
     if ($post && mymail_option('homepage') == $post->ID) {
         return false;
     }
     // outputs the content of the widget
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     $text_before = apply_filters('widget_text_before', isset($instance['text_before']) ? $instance['text_before'] : false);
     $form = apply_filters('widget_form', $instance['form']);
     $text_after = apply_filters('widget_text_after', isset($instance['text_after']) ? $instance['text_after'] : false);
     echo $before_widget;
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     require_once MYMAIL_DIR . '/classes/form.class.php';
     global $mymail_form;
     if (!$mymail_form) {
         $mymail_form = new mymail_form();
     }
     if ($text_before) {
         echo '<div class="mymail-widget-text mymail-widget-text-before">' . $text_before . '</div>';
     }
     echo $mymail_form->form($form, 1, 'mymail-in-widget');
     if ($text_after) {
         echo '<div class="mymail-widget-text mymail-widget-text-before">' . $text_after . '</div">';
     }
     echo $after_widget;
 }
 public function ajax_form_submit()
 {
     $return['success'] = false;
     if (!isset($_POST['_extern'])) {
         $this->ajax_nonce(json_encode($return));
     }
     require_once MYMAIL_DIR . '/classes/form.class.php';
     global $mymail_form;
     if (!$mymail_form) {
         $mymail_form = new mymail_form();
     }
     $return = $mymail_form->handle_submission();
     $return['success'] = !isset($return['error']);
     echo json_encode($return);
     exit;
 }