[wp-hackers] Need WP/PHP guru eyeballs/feedback on my WP_Widget wrapper class
mickyhulse.lists at gmail.com
Tue Jun 25 18:20:21 UTC 2013
Thanks for the feedback. I apologize for lack of WordPress version.
I'm running version 3.5.1.
I'll try to create a simple version of my code. I'm pretty sure I get
the same errors when I remove everything but the very basic code.
Thanks for the kick in the pants! :)
On Tue, Jun 25, 2013 at 11:11 AM, Dobri <dyordan1 at ramapo.edu> wrote:
> Kind of hard to debug your code having no idea what version of wordpress you're using. Someone would have to download your thing and run it himself to figure out what's going on. A version number would be helpful for on-the-fly debugging.
> Also, Xdebug.
> On Tue, 25 Jun 2013, at 1:55 PM, Micky Hulse wrote:
>> Currently, I have a setup for custom widgets where I create a simple
>> class for each new widget. For example:
>> While the above works well, I'm finding that I'm repeating a little
>> bit of boilerplate code for each widget (even after extending an
>> abstract class with most of the boilerplate in that).
>> In an attempt to improve my code, and avoid repeating myself, I
>> created this class:
>> Inspired by WPAlchemy, I thought it would be cool to create my custom
>> widgets like so:
>> $medium_rectangle_1 = new foo_Widget(
>> 'id_base' => 'medium_rectangle_1',
>> 'name' => 'Medium Rectangle 1',
>> 'description' => 'Standard Advertising Unit',
>> 'template' => STYLESHEETPATH .
>> Unfortunately, I keep getting this PHP notice:
>> Notice: Undefined property: Foo_Widget::$option_name in
>> /.../wp-includes/widgets.php on line 291 Warning: array_merge():
>> Argument #2 is not an array in /.../wp-includes/widgets.php on line
>> ... and the widget does not show in the admin (well, there's an empty,
>> useless, widget box with no label).
>> Now, I know my code could use some more work (I'm kinda pushing the
>> limits of my WP/PHP skillz) ... I just wanted to see if anyone here
>> had any tips as to what I might be doing wrong?
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers