public function cancel() { if (!$this->is_scheduled()) { return new WP_Error('hm_backdrop_not_scheduled', __('Task is not scheduled to run', 'hm_backdrop')); } WP_Temporary::delete('hm_backdrop-' . $this->key); return true; }
public function run() { if (empty($_POST['key'])) { return new WP_Error('hm_backdrop_no_key', __('No key supplied', 'hm_backdrop')); } $data = WP_Temporary::get('hm_backdrop-' . $_POST['key']); if (empty($data)) { return new WP_Error('hm_backdrop_invalid_key', __('Supplied key was not valid', 'hm_backdrop')); } $result = call_user_func_array($data['callback'], $data['params']); WP_Temporary::delete('hm_backdrop-' . $_POST['key']); if (is_wp_error($result)) { return $result; } return true; }
* * @package Purge_Cache_for_CloudFlare * @subpackage Unistall */ /* Exit if accessed directly or not in unistall */ if (!defined('ABSPATH') || !defined('WP_UNINSTALL_PLUGIN')) { exit; } // Load dependencies require __DIR__ . '/vendor/autoload.php'; /* * Remove options on uninstallation of plugin. * * @since 1.0 */ delete_option('purge_cache_for_cloudflare_api_key'); delete_option('purge_cache_for_cloudflare_api_email_address'); delete_option('purge_cache_for_cloudflare_urls'); /* * Clean expired temporaries on uninstallation of plugin. * * @since 1.0 */ WP_Temporary::clean(); /* * Delete temporaries on uninstallation of plugin. * * @since 1.0 */ WP_Temporary::delete('purge_cache_for_cloudflare_requests_limit');
/** * Process items from queue. * * By default, every six minutes send ten emails. * * @since 1.0 * @access public */ public function process_queue() { // Look for existing addresses $existing = $this->get_queue(); if (!is_array($existing) && $existing) { return false; } // Check how much emails are already sent in this interval $sent = WP_Temporary::get('simple_email_queue_sent'); if (!$sent) { $sent = 0; } /* * Maximum number of allowed email to send * is difference between maximum allowed and * number of sent emails in this interval. */ $max = $this->max() - $sent; $num_sent = 0; foreach ($existing as $key => $value) { if ($num_sent >= $max) { break; } $email_to = key($value); $email_key = $value[$email_to]; $this->send_email($email_to, $email_key); // Remove item from array unset($existing[$key]); // Increase number of sent emails $num_sent++; } // Save temporary that stores existing of temporary based on existence mail in queue if ($existing) { WP_Temporary::set('simple_email_queue_exist', 1, WEEK_IN_SECONDS); } else { WP_Temporary::delete('simple_email_queue_exist'); } // Save new queue $this->set_queue($existing); // Save new number of sent emails in this interval $new_sent = $sent + $num_sent; WP_Temporary::update('simple_email_queue_sent', $new_sent, $this->interval()); }
/** * Delete cache content for name. * * @access public * * @param string $string Name of cache that is deleted. * @return bool True if deletion is successful, false otherwise. */ public static function delete($name) { return \WP_Temporary::delete(self::key($name)); }