Commit 48f21807 authored by lucha's avatar lucha

removed obsolete wp-super-memcache plugin

parent d646b316
This diff is collapsed.
<?php
# WP SUPER CACHE 1.2
function wpcache_broken_message() {
if ( false == strpos( $_SERVER[ 'REQUEST_URI' ], 'wp-admin' ) )
echo "<!-- WP Super Cache is installed but broken. The constant WPCACHEHOME must be set in the file wp-config.php and point at the WP Super Cache plugin directory. -->";
}
if ( false == defined( 'WPCACHEHOME' ) ) {
define( 'ADVANCEDCACHEPROBLEM', 1 );
} elseif ( !include_once( WPCACHEHOME . 'wp-cache-phase1.php' ) ) {
if ( !@is_file( WPCACHEHOME . 'wp-cache-phase1.php' ) ) {
define( 'ADVANCEDCACHEPROBLEM', 1 );
}
}
if ( defined( 'ADVANCEDCACHEPROBLEM' ) )
register_shutdown_function( 'wpcache_broken_message' );
?>
<?php
/* Taken from OSSDL CDN off-linker, a plugin by W-Mark Kubacki (http://mark.ossdl.de/) and used with permission */
/* Set up some defaults */
if ( get_option( 'ossdl_off_cdn_url' ) == false )
add_option('ossdl_off_cdn_url', get_option('siteurl'));
$ossdl_off_blog_url = get_option('siteurl');
$ossdl_off_cdn_url = trim( get_option('ossdl_off_cdn_url') );
if ( get_option( 'ossdl_off_include_dirs' ) == false )
add_option('ossdl_off_include_dirs', 'wp-content,wp-includes');
$ossdl_off_include_dirs = trim(get_option('ossdl_off_include_dirs'));
if ( get_option( 'ossdl_off_exclude' ) == false )
add_option('ossdl_off_exclude', '.php');
$ossdl_off_exclude = trim(get_option('ossdl_off_exclude'));
$arr_of_excludes = array_map('trim', explode(',', $ossdl_off_exclude));
if ( !is_array( $arr_of_excludes ) )
$arr_of_excludes = array();
if ( get_option( 'ossdl_cname' ) == false )
add_option('ossdl_cname', '');
$ossdl_cname = trim(get_option('ossdl_cname'));
$ossdl_https = trim(get_option('ossdl_https'));
$arr_of_cnames = array_map('trim', explode(',', $ossdl_cname));
if ($arr_of_cnames[0] == '') $arr_of_cnames = array();
/**
* Determines whether to exclude a match.
*
* @param String $match URI to examine
* @param Array $excludes array of "badwords"
* @return Boolean true if to exclude given match from rewriting
*/
function scossdl_off_exclude_match($match, $excludes) {
foreach ($excludes as $badword) {
if (stristr($match, $badword) != false) {
return true;
}
}
return false;
}
/**
* Compute string modulo, based on SHA1 hash
*/
function scossdl_string_mod($s, $mod) {
/* The full SHA1 is too large for PHP integer types. This should be
* enough for our purpose */
$n = hexdec(substr(sha1($s), 0, 5));
return $n % $mod;
}
/**
* Rewriter of URLs, used as replace-callback.
*
* Called by #scossdl_off_filter.
*/
function scossdl_off_rewriter($match) {
global $ossdl_off_blog_url, $ossdl_off_cdn_url, $arr_of_excludes, $arr_of_cnames, $ossdl_https;
if ( $ossdl_off_cdn_url == '' )
return $match[0];
if ( $ossdl_https && substr( $match[0], 0, 5 ) == 'https' )
return $match[0];
if ( false == in_array( $ossdl_off_cdn_url, $arr_of_cnames ) )
$arr_of_cnames[] = $ossdl_off_cdn_url;
if ( scossdl_off_exclude_match( $match[0], $arr_of_excludes ) ) {
return $match[0];
} else {
$include_dirs = scossdl_off_additional_directories();
if ( preg_match( '/' . $include_dirs . '/', $match[0] ) ) {
$offset = scossdl_string_mod($match[1], count($arr_of_cnames));
return str_replace($ossdl_off_blog_url, $arr_of_cnames[$offset], $match[0]);
} else {
return $match[0];
}
}
}
/**
* Creates a regexp compatible pattern from the directories to be included in matching.
*
* @return String with the pattern with {@literal |} as prefix, or empty
*/
function scossdl_off_additional_directories() {
global $ossdl_off_include_dirs;
$input = explode(',', $ossdl_off_include_dirs);
if ($ossdl_off_include_dirs == '' || count($input) < 1) {
return 'wp\-content|wp\-includes';
} else {
return implode('|', array_map('quotemeta', array_map('trim', $input)));
}
}
/**
* Output filter which runs the actual plugin logic.
*/
function scossdl_off_filter($content) {
global $ossdl_off_blog_url, $ossdl_off_cdn_url;
if ($ossdl_off_blog_url == $ossdl_off_cdn_url) { // no rewrite needed
return $content;
} else {
$dirs = scossdl_off_additional_directories();
$regex = '#(?<=[(\"\'])'.quotemeta($ossdl_off_blog_url).'/(?:((?:'.$dirs.')[^\"\')]+)|([^/\"\']+\.[^/\"\')]+))(?=[\"\')])#';
return preg_replace_callback($regex, 'scossdl_off_rewriter', $content);
}
}
/**
* Registers scossdl_off_filter as output buffer, if needed.
*/
function do_scossdl_off_ob_start() {
global $ossdl_off_blog_url, $ossdl_off_cdn_url;
if ($ossdl_off_blog_url != $ossdl_off_cdn_url) {
add_filter( 'wp_cache_ob_callback_filter', 'scossdl_off_filter' );
}
}
if ( false == isset( $ossdlcdn ) )
$ossdlcdn = 1; // have to default to on for existing users.
if ( $ossdlcdn == 1 )
add_action('init', 'do_scossdl_off_ob_start');
function scossdl_off_options() {
global $ossdlcdn, $wp_cache_config_file;
$valid_nonce = isset($_REQUEST['_wpnonce']) ? wp_verify_nonce($_REQUEST['_wpnonce'], 'wp-cache') : false;
if ( $valid_nonce && isset($_POST['action']) && ( $_POST['action'] == 'update_ossdl_off' )){
update_option('ossdl_off_cdn_url', $_POST['ossdl_off_cdn_url']);
update_option('ossdl_off_include_dirs', $_POST['ossdl_off_include_dirs'] == '' ? 'wp-content,wp-includes' : $_POST['ossdl_off_include_dirs']);
update_option('ossdl_off_exclude', $_POST['ossdl_off_exclude']);
update_option('ossdl_cname', $_POST['ossdl_cname']);
update_option('ossdl_https', (int)$_POST['ossdl_https']);
if ( isset( $_POST[ 'ossdlcdn' ] ) ) {
$ossdlcdn = 1;
} else {
$ossdlcdn = 0;
}
wp_cache_replace_line('^ *\$ossdlcdn', "\$ossdlcdn = $ossdlcdn;", $wp_cache_config_file);
}
$example_cdn_uri = str_replace( 'http://', 'http://cdn.', str_replace( 'www.', '', get_option( 'siteurl' ) ) );
$example_cnames = str_replace( 'http://cdn.', 'http://cdn1.', $example_cdn_uri );
$example_cnames .= ',' . str_replace( 'http://cdn.', 'http://cdn2.', $example_cdn_uri );
$example_cnames .= ',' . str_replace( 'http://cdn.', 'http://cdn3.', $example_cdn_uri );
$example_cdn_uri = get_option('ossdl_off_cdn_url') == get_option('siteurl') ? $example_cdn_uri : get_option('ossdl_off_cdn_url');
$example_cdn_uri .= '/wp-includes/js/prototype.js';
?>
<p><?php _e( 'Your website probably uses lots of static files. Image, Javascript and CSS files are usually static files that could just as easily be served from another site or CDN. Therefore this plugin replaces any links in the <code>wp-content</code> and <code>wp-includes</code> directories (except for PHP files) on your site with the URL you provide below. That way you can either copy all the static content to a dedicated host or mirror the files to a CDN by <a href="http://knowledgelayer.softlayer.com/questions/365/How+does+Origin+Pull+work%3F" target="_blank">origin pull</a>.', 'wp-super-cache' ); ?></p>
<p><?php printf( __( 'The <a href="%1$s">CDN Sync Tool</a> plugin will help upload files to Amazon S3/Cloudfront if you would rather not depend on origin pull. See the <a href="%2$s">plugin support forum</a> if you have any queries about this plugin.', 'wp-super-cache' ), 'http://wordpress.org/extend/plugins/cdn-sync-tool/', 'http://wordpress.org/tags/cdn-sync-tool?forum_id=10' ); ?></p>
<p><?php printf( __( '<strong style="color: red">WARNING:</strong> Test some static urls e.g., %s to ensure your CDN service is fully working before saving changes.', 'wp-super-cache' ), '<code>' . $example_cdn_uri . '</code>' ); ?></p>
<p><?php _e( 'You can define different CDN URLs for each site on a multsite network.', 'wp-super-cache' ); ?></p>
<p><form method="post" action="">
<?php wp_nonce_field('wp-cache'); ?>
<table class="form-table"><tbod>
<tr valign="top">
<td style='text-align: right'>
<input id='ossdlcdn' type="checkbox" name="ossdlcdn" value="1" <?php if ( $ossdlcdn ) echo "checked=1"; ?> />
</td>
<th scope="row"><label for="ossdlcdn"><?php _e( 'Enable CDN Support', 'wp-super-cache' ); ?></label></th>
</tr>
<tr valign="top">
<th scope="row"><label for="ossdl_off_cdn_url"><?php _e( 'Off-site URL', 'wp-super-cache' ); ?></label></th>
<td>
<input type="text" name="ossdl_off_cdn_url" value="<?php echo(get_option('ossdl_off_cdn_url')); ?>" size="64" class="regular-text code" /><br />
<span class="description"><?php printf( __( 'The new URL to be used in place of %1$s for rewriting. No trailing <code>/</code> please.<br />Example: <code>%2$s</code>.', 'wp-super-cache' ), get_option( 'siteurl' ), $example_cdn_uri ); ?></span>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="ossdl_off_include_dirs"><?php _e( 'Include directories', 'wp-super-cache' ); ?></label></th>
<td>
<input type="text" name="ossdl_off_include_dirs" value="<?php echo esc_attr( get_option( 'ossdl_off_include_dirs' ) ); ?>" size="64" class="regular-text code" /><br />
<span class="description"><?php _e( 'Directories to include in static file matching. Use a comma as the delimiter. Default is <code>wp-content, wp-includes</code>, which will be enforced if this field is left empty.', 'wp-super-cache' ); ?></span>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="ossdl_off_exclude"><?php _e( 'Exclude if substring', 'wp-super-cache' ); ?></label></th>
<td>
<input type="text" name="ossdl_off_exclude" value="<?php echo esc_attr( get_option( 'ossdl_off_exclude' ) ); ?>" size="64" class="regular-text code" /><br />
<span class="description"><?php _e( 'Excludes something from being rewritten if one of the above strings is found in the match. Use a comma as the delimiter like this, <code>.php, .flv, .do</code>, and always include <code>.php</code> (default).', 'wp-super-cache' ); ?></span>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="ossdl_cname"><?php _e( 'Additional CNAMES', 'wp-super-cache' ); ?></label></th>
<td>
<input type="text" name="ossdl_cname" value="<?php echo esc_attr( get_option( 'ossdl_cname' ) ); ?>" size="64" class="regular-text code" /><br />
<span class="description"><?php printf( __( 'These <a href="http://en.wikipedia.org/wiki/CNAME_record">CNAMES</a> will be used in place of %1$s for rewriting (in addition to the off-site URL above). Use a comma as the delimiter. For pages with a large number of static files, this can improve browser performance. CNAMEs may also need to be configured on your CDN.<br />Example: %2$s', 'wp-super-cache' ), get_option( 'siteurl' ), $example_cnames ); ?></span>
</td>
</tr>
<tr valign="top">
<th scope="row" colspan='2'><label><input type='checkbox' name='ossdl_https' value='1' <?php if ( get_option( 'ossdl_https' ) ) { echo 'checked'; } ?> /> <?php _e( 'Skip https URLs to avoid "mixed content" errors', 'wp-super-cache' ); ?></label></th>
</tr>
</tbody></table>
<input type="hidden" name="action" value="update_ossdl_off" />
<p class="submit"><input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
</form></p>
<p><?php _e( 'CDN functionality provided by <a href="http://wordpress.org/extend/plugins/ossdl-cdn-off-linker/">OSSDL CDN Off Linker</a> by <a href="http://mark.ossdl.de/">Mark Kubacki</a>', 'wp-super-cache' ); ?></p>
<?php
}
?>
<?php
function awaitingmoderation_action( $buffer ) {
$buffer = str_replace( __( 'Your comment is awaiting moderation.' ), '', $buffer );
return $buffer;
}
function awaitingmoderation_actions() {
global $cache_awaitingmoderation;
if( $cache_awaitingmoderation == '1' ) {
add_filter( 'wpsupercache_buffer', 'awaitingmoderation_action' );
}
}
add_cacheaction( 'add_cacheaction', 'awaitingmoderation_actions' );
//Your comment is awaiting moderation.
function wp_supercache_awaitingmoderation_admin() {
global $cache_awaitingmoderation, $wp_cache_config_file, $valid_nonce;
$cache_awaitingmoderation = $cache_awaitingmoderation == '' ? '0' : $cache_awaitingmoderation;
if(isset($_POST['cache_awaitingmoderation']) && $valid_nonce) {
$cache_awaitingmoderation = (int)$_POST['cache_awaitingmoderation'];
wp_cache_replace_line('^ *\$cache_awaitingmoderation', "\$cache_awaitingmoderation = '$cache_awaitingmoderation';", $wp_cache_config_file);
$changed = true;
} else {
$changed = false;
}
$id = 'awaitingmoderation-section';
?>
<fieldset id="<?php echo $id; ?>" class="options">
<h4><?php _e( 'Awaiting Moderation', 'wp-super-cache' ); ?></h4>
<form name="wp_manager" action="<?php echo $_SERVER[ "REQUEST_URI" ]; ?>" method="post">
<label><input type="radio" name="cache_awaitingmoderation" value="1" <?php if( $cache_awaitingmoderation ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
<label><input type="radio" name="cache_awaitingmoderation" value="0" <?php if( !$cache_awaitingmoderation ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
<p><?php _e( 'Enables or disables plugin to Remove the text "Your comment is awaiting moderation." when someone leaves a moderated comment.', 'wp-super-cache' ); ?></p>
<?php
if ($changed) {
if ( $cache_awaitingmoderation )
$status = __( "enabled" );
else
$status = __( "disabled" );
echo "<p><strong>" . sprintf( __( "Awaiting Moderation is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
}
echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
?>
</form>
</fieldset>
<?php
}
add_cacheaction( 'cache_admin_page', 'wp_supercache_awaitingmoderation_admin' );
?>
<?php
function wp_supercache_badbehaviour( $file ) {
global $cache_badbehaviour;
if( $cache_badbehaviour != 1 )
return $file;
wp_supercache_badbehaviour_include();
return $file;
}
add_cacheaction( 'wp_cache_served_cache_file', 'wp_supercache_badbehaviour' );
function wp_supercache_badbehaviour_include() {
$bbfile = get_bb_file_loc();
if( !$bbfile )
require_once( $bbfile );
}
function get_bb_file_loc() {
global $cache_badbehaviour_file;
if( $cache_badbehaviour_file )
return $cache_badbehaviour_file;
if( file_exists( WP_CONTENT_DIR . '/plugins/bad-behavior/bad-behavior-generic.php' ) ) {
$bbfile = WP_CONTENT_DIR . '/plugins/bad-behavior/bad-behavior-generic.php';
} elseif( file_exists( WP_CONTENT_DIR . '/plugins/Bad-Behavior/bad-behavior-generic.php' ) ) {
$bbfile = WP_CONTENT_DIR . '/plugins/Bad-Behavior/bad-behavior-generic.php';
} else {
$bbfile = false;
}
return $bbfile;
}
function wp_supercache_badbehaviour_admin() {
global $cache_badbehaviour, $wp_cache_config_file, $valid_nonce;
$cache_badbehaviour = $cache_badbehaviour == '' ? 0 : $cache_badbehaviour;
if ( $cache_badbehaviour == 'no' )
$cache_badbehaviour = 0;
$err = false;
if ( isset( $_POST['cache_badbehaviour'] ) && $valid_nonce ) {
$bbfile = get_bb_file_loc();
if( !$bbfile ) {
$_POST[ 'cache_badbehaviour' ] = 0;
$err = __( 'Bad Behaviour not found. Please check your install.', 'wp-super-cache' );
}
if ( $cache_badbehaviour == (int)$_POST['cache_badbehaviour'] ) {
$changed = false;
} else {
$changed = true;
}
$cache_badbehaviour = (int)$_POST['cache_badbehaviour'];
wp_cache_replace_line('^ *\$cache_compression', "\$cache_compression = 0;", $wp_cache_config_file);
wp_cache_replace_line('^ *\$cache_badbehaviour', "\$cache_badbehaviour = $cache_badbehaviour;", $wp_cache_config_file);
wp_cache_replace_line('^ *\$cache_badbehaviour_file', "\$cache_badbehaviour_file = '$bbfile';", $wp_cache_config_file);
$changed = true;
}
$id = 'badbehavior-section';
?>
<fieldset id="<?php echo $id; ?>" class="options">
<h4><?php _e( 'Bad Behavior', 'wp-super-cache' ); ?></h4>
<form name="wp_manager" action="<?php echo $_SERVER[ "REQUEST_URI" ]; ?>" method="post">
<label><input type="radio" name="cache_badbehaviour" value="1" <?php if( $cache_badbehaviour ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
<label><input type="radio" name="cache_badbehaviour" value="0" <?php if( !$cache_badbehaviour ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
<p><?php _e( '', 'wp-super-cache' ); ?></p><?php
echo '<p>' . sprintf( __( '(Only legacy caching supported, disabled compression and requires <a href="http://www.bad-behavior.ioerror.us/">Bad Behavior</a> in "%s/plugins/bad-behavior/") ', 'wp-super-cache' ), WP_CONTENT_DIR ) . '</p>';
if ( isset( $changed ) && $changed ) {
if ( $cache_badbehaviour )
$status = __( "enabled" );
else
$status = __( "disabled" );
echo "<p><strong>" . sprintf( __( "Bad Behavior support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
}
echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
?>
</form>
</fieldset>
<?php
if( $err )
echo "<p><strong>" . __( 'Warning!', 'wp-super-cache' ) . "</strong> $err</p>";
}
add_cacheaction( 'cache_admin_page', 'wp_supercache_badbehaviour_admin' );
?>
<?php
function domain_mapping_gc_cache( $function, $directory ) {
global $cache_path;
if ( !function_exists( 'domain_mapping_warning' ) )
return false;
$siteurl = domain_mapping_siteurl( false );
if ( !$siteurl )
return false;
$protocol = ( 'on' == strtolower( $_SERVER['HTTPS' ] ) ) ? 'https://' : 'http://';
$siteurl = trailingslashit( str_replace( $protocol, '', $siteurl ) );
if ( $directory == 'homepage' )
$directory = '';
switch( $function ) {
case "rebuild":
@wp_cache_rebuild_or_delete( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html' );
@wp_cache_rebuild_or_delete( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html.gz' );
break;
case "prune":
prune_super_cache( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html', true, true );
prune_super_cache( $cache_path . 'supercache/' . $siteurl . $directory . 'index.html.gz', true, true );
break;
}
return $directory;
}
function domain_mapping_supercachedir( $dir ) {
global $cache_path;
if ( !function_exists( 'domain_mapping_warning' ) )
return $dir;
$siteurl = domain_mapping_siteurl( false );
if ( !$siteurl )
return $dir;
$protocol = ( 'on' == strtolower( $_SERVER['HTTPS' ] ) ) ? 'https://' : 'http://';
$siteurl = str_replace( $protocol, '', $siteurl );
return $cache_path . 'supercache/' . $siteurl;
}
function domain_mapping_actions() {
global $cache_domain_mapping;
if( $cache_domain_mapping == '1' ) {
add_filter( 'wp_super_cache_supercachedir', 'domain_mapping_supercachedir' );
add_action( 'gc_cache', 'domain_mapping_gc_cache', 10, 2 );
}
}
add_cacheaction( 'add_cacheaction', 'domain_mapping_actions' );
function wp_supercache_domain_mapping_admin() {
global $cache_domain_mapping, $wp_cache_config_file, $valid_nonce;
$cache_domain_mapping = $cache_domain_mapping == '' ? '0' : $cache_domain_mapping;
if(isset($_POST['cache_domain_mapping']) && $valid_nonce) {
if ( $cache_domain_mapping == (int)$_POST['cache_domain_mapping'] ) {
$changed = false;
} else {
$changed = true;
}
$cache_domain_mapping = (int)$_POST['cache_domain_mapping'];
wp_cache_replace_line('^ *\$cache_domain_mapping', "\$cache_domain_mapping = '$cache_domain_mapping';", $wp_cache_config_file);
}
$id = 'domain_mapping-section';
?>
<fieldset id="<?php echo $id; ?>" class="options">
<h4><?php _e( 'Domain Mapping', 'wp-super-cache' ); ?></h4>
<form name="wp_manager" action="<?php echo $_SERVER[ "REQUEST_URI" ]; ?>" method="post">
<label><input type="radio" name="cache_domain_mapping" value="1" <?php if( $cache_domain_mapping ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
<label><input type="radio" name="cache_domain_mapping" value="0" <?php if( !$cache_domain_mapping ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
<p><?php _e( '', 'wp-super-cache' ); ?></p><?php
echo '<p>' . __( 'Provides support for <a href="http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/">Domain Mapping</a> plugin to map multiple domains to a blog.', 'wp-super-cache' ) . '</p>';
if ( isset( $changed ) && $changed ) {
if ( $cache_domain_mapping )
$status = __( "enabled" );
else
$status = __( "disabled" );
echo "<p><strong>" . sprintf( __( "Domain Mapping support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
}
echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
?>
</form>
</fieldset>
<?php
}
add_cacheaction( 'cache_admin_page', 'wp_supercache_domain_mapping_admin' );
function wp_supercache_domain_mapping_notice() {
global $cache_enabled, $cache_domain_mapping;
if( $cache_enabled )
echo '<div class="error"><p><strong>' . __('Domain Mapping plugin detected! Please go to the Supercache plugins page and enable the domain mapping helper plugin.', 'wp-super-cache' ) . '</strong></p></div>';
}
function wp_supercache_domain_mapping_exists() {
global $cache_domain_mapping;
if ( $cache_domain_mapping == 1 )
return false;
if ( is_admin() && function_exists( 'domain_mapping_warning' ) )
add_action( 'admin_notices', 'wp_supercache_domain_mapping_notice' );
}
if ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'wpsupercache' ) {
add_cacheaction( 'add_cacheaction', 'wp_supercache_domain_mapping_exists' );
}
?>
<?php
if ( defined( 'WP_ALLOW_MULTISITE' ) )
add_cacheaction( 'add_cacheaction', 'wp_super_cache_multisite_init' );
function wp_super_cache_multisite_init() {
add_filter( 'wpmu_blogs_columns', 'wp_super_cache_blogs_col' );
add_action( 'manage_sites_custom_column', 'wp_super_cache_blogs_field', 10, 2 );
add_action( 'init', 'wp_super_cache_override_on_flag' );
}
function wp_super_cache_blogs_col( $col ) {
$col[ 'wp_super_cache' ] = __( 'Cached', 'wp-super-cache' );
return $col;
}
function wp_super_cache_blogs_field( $name, $blog_id ) {
if ( $name != 'wp_super_cache' )
return false;
if ( isset( $_GET[ 'id' ] ) && $blog_id == $_GET[ 'id' ] ) {
$valid_nonce = isset( $_GET[ '_wpnonce' ] ) ? wp_verify_nonce( $_GET[ '_wpnonce' ], 'wp-cache' . $_GET[ 'id' ] ) : false;
if ( $valid_nonce && isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'disable_cache' ) {
add_blog_option( $_GET[ 'id' ], 'wp_super_cache_disabled', 1 );
} elseif ( $valid_nonce && isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'enable_cache' ) {
delete_blog_option( $_GET[ 'id' ], 'wp_super_cache_disabled' );
}
}
if ( get_blog_option( $blog_id, 'wp_super_cache_disabled' ) == 1 ) {
echo "<a href='" . wp_nonce_url( add_query_arg( array( 'action' => 'enable_cache', 'id' => $blog_id ) ), 'wp-cache' . $blog_id ) . "'>" . __( 'Enable', 'wp-super-cache' ) . "</a>";
} else {
echo "<a href='" . wp_nonce_url( add_query_arg( array( 'action' => 'disable_cache', 'id' => $blog_id ) ), 'wp-cache' . $blog_id ) . "'>" . __( 'Disable', 'wp-super-cache' ) . "</a>";
}
}
function wp_super_cache_multisite_notice() {
if ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'wpsupercache' )
echo '<div class="error"><p><strong>' . __( 'Caching has been disabled on this blog on the Network Admin Sites page.', 'wp-super-cache' ) . '</strong></p></div>';
}
function wp_super_cache_override_on_flag() {
global $cache_enabled, $super_cache_enabled;
if ( $cache_enabled != true )
return false;