Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

So I have a plugin that I've created for the admin are when creating post... and I'd like to supply a widget along with it.

I'm trying to figure out the best way to initialize my widget. I'm initializing my plugin like so:

function call_menu_per_page_class() 
{
    return new MenuPerPage();
}
if ( is_admin() )
    add_action( 'admin_menu', 'call_my_class' );

Obviously, the widget does NOT require someone to be an admin to view it... it will be viewed in a sidebar within my Theme.

Is there a specific action/filter and hook that I should use to execute my widget class?

Remember, this is being packed with my plugin... so it can't be called from functions.php

share|improve this question
add comment

migrated from stackoverflow.com Oct 10 '11 at 11:12

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 0 down vote accepted

According to Codex register_widget() should be hooked to widgets_init.

Hook into init then and at that point hook further different methods to appropriate hooks later.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.