WordPress.org

Plugin Directory

Changeset 609482


Ignore:
Timestamp:
10/08/12 10:07:29 (19 months ago)
Author:
donncha
Message:
  • Use LOGGED_IN_COOKIE in more places, props askapache
  • Make sure to check if that constant is defined before using it to avoid fatal errors
  • Added wpsc_get_logged_in_cookie() to get cookie value without requiring rewrites of the .htaccess file
Location:
wp-super-cache/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-super-cache/trunk/wp-cache-phase1.php

    r608016 r609482  
    338338function wp_cache_get_cookies_values() { 
    339339    $string = ''; 
     340    if ( defined( 'LOGGED_IN_COOKIE' ) ) 
     341        $logged_in_cookie = preg_quote( constant( 'LOGGED_IN_COOKIE' ) ); 
     342    else     
     343        $logged_in_cookie = 'wordpress_logged_in'; 
    340344    while ($key = key($_COOKIE)) { 
    341         if ( preg_match( "/^wp-postpass|^wordpress_logged_in|^comment_author_/", $key ) ) { 
     345        if ( preg_match( "/^wp-postpass|^" . $logged_in_cookie . "|^comment_author_/", $key ) ) { 
    342346            if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( "Cookie detected: $key", 5 ); 
    343347            $string .= $_COOKIE[ $key ] . ","; 
  • wp-super-cache/trunk/wp-cache.php

    r608439 r609482  
    322322            <li> <?php _e( 'Scroll down the Advanced Settings page and click the <strong>Update Mod_Rewrite Rules</strong> button.', 'wp-super-cache' ); ?></li> 
    323323            <li> <?php printf( __( 'Delete the plugin mod_rewrite rules in %s.htaccess enclosed by <code># BEGIN WPSuperCache</code> and <code># END WPSuperCache</code> and let the plugin regenerate them by reloading this page.', 'wp-super-cache' ), $home_path ); ?></li> 
    324             <li> <?php printf( __( 'Add the rules yourself. Edit %s.htaccess and find the block of code enclosed by the lines <code># BEGIN WPSuperCache</code> and <code># END WPSuperCache</code>. There are two sections that look very similar. Just below the line <code>%%{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$</code> add these lines: (do it twice, once for each section)', 'wp-super-cache' ), $home_path ); ?></p> 
     324            <li> <?php printf( __( 'Add the rules yourself. Edit %s.htaccess and find the block of code enclosed by the lines <code># BEGIN WPSuperCache</code> and <code># END WPSuperCache</code>. There are two sections that look very similar. Just below the line <code>%%{HTTP:Cookie} !^.*(comment_author_|%s|wp-postpass_).*$</code> add these lines: (do it twice, once for each section)', 'wp-super-cache' ), $home_path, wpsc_get_logged_in_cookie() ); ?></p> 
    325325            <div style='padding: 2px; margin: 2px; border: 1px solid #333; width:400px; overflow: scroll'><pre><?php echo "RewriteCond %{HTTP_user_agent} !^.*(" . addcslashes( implode( '|', $wp_cache_mobile_browsers ), ' ' ) . ").*\nRewriteCond %{HTTP_user_agent} !^(" . addcslashes( implode( '|', $wp_cache_mobile_prefixes ), ' ' ) . ").*"; ?></pre></div></li></ol></div><?php  
    326326    } 
     
    27252725} 
    27262726 
     2727/*  
     2728 * Return LOGGED_IN_COOKIE if it doesn't begin with wordpress_logged_in 
     2729 * to avoid having people update their .htaccess file 
     2730 */ 
     2731function wpsc_get_logged_in_cookie() { 
     2732    $logged_in_cookie = 'wordpress_logged_in'; 
     2733    if ( defined( 'LOGGED_IN_COOKIE' ) && substr( constant( 'LOGGED_IN_COOKIE' ), 0, 19 ) != 'wordpress_logged_in' )  
     2734        $logged_in_cookie = constant( 'LOGGED_IN_COOKIE' ); 
     2735    return $logged_in_cookie; 
     2736} 
     2737 
    27272738function wpsc_get_htaccess_info() { 
    27282739    global $wp_cache_mobile_enabled, $wp_cache_mobile_prefixes, $wp_cache_mobile_browsers, $wp_cache_disable_utf8; 
     
    27682779    $condition_rules[] = "RewriteCond %{REQUEST_METHOD} !POST"; 
    27692780    $condition_rules[] = "RewriteCond %{QUERY_STRING} !.*=.*"; 
    2770     $condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$"; 
     2781    $condition_rules[] = "RewriteCond %{HTTP:Cookie} !^.*(comment_author_|" . wpsc_get_logged_in_cookie() . "|wp-postpass_).*$"; 
    27712782    $condition_rules[] = "RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\\\"]+ [NC]"; 
    27722783    $condition_rules[] = "RewriteCond %{HTTP:Profile} !^[a-z0-9\\\"]+ [NC]"; 
Note: See TracChangeset for help on using the changeset viewer.