static function send_manage_subscription($subscriberID, $listids, $lists) { $subscriber = SendPress_Data::get_subscriber($subscriberID); $l = ''; foreach ($lists as $list) { if (in_array($list->ID, $listids)) { $l .= $list->post_title . " <br>"; } } // add_filter( 'the_content', array( $this, 'the_content') ); $optin = SendPress_Data::get_template_id_by_slug('double-optin'); $user = SendPress_Data::get_template_id_by_slug('user-style'); SendPress_Posts::copy_meta_info($optin, $user); $message = new SendPress_Email(); $message->id($optin); $message->subscriber_id($subscriberID); $message->remove_links(true); $message->purge(true); $html = $message->html(); $message->purge(false); $text = $message->text(); $code = array("id" => $subscriberID, "listids" => implode(',', $listids), "view" => "confirm"); $code = SendPress_Data::encrypt($code); if (SendPress_Option::get('old_permalink') || !get_option('permalink_structure')) { $link = home_url() . "?sendpress=" . $code; } else { $link = home_url() . "/sendpress/" . $code; } $href = $link; $html_href = "<a href='" . $link . "'>" . $link . "</a>"; $html = str_replace("*|SP:CONFIRMLINK|*", $html_href, $html); $text = str_replace("*|SP:CONFIRMLINK|*", $href, $text); $text = nl2br($text); $sub = $message->subject(); SendPress_Data::register_event('confirm_sent', $subscriberID); SendPress_Manager::send($subscriber->email, $sub, $html, $text, false); }
static function fetch_mail_from_queue() { @ini_set('max_execution_time', 0); global $wpdb; $count = SendPress_Option::get('emails-per-hour'); $emails_per_hour = SendPress_Option::get('emails-per-hour'); if (SendPress_Manager::limit_reached()) { return; } for ($i = 0; $i < $count; $i++) { $email = $this->wpdbQuery("SELECT * FROM " . SendPress_Data::queue_table() . " WHERE success = 0 AND max_attempts != attempts AND inprocess = 0 ORDER BY id LIMIT 1", "get_row"); if ($email != null) { if (SendPress_Manager::limit_reached()) { break; } $attempts++; SendPress_Data::queue_email_process($email->id); $result = SendPress_Manager::send_email_from_queue($email); $email_count++; if ($result) { $wpdb->update(SendPress_Data::queue_table(), array('success' => 1, 'inprocess' => 3), array('id' => $email->id)); $senddata = array('sendat' => date('Y-m-d H:i:s'), 'reportID' => $email->emailID, 'subscriberID' => $email->subscriberID); //$wpdb->insert( $this->subscriber_open_table(), $senddata); $count++; SendPress_Data::register_event('send', $email->subscriberID, $email->emailID); // SendPress_Data::update_report_sent_count( $email->emailID ); } else { $wpdb->update(SendPress_Data::queue_table(), array('attempts' => $email->attempts + 1, 'inprocess' => 0, 'last_attempt' => date('Y-m-d H:i:s')), array('id' => $email->id)); } } else { //We ran out of emails to process. break; } } return; }