forked from crowdfavorite-mirrors/wp-w3-total-cache
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add 0.9.4 from http://plugins.svn.wordpress.org/w3-total-cache/tags/0…
- Loading branch information
Showing
385 changed files
with
83,645 additions
and
64,659 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?php | ||
|
||
/** | ||
* W3 ObjectCache plugin | ||
*/ | ||
if (!defined('W3TC')) { | ||
die(); | ||
} | ||
define('W3TC_MARKER_BEGIN_CLOUDFLARE', '# BEGIN W3TC CloudFlare'); | ||
define('W3TC_MARKER_END_CLOUDFLARE', '# END W3TC CloudFlare'); | ||
|
||
w3_require_once(W3TC_LIB_W3_DIR . '/Plugin.php'); | ||
|
||
/** | ||
* Class W3_Plugin_CloudFlare | ||
*/ | ||
class W3_Plugin_CloudFlare extends W3_Plugin{ | ||
/** | ||
* @var CloudFlareAPI $cf | ||
*/ | ||
private $cf; | ||
|
||
/** | ||
* Runs plugin | ||
*/ | ||
function run() { | ||
w3_require_once(W3TC_CORE_EXTENSION_DIR. '/CloudFlare/CloudFlareAPI.php'); | ||
$this->cf = new CloudFlareAPI(); | ||
add_action('wp_set_comment_status', array($this, 'set_comment_status'), 1, 2); | ||
add_action('w3tc_flush_all', array($this, 'flush_all')); | ||
$this->cf->fix_remote_addr(); | ||
} | ||
|
||
public function flush_all() { | ||
$this->flush_cloudflare(); | ||
} | ||
|
||
/** | ||
* @param $id | ||
* @param $status | ||
*/ | ||
function set_comment_status($id, $status) { | ||
$this->cf->report_if_spam($id, $status); | ||
} | ||
|
||
/** | ||
* @param $state | ||
* @return bool | ||
*/ | ||
public function send_minify_headers($state) { | ||
/** | ||
* @var W3_Config $config | ||
*/ | ||
$config = w3_instance('W3_Config'); | ||
return ($config->get_boolean('cloudflare.enabled') && !$this->cf->minify_enabled()); | ||
} | ||
|
||
|
||
/** | ||
* Purge the CloudFlare cache | ||
* @return void | ||
*/ | ||
function flush_cloudflare() { | ||
$response = null; | ||
|
||
w3_require_once(W3TC_LIB_W3_DIR . '/Request.php'); | ||
|
||
$email = $this->_config->get_string('email'); | ||
$key = $this->_config->get_string('key'); | ||
$zone = $this->_config->get_string('zone'); | ||
|
||
|
||
if ($email && $key && $zone) { | ||
$config = array( | ||
'email' => $email, | ||
'key' => $key, | ||
'zone' => $zone | ||
); | ||
|
||
w3_require_once(W3TC_CORE_EXTENSION_DIR . '/CloudFlare/CloudFlareAPI.php'); | ||
@$cloudflareAPI = new CloudFlareAPI($config); | ||
$cloudflareAPI->purge(); | ||
} | ||
} | ||
|
||
public function menu_bar($menu_items) { | ||
$menu_items = array_merge($menu_items, array( | ||
array( | ||
'id' => 'cloudflare', | ||
'title' => __('CloudFlare', 'w3-total-cache'), | ||
'href' => 'https://www.cloudflare.com' | ||
), | ||
array( | ||
'id' => 'cloudflare-my-websites', | ||
'parent' => 'cloudflare', | ||
'title' => __('My Websites', 'w3-total-cache'), | ||
'href' => 'https://www.cloudflare.com/my-websites.html' | ||
), | ||
array( | ||
'id' => 'cloudflare-analytics', | ||
'parent' => 'cloudflare', | ||
'title' => __('Analytics', 'w3-total-cache'), | ||
'href' => 'https://www.cloudflare.com/analytics.html' | ||
), | ||
array( | ||
'id' => 'cloudflare-account', | ||
'parent' => 'cloudflare', | ||
'title' => __('Account', 'w3-total-cache'), | ||
'href' => 'https://www.cloudflare.com/my-account.html' | ||
) | ||
)); | ||
return $menu_items; | ||
} | ||
} |
Oops, something went wrong.