public function w3tc_cloudflare_flush() { $c = Dispatcher::config(); $api = new Extension_CloudFlare_Api(array('email' => $c->get_string(array('cloudflare', 'email')), 'key' => $c->get_string(array('cloudflare', 'key')), 'zone_id' => $c->get_string(array('cloudflare', 'zone_id')), 'timelimit_api_request' => $c->get_integer(array('cloudflare', 'timelimit.api_request')))); try { $v = $api->purge(); } catch (\Exception $ex) { Util_Admin::redirect_with_custom_messages2(array('errors' => array('cloudflare_flush' => __('Failed to flush CloudFlare cache: ', 'w3-total-cache') . $ex->getMessage()))); return; } Util_Admin::redirect_with_custom_messages2(array('notes' => array('cloudflare_flush' => __('CloudFlare cache successfully emptied.', 'w3-total-cache')))); }
public function w3tc_flush_execute_delayed_operations($actions_made) { if ($this->flush_operation_requested) { $c = Dispatcher::config(); $api = new Extension_CloudFlare_Api(array('email' => $c->get_string(array('cloudflare', 'email')), 'key' => $c->get_string(array('cloudflare', 'key')), 'zone_id' => $c->get_string(array('cloudflare', 'zone_id')), 'timelimit_api_request' => $c->get_integer(array('cloudflare', 'timelimit.api_request')))); $action_made = array('module' => 'cloudflare'); try { $api->purge(); } catch (\Exception $ex) { $action_made['error'] = 'Failed to purge CloudFlare cache: ' . $ex->getMessage(); } $this->flush_operation_requested = false; $actions_made[] = $action_made; } return $actions_made; }