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

J.D. Grimes jdg at codesymphony.co
Sat Jun 29 21:47:48 UTC 2013


> Maybe if I passed __CLASS__ from the child class into the parent
> class's register_widget()? I'll have to play around with that.


I think you could do this instead of using __CLASS__:
$class = get_class( $this );
See here:
http://stackoverflow.com/a/1166592/1924128

I'm not sure if that works in all versions of PHP, but according to the poster there it works in 5.2.9.

-J.D.

On Jun 29, 2013, at 2:17 PM, Micky Hulse <mickyhulse.lists at gmail.com> wrote:

> On Sat, Jun 29, 2013 at 6:04 AM, J.D. Grimes <jdg at codesymphony.co> wrote:
>> You need to register the widget with the register_widget() function like this:
>> Then it should work.
> 
> Ahh, that makes sense. Thank you for the clarification, I really appreciate it.
> 
> I assumed that I did not need to register_widget() because I have that
> in the class I'm extending.
> 
> add_action(
> 'widgets_init',
> function() {
> register_widget(__CLASS__);
> }
> );
> 
> Maybe if I passed __CLASS__ from the child class into the parent
> class's register_widget()? I'll have to play around with that.
> 
> Either way, thanks to your help, I now have a better understanding of
> WP widgets. Thanks so much for your help and guidance. :)
> 
> Thanks again to everyone who has given me help.
> 
> Cheers,
> Micky
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list