[wp-hackers] Need WP/PHP guru eyeballs/feedback on my WP_Widget wrapper class

Micky Hulse mickyhulse.lists at gmail.com
Fri Jun 28 22:52:50 UTC 2013


On Tue, Jun 25, 2013 at 5:33 PM, J.D. Grimes <jdg at codesymphony.co> wrote:
> Hey Micky, I was thinking about this and I think I've found a good solution for you. Just extend the Foo_Widget class with child classes like this:

Hi J.D.,

I finally had a chance to test your suggestion using my test
Foo_Widget class. Unfortunately, I'm getting the same results as
before.

[snip]

include_once('class.foo_widget.php');

class Foo_Widget_2 extends Foo_Widget {

    function __construct() {

        parent::__construct(
            array(
                'id_base' => 'foo_test_widget',
                'name' => 'Foo Test Widget',
            )
        );

    }
}

new Foo_Widget_2();

[/snip]

The above gets include_once into my functions.php.

This is the Foo_Widget() class (same one from before):

<https://gist.github.com/mhulse/5861847>

When I test the above code, I just see an empty widget under
"Available Widgets". When inspecting with Firebug, neither "id_base"
or "name" made it through.

If it's not too much trouble, could you confirm that the code you are
using is the same as the stuff I'm using?

If you got it to work, I must be doing something wrong (or, maybe I
need to upgrade to the latest WP? We're one version behind).

Thanks so much! I owe you one! :-)


More information about the wp-hackers mailing list