Skip to content

K2 + WordPress 2.5 = Broken? I Can Fix That

March 28, 2008
tags: , ,

TRICK: If you are using WordPress 2.5 with K2, please be advised that it will not work. Nope, not at all. You will get a error that may or may not look like this:

Fatal error: Call to undefined function wp_register_sidebar_widget() in /***/*****/***/***/********/***/*************/wp-admin/includes/dashboard.php on line 31

Well, I’ve found the solution so that K2 and WordPress 2.5 can live together… for now.

Go to your K2 installation and find apps/includes/widgets-removal.php. Open that up in Notepad or a code editor, and paste this in instead:

<?php
if(get_option('k2sidebarmanager') != 1) {
	remove_action('plugins_loaded', 'wp_maybe_load_widgets', 0);
	if( is_admin() ){ // If someone is trying to access the admin page
		global $pagenow;
		if( $pagenow == 'index.php' ) wp_maybe_load_widgets();
	}
}
?>

Magically, it will work.

Here’s why: WordPress 2.5 has a slick new dashboard that takes use of widgets to work. K2 blocks widgets when you use Sidebar Modules (which is awesome), so WordPress 2.5 can’t get to widgets.

What this does is make it so that Widgets is disabled for everywhere so that Sidebar Modules will work, EXCEPT for the dashboard. This pretty much solves it.

Nice and simple.

Note: If you want widgets with K2, don’t use the code above and comment out (add // to the beginning) the line that begins with remove_action(…).

Update: Apparently there’s been a lot of public interest in this, so I’m putting up a challenge for somebody to make a WordPress plugin to do this so that other themes using Sidebar Modules will be able to use the fix. Anybody up to the challenge? If you are, 1) make it into a plugin, 2) leave me a comment so I know, and we’ll 3) put it up on chaotic tech! With your name, of course.

61 Comments leave one →
  1. March 29, 2008 4:43 pm

    i get the idea, but i can’t use the code you posed here to fix it. pls include a .txt for us to use?

    Editor: Click where it says “plain text” at the top of the text box.

  2. March 29, 2008 4:45 pm

    nevermind, figured it out. here’s exactly wht you need to get it fixed!

  3. March 29, 2008 5:39 pm

    Thanks for this, it worked great. However it seems that the HTML formatting tags haven’t been stripped out from the code. And the if() block is missing a closing curly brace. Just to clarify, my entire file looks like this (and it works with 2.5):

    Editor’s Note: I’ve moved the info you need to the post. Thanks!

    Thanks again for the fix!

  4. March 29, 2008 5:40 pm

    Sorry, my code didn’t submit. You can find it here:
    Editor’s Note: Removed and placed in post.

  5. March 29, 2008 6:45 pm

    Thanks, Jeremy. I’ve updated the code with your cleaned version instead. Glad to see all the great response from readers! Seems my editor messed up my code.

  6. March 29, 2008 6:51 pm

    Cheers matey.

  7. March 29, 2008 6:55 pm

    Thanks, John, as well as everyone else for their fierce support. I thrive on comment and replies.

  8. Stefan permalink
    March 29, 2008 7:09 pm

    THANKS!

  9. March 29, 2008 8:33 pm

    It worked for me, except now I can’t reactivate any of my plugins, including askimet!

  10. March 29, 2008 8:40 pm

    Der, it turns out it was because I left an empty line before the above code. Nice work!

  11. March 30, 2008 7:00 am

    Cheers for that – I found this somewhere else and put it below the existing } – that didn’t work! (Oops)

  12. March 30, 2008 1:17 pm

    You can also update to K2 rc5 http://kaytwo.googlecode.com/files/K2%20Release%20Candidate%205.zip

  13. March 30, 2008 1:58 pm

    Thanks for this fix.

  14. March 30, 2008 3:23 pm

    @molgar: That would be useful, but Michael Heillemann needs to post the version up to getk2.com now! Until then, most of the people are using RC3.

  15. March 30, 2008 5:10 pm

    I used the code above but it doesn’t work perfectly for me… When I enable k2’s sidebar manager, it doesn’t show up and the “widget” under “design” is still there; however, when I disable k2’s sidebar manager, the widget is also gone…

    @molgar: I upgrade to k2 rc5 from march 7th’s rc5 version but k2’s sidebar manager is still not working… a fatal error message appears:
    “Fatal error: Call to a member function on a non-object in /html/wp-content/themes/k2/app/classes/sbm.php on line 704 ”

    Can anybody help me? Thx in advance!

  16. March 30, 2008 5:38 pm

    @Alan: Please direct support requests to the WordPress support forums or Trac, because I’m unable to help you here.

  17. March 30, 2008 9:02 pm

    Thank you sooo much! This also fixed my wordpress problem.

  18. juergentreml permalink
    March 31, 2008 2:05 am

    the above code doesn’t work. it seems to contain a tiny little logical error:

    if(get_option(‘k2sidebarmanager’) != 1) {

    should be changed to

    if(get_option(‘k2sidebarmanager’) == 1) {

  19. March 31, 2008 5:08 am

    WOW!

    Thank so so so so so much!! You’re my hero (: LOL

  20. March 31, 2008 8:09 am

    The RC5 version of K2 above is deprecated. I would not expect much support on it.

  21. March 31, 2008 8:14 am

    You could try using the disable wordpress widgets plugin to fix the SBM problem until the real RC 5 version (or whatever it will be named) of K2 is released.

  22. March 31, 2008 10:22 am

    Works great! thank you.

    PS: What’s the plugin for the syntax?

  23. March 31, 2008 11:56 am

    I still get some errors when I delete my spam, edit an existing post, add a category or publish a new post. Is that related to K2 at all?

  24. March 31, 2008 12:42 pm

    thanks for this solution.

  25. March 31, 2008 12:44 pm

    Ah thank you… works so much better now.
    : )

  26. March 31, 2008 1:09 pm

    Sorry, but when i try to send a post, it says :

    Warning: Cannot modify header information – headers already sent by (output started at /opt/lampp/htdocs/wordpress25/wp-content/themes/k2/app/includes/widgets-removal.php:11) in /opt/lampp/htdocs/wordpress25/wp-includes/pluggable.php on line 689

    Do you know how to fix that ?

  27. March 31, 2008 2:09 pm

    Updating the getk2 site would be really great. I tried this fix with RC4 and it’s not working. I’m going to completely uninstall k2 and try RC5.

  28. March 31, 2008 3:09 pm

    @Petter: The whole point of the fix is to get WordPress and SBM working. If you don’t want SBM, then don’t use my code and just comment out remove_action().

    @Koki: It comes with WordPress.com.

    @Todd: Nope. Update to the latest version.

    @Francios B.: No, I don’t. Submit to WordPress forums or Trac for help.

    @Richard Mondello: I hope it gets updated. The fix is tested for RC3.

    @juergentreml: Really? I will try to look into it.

    Thanks for the great feedback.

  29. March 31, 2008 8:41 pm

    Yeah, I’m now getting the same wp-includes/pluggable.php on line 689 error as Francois above…

  30. April 1, 2008 1:00 pm

    omg, thank you so much!!

  31. April 3, 2008 5:53 am

    Thanks guys, this fix whipped my WP back into shape in no time.

  32. April 3, 2008 10:33 am

    Eh.. “apps/includes/widgets-removal.php” I’m trying to use K2 RC5 revision 652, but there’s no widgets-removal.php in that map. 😕

  33. April 7, 2008 1:22 am

    I have updated from 2.3.3 to 2.5 and I was receiving errors, and now also after coming back to my backup , I receive this error:
    http://www.naimaclub.it/blues/

    an I cook them for you in may
    Warning: Cannot modify header information – headers already sent by (output started at /var/www/inp20118/blues/wp-config.php:1) in /var/www/inp20118/blues/wp-includes/pluggable.php on line 689

  34. April 7, 2008 1:46 am

    sorry, problem solved!
    I founded instructions here:
    http://codex.wordpress.org/Answers-Troubleshooting

  35. April 9, 2008 7:56 am

    i tried the code thing from this post, but then bounced me into another fatal error. K2 will fix the whole thing soon (as they said on their blogsite) however found something easier to remove the problem so in the meanwhile & whithout the code hustle….

    as written on http://getk2.com/forum/showthread.php?p=22342

    1. if you use k2 theme. u can’t open “wp-admin/” .
    2. but you can open “/wp-admin/themes.php” (or “/wp-admin/themes.php?page=k2-options”) ok open it.
    3. click “K2 Option” and disable “Sidebar Manager” .
    4. click “Save” and rejoin to “wp-admin/” .

    thanks Priesdelly!

  36. April 11, 2008 2:38 am

    Thanks Buddy u made my day with this useful piece of code !

  37. Poster permalink
    April 14, 2008 9:12 am

    ahaha … last night at about 1pm I installed a demo wordpress and today at the meeting with the customer (a company with 4000 employees) it just showed the above error message! always good to have a smart thing to say in those moments like … huh I think my dog ate that page … 😉

  38. Steve permalink
    June 18, 2008 8:31 am

    This gives me a ray of hope. I love Sidebar Modules, and am so depressed that I may be forced to swallow the WordPress Widgets after upgrading to version 2.5.1

    Your fix is for the K2 theme, but I’m guessing it could also work for the Sidebar Modules plugin from Nybble Labs which I’m currently using on other themes: http://nybblelabs.org.uk/projects/sidebar-modules/

    I also used the Disable WP Widgets plugin to kill widgets from WP 2.2+: http://schulte.mn/2007/05/04/disable-wordpress-widgets/

    But neither of these work in WP 2.5+ anymore. I noticed your code above contains the same line as the Disable WP Widgets plugin:

    remove_action(‘plugins_loaded’, ‘wp_maybe_load_widgets’, 0 )

    Any ideas on how to adapt this fix to work with Nybble Labs Sidebar Modules? I’m guessing I would need to replace ‘k2sidebarmanager’ with something else. But I’m not sure what.

  39. June 18, 2008 8:56 am

    @Steve (38): That’s right. The line is also in the Disable WP Widgets plugin but this one does something different than the rest, and that’s because it lets all queries for widgets within your control panel go through, but all others are blocked up, forcing Sidebar Modules.

    So anyone up for the challenge? It takes a few minutes to convert the code into a plugin, and we could offer it up on a plugin directory of some sort. Unfortunately, I am unable to do it. So anyone else wanna?

  40. Steve permalink
    June 20, 2008 3:13 pm

    Thanks for your response Brad! I just posted a comment over on the blog of the Disable WP Widgets creator for more info/input.

  41. June 21, 2008 12:53 pm

    @Steve (40): That would probably be a good idea; having the original plugin author modify his / her plugin instead of having us change it up.

    In theory, the plugin will be able to work with any theme that uses Sidebar Modules, because all it does is block out WordPress Widgets for everything except the administration. And it isn’t too hard to make a plugin, really, I just don’t have the time.

  42. July 9, 2008 1:35 pm

    I’m with Steve! I want SBM Reloaded with 2.5.1 to work. Any fixes yet to reenable the Dashboard?

  43. September 18, 2008 10:02 am

    Any word on a fix for Sidebar Modules plugin? It’s still the best out there!!! Help!

  44. Hosterr permalink
    December 14, 2008 9:23 am

    Many thanks

Trackbacks

  1. Upgraded to WordPress 2.5 at edsmiley.com
  2. How to fix your K2 powered wordpress blog after upgrading to 2.5 at Advanced CSS Design Resources - last-child.com
  3. WordPress update at ozmonic.com
  4. New Version of Wordpress at Jaywalk Blog
  5. WordPress 2.5 Update (+ K2 Snag) at A Mind Lost
  6. Wordpress 2.5 Troubleshooting at BlueCat is sleepy
  7. Error en Wordpress 2.5 con el tema K2 at El Módem
  8. Internetpret voor 2008-3-31 :: Dikkie
  9. Aux users de WP2.5 et de K2 - Miniping’s Blog & Life
  10. Wordpressssss! :shakes fist: at Randomness.
  11. Folgendes bekam ich angezeigt auf kikamagazin bloggt
  12. CornGuo’s BLOG, of murmurs » Archives » My patch for SBM on WordPress 2.5
  13. K2 Theme and WP 2.5 at blog.hoefers.com
  14. Wordpress 2.5 Fatal Error wp_register_sidebar_widget
  15. Unwakeable Theme And WordPress 2.5 at T. Longren
  16. Error al acceder al panel de adminsitración en K2 at Dublog
  17. Fatal error: Call to undefined function wp_register_sidebar_widget() in… | Tom Raftery's Social Media

Leave a reply to Brad Cancel reply