function save()
 {
     if (isset($_POST['delete-this-user']) && $_POST['delete-this-user'] == 'yes') {
         SendPress_Data::delete_subscriber($_POST['subscriberID']);
         if ($_GET['listID']) {
             SendPress_Admin::redirect('Subscribers_Subscribers', array('listID' => $_GET['listID']));
         } else {
             SendPress_Admin::redirect('Subscribers_All');
         }
     } else {
         global $post;
         $subscriber_info = array('email' => $_POST['email'], 'firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname']);
         SendPress_Data::update_subscriber($_POST['subscriberID'], $subscriber_info);
         $args = array('post_type' => 'sendpress_list', 'post_status' => array('publish', 'draft'), 'posts_per_page' => 100, 'order' => 'ASC', 'orderby' => 'title');
         $postslist = get_posts($args);
         foreach ($postslist as $post) {
             setup_postdata($post);
             if (isset($_POST[$post->ID . "-status"]) && $_POST[$post->ID . "-status"] > 0) {
                 SendPress_Data::update_subscriber_status($post->ID, $_POST['subscriberID'], $_POST[$post->ID . "-status"]);
             } else {
                 SendPress_Data::remove_subscriber_status($post->ID, $_POST['subscriberID']);
             }
             $notifications = SendPress_Data::get_post_notification_types();
             if (isset($_POST[$post->ID . "-pn"]) && array_key_exists($_POST[$post->ID . "-pn"], $notifications)) {
                 SendPress_Data::update_subscriber_meta($_POST['subscriberID'], 'post_notifications', $_POST[$post->ID . "-pn"], $post->ID);
             }
         }
         wp_reset_postdata();
     }
     SendPress_Admin::redirect('Subscribers_Subscriber', array('subscriberID' => $_POST['subscriberID']));
 }
 function prerender()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     //print_r($info);
     $info = $this->data();
     if (isset($info->listids)) {
         $lists = explode(',', $info->listids);
         foreach ($lists as $list_id) {
             if ($list_id > 0) {
                 $status = SendPress_Data::get_subscriber_list_status($list_id, $info->id);
                 if (!isset($status) || $status->status != '2') {
                     SendPress_Data::update_subscriber_status($list_id, $info->id, '2');
                 }
             }
         }
     }
     if (SendPress_Option::get('confirm-page') == 'custom') {
         $page = SendPress_Option::get('confirm-page-id');
         if ($page != false) {
             $plink = get_permalink($page);
             if ($plink != "") {
                 wp_safe_redirect(esc_url_raw($plink));
                 exit;
             }
         }
     }
 }
 function prerender()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     //print_r($info);
     $info = $this->data();
     if (isset($info->id)) {
         $lists = SendPress_Data::get_list_ids_for_subscriber($info->id);
         //$lists = explode(',',$info->listids);
         foreach ($lists as $list) {
             $status = SendPress_Data::get_subscriber_list_status($list->listID, $info->id);
             if ($status->statusid == 1) {
                 SendPress_Data::update_subscriber_status($list->listID, $info->id, '2');
             }
         }
         SPNL()->db("Subscribers_Tracker")->open($info->report, $info->id, 4);
     }
     if (SendPress_Option::get('confirm-page') == 'custom') {
         $page = SendPress_Option::get('confirm-page-id');
         if ($page != false) {
             $plink = get_permalink($page);
             if ($plink != "") {
                 wp_safe_redirect(esc_url_raw($plink));
                 exit;
             }
         }
     }
 }
 function list_subscription()
 {
     $this->verify_ajax_call();
     $s = new SendPress();
     $lid = $_POST['lid'];
     $sid = $_POST['sid'];
     $status = $_POST['status'];
     echo json_encode(SendPress_Data::update_subscriber_status($lid, $sid, $status));
     die;
 }
 function create_subscriber()
 {
     $email = $_POST['email'];
     $fname = $_POST['firstname'];
     $lname = $_POST['lastname'];
     $listID = $_POST['listID'];
     $status = $_POST['status'];
     if (is_email($email)) {
         $result = SendPress_Data::add_subscriber(array('firstname' => $fname, 'email' => $email, 'lastname' => $lname));
         SendPress_Data::update_subscriber_status($listID, $result, $status, false);
     }
     SendPress_Admin::redirect('Subscribers_Subscribers', array('listID' => $listID));
 }
 function create_subscribers()
 {
     $csvadd = "email,firstname,lastname\n" . trim($_POST['csv-add']);
     $listID = SPNL()->validate->int($_POST['listID']);
     if ($listID > 0) {
         $newsubscribers = SendPress_Data::subscriber_csv_post_to_array($csvadd);
         foreach ($newsubscribers as $subscriberx) {
             if (is_email(trim($subscriberx['email']))) {
                 $result = SendPress_Data::add_subscriber(array('firstname' => trim($subscriberx['firstname']), 'email' => trim($subscriberx['email']), 'lastname' => trim($subscriberx['lastname'])));
                 SendPress_Data::update_subscriber_status($listID, $result, 2, false);
             }
         }
     }
     wp_redirect(esc_url_raw(admin_url('admin.php?page=' . SPNL()->validate->page($_GET['page']) . "&view=subscribers&listID=" . $listID)));
 }
 static function subscribe_user($listid, $email, $first, $last, $status = 2, $custom = array())
 {
     $success = false;
     $subscriberID = SendPress_Data::add_subscriber(array('firstname' => $first, 'lastname' => $last, 'email' => $email));
     //SendPress_Error::log($subscriberID);
     if (false === $subscriberID) {
         return false;
     }
     $args = array('post_type' => 'sendpress_list', 'numberposts' => -1, 'offset' => 0, 'orderby' => 'post_title', 'order' => 'DESC');
     $lists = get_posts($args);
     $listids = explode(',', $listid);
     $already_subscribed = false;
     if ($status == 2 && SendPress_Option::is_double_optin()) {
         $inlists = SendPress_Data::get_active_list_ids_for_subscriber($subscriberID);
         //SendPress_Error::log($inlists);
         if ($inlists) {
             $already_subscribed = true;
         } else {
             $status = 1;
             SendPress_Manager::send_optin($subscriberID, $listids, $lists);
         }
     }
     foreach ($lists as $list) {
         if (in_array($list->ID, $listids)) {
             $current_status = SendPress_Data::get_subscriber_list_status($list->ID, $subscriberID);
             if (empty($current_status) || isset($current_status->status) && $current_status->status < 2) {
                 $success = SendPress_Data::update_subscriber_status($list->ID, $subscriberID, $status);
             } else {
                 $success = true;
             }
             foreach ($custom as $key => $value) {
                 SendPress_Data::update_subscriber_meta($subscriberID, $key, $value, $list->ID);
             }
         }
     }
     if ($success == false) {
         return false;
     }
     return array('success' => $success, 'already' => $already_subscribed);
 }
 private static function handle_unsubscribes()
 {
     $_nonce_value = 'sendpress-is-awesome';
     $c = false;
     if (!empty($_POST) && check_admin_referer($_nonce_value)) {
         $args = array('meta_key' => 'public', 'meta_value' => 1, 'post_type' => 'sendpress_list', 'post_status' => 'publish', 'posts_per_page' => -1, 'ignore_sticky_posts' => 1);
         $my_query = new WP_Query($args);
         if ($my_query->have_posts()) {
             while ($my_query->have_posts()) {
                 $my_query->the_post();
                 $list_id = $my_query->post->ID;
                 if (isset($_POST['subscribe_' . $list_id])) {
                     $list_status = SendPress_Data::get_subscriber_list_status($list_id, $_POST['subscriberid']);
                     if (isset($list_status->status)) {
                         SendPress_Data::update_subscriber_status($list_id, $_POST['subscriberid'], $_POST['subscribe_' . $list_id]);
                     } elseif ($_POST['subscribe_' . $list_id] == '2') {
                         SendPress_Data::update_subscriber_status($list_id, $_POST['subscriberid'], $_POST['subscribe_' . $list_id]);
                     }
                 }
                 $c = true;
             }
         }
         //do_action('sendpress_public_view_manage_save', $_POST);
     }
     wp_reset_query();
     return $c;
 }
Пример #9
0
             $count++;
         }
     }
     update_post_meta($new_id, '_send_count', $count);
     update_post_meta($new_id, '_send_data', $info);
     $this->log('END ADD QUEUE');
     wp_redirect(esc_url_raw(admin_url('admin.php?page=sp-queue')));
     break;
 case 'create-subscribers':
     $csvadd = "email,firstname,lastname\n" . trim($_POST['csv-add']);
     $listID = $_POST['listID'];
     $newsubscribers = $this->subscriber_csv_post_to_array($csvadd);
     foreach ($newsubscribers as $subscriberx) {
         if (is_email(trim($subscriberx['email']))) {
             $result = SendPress_Data::add_subscriber(array('firstname' => trim($subscriberx['firstname']), 'email' => trim($subscriberx['email']), 'lastname' => trim($subscriberx['lastname'])));
             SendPress_Data::update_subscriber_status($listID, $result, 2, false);
         }
     }
     wp_redirect(esc_url_raw(admin_url('admin.php?page=' . $_GET['page'] . "&view=subscribers&listID=" . $listID)));
     break;
 case 'save-send':
     /*
         $csvadd ="email,firstname,lastname\n" . trim($_POST['test-add']);
         $data=   $this->subscriber_csv_post_to_array($csvadd);
         $listids = isset($_POST['listIDS']) ? $_POST['listIDS'] : array();
     SendPress_Option::set('current_send_'. $_POST['post_ID'], array(
         'listIDS' =>  $listids,
         'testemails'=> $data
         ));
     SendPress_Option::set('current_send_subject_'. $_POST['post_ID'],$_POST['post_subject']);
     
Пример #10
0
 function linkListSubscriber($listID, $subscriberID, $status = 0)
 {
     _deprecated_function(__FUNCTION__, '0.8.9', 'SendPress_Data::update_subscriber_status()');
     return SendPress_Data::update_subscriber_status($listID, $subscriberID, $status);
 }