Exemplo n.º 1
0
 /**
  * Add/Remove emails from the subscribers table
  */
 static function manage_subscribers()
 {
     $wpdb = Follow_Up_Emails::instance()->wpdb;
     $post = stripslashes_deep($_POST);
     if (!empty($post['button_add'])) {
         // add an email address to the excludes list
         $email = sanitize_email($post['email']);
         $status = fue_add_subscriber($email);
         if (is_wp_error($status)) {
             wp_redirect('admin.php?page=followup-emails-subscribers&error=' . urlencode($status->get_error_message()));
             exit;
         }
         wp_redirect('admin.php?page=followup-emails-subscribers&added=' . urlencode($email));
         exit;
     } elseif (!empty($post['button_csv'])) {
         // process importing request
         if (isset($_FILES['csv']) && is_uploaded_file($_FILES['csv']['tmp_name'])) {
             ini_set("auto_detect_line_endings", true);
             $fh = @fopen($_FILES['csv']['tmp_name'], 'r');
             $i = 0;
             $added = 0;
             while ($row = fgetcsv($fh)) {
                 $i++;
                 if (empty($row) || empty($row[0])) {
                     continue;
                 }
                 $status = fue_add_subscriber($row[0]);
                 if (!is_wp_error($status)) {
                     $added++;
                 }
             }
             wp_redirect('admin.php?page=followup-emails-subscribers&imported=' . $added);
             exit;
         }
     } elseif (!empty($post['button_delete'])) {
         $emails = $post['email'];
         $email_ids = '';
         if (is_array($emails) && !empty($emails)) {
             $email_ids = "'" . implode("','", array_map('absint', $emails)) . "'";
         }
         if (!empty($email_ids)) {
             $wpdb->query("DELETE FROM {$wpdb->prefix}followup_subscribers WHERE id IN({$email_ids})");
         }
         wp_redirect('admin.php?page=followup-emails-subscribers&deleted=' . count($emails));
         exit;
     }
     wp_redirect('admin.php?page=followup-emails-optouts');
     exit;
 }
Exemplo n.º 2
0
 public static function process_subscription_request()
 {
     if (empty($_POST['fue_action']) || $_POST['fue_action'] != 'subscribe') {
         return;
     }
     if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'fue_subscribe')) {
         wp_die('Sorry, your browser submitted an invalid request. Please try again.');
     }
     $back = $_POST['_wp_http_referer'];
     $email = !empty($_POST['fue_subscriber_email']) ? $_POST['fue_subscriber_email'] : '';
     $id = fue_add_subscriber($email);
     if (is_wp_error($id)) {
         $args = array('error' => urlencode($id->get_error_message()), 'email' => urlencode($email));
     } else {
         $args = array('error' => '', 'fue_subscribed' => 'yes');
     }
     wp_redirect(add_query_arg($args, $back));
     exit;
 }