5fbcf025 by Jeff Balicki

t

1 parent 881df4ef
Showing 68 changed files with 2401 additions and 0 deletions
<?php
// WP SUPER CACHE 1.2
function wpcache_broken_message() {
global $wp_cache_config_file;
if ( isset( $wp_cache_config_file ) == false ) {
return '';
}
$doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
$xmlrpc_request = defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST;
$rest_request = defined( 'REST_REQUEST' ) && REST_REQUEST;
$robots_request = strpos( $_SERVER['REQUEST_URI'], 'robots.txt' ) != false;
$skip_output = ( $doing_ajax || $xmlrpc_request || $rest_request || $robots_request );
if ( false == strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) && ! $skip_output ) {
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' );
}
This diff could not be displayed because it is too large.
<?php
extract( wpsc_update_debug_settings() ); // $wp_super_cache_debug, $wp_cache_debug_log, $wp_cache_debug_ip, $wp_super_cache_comments, $wp_super_cache_front_page_check, $wp_super_cache_front_page_clear, $wp_super_cache_front_page_text, $wp_super_cache_front_page_notification, $wp_super_cache_advanced_debug, $wp_cache_debug_username
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
echo '<a name="debug"></a>';
echo '<fieldset class="options">';
echo '<p>' . __( 'Fix problems with the plugin by debugging it here. It will log to a file in your cache directory.', 'wp-super-cache' ) . '</p>';
if ( ! isset( $wp_cache_debug_log ) || $wp_cache_debug_log == '' ) {
extract( wpsc_create_debug_log() ); // $wp_cache_debug_log, $wp_cache_debug_username
}
$log_file_link = "<a href='" . site_url( str_replace( ABSPATH, '', "{$cache_path}view_{$wp_cache_debug_log}?wp-admin=1&wp-json=1&filter=" ) ) . "'>$wp_cache_debug_log</a>";
if ( $wp_super_cache_debug == 1 ) {
echo "<p>" . sprintf( __( 'Currently logging to: %s', 'wp-super-cache' ), $log_file_link ) . "</p>";
} else {
echo "<p>" . sprintf( __( 'Last Logged to: %s', 'wp-super-cache' ), $log_file_link ) . "</p>";
}
echo "<p>" . sprintf( __( 'Username/Password: %s', 'wp-super-cache' ), $wp_cache_debug_username ) . "</p>";
echo '<form name="wpsc_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'debug', $admin_url ) ) . '" method="post">';
wp_nonce_field('wp-cache');
echo "<input type='hidden' name='wpsc_delete_log' value='1' />";
submit_button( __( 'Delete', 'wp-super-cache' ), 'delete', 'wpsc_delete_log_form', false );
echo "</form>";
echo '<form name="wpsc_delete" action="' . esc_url_raw( add_query_arg( 'tab', 'debug', $admin_url ) ) . '" method="post">';
if ( ! isset( $wp_super_cache_debug ) || $wp_super_cache_debug == 0 ) {
$debug_status_message = __( 'Enable Logging', 'wp-super-cache' );
$not_status = 1;
} else {
$debug_status_message = __( 'Disable Logging', 'wp-super-cache' );
$not_status = 0;
}
echo "<input type='hidden' name='wp_super_cache_debug' value='" . $not_status . "' />";
wp_nonce_field('wp-cache');
submit_button( $debug_status_message, 'primary', 'wpsc_log_status', true );
echo "</form>";
echo '<form name="wp_cache_debug" action="' . esc_url_raw( add_query_arg( 'tab', 'debug', $admin_url ) ) . '" method="post">';
echo "<input type='hidden' name='wp_cache_debug' value='1' /><br />";
echo "<table class='form-table'>";
echo "<tr><th>" . __( 'IP Address', 'wp-super-cache' ) . "</th><td> <input type='text' size='20' name='wp_cache_debug_ip' value='{$wp_cache_debug_ip}' /> " . sprintf( __( '(only log requests from this IP address. Your IP is %s)', 'wp-super-cache' ), $_SERVER[ 'REMOTE_ADDR' ] ) . "</td></tr>";
echo "<tr><th valign='top'>" . __( 'Cache Status Messages', 'wp-super-cache' ) . "</th><td><input type='checkbox' name='wp_super_cache_comments' value='1' " . checked( 1, $wp_super_cache_comments, false ) . " /> " . __( 'enabled', 'wp-super-cache' ) . "<br />";
echo __( 'Display comments at the end of every page like this:', 'wp-super-cache' ) . "<br />";
echo "<pre>&lt;!-- Dynamic page generated in 0.450 seconds. -->
&lt;!-- Cached page generated by WP-Super-Cache on " . date( "Y-m-d H:i:s", time() ) . " -->
&lt;!-- super cache --></pre></td></tr>";
echo "</table>\n";
if ( isset( $wp_super_cache_advanced_debug ) ) {
echo "<h5>" . __( 'Advanced', 'wp-super-cache' ) . "</h5><p>" . __( 'In very rare cases two problems may arise on some blogs:<ol><li> The front page may start downloading as a zip file.</li><li> The wrong page is occasionally cached as the front page if your blog uses a static front page and the permalink structure is <em>/%category%/%postname%/</em>.</li></ol>', 'wp-super-cache' ) . '</p>';
echo "<p>" . __( 'I&#8217;m 99% certain that they aren&#8217;t bugs in WP Super Cache and they only happen in very rare cases but you can run a simple check once every 5 minutes to verify that your site is ok if you&#8217;re worried. You will be emailed if there is a problem.', 'wp-super-cache' ) . "</p>";
echo "<table class='form-table'>";
echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_check' value='1' " . checked( 1, $wp_super_cache_front_page_check, false ) . " /> " . __( 'Check front page every 5 minutes.', 'wp-super-cache' ) . "</td></tr>";
echo "<tr><td valign='top'>" . __( 'Front page text', 'wp-super-cache' ) . "</td><td> <input type='text' size='30' name='wp_super_cache_front_page_text' value='{$wp_super_cache_front_page_text}' /> (" . __( 'Text to search for on your front page. If this text is missing, the cache will be cleared. Leave blank to disable.', 'wp-super-cache' ) . ")</td></tr>";
echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_clear' value='1' " . checked( 1, $wp_super_cache_front_page_clear, false ) . " /> " . __( 'Clear cache on error.', 'wp-super-cache' ) . "</td></tr>";
echo "<tr><td valign='top' colspan='2'><input type='checkbox' name='wp_super_cache_front_page_notification' value='1' " . checked( 1, $wp_super_cache_front_page_notification, false ) . " /> " . __( 'Email the blog admin when checks are made. (useful for testing)', 'wp-super-cache' ) . "</td></tr>";
echo "</table>\n";
}
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save Settings', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
echo "</form>\n";
echo '</fieldset>';
<a name='lockdown'></a>
<fieldset class="options">
<h4><?php _e( 'Lock Down:', 'wp-super-cache' ); ?> <?php echo $wp_lock_down == '0' ? '<span style="color:red">' . __( 'Disabled', 'wp-super-cache' ) . '</span>' : '<span style="color:green">' . __( 'Enabled', 'wp-super-cache' ) . '</span>'; ?></h4>
<p><?php _e( 'Prepare your server for an expected spike in traffic by enabling the lock down. When this is enabled, new comments on a post will not refresh the cached static files.', 'wp-super-cache' ); ?></p>
<p><?php _e( 'Developers: Make your plugin lock down compatible by checking the "WPLOCKDOWN" constant. The following code will make sure your plugin respects the WPLOCKDOWN setting.', 'wp-super-cache' ); ?>
<blockquote><code>if( defined( 'WPLOCKDOWN' ) && constant( 'WPLOCKDOWN' ) ) {
&nbsp;&nbsp;&nbsp;&nbsp;echo "<?php _e( 'Sorry. My blog is locked down. Updates will appear shortly', 'wp-super-cache' ); ?>";
}</code></blockquote>
<?php
if( $wp_lock_down == '1' ) {
?><p><?php _e( 'WordPress is locked down. Super Cache static files will not be deleted when new comments are made.', 'wp-super-cache' ); ?></p><?php
} else {
?><p><?php _e( 'WordPress is not locked down. New comments will refresh Super Cache static files as normal.', 'wp-super-cache' ); ?></p><?php
}
$new_lockdown = $wp_lock_down == '1' ? '0' : '1';
$new_lockdown_desc = $wp_lock_down == '1' ? __( 'Disable', 'wp-super-cache' ) : __( 'Enable', 'wp-super-cache' );
echo '<form name="wp_lock_down" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#lockdown' ) . '" method="post">';
echo "<input type='hidden' name='wp_lock_down' value='{$new_lockdown}' />";
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . ' value="' . esc_attr( $new_lockdown_desc . ' ' . __( 'Lock Down', 'wp-super-cache' ) ) . '" /></div>';
wp_nonce_field( 'wp-cache' );
echo '</form>';
?></fieldset><?php
if( $cache_enabled == true && $super_cache_enabled == true ) {
?><a name='direct'></a>
<fieldset class="options">
<h4><?php _e( 'Directly Cached Files', 'wp-super-cache' ); ?></h4><?php
$cached_direct_pages = wpsc_update_direct_pages();
$readonly = '';
if( !is_writeable_ACLSafe( ABSPATH ) ) {
$readonly = 'READONLY';
?><p style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><strong><?php _e( 'Warning!', 'wp-super-cache' ); ?></strong> <?php printf( __( 'You must make %s writable to enable this feature. As this is a security risk, please make it read-only after your page is generated.', 'wp-super-cache' ), ABSPATH ); ?></p><?php
} else {
$abspath_stat = stat(ABSPATH . '/');
$abspath_mode = decoct( $abspath_stat[ 'mode' ] & 0777 );
if ( substr( $abspath_mode, -2 ) == '77' ) {
?><p style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><strong><?php _e( 'Warning!', 'wp-super-cache' ); ?></strong> <?php printf( __( '%s is writable. Please make it readonly after your page is generated as this is a security risk.', 'wp-super-cache' ), ABSPATH ); ?></p><?php
}
}
echo '<form name="direct_page" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#direct' ) . '" method="post">';
if( is_array( $cached_direct_pages ) ) {
$out = '';
foreach( $cached_direct_pages as $page ) {
if( $page == '' )
continue;
$generated = '';
if( is_file( ABSPATH . $page . '/index.html' ) )
$generated = '<input class="button-secondary" type="Submit" name="deletepage" value="' . $page . '">';
$out .= "<tr><td><input type='text' $readonly name='direct_pages[]' size='30' value='$page' /></td><td>$generated</td></tr>";
}
if( $out != '' ) {
?><table><tr><th><?php _e( 'Existing direct page', 'wp-super-cache' ); ?></th><th><?php _e( 'Delete cached file', 'wp-super-cache' ); ?></th></tr><?php
echo "$out</table>";
}
}
if ( 'READONLY' !== $readonly ) {
echo esc_html__( 'Add direct page:', 'wp-super-cache' ) . '<input type="text" name="new_direct_page" size="30" value="" />';
}
echo '<p>' . sprintf(
esc_html__( 'Directly cached files are files created directly off %s where your blog lives. This feature is only useful if you are expecting a major Digg or Slashdot level of traffic to one post or page.', 'wp-super-cache' ),
esc_attr( ABSPATH )
) . '</p>';
if ( 'READONLY' !== $readonly ) {
echo '<p>' . sprintf( __( 'For example: to cache <em>%1$sabout/</em>, you would enter %1$sabout/ or /about/. The cached file will be generated the next time an anonymous user visits that page.', 'wp-super-cache' ),
esc_attr( trailingslashit( get_option( 'home' ) ) )
) . '</p>';
echo '<p>' . esc_html__( 'Make the textbox blank to remove it from the list of direct pages and delete the cached file.', 'wp-super-cache' ) . '</p>';
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . ' value="' . esc_attr__( 'Update Direct Pages', 'wp-super-cache' ) . '" /></div>';
}
wp_nonce_field( 'wp-cache' );
echo '</form>';
?>
</fieldset>
<?php
} // if $super_cache_enabled
<?php
echo '<a name="preload"></a>';
if ( ! $cache_enabled || ! $super_cache_enabled || true === defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
echo '<div class="notice notice-warning"><p>' . __( 'Preloading of cache disabled. Please make sure simple or expert mode is enabled or talk to your host administrator.', 'wp-super-cache' ) . '</p></div>';
return;
}
$count = wpsc_post_count();
if ( $count > 1000 ) {
$min_refresh_interval = 720;
} else {
$min_refresh_interval = 30;
}
echo '<p>' . __( 'This will cache every published post and page on your site. It will create supercache static files so unknown visitors (including bots) will hit a cached page. This will probably help your Google ranking as they are using speed as a metric when judging websites now.', 'wp-super-cache' ) . '</p>';
echo '<p>' . __( 'Preloading creates lots of files however. Caching is done from the newest post to the oldest so please consider only caching the newest if you have lots (10,000+) of posts. This is especially important on shared hosting.', 'wp-super-cache' ) . '</p>';
echo '<p>' . __( 'In &#8217;Preload Mode&#8217; regular garbage collection will be disabled so that old cache files are not deleted. This is a recommended setting when the cache is preloaded.', 'wp-super-cache' ) . '</p>';
echo '<form name="cache_filler" action="' . esc_url_raw( add_query_arg( 'tab', 'preload', $admin_url ) ) . '" method="POST">';
echo '<input type="hidden" name="action" value="preload" />';
echo '<input type="hidden" name="page" value="wpsupercache" />';
echo '<p>' . sprintf( __( 'Refresh preloaded cache files every %s minutes. (0 to disable, minimum %d minutes.)', 'wp-super-cache' ), "<input type='text' size=4 name='wp_cache_preload_interval' value='" . (int) $wp_cache_preload_interval . "' />", $min_refresh_interval ) . '</p>';
if ( $count > 100 ) {
$step = (int)( $count / 10 );
$select = "<select name='wp_cache_preload_posts' size=1>";
$select .= "<option value='all' ";
if ( ! isset( $wp_cache_preload_posts ) || $wp_cache_preload_posts == 'all' ) {
$checked = 'selectect=1 ';
$best = 'all';
} else {
$checked = ' ';
$best = $wp_cache_preload_posts;
}
$select .= "{$checked}>" . __( 'all', 'wp-super-cache' ) . "</option>";
for( $c = $step; $c < $count; $c += $step ) {
$checked = ' ';
if ( $best == $c )
$checked = 'selected=1 ';
$select .= "<option value='$c'{$checked}>$c</option>";
}
$checked = ' ';
if ( $best == $count )
$checked = 'selected=1 ';
$select .= "<option value='$count'{$checked}>$count</option>";
$select .= "</select>";
echo '<p>' . sprintf( __( 'Preload %s posts.', 'wp-super-cache' ), $select ) . '</p>';
} else {
echo '<input type="hidden" name="wp_cache_preload_posts" value="' . $count . '" />';
}
echo '<input type="checkbox" name="wp_cache_preload_on" value="1" ';
echo $wp_cache_preload_on == 1 ? 'checked=1' : '';
echo ' /> ' . __( 'Preload mode (garbage collection disabled. Recommended.)', 'wp-super-cache' ) . '<br />';
echo '<input type="checkbox" name="wp_cache_preload_taxonomies" value="1" ';
echo $wp_cache_preload_taxonomies == 1 ? 'checked=1' : '';
echo ' /> ' . __( 'Preload tags, categories and other taxonomies.', 'wp-super-cache' ) . '<br />';
echo __( 'Send me status emails when files are refreshed.', 'wp-super-cache' ) . '<br />';
if ( !isset( $wp_cache_preload_email_volume ) )
$wp_cache_preload_email_volume = 'none';
echo '<select type="select" name="wp_cache_preload_email_volume">';
echo '<option value="none" '. selected( 'none', $wp_cache_preload_email_volume ) . '>'. __( 'No Emails', 'wp-super-cache' ) . '</option>';
echo '<option value="many" '. selected( 'many', $wp_cache_preload_email_volume ) . '>'. __( 'Many emails, 2 emails per 100 posts.', 'wp-super-cache' ) . '</option>';
echo '<option value="medium" '. selected( 'medium', $wp_cache_preload_email_volume ) . '>'. __( 'Medium, 1 email per 100 posts.', 'wp-super-cache' ) . '</option>';
echo '<option value="less" '. selected( 'less', $wp_cache_preload_email_volume ) . '>'. __( 'Less emails, 1 at the start and 1 at the end of preloading all posts.', 'wp-super-cache' ) . '</option>';
echo "</select>";
if ( wp_next_scheduled( 'wp_cache_preload_hook' ) || wp_next_scheduled( 'wp_cache_full_preload_hook' ) ) {
$currently_preloading = true;
}
echo '<div class="submit"><input class="button-primary" type="submit" name="preload" value="' . __( 'Save Settings', 'wp-super-cache' ) . '" />';
echo '</div>';
wp_nonce_field( 'wp-cache' );
echo '</form>';
echo '<form name="do_preload" action="' . esc_url_raw( add_query_arg( 'tab', 'preload', $admin_url ) ) . '" method="POST">';
echo '<input type="hidden" name="action" value="preload" />';
echo '<input type="hidden" name="page" value="wpsupercache" />';
echo '<div class="submit">';
if ( false == $currently_preloading ) {
echo '<input class="button-primary" type="submit" name="preload_now" value="' . __( 'Preload Cache Now', 'wp-super-cache' ) . '" />';
} else {
echo '<input class="button-primary" type="submit" name="preload_off" value="' . __( 'Cancel Cache Preload', 'wp-super-cache' ) . '" />';
}
echo '</div>';
wp_nonce_field( 'wp-cache' );
echo '</form>';
<?php
echo '<a name="useragents"></a><fieldset class="options"><h4>' . __( 'Rejected User Agents', 'wp-super-cache' ) . '</h4>';
echo "<p>" . __( 'Strings in the HTTP &#8217;User Agent&#8217; header that prevent WP-Cache from caching bot, spiders, and crawlers&#8217; requests. Note that super cached files are still sent to these agents if they already exists.', 'wp-super-cache' ) . "</p>\n";
echo '<form name="wp_edit_rejected_user_agent" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#useragents' ) . '" method="post">';
echo '<textarea name="wp_rejected_user_agent" cols="40" rows="4" style="width: 50%; font-size: 12px;" class="code">';
foreach( $cache_rejected_user_agent as $ua ) {
echo esc_html( $ua ) . "\n";
}
echo '</textarea> ';
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save UA Strings', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
echo '</form>';
echo "</fieldset>\n";
<?php
echo '<fieldset class="options"><h4>' . __( 'Fix Configuration', 'wp-super-cache' ) . '</h4>';
echo '<form name="wp_restore" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#top' ) . '" method="post">';
echo '<input type="hidden" name="wp_restore_config" />';
echo '<div class="submit"><input class="button-secondary" type="submit" ' . SUBMITDISABLED . 'id="deletepost" value="' . __( 'Restore Default Configuration', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
echo "</form>\n";
echo '</fieldset>';
<?php
echo '<a name="trackingparameters"></a><fieldset class="options"><h4>' . __( 'Tracking Parameters', 'wp-super-cache' ) . '</h4>';
echo '<form name="edit_tracking_parameters" action="' . esc_url_raw( add_query_arg( 'tab', 'settings', $admin_url ) . '#trackingparameters' ) . '" method="post">';
echo "<p>" . __( 'Tracking parameters to ignore when caching. Visitors from Facebook, Twitter and elsewhere to your website will go to a URL with tracking parameters added. This setting allows the plugin to ignore those parameters and show an already cached page. Any actual tracking by Google Analytics or other Javascript based code should still work as the URL of the page is not modified.', 'wp-super-cache' ) . "</p>\n";
echo '<textarea name="tracking_parameters" cols="20" rows="10" style="width: 50%; font-size: 12px;" class="code">';
foreach ( $wpsc_tracking_parameters as $parameter) {
echo esc_html( $parameter ) . "\n";
}
echo '</textarea> ';
echo "<p><label><input type='checkbox' name='wpsc_ignore_tracking_parameters' value='1' " . checked( 1, $wpsc_ignore_tracking_parameters, false ) . " /> " . __( 'Enable', 'wp-super-cache' ) . "</label></p>";
echo '<div class="submit"><input class="button-primary" type="submit" ' . SUBMITDISABLED . 'value="' . __( 'Save', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
echo "</form>\n";
<?php
function awaitingmoderation_action( $buffer ) {
$buffer = str_replace( __( 'Your comment is awaiting moderation.', 'wp-super-cache' ), '', $buffer );
return $buffer;
}
function awaitingmoderation_actions() {
global $cache_awaitingmoderation;
if ( '1' === $cache_awaitingmoderation ) {
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="" 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', 'wp-super-cache' );
} else {
$status = __( 'disabled', 'wp-super-cache' );
}
echo '<p><strong>' . sprintf( __( 'Awaiting Moderation is now %s', 'wp-super-cache' ), $status ) . '</strong></p>';
}
echo '<div class="submit"><input class="button-primary" ' . 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' );
function wpsc_awaiting_moderation_list( $list ) {
$list['awaitingmoderation'] = array(
'key' => 'awaitingmoderation',
'url' => '',
'title' => __( 'Awaiting Moderation', 'wp-super-cache' ),
'desc' => __( 'Enables or disables plugin to Remove the text "Your comment is awaiting moderation." when someone leaves a moderated comment.', 'wp-super-cache' ),
);
return $list;
}
add_cacheaction( 'wpsc_filter_list', 'wpsc_awaiting_moderation_list' );
<?php
function wp_supercache_badbehaviour( $file ) {
global $cache_badbehaviour;
if ( 1 !== $cache_badbehaviour ) {
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 ( 'no' === $cache_badbehaviour ) {
$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="" 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 WPCache 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', 'wp-super-cache' );
} else {
$status = __( 'disable', 'wp-super-cache' );
}
echo '<p><strong>' . sprintf( __( 'Bad Behavior support is now %s', 'wp-super-cache' ), $status ) . '</strong></p>';
}
echo '<div class="submit"><input class="button-primary" ' . 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' );
function wpsc_badbehaviour_list( $list ) {
$list['badbehaviour'] = array(
'key' => 'badbehaviour',
'url' => 'http://www.bad-behavior.ioerror.us/',
'title' => __( 'Bad Behavior', 'wp-super-cache' ),
'desc' => sprintf( __( 'Support for Bad Behavior. (Only WPCache caching supported, disabled compression and requires Bad Behavior in "%s/plugins/bad-behavior/") ', 'wp-super-cache' ), WP_CONTENT_DIR ),
);
return $list;
}
add_cacheaction( 'wpsc_filter_list', 'wpsc_badbehaviour_list' );
<?php
function domain_mapping_gc_cache( $function, $directory ) {
global $cache_path;
if ( ! function_exists( 'domain_mapping_warning' ) ) {
return;
}
$siteurl = domain_mapping_siteurl( false );
if ( ! $siteurl ) {
return;
}
$sitedir = trailingslashit( preg_replace( '`^(https?:)?//`', '', $siteurl ) );
if ( 'homepage' === $directory ) {
$directory = '';
}
switch ( $function ) {
case 'rebuild':
wpsc_rebuild_files( $cache_path . 'supercache/' . $sitedir . $directory );
break;
case 'prune':
wpsc_delete_files( $cache_path . 'supercache/' . $sitedir . $directory );
break;
}
}
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;
}
$sitedir = trailingslashit( preg_replace( '`^(https?:)?//`', '', $siteurl ) );
return trailingslashit( $cache_path . 'supercache/' . $sitedir );
}
function domain_mapping_actions() {
global $cache_domain_mapping;
$cache_domain_mapping = (int) $cache_domain_mapping;
if ( 1 !== $cache_domain_mapping ) {
return;
}
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;
$requested_state = isset( $_POST['cache_domain_mapping'] ) ? (int) $_POST['cache_domain_mapping'] : null;
$cache_domain_mapping = (int) $cache_domain_mapping;
$changed = false;
if ( null !== $requested_state && $valid_nonce ) {
$cache_domain_mapping = $requested_state;
wp_cache_replace_line( '^\s*\$cache_domain_mapping\s*=', '$cache_domain_mapping = ' . intval( $cache_domain_mapping ) . ';', $wp_cache_config_file );
$changed = true;
}
$id = 'domain_mapping-section';
?>
<fieldset id="<?php echo esc_attr( $id ); ?>" class="options">
<h4><?php esc_html_e( 'Domain Mapping', 'wp-super-cache' ); ?></h4>
<form name="wp_manager" action="" method="post">
<label><input type="radio" name="cache_domain_mapping" value="1" <?php checked( $cache_domain_mapping ); ?>/> <?php esc_html_e( 'Enabled', 'wp-super-cache' ); ?></label>
<label><input type="radio" name="cache_domain_mapping" value="0" <?php checked( ! $cache_domain_mapping ); ?>/> <?php esc_html_e( 'Disabled', 'wp-super-cache' ); ?></label>
<?php
echo '<p>' . __( 'Provides support for <a href="https://wordpress.org/plugins/wordpress-mu-domain-mapping/">Domain Mapping</a> plugin to map multiple domains to a blog.', 'wp-super-cache' ) . '</p>';
if ( $changed ) {
echo '<p><strong>' . sprintf(
esc_html__( 'Domain Mapping support is now %s', 'wp-super-cache' ),
esc_html( $cache_domain_mapping ? __( 'enabled', 'wp-super-cache' ) : __( 'disabled', 'wp-super-cache' ) )
) . '</strong></p>';
}
echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . ' type="submit" value="' . esc_html__( '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;
if ( $cache_enabled ) {
echo '<div class="error"><p><strong>' . esc_html__( '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;
$cache_domain_mapping = (int) $cache_domain_mapping;
if ( 1 === $cache_domain_mapping ) {
return;
}
if ( is_admin() && function_exists( 'domain_mapping_warning' ) ) {
add_action( 'admin_notices', 'wp_supercache_domain_mapping_notice' );
}
}
if ( isset( $_GET['page'] ) && 'wpsupercache' === $_GET['page'] ) {
add_cacheaction( 'add_cacheaction', 'wp_supercache_domain_mapping_exists' );
}
function wpsc_domain_mapping_list( $list ) {
$list['domain_mapping'] = array(
'key' => 'domain_mapping',
'url' => 'https://wordpress.org/plugins/wordpress-mu-domain-mapping/',
'title' => esc_html__( 'Domain Mapping', 'wp-super-cache' ),
'desc' => esc_html__( 'Provides support for Domain Mapping plugin to map multiple domains to a blog.', 'wp-super-cache' ),
);
return $list;
}
add_cacheaction( 'wpsc_filter_list', 'wpsc_domain_mapping_list' );
<?php
/*
* On the Advanced Settings page enable "Enable dynamic caching" and clear
* the cache.
*
* Plugin authors: NEVER define the template tag for your users. Make them
* choose one so it will be unique to their site.
*
* There are two examples in this file. Both use template tags that must be
* kept secret.
*
* GLOSSARY:
*
* Dynamic content: the text or widget you want to show visitors to your site
* that changes every time it's viewed.
* Placeholder/template tag: the string of random characters placed in your
* theme file or printed in an action where the dynamic content will go.
* Output buffer (ob): any text that is printed by PHP to be sent to the browser
* but captured by PHP for further manipulation.
* OB Callback function: A function that is called when the output buffer is
* filled with a html page. The contents of the page are passed to the function
* for processing.
*
* **** MAKE SURE YOU KEEP THE TEMPLATE TAG SECRET ****
* You should probably add 'deny from all' to the .htaccess in the cache directory
* so visitors can't directly load any cached html files and discover the secret
* tag. Or you can move the cache directory out of the web path and set the
* cache location to that new directory on the advanced settings page.
*
*/
/*
* EXAMPLE 1
* http://ocaoimh.ie/2013/10/21/shiny-new-dynamic-content-wp-super-cache/
* Replace a string in your theme with the dynamic content.
*
* dynamic_cache_test_init()
* This function is the first one to be called. This function hooks
* dynamic_cache_test_template() to the WordPress action, wp_footer.
* This script is loaded before WordPress is and the add_action()
* function isn't defined at this time.
* This init function hooks onto the cache action "add_cacheaction"
* that fires after WordPress (and add_action) is loaded.
*
*
* dynamic_cache_test_template_tag()
* This function hooks on to wp_footer and displays the secret template
* tag that will be replaced by our dynamic content on each page view.
*
*
* dynamic_cache_test_filter()
* This function hooks on to the filter through which all the cached data
* sent to visitors is sent.
* In this simple example the template tag is replaced by a html comment
* containing the text "Hello world at " and the current server time.
* If you want to use the output of a WordPress plugin or command you
* must enable "late init" on the settings page. Each time you reload
* the cached page this time will change. View the page source to examine
* this text.
*
* Chronology of a request:
* 1. dynamic_cache_test_init() hooks dynamic_cache_test_template_tag() on
* to the wp_footer action. dynamic_cache_test_filter() is hooked on to
* the wpsc_cachedata filter.
* 2. An output buffer is created by WP Super Cache.
* 3. Most of the page is generated by WordPress.
* 4. The wp_footer action fires and the TAG is printed to the page.
* 5. Processing continues and the page is created.
* 6. The output buffer finishes. A WP Super Cache callback function runs
* and saves the output buffer to a cache file. The wpsc_cachedata
* filter is called.
* 7. The function dynamic_cache_test_filter() runs and replaces the TAG in
* the buffer with the "Hello world" string.
* 8. The output buffer is pushed to the browser to be displayed.
*/
define( 'DYNAMIC_CACHE_TEST_TAG', '' ); // Change this to a secret placeholder tag.
if ( '' !== DYNAMIC_CACHE_TEST_TAG ) {
function dynamic_cache_test_safety( $safety ) {
return 1;
}
add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_cache_test_safety' );
function dynamic_cache_test_filter( $cachedata ) {
return str_replace( DYNAMIC_CACHE_TEST_TAG, '<!-- Hello world at ' . date( 'H:i:s' ) . ' -->', $cachedata );
}
add_cacheaction( 'wpsc_cachedata', 'dynamic_cache_test_filter' );
function dynamic_cache_test_template_tag() {
echo DYNAMIC_CACHE_TEST_TAG; // This is the template tag.
}
function dynamic_cache_test_init() {
add_action( 'wp_footer', 'dynamic_cache_test_template_tag' );
}
add_cacheaction( 'add_cacheaction', 'dynamic_cache_test_init' );
}
/*
* EXAMPLE 2
*
* This is going to be complicated. Hang on!
*
* When the cache file for a new page is generated the plugin uses an output
* buffer to capture the page. A callback function processes the buffer and
* writes to the cache file. The placeholder tag for any dynamic content has
* to be written to that cache file but also, it has to be replaced with
* dynamic content before the page is shown to the user.
* More on output buffers here: http://php.net/ob_start
*
* Unfortunately an extra output buffer is often required when capturing dynamic
* content such as sidebar widgets. Due to a quirk of the way PHP works it's
* not possible to have an output buffer run in an output buffer callback. That
* dynamic content has to be generated before the callback function is reached.
* The following error occurs when an output buffer is created in the
* callback function of another output buffer:
* "PHP Fatal error: ob_start(): Cannot use output buffering in output buffering display handlers in..."
*
* In this example the function add_action() isn't available when this file is
* loaded so dynamic_output_buffer_init() is hooked on to the "add_cacheaction"
* cacheaction. That function then hooks dynamic_output_buffer_test() on to the
* familiar wp_footer action.
*
* The first time dynamic_output_buffer_test() runs it generates the dynamic
* content and captures it with ob_start() in the DYNAMIC_OB_TEXT constant.
*
* When the main WP Super Cache output buffer is ready the callback is called.
* This fires the wpsc_cachedata_safety filter. If the DYNAMIC_OB_TEXT constant
* is set, which means dynamic content is ready, then it returns 1, a signal
* that everything is ok.
* Finally, the wpsc_cachedata filter is run. The function
* dynamic_output_buffer_test() is hooked on to it. Since DYNAMIC_OB_TEXT is
* set it replaces the placeholder text with that constant.
* The resulting html is then sent to the browser.
*
* Already cached pages call the safety filter, and then the wpsc_cachedata
* filter so any hooked function must be ready to generate dynamic content. The
* very last line of dynamic_output_buffer_test() replaces the placeholder tag
* with the dynamic content in the cache file.
*
* Use an output buffer to capture dynamic content while the page is generated
* and insert into the right place:
* Remember to add the DYNAMIC_OUTPUT_BUFFER_TAG text (as defined below) to
* your theme where the dynamic content should be.
*
* dynamic_output_buffer_test() is a function that uses the wpsc_cachedata
* filter to add a small message and the current server time to every web
* page. The time increments on every reload.
*
*/
define( 'DYNAMIC_OUTPUT_BUFFER_TAG', '' ); // Change this to a secret placeholder tag.
if ( '' !== DYNAMIC_OUTPUT_BUFFER_TAG ) {
function dynamic_output_buffer_test( $cachedata = 0 ) {
if ( defined( 'DYNAMIC_OB_TEXT' ) ) {
return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG, DYNAMIC_OB_TEXT, $cachedata );
}
ob_start();
// call the sidebar function, do something dynamic
echo '<p>This is a test. The current time on the server is: ' . date( 'H:i:s' ) . '</p>';
$text = ob_get_contents();
ob_end_clean();
if ( 0 === $cachedata ) { // called directly from the theme so store the output.
define( 'DYNAMIC_OB_TEXT', $text );
} else { // called via the wpsc_cachedata filter. We only get here in cached pages in wp-cache-phase1.php.
return str_replace( DYNAMIC_OUTPUT_BUFFER_TAG, $text, $cachedata );
}
}
add_cacheaction( 'wpsc_cachedata', 'dynamic_output_buffer_test' );
function dynamic_output_buffer_init() {
add_action( 'wp_footer', 'dynamic_output_buffer_test' );
}
add_cacheaction( 'add_cacheaction', 'dynamic_output_buffer_init' );
function dynamic_output_buffer_test_safety( $safety ) {
if ( defined( 'DYNAMIC_OB_TEXT' ) ) {// this is set when you call dynamic_output_buffer_test() from the theme.
return 1; // ready to replace tag with dynamic content.
} else {
return 0; // tag cannot be replaced.
}
}
add_cacheaction( 'wpsc_cachedata_safety', 'dynamic_output_buffer_test_safety' );
}
<?php
function wp_super_cache_jetpack_admin() {
global $cache_jetpack, $wp_cache_config_file, $valid_nonce;
$cache_jetpack = '' === $cache_jetpack ? '0' : $cache_jetpack;
if ( isset( $_POST['cache_jetpack'] ) && $valid_nonce ) {
if ( $cache_jetpack === (int) $_POST['cache_jetpack'] ) {
$changed = false;
} else {
$changed = true;
}
$cache_jetpack = (int) $_POST['cache_jetpack'];
wp_cache_replace_line( '^ *\$cache_jetpack', "\$cache_jetpack = '$cache_jetpack';", $wp_cache_config_file );
if ( $changed && $cache_jetpack ) {
wp_cache_replace_line( '^ *\$wp_cache_mobile_enabled', '$wp_cache_mobile_enabled = 1;', $wp_cache_config_file );
wp_cache_replace_line( '^ *\$wp_cache_mod_rewrite', '$wp_cache_mod_rewrite = 0;', $wp_cache_config_file );
wp_cache_replace_line( '^ *\$super_cache_enabled', '$super_cache_enabled = 1;', $wp_cache_config_file );
}
}
$id = 'jetpack-section';
?>
<fieldset id="<?php echo $id; ?>" class="options">
<h4><?php _e( 'Jetpack Mobile Theme', 'wp-super-cache' ); ?></h4>
<?php
if ( false === file_exists( dirname( WPCACHEHOME ) . '/jetpack/class.jetpack-user-agent.php' ) ) {
echo '<strong>' . sprintf( __( 'Jetpack not found in %s. Install it and enable the mobile theme and this helper plugin to cache visits by mobile visitors.', 'wp-super-cache' ), dirname( WPCACHEHOME ) ) . '</strong>';
} else {
?>
<form name="wp_manager" action="" method="post">
<label><input type="radio" name="cache_jetpack" value="1" <?php if ( $cache_jetpack ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
<label><input type="radio" name="cache_jetpack" value="0" <?php if ( ! $cache_jetpack ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
<?php
echo '<p>' . __( 'Provides support for the <a href="https://wordpress.org/plugins/jetpack/">Jetpack</a> mobile theme and plugin. PHP caching mode and mobile support will be enabled too.', 'wp-super-cache' ) . '</p>';
if ( isset( $changed ) && $changed ) {
if ( $cache_jetpack ) {
$status = __( 'enabled', 'wp-super-cache' );
} else {
$status = __( 'disabled', 'wp-super-cache' );
}
echo '<p><strong>' . sprintf( __( 'Jetpack Mobile Theme support is now %s', 'wp-super-cache' ), $status ) . '</strong></p>';
}
echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field( 'wp-cache' );
?>
</form>
<?php } ?>
</fieldset>
<?php
}
add_cacheaction( 'cache_admin_page', 'wp_super_cache_jetpack_admin' );
function wp_super_cache_jetpack_cookie_check( $cache_key ) {
if ( false === function_exists( 'jetpack_is_mobile' ) ) {
if ( file_exists( dirname( WPCACHEHOME ) . '/jetpack-dev/class.jetpack-user-agent.php' ) ) {
wp_cache_debug( "wp_super_cache_jetpack_cookie_check: jetpack dev detected. Returning 'normal' to avoid loading Jetpack." );
return 'normal';
} elseif ( file_exists( dirname( WPCACHEHOME ) . '/jetpack/class.jetpack-user-agent.php' ) ) {
include_once dirname( WPCACHEHOME ) . '/jetpack/class.jetpack-user-agent.php';
} else {
wp_cache_debug( 'wp_super_cache_jetpack_cookie_check: jetpack UA file not found.' );
}
}
if ( isset ( $_COOKIE['akm_mobile'] ) ) {
if ( $_COOKIE['akm_mobile'] == 'true' ) {
return 'mobile';
} elseif ( $_COOKIE['akm_mobile'] == 'false' ) {
return 'normal';
}
}
if ( function_exists( 'jetpack_is_mobile' ) ) {
if ( jetpack_is_mobile() ) {
return 'mobile';
} else {
return 'normal';
}
} else {
return 'normal';
}
}
if ( isset( $cache_jetpack ) && '1' === $cache_jetpack ) {
add_cacheaction( 'wp_cache_check_mobile', 'wp_super_cache_jetpack_cookie_check' );
}
function wpsc_cache_jetpack_list( $list ) {
$list['jetpack'] = array(
'key' => 'jetpack',
'url' => 'https://wordpress.org/plugins/jetpack/',
'title' => __( 'Jetpack Mobile Theme', 'wp-super-cache' ),
'desc' => __( 'Provides support for the Jetpack mobile theme and plugin. PHP caching mode and mobile support will be enabled too.', 'wp-super-cache' ),
);
return $list;
}
add_cacheaction( 'wpsc_filter_list', 'wpsc_cache_jetpack_list' );
<?php
if ( is_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', 9 );
}
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 ( 'wp_super_cache' !== $name ) {
return false;
}
$blog_id = (int) $blog_id;
if ( isset( $_GET['id'], $_GET['action'], $_GET['_wpnonce'] )
&& $blog_id === filter_input( INPUT_GET, 'id', FILTER_VALIDATE_INT )
&& wp_verify_nonce( $_GET['_wpnonce'], 'wp-cache' . $blog_id )
) {
if ( 'disable_cache' === filter_input( INPUT_GET, 'action' ) ) {
add_blog_option( $blog_id, 'wp_super_cache_disabled', 1 );
} elseif ( 'enable_cache' === filter_input( INPUT_GET, 'action' ) ) {
delete_blog_option( $blog_id, 'wp_super_cache_disabled' );
}
}
if ( 1 === (int) get_blog_option( $blog_id, 'wp_super_cache_disabled' ) ) {
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 ( 'wpsupercache' === filter_input( INPUT_GET, 'page' ) ) {
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 ( true !== $cache_enabled ) {
return false;
}
if ( 1 === (int) get_option( 'wp_super_cache_disabled' ) ) {
$cache_enabled = false;
$super_cache_enabled = false;
define( 'DONOTCACHEPAGE', 1 );
define( 'SUBMITDISABLED', 'disabled style="color: #aaa" ' );
if ( is_admin() ) {
add_action( 'admin_notices', 'wp_super_cache_multisite_notice' );
}
}
}
<?php
function wp_super_cache_wptouch_admin() {
global $cache_wptouch, $wp_cache_config_file, $valid_nonce;
$cache_wptouch = '' === $cache_wptouch ? '0' : $cache_wptouch;
if ( isset( $_POST['cache_wptouch'] ) && $valid_nonce ) {
if ( $cache_wptouch === (int) $_POST['cache_wptouch'] ) {
$changed = false;
} else {
$changed = true;
}
$cache_wptouch = (int) $_POST['cache_wptouch'];
wp_cache_replace_line( '^ *\$cache_wptouch', "\$cache_wptouch = '$cache_wptouch';", $wp_cache_config_file );
}
$id = 'wptouch-section';
?>
<fieldset id="<?php echo $id; ?>" class="options">
<h4><?php _e( 'WPTouch', 'wp-super-cache' ); ?></h4>
<form name="wp_manager" action="" method="post">
<label><input type="radio" name="cache_wptouch" value="1" <?php if ( $cache_wptouch ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
<label><input type="radio" name="cache_wptouch" value="0" <?php if ( ! $cache_wptouch ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Disabled', 'wp-super-cache' ); ?></label>
<?php
echo '<p>' . __( 'Provides support for <a href="https://wordpress.org/plugins/wptouch/">WPTouch</a> mobile theme and plugin.', 'wp-super-cache' ) . '</p>';
if ( isset( $changed ) && $changed ) {
if ( $cache_wptouch ) {
$status = __( 'enabled', 'wp-super-cache' );
} else {
$status = __( 'disabled', 'wp-super-cache' );
}
echo '<p><strong>' . sprintf( __( 'WPTouch support is now %s', 'wp-super-cache' ), $status ) . '</strong></p>';
}
echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field( 'wp-cache' );
?>
</form>
</fieldset>
<?php
}
add_cacheaction( 'cache_admin_page', 'wp_super_cache_wptouch_admin' );
function wp_super_cache_wptouch_notice() {
global $cache_enabled;
if ( $cache_enabled ) {
echo '<div class="error"><p><strong>' . __( 'WPTouch plugin detected! Please go to the Supercache plugins page and enable the WPTouch helper plugin.', 'wp-super-cache' ) . '</strong></p></div>';
}
}
function wp_super_cache_wptouch_exists() {
global $cache_wptouch;
if ( '1' === $cache_wptouch ) {
return false;
}
if ( is_admin() && function_exists( 'wptouch_get_plugin_dir_name' ) ) {
add_action( 'admin_notices', 'wp_super_cache_wptouch_notice' );
}
}
if ( isset( $_GET['page'] ) && 'wpsupercache' === $_GET['page'] ) {
add_cacheaction( 'add_cacheaction', 'wp_super_cache_wptouch_exists' );
}
// disable mobile checking if.
function wp_super_cache_maybe_disable_wptouch( $t ) {
global $cache_wptouch, $wptouch_exclude_ua;
if ( '1' !== $cache_wptouch ) {
return false;
}
if ( ( isset( $_COOKIE['wptouch_switch_toggle'] ) && 'normal' === $_COOKIE['wptouch_switch_toggle'] ) ||
( isset( $_COOKIE['wptouch-pro-view'] ) && 'desktop' === $_COOKIE['wptouch-pro-view'] ) ) {
return true;
}
$ua = explode( ',', $wptouch_exclude_ua );
foreach ( $ua as $agent ) {
if ( preg_match( "#$agent#i", $_SERVER['HTTP_HOST'] ) ) {
return true; // disable mobile ua check if matches the exclude list in wptouch.
}
}
return false;
}
add_cacheaction( 'disable_mobile_check', 'wp_super_cache_maybe_disable_wptouch' );
function wp_super_cache_wptouch_browsers( $browsers ) {
global $wptouch_exclude_ua, $wp_cache_config_file;
if ( false === function_exists( 'bnc_wptouch_get_exclude_user_agents' ) || false === function_exists( 'bnc_wptouch_get_user_agents' ) ) {
return $browsers;
}
$browsers = implode( ',', bnc_wptouch_get_exclude_user_agents() ); // hack, support exclude agents too.
if ( $browsers !== $wptouch_exclude_ua ) {
wp_cache_replace_line( '^ *\$wptouch_exclude_ua', "\$wptouch_exclude_ua = '$browsers';", $wp_cache_config_file );
$wptouch_exclude_ua = $browsers;
}
return bnc_wptouch_get_user_agents();
}
function wp_super_cache_wptouch_prefixes( $prefixes ) {
return array(); // wptouch doesn't support UA prefixes.
}
function wp_super_cache_wptouch_cookie_check( $cache_key ) {
if ( false === isset( $_COOKIE['wptouch_switch_toggle'] ) ) {
return $cache_key;
}
if ( 'normal' === $_COOKIE['wptouch_switch_toggle'] || 'mobile' === $_COOKIE['wptouch_switch_toggle'] ) {
return $_COOKIE['wptouch_switch_toggle'];
}
if ( isset( $_COOKIE['wptouch-pro-view'] ) ) {
if ( 'desktop' === $_COOKIE['wptouch-pro-view'] ) {
return 'normal';
} else {
return $_COOKIE['wptouch-pro-view'];
}
}
return $cache_key;
}
if ( isset( $cache_wptouch ) && '1' === $cache_wptouch ) {
add_cacheaction( 'wp_super_cache_mobile_browsers', 'wp_super_cache_wptouch_browsers' );
add_cacheaction( 'wp_super_cache_mobile_prefixes', 'wp_super_cache_wptouch_prefixes' );
add_cacheaction( 'wp_cache_check_mobile', 'wp_super_cache_wptouch_cookie_check' );
}
function wpsc_wptouch_list( $list ) {
$list['wptouch'] = array(
'key' => 'wptouch',
'url' => 'https://wordpress.org/plugins/wptouch/',
'title' => __( 'WPTouch', 'wp-super-cache' ),
'desc' => __( 'Provides support for WPTouch mobile theme and plugin.', 'wp-super-cache' ),
);
return $list;
}
add_cacheaction( 'wpsc_filter_list', 'wpsc_wptouch_list' );
<?php
class WP_Super_Cache_Rest_Delete_Cache extends WP_REST_Controller {
/**
* Get a collection of items
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
$params = $request->get_json_params();
if ( isset( $params['id'] ) && is_numeric( $params['id'] ) ) {
wpsc_delete_post_cache( $params['id'] );
} elseif ( !empty( $params['expired'] ) ) {
global $file_prefix;
wp_cache_clean_expired( $file_prefix );
} elseif ( isset( $params['url'] ) ) {
global $cache_path;
$directory = $cache_path . 'supercache/' . $params[ 'url' ];
wpsc_delete_files( $directory );
prune_super_cache( $directory . '/page', true );
} else {
global $file_prefix;
wp_cache_clean_cache( $file_prefix, !empty( $params['all'] ) );
}
return rest_ensure_response( array( 'Cache Cleared' => true ) );
}
}
<?php
class WP_Super_Cache_Rest_Get_Cache extends WP_REST_Controller {
/**
* Get a collection of items
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
global $valid_nonce;
$valid_nonce = true;
$_GET[ 'listfiles' ] = 1;
$sizes = wpsc_generate_sizes_array();
$supercachedir = get_supercache_dir();
$list = wpsc_dirsize( $supercachedir, $sizes );
$return_list = array();
foreach( $list as $type => $file_list ) {
foreach ( $file_list as $state => $value ) {
if ( is_array( $value ) ) {
foreach( $value as $filenames ) {
foreach( $filenames as $filename => $t ) {
if ( $type == 'wpcache' ) {
$filename = dirname( $filename );
}
if ( false == isset( $return_list[ $type ][ $state ] ) || false == in_array( $filename, $return_list[ $type ][ $state ] ) )
$return_list[ $type ][ $state ][] = $filename;
}
}
}
}
if ( isset ( $return_list[ $type ] ) ) {
$list[ $type ] = $return_list[ $type ];
}
unset( $return_list[ $type ] );
}
return rest_ensure_response( $list );
}
}
<?php
class WP_Super_Cache_Rest_Get_Plugins extends WP_REST_Controller {
/**
* GET a list of plugins through the /plugins/ endpoint
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
$list = wpsc_get_plugin_list();
return rest_ensure_response( $list );
}
}
<?php
require_once( dirname( __FILE__ ) . '/class.wp-super-cache-settings-map.php' );
class WP_Super_Cache_Rest_Get_Settings extends WP_REST_Controller {
/**
* Get the settings.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
$settings = array();
global $wp_cache_config_file;
if ( defined( 'WPLOCKDOWN' ) ) {
$config_file = file_get_contents( $wp_cache_config_file );
if ( false === strpos( $config_file, "defined( 'WPLOCKDOWN' )" ) ) {
wp_cache_replace_line( '^.*WPLOCKDOWN', "if ( ! defined( 'WPLOCKDOWN' ) ) define( 'WPLOCKDOWN', " . $this->get_is_lock_down_enabled() . " );", $wp_cache_config_file );
}
}
if ( function_exists( "opcache_invalidate" ) ) {
@opcache_invalidate( $wp_cache_config_file );
}
include( $wp_cache_config_file );
foreach ( WP_Super_Cache_Settings_Map::$map as $name => $map ) {
if ( isset ( $map['get'] ) ) {
$get_method = $map['get'];
if ( method_exists( $this, $get_method ) ) {
$settings[ $name ] = $this->$get_method();
} elseif ( function_exists( $get_method ) ) {
$settings[ $name ] = $get_method();
}
} else if ( isset ( $map['option'] ) ) {
$settings[ $name ] = get_option( $map['option'] );
} elseif ( isset( $map['global'] ) ) {
if ( false == isset( $GLOBALS[ $map[ 'global' ] ] ) ) {
$settings[ $name ] = false;
} else {
$settings[ $name ] = $GLOBALS[ $map[ 'global' ] ];
}
}
}
return $this->prepare_item_for_response( $settings, $request );
}
/**
* @return string
*/
public function get_ossdl_off_blog_url() {
$url = get_option( 'ossdl_off_blog_url' );
if ( ! $url )
$url = apply_filters( 'ossdl_off_blog_url', untrailingslashit( get_option( 'siteurl' ) ) );
return $url;
}
/**
* @return string
*/
public function get_cache_path_url() {
global $cache_path;
return site_url( str_replace( ABSPATH, '', "{$cache_path}" ) );
}
/**
* @return string
*/
public function get_cache_type() {
global $wp_cache_config_file;
if ( function_exists( "opcache_invalidate" ) ) {
@opcache_invalidate( $wp_cache_config_file );
}
include( $wp_cache_config_file );
if ( $wp_cache_mod_rewrite == 1 ) {
return 'mod_rewrite';
} else {
return 'PHP';
}
}
/**
* Prepare the item for the REST response
*
* @param mixed $item WordPress representation of the item.
* @param WP_REST_Request $request Request object.
* @return mixed
*/
public function prepare_item_for_response( $item, $request ) {
$settings = array();
$integers = array( 'cache_max_time', 'preload_interval' );
$string_arrays = array( 'cache_stats', 'cache_acceptable_files', 'cache_rejected_uri', 'cache_rejected_user_agent',
'cache_direct_pages' );
foreach( $item as $key => $value ) {
if ( is_array( $value ) && false == in_array( $key, $string_arrays ) ) {
array_walk( $value, array( $this, 'make_array_bool' ) );
} elseif ( ( $value === 0 || $value === 1 ) && false == in_array( $key, $integers ) ) {
$value = (bool)$value;
}
$settings[ $key ] = $value;
}
$strings_to_bool = array( 'ossdl_https', 'refresh_current_only_on_comments' );
foreach( $strings_to_bool as $key ) {
if ( isset( $settings[ $key ] ) ) {
$settings[ $key ] = (bool)$settings[ $key ];
}
}
return rest_ensure_response( $settings );
}
/**
* @param mixed $value
* @param string $key
*/
public function make_array_bool( &$value, $key ) {
if ( $value == 0 || $value == 1 ) {
$value = (bool) $value;
}
}
/**
* @return bool
*/
protected function get_is_submit_enabled() {
global $wp_cache_config_file;
return is_writeable_ACLSafe( $wp_cache_config_file );
}
/**
* @return bool
*/
protected function get_is_preload_enabled() {
return false === defined( 'DISABLESUPERCACHEPRELOADING' );
}
/**
* @return false|int
*/
protected function get_next_gc() {
return wp_next_scheduled( 'wp_cache_gc' );
}
/**
* @return int
*/
protected function get_is_preload_active() {
if ( wp_next_scheduled( 'wp_cache_preload_hook' ) || wp_next_scheduled( 'wp_cache_full_preload_hook' ) ) {
return true;
} else {
return false;
}
}
/**
* @return int
*/
protected function get_minimum_preload_interval() {
global $wpdb;
$count = $this->get_post_count();
if ( $count > 1000 ) {
$min_refresh_interval = 720;
} else {
$min_refresh_interval = 30;
}
return $min_refresh_interval;
}
/**
* @return int
*/
protected function get_is_lock_down_enabled() {
if ( defined( 'WPLOCKDOWN' ) ) {
return constant( 'WPLOCKDOWN' ) ? 1 : 0;
}
return 0;
}
/**
* @return int
*/
protected function get_post_count() {
return wpsc_post_count();
}
/**
* @return string
*/
protected function get_default_cache_path() {
return WP_CONTENT_DIR . '/wp-cache/';
}
}
<?php
class WP_Super_Cache_Rest_Get_Stats extends WP_REST_Controller {
/**
* Get the cache stats for the site.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
global $valid_nonce;
$_GET[ 'listfiles' ] = 1;
$valid_nonce = true;
return rest_ensure_response( wp_cache_regenerate_cache_file_stats() );
}
}
<?php
class WP_Super_Cache_Rest_Get_Status extends WP_REST_Controller {
/**
* Get any status that might be visible.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
$status = array();
include_once( ABSPATH . 'wp-admin/includes/file.php' ); // get_home_path()
include_once( ABSPATH . 'wp-admin/includes/misc.php' ); // extract_from_markers()
$this->add_rewrite_status( $status );
$this->add_cache_disabled_status( $status );
$this->add_compression_status( $status );
$this->add_php_mod_rewrite_status( $status );
$this->add_preload_status( $status );
if ( empty( $status ) ) {
return rest_ensure_response( new stdclass() );
} else {
return rest_ensure_response( $status );
}
}
/**
* @param array $status
*/
protected function add_preload_status( & $status ) {
global $wp_cache_config_file;
include( $wp_cache_config_file );
if ( false == $cache_enabled ) {
$status[ 'preload_disabled_cache_off' ] = true;
}
if ( false == $super_cache_enabled ) {
$status[ 'preload_disabled_supercache_off' ] = true;
}
if ( true === defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
$status[ 'preload_disabled_by_admin' ] = true;
}
}
/**
* @param array $status
*/
protected function add_php_mod_rewrite_status( & $status ) {
global $wp_cache_config_file;
include( $wp_cache_config_file );
if ( $cache_enabled && !$wp_cache_mod_rewrite ) {
$scrules = trim( implode( "\n", extract_from_markers( trailingslashit( get_home_path() ) . '.htaccess', 'WPSuperCache' ) ) );
if ( $scrules != '' ) {
$status[ 'php_mod_rewrite' ] = true;
}
}
}
/**
* @param array $status
*/
protected function add_cache_disabled_status( & $status ) {
global $wp_cache_config_file;
if ( ! is_writeable_ACLSafe( $wp_cache_config_file ) ) {
$status['cache_disabled'] = true;
}
}
/**
* @param array $status
*/
protected function add_compression_status( & $status ) {
if ( defined( 'WPSC_DISABLE_COMPRESSION' ) ) {
$status['compression_disabled_by_admin'] = true;
} elseif ( false == function_exists( 'gzencode' ) ) {
$status['compression_disabled_no_gzencode'] = true;
}
}
/**
* @param array $status
*/
protected function add_rewrite_status( & $status ) {
global $home_path, $wp_cache_config_file;
include( $wp_cache_config_file );
// Return if the rewrite caching is disabled.
if ( ! $cache_enabled || ! $super_cache_enabled || ! $wp_cache_mod_rewrite ) {
return;
}
$scrules = implode( "\n", extract_from_markers( $home_path . '.htaccess', 'WPSuperCache' ) );
extract( wpsc_get_htaccess_info() );
if ( $scrules != $rules ) {
$status[ 'mod_rewrite_rules' ] = true;
}
$got_rewrite = apache_mod_loaded( 'mod_rewrite', true );
if ( $wp_cache_mod_rewrite && false == apply_filters( 'got_rewrite', $got_rewrite ) ) {
$status[ 'mod_rewrite_missing' ] = true;
}
if ( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) {
$status[ 'htaccess_ro' ] = true;
}
}
}
<?php
class WP_Super_Cache_Rest_Preload extends WP_REST_Controller {
/**
* Update the cache settings.
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
$parameters = $request->get_json_params();
if ( defined( 'DISABLESUPERCACHEPRELOADING' ) ) {
wp_cache_debug( 'WP_Super_Cache_Rest_Preload: preload disabled by admin' );
return rest_ensure_response( array( 'error' => 'preload disabled by admin' ) );
}
if ( isset( $parameters[ 'enable' ] ) ) {
if ( $parameters[ 'enable' ] == true ) {
wp_cache_debug( 'WP_Super_Cache_Rest_Preload: enable' );
wpsc_enable_preload();
return( rest_ensure_response( array( 'enabled' => true ) ) );
} else {
wp_cache_debug( 'WP_Super_Cache_Rest_Preload: cancel' );
wpsc_cancel_preload();
return( rest_ensure_response( array( 'enabled' => false ) ) );
}
}
}
}
<?php
class WP_Super_Cache_Rest_Test_Cache extends WP_REST_Controller {
/**
* Get a collection of items
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
global $cache_path;
$url = trailingslashit( get_bloginfo( 'url' ) );
$response = array( 'status' => 'UNKNOWN' );
$has_errors = false;
$attempts = array( 'prime', 'first', 'second' );
$c = 0;
foreach ( $attempts as $attempt_name ) {
$attempt = array();
$page[ $c ] = wp_remote_get( $url, array('timeout' => 60, 'blocking' => true ) );
if ( ! is_wp_error( $page[ $c ] ) ) {
$fp = fopen( $cache_path . $c . ".html", "w" );
fwrite( $fp, $page[ $c ][ 'body' ] );
fclose( $fp );
}
if ( is_wp_error( $page[ $c ] ) ) {
$has_errors = true;
$attempt['status'] = false;
$attempt['errors'] = $this->format_error( $page[ $c ] );
} elseif ( $page[ $c ]['response']['code'] != 200 ) {
$has_errors = true;
$attempt['status'] = false;
$attempt['errors'] = array( $page[ $c ]['response']['message'] );
// Don't run this step on prime cache.
} elseif ( 0 !== $c && 0 === preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[ $c ]['body'], $matches2 ) ) {
$has_errors = true;
$attempt['status'] = false;
$attempt['errors'] = array( __( 'Timestamps not found', 'wp-super-cache' ) );
} else {
$attempt['status'] = true;
}
$response[ 'attempts' ][ $attempt_name ] = $attempt;
$c++;
}
if (
false == $has_errors &&
preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[ 1 ][ 'body' ], $matches1 ) &&
preg_match( '/(Cached page generated by WP-Super-Cache on) ([0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*)/', $page[ 2 ][ 'body' ], $matches2 ) &&
$matches1[2] == $matches2[2]
) {
$response[ 'status' ] = true;
} else {
$response[ 'status' ] = false;
$response[ 'error' ] = array( __( 'Timestamps do not match', 'wp-super-cache' ) );
}
$error = '';
if ( $response[ 'status' ] == false ) {
if ( isset( $response[ 'error' ] ) ) {
$error = $response[ 'error' ];
} else {
foreach( $response[ 'attempts' ] as $attempt ) {
$error .= $attempt[ 'errors' ] . "\n";
}
}
return new WP_Error( 'test_error', $error, array( 'status' => 500 ) );
}
return rest_ensure_response( $response );
}
/**
* @param WP_Error $error
* @return array
*/
protected function format_error( WP_Error $error ) {
$messages = array();
foreach ( $error->get_error_codes() as $code ) {
foreach ( $error->get_error_messages( $code ) as $err ) {
$messages[] = $err;
}
}
return $messages;
}
}
<?php
class WP_Super_Cache_Rest_Update_Plugins extends WP_REST_Controller {
/**
* Toggle plugins on/off through the /plugins/ endpoint
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|WP_REST_Response
*/
public function callback( $request ) {
$parameters = $request->get_json_params();
global $valid_nonce;
$valid_nonce = true;
wpsc_update_plugin_list( $parameters );
$list = wpsc_get_plugin_list();
return rest_ensure_response( $list );
}
}
<?php
class WP_Super_Cache_Settings_Map {
/**
* A map describing how settings transform from their external names
* into internal methods and globals.
*
* Key definitions:
*
* - get: A getter method or function that will be called to return the var
* - set: A setter method or function that will be called to set the var
* - option: An option name that will be used to get or set the var
* - global: A name of a global that can GET
*
* @var array
*/
public static $map = array(
'is_submit_enabled' => array(
'get' => 'get_is_submit_enabled',
'set' => '',
),
'is_preload_enabled' => array(
'get' => 'get_is_preload_enabled',
'set' => '',
),
'cache_lock_down' => array(
'get' => 'get_is_lock_down_enabled',
'set' => 'set_lock_down',
),
'cache_next_gc' => array(
'get' => 'get_next_gc',
'set' => '',
),
'cache_gc_email_me' => array(
'global' => 'cache_gc_email_me',
'set' => 'set_time_setting',
),
'cache_path_url' => array(
'get' => 'get_cache_path_url',
),
'cache_type' => array(
'get' => 'get_cache_type',
'set' => 'set_super_cache_enabled',
),
'is_preloading' => array(
'get' => 'wpsc_is_preloading',
'set' => '',
),
'post_count' => array(
'get' => 'get_post_count',
'set' => '',
),
'is_cache_enabled' => array(
'global' => 'cache_enabled',
'set' => 'set_cache_enabled',
),
'is_super_cache_enabled' => array(
'global' => 'super_cache_enabled',
'set' => 'set_super_cache_enabled',
),
'is_mobile_enabled' => array(
'global' => 'wp_cache_mobile_enabled',
),
'is_mfunc_enabled' => array(
'global' => 'wp_cache_mfunc_enabled',
),
'cache_list' => array(
'global' => 'wp_supercache_cache_list',
),
'clear_cache_on_post_edit' => array(
'global' => 'wp_cache_clear_on_post_edit',
),
'wpsc_save_headers' => array(
'global' => 'wpsc_save_headers',
),
'cache_rebuild' => array(
'global' => 'cache_rebuild_files',
),
'dont_cache_logged_in' => array(
'global' => 'wp_cache_not_logged_in',
),
'make_known_anon' => array(
'global' => 'wp_cache_make_known_anon',
),
'cache_path' => array(
'global' => 'cache_path',
'set' => 'set_wp_cache_location',
),
'default_cache_path' => array(
'get' => 'get_default_cache_path',
),
'use_object_cache' => array(
'global' => 'wp_cache_object_cache',
),
'refresh_current_only_on_comments' => array(
'global' => 'wp_cache_refresh_single_only',
),
'cache_compression' => array(
'global' => 'cache_compression',
'set' => 'set_cache_compression',
),
'cache_mod_rewrite' => array(
'global' => 'wp_cache_mod_rewrite',
),
'use_304_headers' => array(
'global' => 'wp_supercache_304',
),
'cache_late_init' => array(
'global' => 'wp_super_cache_late_init',
),
'front_page_checks' => array(
'global' => 'wp_cache_front_page_checks',
),
'cache_page_secret' => array(
'global' => 'cache_page_secret',
),
'disable_utf8' => array(
'global' => 'wp_cache_disable_utf8',
),
'no_cache_for_get' => array(
'global' => 'wp_cache_no_cache_for_get',
),
'cache_schedule_type' => array(
'global' => 'cache_schedule_type',
'set' => 'set_time_setting',
),
'cache_scheduled_time' => array(
'global' => 'cache_scheduled_time',
'set' => 'set_time_setting',
),
'cache_max_time' => array(
'global' => 'cache_max_time',
'set' => 'set_time_setting',
),
'cache_time_interval' => array(
'global' => 'cache_time_interval',
'set' => 'set_time_setting',
),
'shutdown_garbage_collector' => array(
'global' => 'wp_cache_shutdown_gc',
),
'pages' => array(
'global' => 'wp_cache_pages',
),
'minimum_preload_interval' => array(
'get' => 'get_minimum_preload_interval',
),
'preload_interval' => array(
'global' => 'wp_cache_preload_interval',
'set' => 'set_preload_setting',
),
'preload_posts' => array(
'global' => 'wp_cache_preload_posts',
'set' => 'set_preload_setting',
),
'preload_on' => array(
'global' => 'wp_cache_preload_on',
'set' => 'set_preload_setting',
),
'preload_active' => array(
'get' => 'get_is_preload_active',
),
'preload_taxonomies' => array(
'global' => 'wp_cache_preload_taxonomies',
'set' => 'set_preload_setting',
),
'preload_email_me' => array(
'global' => 'wp_cache_preload_email_me',
'set' => 'set_preload_setting',
),
'preload_email_volume' => array(
'global' => 'wp_cache_preload_email_volume',
'set' => 'set_preload_setting',
),
'cache_mobile_browsers' => array(
'global' => 'wp_cache_mobile_browsers',
),
'cache_mobile_prefixes' => array(
'global' => 'wp_cache_mobile_prefixes',
),
'cache_disable_locking' => array(
'global' => 'wp_cache_mutex_disabled',
),
'cache_hello_world' => array(
'global' => 'wp_cache_hello_world',
),
'cache_schedule_interval' => array(
'global' => 'cache_schedule_interval',
'set' => 'set_time_setting',
),
'cache_acceptable_files' => array(
'global' => 'cache_acceptable_files',
),
'cache_rejected_uri' => array(
'global' => 'cache_rejected_uri',
),
'cache_rejected_user_agent' => array(
'global' => 'cache_rejected_user_agent',
),
'cache_direct_pages' => array(
'global' => 'cached_direct_pages',
'set' => 'set_cache_direct_pages',
),
'new_direct_page' => array(
'set' => 'new_direct_page',
),
'ossdl_cname' => array(
'option' => 'ossdl_cname',
'set' => 'set_ossdl_cname',
),
'ossdl_https' => array(
'option' => 'ossdl_https',
'set' => 'set_ossdl_https',
),
'ossdl_off_cdn_url' => array(
'option' => 'ossdl_off_cdn_url',
'set' => 'set_ossdl_off_cdn_url',
),
'ossdl_off_blog_url' => array(
'option' => 'ossdl_off_blog_url',
'set' => 'set_ossdl_off_blog_url',
),
'ossdl_off_exclude' => array(
'option' => 'ossdl_off_exclude',
'set' => 'set_ossdl_off_exclude',
),
'ossdl_off_include_dirs' => array(
'option' => 'ossdl_off_include_dirs',
'set' => 'set_ossdl_off_include_dirs',
),
'ossdlcdn' => array(
'global' => 'ossdlcdn',
'set' => 'set_ossdlcdn',
),
'wp_super_cache_debug' => array(
'global' => 'wp_super_cache_debug',
),
'wp_cache_debug_username' => array(
'get' => 'wpsc_debug_username',
),
'wp_cache_debug_log' => array(
'global' => 'wp_cache_debug_log',
),
'wp_cache_debug_ip' => array(
'global' => 'wp_cache_debug_ip',
),
'wp_super_cache_comments' => array(
'global' => 'wp_super_cache_comments',
),
'wp_super_cache_front_page_check' => array(
'global' => 'wp_super_cache_front_page_check',
),
'wp_super_cache_front_page_clear' => array(
'global' => 'wp_super_cache_front_page_clear',
),
'wp_super_cache_front_page_text' => array(
'global' => 'wp_super_cache_front_page_text',
),
'wp_super_cache_front_page_notification' => array(
'global' => 'wp_super_cache_front_page_notification',
),
);
}
<?php
require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-get-settings.php' );
require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-update-settings.php' );
require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-get-stats.php' );
require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-get-cache.php' );
require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-get-status.php' );
require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-test-cache.php' );
require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-delete-cache.php' );
require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-preload.php' );
require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-get-plugins.php' );
require_once( dirname( __FILE__ ) . '/class.wp-super-cache-rest-update-plugins.php' );
class WP_Super_Cache_Router {
/**
* Register the routes for the objects of the controller.
*
* GET /wp-super-cache/v1/settings
* POST /wp-super-cache/v1/settings
* GET /wp-super-cache/v1/stats
* GET /wp-super-cache/v1/cache
* POST /wp-super-cache/v1/cache
*/
public static function register_routes() {
$version = '1';
$namespace = 'wp-super-cache/v' . $version;
$get_settings = new WP_Super_Cache_Rest_Get_Settings();
$update_settings = new WP_Super_Cache_Rest_Update_Settings();
$get_stats = new WP_Super_Cache_Rest_Get_Stats();
$get_cache = new WP_Super_Cache_Rest_Get_Cache();
$test_cache = new WP_Super_Cache_Rest_Test_Cache();
$delete_cache = new WP_Super_Cache_Rest_Delete_Cache();
$preload_cache = new WP_Super_Cache_Rest_Preload();
$get_status = new WP_Super_Cache_Rest_Get_Status();
$get_plugins = new WP_Super_Cache_Rest_Get_Plugins();
$update_plugins = new WP_Super_Cache_Rest_Update_Plugins();
register_rest_route( $namespace, '/settings', array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $get_settings, 'callback' ),
'permission_callback' => __CLASS__ . '::get_item_permissions_check',
'args' => array(),
),
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $update_settings, 'callback' ),
'permission_callback' => __CLASS__ . '::update_item_permissions_check',
'args' => array(),
),
) );
register_rest_route( $namespace, '/status', array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $get_status, 'callback' ),
'permission_callback' => __CLASS__ . '::get_item_permissions_check',
) );
register_rest_route( $namespace, '/stats', array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $get_stats, 'callback' ),
'permission_callback' => __CLASS__ . '::get_item_permissions_check',
) );
register_rest_route( $namespace, '/cache', array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $get_cache, 'callback' ),
'permission_callback' => __CLASS__ . '::get_item_permissions_check',
'args' => array(),
),
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $delete_cache, 'callback' ),
'permission_callback' => __CLASS__ . '::delete_item_permissions_check',
'args' => array(),
),
) );
register_rest_route( $namespace, '/preload', array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $preload_cache, 'callback' ),
'permission_callback' => __CLASS__ . '::update_item_permissions_check',
) );
register_rest_route( $namespace, '/cache/test', array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $test_cache, 'callback' ),
'permission_callback' => __CLASS__ . '::create_item_permissions_check',
) );
register_rest_route( $namespace, '/plugins', array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $get_plugins, 'callback' ),
'permission_callback' => __CLASS__ . '::get_item_permissions_check',
'args' => array(),
),
array(
'methods' => WP_REST_Server::CREATABLE,
'callback' => array( $update_plugins, 'callback' ),
'permission_callback' => __CLASS__ . '::update_item_permissions_check',
'args' => array(),
),
) );
}
/**
* Check if a given request has access to get items
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|bool
*/
public static function get_items_permissions_check( $request ) {
return wpsupercache_site_admin();
}
/**
* Check if a given request has access to get a specific item
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|bool
*/
public static function get_item_permissions_check( $request ) {
return self::get_items_permissions_check( $request );
}
/**
* Check if a given request has access to create items
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|bool
*/
public static function create_item_permissions_check( $request ) {
return self::get_items_permissions_check( $request );
}
/**
* Check if a given request has access to update a specific item
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|bool
*/
public static function update_item_permissions_check( $request ) {
return self::create_item_permissions_check( $request );
}
/**
* Check if a given request has access to update a specific item
*
* @param WP_REST_Request $request Full data about the request.
* @return WP_Error|bool
*/
public static function delete_item_permissions_check( $request ) {
return self::update_item_permissions_check( $request );
}
}
function wpsc_load_rest_api() {
$wpsupercache_route = new WP_Super_Cache_Router;
$wpsupercache_route->register_routes();
};
add_action( 'rest_api_init', 'wpsc_load_rest_api' );
<?php
global $WPSC_HTTP_HOST, $cache_enabled, $cache_path, $blogcacheid, $blog_cache_dir;
if ( ! empty( $_SERVER['HTTP_HOST'] ) ) {
$WPSC_HTTP_HOST = function_exists( 'mb_strtolower' ) ? mb_strtolower( $_SERVER['HTTP_HOST'] ) : strtolower( $_SERVER['HTTP_HOST'] );
$WPSC_HTTP_HOST = htmlentities( $WPSC_HTTP_HOST );
} elseif ( PHP_SAPI === 'cli' && function_exists( 'get_option' ) ) {
$WPSC_HTTP_HOST = (string) parse_url( get_option( 'home' ), PHP_URL_HOST );
} else {
$cache_enabled = false;
$WPSC_HTTP_HOST = '';
}
// We want to be able to identify each blog in a WordPress MU install
$blogcacheid = '';
$blog_cache_dir = $cache_path;
if ( is_multisite() ) {
global $current_blog;
if ( is_object( $current_blog ) && function_exists( 'is_subdomain_install' ) ) {
$blogcacheid = is_subdomain_install() ? $current_blog->domain : trim( $current_blog->path, '/' );
} elseif ( ( defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) || ( defined( 'VHOST' ) && VHOST === 'yes' ) ) {
$blogcacheid = $WPSC_HTTP_HOST;
} else {
$request_uri = str_replace( '..', '', preg_replace( '/[ <>\'\"\r\n\t\(\)]/', '', $_SERVER['REQUEST_URI'] ) );
$request_uri = str_replace( '//', '/', $request_uri );
$wpsc_path_segs = array_filter( explode( '/', trim( $request_uri, '/' ) ) );
$wpsc_base_count = defined( 'PATH_CURRENT_SITE' ) ? count( array_filter( explode( '/', trim( PATH_CURRENT_SITE, '/' ) ) ) ) : 0;
if ( '/' !== substr( $request_uri, -1 ) ) {
$wpsc_path_segs = array_slice( $wpsc_path_segs, 0, -1 );
}
if ( count( $wpsc_path_segs ) > $wpsc_base_count &&
( ! defined( 'PATH_CURRENT_SITE' ) || 0 === strpos( $request_uri, PATH_CURRENT_SITE ) )
) {
$blogcacheid = $wpsc_path_segs[ $wpsc_base_count ];
}
}
// If blogcacheid is empty then set it to main blog.
if ( empty( $blogcacheid ) ) {
$blogcacheid = 'blog';
}
$blog_cache_dir = str_replace( '//', '/', $cache_path . 'blogs/' . $blogcacheid . '/' );
}
<?php
/*
WP-Cache Config Sample File
See wp-cache.php for author details.
*/
if ( ! defined('WPCACHEHOME') )
define( 'WPCACHEHOME', WP_PLUGIN_DIR . '/wp-super-cache/' );
$cache_compression = 0; // Super cache compression
$cache_enabled = false;
$super_cache_enabled = true;
$cache_max_time = 3600; //in seconds
//$use_flock = true; // Set it true or false if you know what to use
$cache_path = WP_CONTENT_DIR . '/cache/';
$file_prefix = 'wp-cache-';
$ossdlcdn = 0;
// Array of files that have 'wp-' but should still be cached
$cache_acceptable_files = array( 'wp-comments-popup.php', 'wp-links-opml.php', 'wp-locations.php' );
$cache_rejected_uri = array('wp-.*\\.php', 'index\\.php');
$cache_rejected_user_agent = array();
$cache_rebuild_files = 1;
// Disable the file locking system.
// If you are experiencing problems with clearing or creating cache files
// uncommenting this may help.
$wp_cache_mutex_disabled = 1;
// Just modify it if you have conflicts with semaphores
$sem_id = 5419;
if ( '/' != substr($cache_path, -1)) {
$cache_path .= '/';
}
$wp_cache_mobile = 0;
$wp_cache_mobile_whitelist = 'Stand Alone/QNws';
$wp_cache_mobile_browsers = 'Android, 2.0 MMP, 240x320, AvantGo, BlackBerry, Blazer, Cellphone, Danger, DoCoMo, Elaine/3.0, EudoraWeb, hiptop, IEMobile, iPhone, iPod, KYOCERA/WX310K, LG/U990, MIDP-2.0, MMEF20, MOT-V, NetFront, Newt, Nintendo Wii, Nitro, Nokia, Opera Mini, Palm, Playstation Portable, portalmmm, Proxinet, ProxiNet, SHARP-TQ-GX10, Small, SonyEricsson, Symbian OS, SymbianOS, TS21i-10, UP.Browser, UP.Link, Windows CE, WinWAP';
// change to relocate the supercache plugins directory
$wp_cache_plugins_dir = WPCACHEHOME . 'plugins';
// set to 1 to do garbage collection during normal process shutdown instead of wp-cron
$wp_cache_shutdown_gc = 0;
$wp_super_cache_late_init = 0;
// uncomment the next line to enable advanced debugging features
$wp_super_cache_advanced_debug = 0;
$wp_super_cache_front_page_text = '';
$wp_super_cache_front_page_clear = 0;
$wp_super_cache_front_page_check = 0;
$wp_super_cache_front_page_notification = '0';
$wp_cache_anon_only = 0;
$wp_supercache_cache_list = 0;
$wp_cache_debug_to_file = 0;
$wp_super_cache_debug = 0;
$wp_cache_debug_level = 5;
$wp_cache_debug_ip = '';
$wp_cache_debug_log = '';
$wp_cache_debug_email = '';
$wp_cache_pages[ "search" ] = 0;
$wp_cache_pages[ "feed" ] = 0;
$wp_cache_pages[ "category" ] = 0;
$wp_cache_pages[ "home" ] = 0;
$wp_cache_pages[ "frontpage" ] = 0;
$wp_cache_pages[ "tag" ] = 0;
$wp_cache_pages[ "archives" ] = 0;
$wp_cache_pages[ "pages" ] = 0;
$wp_cache_pages[ "single" ] = 0;
$wp_cache_pages[ "author" ] = 0;
$wp_cache_hide_donation = 0;
$wp_cache_not_logged_in = 0;
$wp_cache_clear_on_post_edit = 0;
$wp_cache_hello_world = 0;
$wp_cache_mobile_enabled = 0;
$wp_cache_cron_check = 0;
$wp_cache_mfunc_enabled = 0;
$wp_cache_make_known_anon = 0;
$wp_cache_refresh_single_only = 0;
$wp_cache_mod_rewrite = 0;
$wp_supercache_304 = 0;
$wp_cache_front_page_checks = 0;
$wp_cache_disable_utf8 = 0;
$wp_cache_no_cache_for_get = 0;
$cache_scheduled_time = "00:00";
$wp_cache_preload_interval = 600;
$cache_schedule_type = 'interval';
$wp_cache_preload_posts = 0;
$wp_cache_preload_on = 0;
$wp_cache_preload_taxonomies = 0;
$wp_cache_preload_email_me = 0;
$wp_cache_preload_email_volume = 'none';
$wp_cache_mobile_prefixes = '';
$cached_direct_pages = array();
$wpsc_served_header = false;
$cache_gc_email_me = 0;
$wpsc_save_headers = 0;
$cache_schedule_interval = 'daily';
$wp_super_cache_comments = 1;
$wpsc_version = 169;
?>
<?php
if ( ! function_exists( 'wp_cache_phase2' ) ) {
require_once dirname( __FILE__ ) . '/wp-cache-phase2.php';
}
// error_reporting(E_ERROR | E_PARSE); // uncomment to debug this file!
if ( !defined( 'WPCACHECONFIGPATH' ) ) {
define( 'WPCACHECONFIGPATH', WP_CONTENT_DIR );
}
if ( ! @include WPCACHECONFIGPATH . '/wp-cache-config.php' ) {
return false;
}
if ( ! defined( 'WPCACHEHOME' ) ) {
define( 'WPCACHEHOME', dirname( __FILE__ ) . '/' );
}
if ( defined( 'DISABLE_SUPERCACHE' ) ) {
wp_cache_debug( 'DISABLE_SUPERCACHE set, super_cache disabled.' );
$super_cache_enabled = 0;
}
require WPCACHEHOME . 'wp-cache-base.php';
if ( '/' === $cache_path || empty( $cache_path ) ) {
define( 'WPSCSHUTDOWNMESSAGE', 'WARNING! Caching disabled. Configuration corrupted. Reset configuration on Advanced Settings page.' );
add_action( 'wp_footer', 'wpsc_shutdown_message' );
define( 'DONOTCACHEPAGE', 1 );
return;
}
if ( $blogcacheid != '' ) {
$blog_cache_dir = str_replace( '//', '/', $cache_path . 'blogs/' . $blogcacheid . '/' );
} else {
$blog_cache_dir = $cache_path;
}
$wp_cache_phase1_loaded = true;
$mutex_filename = 'wp_cache_mutex.lock';
$new_cache = false;
if ( ! isset( $wp_cache_plugins_dir ) ) {
$wp_cache_plugins_dir = WPCACHEHOME . 'plugins';
}
if ( isset( $_GET['donotcachepage'] ) && isset( $cache_page_secret ) && $_GET['donotcachepage'] == $cache_page_secret ) {
$cache_enabled = false;
define( 'DONOTCACHEPAGE', 1 );
}
$plugins = glob( $wp_cache_plugins_dir . '/*.php' );
if ( is_array( $plugins ) ) {
foreach ( $plugins as $plugin ) {
if ( is_file( $plugin ) ) {
require_once $plugin;
}
}
}
if ( isset( $wpsc_plugins ) && is_array( $wpsc_plugins ) ) {
foreach( $wpsc_plugins as $plugin_file ) {
if ( file_exists( ABSPATH . $plugin_file ) ) {
include_once( ABSPATH . $plugin_file );
}
}
}
if (
file_exists( WPCACHEHOME . '../wp-super-cache-plugins/' ) &&
is_dir( WPCACHEHOME . '../wp-super-cache-plugins/' )
) {
$plugins = glob( WPCACHEHOME . '../wp-super-cache-plugins/*.php' );
if ( is_array( $plugins ) ) {
foreach ( $plugins as $plugin ) {
if ( is_file( $plugin ) ) {
require_once $plugin;
}
}
}
}
$wp_start_time = microtime();
if ( wpsc_is_backend() ) {
return true;
}
if ( wpsc_is_rejected_cookie() ) {
define( 'DONOTCACHEPAGE', 1 );
$cache_enabled = false;
wp_cache_debug( 'Caching disabled because rejected cookie found.' );
return true;
}
if ( wpsc_is_caching_user_disabled() ) {
wp_cache_debug( 'Caching disabled for logged in users on settings page.' );
return true;
}
if ( isset( $wp_cache_make_known_anon ) && $wp_cache_make_known_anon ) {
wp_supercache_cache_for_admins();
}
do_cacheaction( 'cache_init' );
if ( ! $cache_enabled || ( isset( $_SERVER['REQUEST_METHOD'] ) && in_array( $_SERVER['REQUEST_METHOD'], array( 'POST', 'PUT', 'DELETE' ) ) ) || isset( $_GET['customize_changeset_uuid'] ) ) {
return true;
}
$file_expired = false;
$cache_filename = '';
$meta_file = '';
$wp_cache_gzip_encoding = '';
$gzipped = 0;
$gzsize = 0;
if ( $cache_compression ) {
$wp_cache_gzip_encoding = gzip_accepted();
}
add_cacheaction( 'supercache_filename_str', 'wp_cache_check_mobile' );
if ( function_exists( 'add_filter' ) ) { // loaded since WordPress 4.6
add_filter( 'supercache_filename_str', 'wp_cache_check_mobile' );
}
$wp_cache_request_uri = wpsc_remove_tracking_params_from_uri( $_SERVER['REQUEST_URI'] ); // Cache this in case any plugin modifies it and filter out tracking parameters.
if ( defined( 'DOING_CRON' ) ) {
extract( wp_super_cache_init() ); // $key, $cache_filename, $meta_file, $cache_file, $meta_pathname
return true;
}
if ( ! isset( $wp_super_cache_late_init ) || ( isset( $wp_super_cache_late_init ) && false == $wp_super_cache_late_init ) ) {
wp_cache_serve_cache_file();
}
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.