Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mospaw committed Apr 15, 2014
1 parent 7237dd5 commit 81c0a6d
Show file tree
Hide file tree
Showing 385 changed files with 83,645 additions and 64,659 deletions.
601 changes: 601 additions & 0 deletions changelog.txt

Large diffs are not rendered by default.

1,908 changes: 1,908 additions & 0 deletions configs/0.9.2.10-ConfigKeys.php

Large diffs are not rendered by default.

1,912 changes: 1,912 additions & 0 deletions configs/0.9.2.11-ConfigKeys.php

Large diffs are not rendered by default.

1,860 changes: 1,860 additions & 0 deletions configs/0.9.2.6-ConfigKeys.php

Large diffs are not rendered by default.

1,860 changes: 1,860 additions & 0 deletions configs/0.9.2.7-ConfigKeys.php

Large diffs are not rendered by default.

1,860 changes: 1,860 additions & 0 deletions configs/0.9.2.8-ConfigKeys.php

Large diffs are not rendered by default.

1,860 changes: 1,860 additions & 0 deletions configs/0.9.2.9-ConfigKeys.php

Large diffs are not rendered by default.

1,983 changes: 1,983 additions & 0 deletions configs/0.9.3-ConfigKeys.php

Large diffs are not rendered by default.

114 changes: 114 additions & 0 deletions extensions/CloudFlare.php
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;
}
}
Loading

0 comments on commit 81c0a6d

Please sign in to comment.