PDA

View Full Version : (PATCH) K2 SVN sidebar manager breaks wp-admin/index.php in WP SVN


jbhannah
January 10th, 2008, 04:35
The problem was that the function wp_get_sidebars_widgets() was being called by the admin index page (the dashboard), but since K2's sidebar manager obviously doesn't use WP's widgets, if the sidebar manager is enabled then the admin dashboard will break. The rest of the admin pages still work, to my knowledge--but the dashboard is what you see first, and it is problematic to have it plain not working.

So here's a quick fix in the form of svn diff output. This is with WP SVN and K2 SVN, and it could be either one that's causing issues, but if you know PHP you'll get the general idea of how this works.

Index: wp-admin/index.php
================================================== =================
--- wp-admin/index.php (revision 6587)
+++ wp-admin/index.php (working copy)
@@ -72,8 +72,12 @@
<p class="youhave"><?php echo $sentence; ?></p>
<?php
$ct = current_theme_info();
-$sidebars_widgets = wp_get_sidebars_widgets();
-$num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev, $curr', 'return $prev+count($curr);' ) );
+if(function_exists(wp_get_sidebars_widgets)) {
+ $sidebars_widgets = wp_get_sidebars_widgets();
+ $num_widgets = array_reduce( $sidebars_widgets, create_function( '$prev, $curr', 'return $prev+count($curr);' ) );
+} else {
+ $num_widgets = 0;
+}
$widgets_text = sprintf( __ngettext( '%d widget', '%d widgets', $num_widgets ), $num_widgets );
?>
<p><?php printf( __( 'You are using %1$s theme with %2$s.' ), $ct->title, "<a href='widgets.php'>$widgets_text</a>" ); ?> <a href="themes.php" class="rbutton"><?php _e('Change Theme'); ?></a> You're using BetaPress TODO.</p>

Basically, check first to see if the wp_get_sidebars_widgets() function exists first. If it doesn't--and this is kind of a hack for now--just spit out that 0 widgets are being used.

kristin
January 10th, 2008, 05:34
Nice! Thanks for this. I'm using the svn for k2 and wp so i havent gotten to use the sbm much yet. I'll give it a try.

kristin
January 10th, 2008, 05:55
Worked like a charm! Awesome!

steveo
January 10th, 2008, 06:45
Be sure to post a bug ticket in trac.wordpress.org. The new WP admin interface still needs a lot of work. I'll try hacking in some sbm features into widgets.