WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#9349 closed defect (bug) (fixed)

Load widgets.php Before Plugins Because Of New WP_Widget Class

Reported by: GamerZ Owned by:
Milestone: 2.8 Priority: high
Severity: normal Version: 2.8
Component: Widgets Keywords: widgets
Focuses: Cc:

Description

widgets.php is only included when wp_maybe_load_widgets() is called in /wp-includes/functions.php.

function wp_maybe_load_widgets() {
	if ( !function_exists( 'dynamic_sidebar' ) ) {
		require_once( ABSPATH . WPINC . '/widgets.php' );
		add_action( '_admin_menu', 'wp_widgets_add_menu' );
	}
}

But in WP2.8 there is a new WP_Widget Class, if I attempt to create a new Widget Class extending on this class in my plugin, it will prompt me "Class 'WP_Widget' not found" because the class is not included before the plugin.

Should we load widgets.php in wp-settings.php? Or we should move the class portion to new file called class-widgets.php?

Change History (2)

comment:1 @ryan6 years ago

I'm thinking we should always load the API and make the default widgets conditional.

comment:2 @ryan6 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [10795]) Separate default widgets from widgets API. Always load API. fixes #9349

Note: See TracTickets for help on using tickets.