Framebusters Break WordPress Theme Activation

If you manage a WordPress site, you probably need to know about this. If you use any “framebuster” javascript in your WordPress theme, and you deactivate that theme and then try to reactivate it, you cannot reactivate it. Well, you can, but you have to take the framebuster code out temporarily.

Okay, some of you may be asking, what is framebuster code and why would I want to use it anyway? The answer is provided by Danny Sullivan of Search Engine Land in his post The Growth of Framebars and Kevin Rose on the Diggbar. In that article, Danny talks about how Digg’s use of the Diggbar can keep you from getting link credit (it passes the credit to Digg).

When I read Danny’s article, I immediately added the framebusting code into the custom_functions.php file for my Thesis theme, so the code would be added to the header. Here’s what the javascript code looks like:

Framebuster Code

I’ve shown it as picture because javascript doesn’t copy nicely into a post. If you want to copy and paste the actual javascript code, you can just view the source of my header.

Anyway, being the perpetual tinkerer that I am, I also decided to tinker with another theme, and activated it for a few hours. But, when I tried to switch back to Thesis, I could not do so. The reason was that WordPress gives you a preview of theme before you can activate it, and the preview is shown within a frame. And, since my Thesis code had the framebuster code within it, it busted the WordPress preview so that I could not choose the activation button.

The fix was simple. After I finally realized what was going on, I just removed the code from my Thesis theme, uploaded the change via ftp, activated the theme, and then added the framebuster code back in and uploaded it via ftp.

So, if you are using the framebuster code and you run into this when you are monkeying around with different themes, now you know the fix.

Update: My good buddy Thomas R. Hall modified the javascript code shown above so that it works to bust frames except those generated within your own site, including the WordPress Theme Activation Frame. The code is shown pictorially below. Again, to copy and paste the actual code, just view the source of this page with your browser and copy and paste the code, modifying it for your site of course. Note: sometimes I have the framebuster code turned off, though, so it is best to just use the code below.

Updated Framebuster Code


 

This entry was posted in Tip and tagged . Bookmark the permalink.
  • http://stein.everybody.org/journal/ Jeremy Stein

    I haven’t tried this code, but it seems that you should be able to check the referer before “busting” the frame. If it’s coming from your own site, then leave it.

  • http://www.keenerliving.com/ Bruce Keener

    Good observation, Jeremy. My knowledge of php and css is not too shabby, but unfortunately I know virtually nothing about javascript, or I would do a variation that would address your point. Maybe someone else can chime in with a solution that won’t bust the WordPress activation.

  • http://diyninjas.com Mitch

    Awesome tip as always, Bruce.

    Just gave this a test with a post using the Digg bar and it works a treat.

    In light of Danny et al’s analysis, I think this is a pretty crucial piece of information to get out there. For those using Thesis, as you mentioned, adding this code really is a piece of cake. I’ve put mine into a function called framebuster() and have hooked in as follows:

    add_action(‘wp_head’,'framebuster’);

    Too easy! Thanks again, Bruce.

  • http://www.keenerliving.com/ Bruce Keener

    Thanks for the comment Mitch, and thanks for pointing out how easy it is to put the code into Thesis. I just use one function for my header that puts in my Google, MSN, Yahoo verification codes, Thickbox and jQuery scripting, and so on, and added the framebuster code to that. A snap as you say.

    I love your work, by the way, and all that you are doing for the “Thesis community.”

  • http://www.davethetruth.com David

    Thanks Bruce, this exactly what I needed. If you want to submit this on digg I’ll shout it to my friends, just let me know: http://digg.com/users/davidthemavin

    Mitch, you left Bruce’s URL in your code so you could end up breaking your site still if you’re using frames somewhere just fyi.

  • http://www.keenerliving.com/ Bruce Keener

    David,
    Glad it helped you. I’m not looking to be Dugg or Stumbled, but thank you for the kind offer.

    Take care
    Bruce