Saturday, May 25, 2013

register child class in another plugin

register child class in another plugin

I think this should be relatively easy, but somehow I cannot figure out how to do this. essentially there's a preexisting plugin that does this:
add_action('widgets_init', create_function('', 'register_widget("Foo");'));
if ( ! class_exists( 'Foo' ) ) {
class Foo extends WP_Widget {
        /*constructs etc*/
}}
now i would like to write another plugin (extension essentially), that extends the above. I tried to do something like the following (and also tried - in vain - to find some examples/documentation )
add_action('widgets_init', create_function('', 'register_widget("Bar");'));
class Bar extends Foo {    
    function __construct() {
        /*do stuff*/
    }
}
but all i ever get is
<b>Fatal error</b>:  Class 'Foo' not found in ...
so I suppose it's a question of making 'Bar' execute AFTER Foo, but I dunno how.
any hints/ideas/snippets or even just links to docs etc would be much appreciated as I am failing at the first hurdle here..:(

No comments:

Post a Comment