function w3tc_opcache_flush()
 {
     $core = Dispatcher::component('SystemOpCache_Core');
     $success = $core->flush();
     if ($success) {
         Util_Admin::redirect_with_custom_messages2(array('notes' => array('OPCache was flushed successfully')), true);
     } else {
         Util_Admin::redirect_with_custom_messages2(array('errors' => array('Failed to flush OPCache')), true);
     }
 }
 public function w3tc_cloudflare_save_settings()
 {
     $api = Extension_CloudFlare_SettingsForUi::api();
     $errors = Extension_CloudFlare_SettingsForUi::settings_set($api);
     if (empty($errors)) {
         Util_Admin::redirect_with_custom_messages2(array('notes' => array('cloudflare_save_done' => __('CloudFlare settings are successfully updated.', 'w3-total-cache'))));
     } else {
         Util_Admin::redirect_with_custom_messages2(array('errors' => array('cloudflare_save_error' => __('Failed to update CloudFlare settings:', 'w3-total-cache') . "<br />\n" . implode("<br />\n", $errors))));
     }
 }
 function w3tc_extensions_activate()
 {
     $config = Dispatcher::config();
     $extension = Util_Request::get_string('w3tc_extensions_activate');
     $ext = Extensions_Util::get_extension($config, $extension);
     if (!is_null($ext)) {
         if (Extensions_Util::activate_extension($extension, $config)) {
             Util_Admin::redirect_with_custom_messages2(array('notes' => array(sprintf(__('Extension <strong>%s</strong> has been successfully activated.', 'w3-total-cache'), $ext['name']))));
             return;
         }
     }
     Util_Admin::redirect(array());
 }
 function w3tc_cdn_rackspace_cdn_domains_reload()
 {
     $c = Dispatcher::config();
     $core = Dispatcher::component('Cdn_Core');
     $cdn = $core->get_cdn();
     try {
         // try to obtain CNAMEs
         $domains = $cdn->service_domains_get();
     } catch (\Exception $ex) {
         Util_Admin::redirect_with_custom_messages2(array('errors' => array('Failed to obtain CNAMEs: ' . $ex->getMessage())), true);
         return;
     }
     $c->set('cdn.rackspace_cdn.domains', $domains);
     $c->save();
     Util_Admin::redirect_with_custom_messages2(array('notes' => array('CNAMEs are reloaded successfully')), true);
 }
 function w3tc_cdn_flush()
 {
     $flush = Dispatcher::component('CacheFlush');
     $flush->flush_all(array('only' => 'cdn'));
     $status = $flush->execute_delayed_operations();
     $errors = array();
     foreach ($status as $i) {
         if (isset($i['error'])) {
             $errors[] = $i['error'];
         }
     }
     if (empty($errors)) {
         Util_Admin::redirect(array('w3tc_note' => 'flush_cdn'), true);
     } else {
         Util_Admin::redirect_with_custom_messages2(array('errors' => array('Failed to flush CDN: ' . implode(', ', $errors))), true);
     }
 }
 function w3tc_licensing_reset_rooturi()
 {
     $license_key = $this->_config->get_string('plugin.license_key');
     delete_transient('w3tc_license_status');
     Licensing_Core::activate_license($license_key, W3TC_VERSION);
     $license = Licensing_Core::check_license($license_key, W3TC_VERSION);
     if ($license) {
         $status = $license->license_status;
         if (substr($status . '.', 0, 7) == 'active.') {
             Util_Admin::redirect_with_custom_messages2(array('notes' => array('Your license has been reset already. Activated for this website now.')), true);
         }
     }
     $r = Licensing_Core::reset_rooturi($this->_config->get_string('plugin.license_key'), W3TC_VERSION);
     if (isset($r->status) && $r->status == 'done') {
         Util_Admin::redirect_with_custom_messages2(array('notes' => array('Email with a link for license reset was sent to you')), true);
     } else {
         Util_Admin::redirect_with_custom_messages2(array('errors' => array('Failed to reset license')), true);
     }
 }
 /**
  * save&flush all action
  *
  * @return void
  */
 public function w3tc_default_save_and_flush()
 {
     $redirect_data = $this->_w3tc_save_options_process();
     $f = Dispatcher::component('CacheFlush');
     $f->flush_all();
     $state_note = Dispatcher::config_state_note();
     $state_note->set('common.show_note.flush_statics_needed', false);
     $state_note->set('common.show_note.flush_posts_needed', false);
     $state_note->set('common.show_note.plugins_updated', false);
     $state_note->set('minify.show_note.need_flush', false);
     $state_note->set('objectcache.show_note.flush_needed', false);
     Util_Admin::redirect_with_custom_messages2($redirect_data);
 }