[wp-trac] [WordPress Trac] #26876: Default widgets causing unnecessary database queries

WordPress Trac noreply at wordpress.org
Mon Jan 20 03:17:58 UTC 2014


#26876: Default widgets causing unnecessary database queries
--------------------------+-----------------------------
 Reporter:  codydh        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Widgets       |    Version:  3.8
 Severity:  minor         |   Keywords:
--------------------------+-----------------------------
 I wasn't able to find this bug reported, so I hope it's not a duplicate.
 Apologies in advance if it is!

 It seems that WordPress is checking the options table of the database for
 four widgets, widget_pages, widget_calendar, widget_tag_cloud, and
 widget_nav_menu, even when these widgets aren't activated, and even when
 the theme has no widget area:

 {{{
 Query: SELECT option_value FROM xy_options WHERE option_name =
 'widget_pages' LIMIT 1
 Query: SELECT option_value FROM xy_options WHERE option_name =
 'widget_calendar' LIMIT 1
 Query: SELECT option_value FROM xy_options WHERE option_name =
 'widget_tag_cloud' LIMIT 1
 Query: SELECT option_value FROM xy_options WHERE option_name =
 'widget_nav_menu' LIMIT 1
 }}}

 One easy fix is to add the following lines to functions.php:

 {{{
 add_action( 'widgets_init', 'remove_unneeded_widgets' );
 function remove_unneeded_widgets() {
     unregister_widget('WP_Widget_Pages');
     unregister_widget('WP_Widget_Calendar');
     unregister_widget('WP_Widget_Tag_Cloud');
     unregister_widget('WP_Nav_Menu_Widget');
 }
 }}}

 Much of this information was corroborated by a StackExchange post
 (http://wordpress.stackexchange.com/questions/81785/remove-unnecessary-
 mysql-query/82420#82420) from early 2013, indicating this may have been
 around for a while.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/26876>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list