Commit 43258b9c authored by ale's avatar ale Committed by lucha
Browse files

[auto] Plugin: wp-super-cache 1.4.4

parent f0f9cee2
<?php
# WP SUPER CACHE 0.8.9.1
# WP SUPER CACHE 1.2
function wpcache_broken_message() {
global $wp_cache_config_file;
if ( isset( $wp_cache_config_file ) == false )
return '';
if ( false == strpos( $_SERVER[ 'REQUEST_URI' ], 'wp-admin' ) )
echo "<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->";
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 ( !include_once( 'CACHEHOME' . 'wp-cache-phase1.php' ) ) {
if ( !@is_file( 'CACHEHOME' . 'wp-cache-phase1.php' ) ) {
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 );
register_shutdown_function( 'wpcache_broken_message' );
}
}
if ( defined( 'ADVANCEDCACHEPROBLEM' ) )
register_shutdown_function( 'wpcache_broken_message' );
?>
......@@ -149,7 +149,6 @@ function scossdl_off_options() {
$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="">
......@@ -196,7 +195,7 @@ function scossdl_off_options() {
<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>
<p><?php _e( 'CDN functionality provided by <a href="http://wordpress.org/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
}
?>
......@@ -16,7 +16,7 @@ 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) {
......@@ -28,9 +28,9 @@ function wp_supercache_awaitingmoderation_admin() {
}
$id = 'awaitingmoderation-section';
?>
<fieldset id="<?php echo $id; ?>" class="options">
<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">
<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>
......@@ -42,7 +42,7 @@ function wp_supercache_awaitingmoderation_admin() {
$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>';
echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
?>
</form>
......
......@@ -33,7 +33,7 @@ function get_bb_file_loc() {
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;
......@@ -59,21 +59,21 @@ function wp_supercache_badbehaviour_admin() {
}
$id = 'badbehavior-section';
?>
<fieldset id="<?php echo $id; ?>" class="options">
<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">
<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 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 ($changed) {
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>';
echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
?>
</form>
......
......@@ -10,7 +10,7 @@ function domain_mapping_gc_cache( $function, $directory ) {
if ( !$siteurl )
return false;
$protocol = ( 'on' == strtolower( $_SERVER['HTTPS' ] ) ) ? 'https://' : 'http://';
$protocol = ( isset( $_SERVER['HTTPS' ] ) && 'on' == strtolower( $_SERVER['HTTPS' ] ) ) ? 'https://' : 'http://';
$siteurl = trailingslashit( str_replace( $protocol, '', $siteurl ) );
if ( $directory == 'homepage' )
......@@ -22,8 +22,8 @@ function domain_mapping_gc_cache( $function, $directory ) {
@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 );
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;
}
......@@ -39,7 +39,7 @@ function domain_mapping_supercachedir( $dir ) {
if ( !$siteurl )
return $dir;
$protocol = ( 'on' == strtolower( $_SERVER['HTTPS' ] ) ) ? 'https://' : 'http://';
$protocol = ( isset( $_SERVER['HTTPS' ] ) && 'on' == strtolower( $_SERVER['HTTPS' ] ) ) ? 'https://' : 'http://';
$siteurl = str_replace( $protocol, '', $siteurl );
return $cache_path . 'supercache/' . $siteurl;
}
......@@ -55,7 +55,7 @@ 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) {
......@@ -69,21 +69,21 @@ function wp_supercache_domain_mapping_admin() {
}
$id = 'domain_mapping-section';
?>
<fieldset id="<?php echo $id; ?>" class="options">
<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">
<form name="wp_manager" action="" 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 ($changed) {
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>';
echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
?>
</form>
......
<?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 ****
*/
/*
* 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 ( $cachedata === 0 ) { // 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." ), 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="http://wordpress.org/extend/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" );
else
$status = __( "disabled" );
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 ( file_exists( dirname( WPCACHEHOME ) . '/jetpack/class.jetpack-user-agent.php' ) ) {
if ( function_exists( "jetpack_is_mobile" ) == false )
include( dirname( WPCACHEHOME ) . '/jetpack/class.jetpack-user-agent.php' );
if ( jetpack_is_mobile() )
return 'mobile';
else
return 'normal';
} else {
wp_cache_debug( "wp_super_cache_jetpack_cookie_check: jetpack UA file not found." );
return "normal";
}
}
if ( isset( $cache_jetpack ) && $cache_jetpack == 1 ) {
add_cacheaction( 'wp_cache_check_mobile', 'wp_super_cache_jetpack_cookie_check' );
}
?>
......@@ -8,9 +8,9 @@ function wp_supercache_searchengine( $string ) {
if( $string != '' )
return $string;
if( $_COOKIE[ '7a1254cba80da02d5478d91cfd0a873a' ] == 1 ) {
if( isset( $_COOKIE[ '7a1254cba80da02d5478d91cfd0a873a' ] ) && $_COOKIE[ '7a1254cba80da02d5478d91cfd0a873a' ] == 1 ) {
$string = 'searchengine';
} elseif( $_SERVER[ 'HTTP_REFERER' ] != '' ) {
} elseif( isset( $_SERVER[ 'HTTP_REFERER' ] ) && $_SERVER[ 'HTTP_REFERER' ] != '' ) {
if( is_array( $passingthrough ) == false )
return $string;
......@@ -54,7 +54,7 @@ add_cacheaction( 'add_cacheaction', 'searchengine_phase2_actions' );
function wp_supercache_searchengine_admin() {
global $cache_no_adverts_for_friends, $wp_cache_config_file, $valid_nonce;
$cache_no_adverts_for_friends = $cache_no_adverts_for_friends == '' ? 'no' : $cache_no_adverts_for_friends;
if(isset($_POST['cache_no_adverts_for_friends']) && $valid_nonce) {
......@@ -63,21 +63,21 @@ function wp_supercache_searchengine_admin() {
}
$id = 'no_adverts_for_friends-section';
?>
<fieldset id="<?php echo $id; ?>" class="options">
<fieldset id="<?php echo $id; ?>" class="options">
<h4><?php _e( 'No Adverts for Friends', 'wp-super-cache' ); ?></h4>
<form name="wp_manager" action="<?php echo $_SERVER[ "REQUEST_URI" ]; ?>" method="post">
<form name="wp_manager" action="" method="post">
<label><input type="radio" name="cache_no_adverts_for_friends" value="1" <?php if( $cache_no_adverts_for_friends == 'yes' ) { echo 'checked="checked" '; } ?>/> <?php _e( 'Enabled', 'wp-super-cache' ); ?></label>
<label><input type="radio" name="cache_no_adverts_for_friends" value="0" <?php if( $cache_no_adverts_for_friends == 'no' ) { 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://ocaoimh.ie/no-adverts-for-friends/">No Adverts for Friends</a>.', 'wp-super-cache' ) . '</p>';
if ($changed) {
if ( isset( $changed ) && $changed ) {
if ( 'yes' == $cache_no_adverts_for_friends )
$status = __( "enabled" );
else
$status = __( "disabled" );
echo "<p><strong>" . sprintf( __( "No Adverts for Friends support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
}
echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
?>
</form>
......
......@@ -2,7 +2,7 @@
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) {
......@@ -16,21 +16,21 @@ function wp_super_cache_wptouch_admin() {
}
$id = 'wptouch-section';
?>
<fieldset id="<?php echo $id; ?>" class="options">
<fieldset id="<?php echo $id; ?>" class="options">
<h4><?php _e( 'WPTouch', 'wp-super-cache' ); ?></h4>
<form name="wp_manager" action="<?php echo $_SERVER[ "REQUEST_URI" ]; ?>" method="post">
<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>
<p><?php _e( '', 'wp-super-cache' ); ?></p><?php
<?php
echo '<p>' . __( 'Provides support for <a href="http://wordpress.org/extend/plugins/wptouch/">WPTouch</a> mobile theme and plugin.', 'wp-super-cache' ) . '</p>';
if ($changed) {
if ( isset( $changed ) && $changed ) {
if ( $cache_wptouch )
$status = __( "enabled" );
else
$status = __( "disabled" );
echo "<p><strong>" . sprintf( __( "WPTouch support is now %s", 'wp-super-cache' ), $status ) . "</strong></p>";
}
echo '<div class="submit"><input ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
echo '<div class="submit"><input class="button-primary" ' . SUBMITDISABLED . 'type="submit" value="' . __( 'Update', 'wp-super-cache' ) . '" /></div>';
wp_nonce_field('wp-cache');
?>
</form>
......@@ -57,13 +57,14 @@ if ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'wpsupercache' ) {
add_cacheaction( 'add_cacheaction', 'wp_super_cache_wptouch_exists' );
}
// disable mobile checking if
// disable mobile checking if
function wp_super_cache_maybe_disable_wptouch( $t ) {
global $cache_wptouch, $wptouch_exclude_ua;
if ( $cache_wptouch != 1 )
return false;
if ( isset( $_COOKIE[ 'wptouch_switch_toggle' ] ) && $_COOKIE['wptouch_switch_toggle'] == 'normal' )
if ( ( isset( $_COOKIE[ 'wptouch_switch_toggle' ] ) && $_COOKIE[ 'wptouch_switch_toggle' ] == 'normal' ) ||
( isset( $_COOKIE[ 'wptouch-pro-view' ] ) && $_COOKIE[ 'wptouch-pro-view' ] == 'desktop' ) )
return true;
$ua = explode( ",", $wptouch_exclude_ua );
......@@ -95,7 +96,7 @@ function wp_super_cache_wptouch_browsers( $browsers ) {
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' ] ) )
......@@ -103,10 +104,17 @@ function wp_super_cache_wptouch_cookie_check( $cache_key ) {
if ( $_COOKIE[ 'wptouch_switch_toggle' ] == 'normal' || $_COOKIE[ 'wptouch_switch_toggle' ] == 'mobile' )
return $_COOKIE[ 'wptouch_switch_toggle' ];
if ( isset( $_COOKIE[ 'wptouch-pro-view' ] ) ) {
if ( $_COOKIE[ 'wptouch-pro-view' ] == 'desktop' )
return 'normal';
else
return $_COOKIE[ 'wptouch-pro-view' ];
}
return $cache_key;
}
if ( $cache_wptouch == 1 ) {
if ( isset( $cache_wptouch ) && $cache_wptouch == 1 ) {
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' );
......
=== WP Super Cache ===
Contributors: donncha, automattic
Tags: performance,caching,wp-cache,wp-super-cache,cache
Tested up to: 3.4
Stable tag: 1.1
Tested up to: 4.2.2
Stable tag: 1.4.4