treehouse : what would you like to learn today?
Web Design Web Development iOS Development

WORDPRESS = Modify Widgets/Plugins via HOOKS

  • Love the site! Hope this is the right spot to post this... here it goes!

    i installed a lovely plugin/widget on a WORDPRESS site and i want to modify the output to my liking (WITHOUT EDITING THE PLUGIN/WIDGET CODE). i have played around with HOOKS and FILTERS but no success as of yet. i was hoping someone could shed some light or point me in the right direction...

    here is an idea of the widget INIT function... the function i want to over ride lives inside...
    function the_init() {
    if ( !function_exists('register_sidebar_widget') || !function_exists('register_widget_control') )
    return;

    // this is the output funtion i want to take over!
    function function_to_take_over($args) {
    extract($args);
    $options = get_option('function_to_take_over');
    $title = empty($options['title']) ? __('lame text i dont like','WPEC') : $options['title'];
    $text = empty($options['text']) ? __('more text i want out of here','WPEC') : $options['text'];
    echo $before_widget;
    echo $before_title . $title . $after_title;
    echo $text;
    op_function();
    echo $after_widget;
    }

    function another_function_in_the_init() {
    // some other function
    }

    wp_register_sidebar_widget('wpemailcapture',__('widget name','WN'), 'function_to_take_over');
    wp_register_widget_control('wpemailcapture',__('widget name','WN'), 'another_function_in_the_init');

    }

    add_action('plugins_loaded', 'the_init');

    so here is my attempt (wrong but hopefully it will show where i am trying to go)...

    in my functions.php...
    // my replacement function
    function function_to_take_over_mg($args) {
    extract($args);
    $options = get_option('function_to_take_over');
    op_function();
    }

    function mod_wig(){
    add_filter('function_to_take_over', 'function_to_take_over_mg');
    }
    add_action('plugins_loaded', 'mod_wig');

    thanks for any and all insight!

    m