File "class-wc-background-emailer.php"
Full path: /home/kosmetik/public_html/wp-content/plugins/woocommerce/includes/class-wc-background-emailer.php
File
size: 3.39 B
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php
use Automattic\Jetpack\Constants;
defined('ABSPATH') || exit;
if (!class_exists('WC_Background_Process', false)) {
include_once dirname(__FILE__) . '/abstracts/class-wc-background-process.php';
}
class WC_Background_Emailer extends WC_Background_Process
{
public function __construct()
{
$this->prefix = 'wp_' . get_current_blog_id();
$this->action = 'wc_emailer';
add_action('shutdown', array($this, 'dispatch_queue'), 100);
parent::__construct();
}
protected function schedule_event()
{
if (!wp_next_scheduled($this->cron_hook_identifier)) {
wp_schedule_event(time() + 10, $this->cron_interval_identifier, $this->cron_hook_identifier);
}
}
protected function task($callback)
{
if (isset($callback['filter'], $callback['args'])) {
try {
WC_Emails::send_queued_transactional_email($callback['filter'], $callback['args']);
} catch (Exception $e) {
if (Constants::is_true('WP_DEBUG')) {
trigger_error('Transactional email triggered fatal error for callback ' . esc_html($callback['filter']), E_USER_WARNING);
}
}
}
return false;
}
protected function close_http_connection()
{
if (session_id()) {
session_write_close();
}
wc_set_time_limit(0);
if (is_callable('fastcgi_finish_request')) {
fastcgi_finish_request();
} else {
if (!headers_sent()) {
header('Connection: close');
}
@ob_end_flush();
flush();
}
}
public function dispatch_queue()
{
if (!empty($this->data)) {
$this->close_http_connection();
$this->save()->dispatch();
}
}
protected function get_post_args()
{
if (property_exists($this, 'post_args')) {
return $this->post_args;
}
$cookies = array();
foreach ($_COOKIE as $name => $value) {
if ('PHPSESSID' === $name) {
continue;
}
$cookies[] = new WP_Http_Cookie(array('name' => $name, 'value' => $value));
}
return array('timeout' => 0.01, 'blocking' => false, 'body' => $this->data, 'cookies' => $cookies, 'sslverify' => apply_filters('https_local_ssl_verify', false));
}
protected function handle()
{
$this->lock_process();
do {
$batch = $this->get_batch();
if (empty($batch->data)) {
break;
}
foreach ($batch->data as $key => $value) {
$task = $this->task($value);
if (false !== $task) {
$batch->data[$key] = $task;
} else {
unset($batch->data[$key]);
}
$this->update($batch->key, $batch->data);
if ($this->time_exceeded() || $this->memory_exceeded()) {
break;
}
}
if (empty($batch->data)) {
$this->delete($batch->key);
}
} while (!$this->time_exceeded() && !$this->memory_exceeded() && !$this->is_queue_empty());
$this->unlock_process();
if (!$this->is_queue_empty()) {
$this->dispatch();
} else {
$this->complete();
}
}
}