[wp-hackers] Widget Weirdness - Doesn't like the file name widgets.php
Alex Andrews
awgandrews at gmail.com
Mon Jun 27 13:13:06 UTC 2011
Hey folks,
Getting something odd going on with Widgets. In the context of a
theme, I am attempting to add customised widgets. For ease of coding,
widgets live in another file includes/widgets.php.
If I do, in the functions.php file:
require_once('includes/widgets.php');
function buffer_widgets_init () {
register_widget('buffer_latest_features_widget');
}
add_action('widgets_init', 'buffer_widgets_init');
Then it fails with a message: Fatal error: Class
'buffer_latest_features_widget' not found in
/Users/alex/Sites/wp-includes/widgets.php on line 324. However, if I
copy and paste the whole code in includes/widgets into the
functions.php file, lo and behold, it finds the
buffer_latest_features_widget class.
The same is true if I rename the file as anything but widgets.php and
move it anywhere - works fine.
Is there any reason for this or am I doing something stupid or wrong?
What's going on?
Thanks a lot.
Alex
More information about the wp-hackers
mailing list