The Blog

WordPress 3.0 Admin Issues (CSS/Javascript)

Recently I moved a WordPress web site from one server to another. The “move-from” server was running an older version of php than the “move-to” server. After logging into the WordPress administration, I noticed that the css was all messed up. Part of the css was working (displaying some icons, colors, etc.), but the majority looked bad.

When I inspected the css, I noticed that only a few css files were loading. I compared the amount of css files loading to a fully-functional admin using the “View page source” feature of Google chrome. The functional admin had loaded more css files.

CSS Loading Issue

It looked like some problem with the following line of html in the source code:

<link rel='stylesheet' href='http://www.mywebsite.com/wp-admin/load-styles.php?c=1&dir=ltr&load=global,wp-admin&ver=6fc53cd39ae6e24cbe8675674f4082af' type='text/css' media='all' /> 

The load-styles.php code wasn’t working right. It wasn’t loading the style sheets. After some searching, I found a temporary solution to the problem by commenting out the following lines in the /wp-admin/load-styles.php file.

/*
if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
 header('Vary: Accept-Encoding'); // Handle proxies
  if ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
    header('Content-Encoding: deflate');
    $out = gzdeflate( $out, 3 );
  } elseif ( false !== strpos( strtolower($_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') && function_exists('gzencode') ) {
    header('Content-Encoding: gzip');
    $out = gzencode( $out, 3 );
  }
}
*/

That fixed all of the css problems, but then I noticed that the JavaScript wasn’t really working. The TinyMCE editor wouldn’t display html, the menu items woudn’t drop-down and some of the links weren’t working.

JavaScript Failing Issues

So, my first thought was to have a look at the JavaScript error console while using the administration. It was telling me that some JavaScript was missing referenced by the following lines of html in the source code:

<script type='text/javascript' src='http://www.mywebsite.com/wp-admin/load-scripts.php?c=1&load=jquery,utils,jquery-ui-core,thickbox&ver=199daaf27165d368f1e6306c15abc9b6'></script> 

This looked like the same problem as the styles loader, and that it could be fixed by commenting out the following lines in the /wp-admin/load-scripts.php:

/*
if ( $compress && ! ini_get('zlib.output_compression') && 'ob_gzhandler' != ini_get('output_handler') && isset($_SERVER['HTTP_ACCEPT_ENCODING']) ) {
  header('Vary: Accept-Encoding'); // Handle proxies
  if ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') && function_exists('gzdeflate') && ! $force_gzip ) {
    header('Content-Encoding: deflate');
    $out = gzdeflate( $out, 3 );
  } elseif ( false !== stripos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') ) {
    header('Content-Encoding: gzip');
    $out = gzencode( $out, 3 );
  }
}
*/

I never got this far. As soon as I found out that it had something to do with zlib.output_compression (see ini_get() function above), I started to look into the differences between the two servers I was working with. I though that one of them might not be using output compression. I checked both servers for this feature; I checked by looking for zlib.output_compression in the php.ini file. Both servers had the feature enabled.

Solution

So, rather than try to debug the servers, I focused on WordPress again. I was using WordPress version 3.0.1 (you can check the version of WordPress you are using if you look at the source of the /wp-includes/version.php file). I decided to upgrade to version 3.2.1, the latest stable release, to see if that would fix the problem.

As soon as I finished the upgrade, everything worked fine. I don’t know why version 3.0.1 was failing on the new server (PHP version 5.2.17), but the problem was resolved with the latest version of WordPress.

Tags: , ,

No comments yet.

Leave a Comment

Remember to play nicely folks, nobody likes a troll.

You must be logged in to post a comment.