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(…).


53 Responses to “K2 + WordPress 2.5 = Broken? I Can Fix That”  

  1. 1 Gray

    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. 2 Gray

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

  3. 3 jeremy

    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. 4 jeremy

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

  5. 5 Brad

    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. 6 John Griffin

    Cheers matey.

  7. 7 Brad

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

  8. 8 Stefan

    THANKS!

  9. 9 Boothy

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

  10. 10 Boothy

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

  11. 11 cr0wley

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

  12. 12 molgar
  13. 13 Andrew

    Thanks for this fix.

  14. 14 Brad

    @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. 15 Alan

    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. 16 Brad

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

  17. 17 Jon Andrews

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

  18. 18 juergentreml

    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. 19 diditellyou

    WOW!

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

  20. 20 Petter

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

  21. 21 Petter

    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. 22 Koki

    Works great! thank you.

    PS: What’s the plugin for the syntax?

  23. 23 Todd

    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. 24 bramloquet

    thanks for this solution.

  25. 25 lucky

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

  26. 26 François B.

    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. 27 Richard Mondello

    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. 28 Brad

    @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. 29 Olly

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

  30. 30 A

    omg, thank you so much!!

  31. 31 Rizwan

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

  32. 32 adrianusv

    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. 33 escaliers

    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. 34 escaliers

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

  35. 35 rudds

    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. 36 Johnson

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

  37. 37 Poster

    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 … ;-)

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

Leave a Reply