Getting PHP Speedy Plugin to Work with WordPress 2.6

WordPress 2.6 significantly improves the way JavaScript and CSS files can be added to the HTML <head>, and because of these changes the methods of WP_Scripts class have been altered a lot.

Therefore PHP Speedy — my favourit plugin which I think should be incorporated into the WordPress core — requires the following changes to work with WordPress 2.6.

Replace lines 774 to 787 in php_speedy_wp.php:

if(!method_exists($wp_scripts,'default_scripts')) {
   $wp_scripts = new WP_Scripts();
   $wp_scripts->default_scripts();
}

//Which libraries are used by this installation?
foreach($wp_scripts->scripts AS $object) {

with:

// check if $wp_scripts is loaded and not empty
if(!is_object($wp_scripts) && empty($wp_scripts)) {
   $wp_scripts = new WP_Scripts();
}

if (method_exists($wp_scripts,'default_scripts')) {
   // if wp 2.5
   $wp_did_register = $wp_scripts->scripts;
} else {
   // if wp 2.6
   $wp_did_register = $wp_scripts->registered;
}

//Which libraries are used by this installation?
foreach($wp_did_register AS $object) {

Notice that the only change is the $wp_scripts->registered variable which is replacing $wp_scripts->scripts in WordPress 2.6.

9 Comments

Mario 1 year, 8 months ago

awesome, deserve a try!
and nice design here.

kM 1 year, 7 months ago

The plugin is work really great! Thanx for the code!

ghprod 1 year, 6 months ago

So is it working with wp 2.6.1?

I’ll try it at home :)

Thnx

Kaspars 1 year, 6 months ago

ghprod, yes, it does. Get the latest version of the plugin from the author’s website.

Andy 1 year, 4 months ago

He man! As you know I adore the php speedy plugin as much as you.. The author of the plugin isn’t as speedy as u and as you’ve fixed the last comptability problem I hope you can help now again ;) Could you make the plugin working in Wordpress 2.7? In my case the whole site just doesn’t show at all when I activate the plugin 0.4.7 :(

Kaspars 1 year, 4 months ago

Andy, I tried fixing it a long time ago, but it seems like this time there is more work to be done. I’ll be sure to post a fix once I can find it.

Andy 1 year, 3 months ago

Hope someone can come up with a fix soon.. ;) That plugin has been a pure lifesaver..

kaosklub 1 year, 3 months ago

Do you have any idea of the current state of the php-speedy plugin in wordpress 2.7?
Does it works?

Thanks.
Nice Blog.

Kaspars 1 year, 3 months ago

kaosklub, as far as I know, it doesn’t work.

Leave a comment

Note: Basic HTML formatting is allowed. If you post HTML or PHP fragments, wrap them with <code>...</code> which will automatically encode the HTML entities.

Es vienmēr tevi mīlēšu, Sirsniņ!