[theme-reviewers] WP_DEBUG notices with the_widget()
Justin Tadlock
justin at justintadlock.com
Wed Feb 22 20:07:18 UTC 2012
One thing I recently noticed with my themes that have widgets is that I
get some undefined index/variable notices when using the_widget()
function to output a widget created by my theme. This wouldn't show up
unless someone actually used the_widget() function. Using it as a
regular widget in a dynamic sidebar is fine because the variables always
get set on widget save.
This issue arises when you're building a widget with options.
Typically, you'd grab these options from the $instance parameter for the
widget() method. When calling the_widget( 'My_Widget_Class' ); in my
theme, WP_DEBUG goes crazy. The problem is simply that there's no
checks if $instance['some_option'] has been set.
I'm going through all my widgets right now to update them for this use
case. I don't think it's overly important because it's a pretty rare
scenario and definitely one you wouldn't notice in a typical review, but
I thought I'd post it here for you all.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20120222/e70c1f52/attachment.htm>
More information about the theme-reviewers
mailing list