The MU forums have moved to WordPress.org

how to add widgets site wide? (7 posts)

  1. samuelaguilera
    Member
    Posted 14 years ago #

    Hi!

    I'm making a little simple plugin to add a dashboard widget, and it works ok for the main blog dashboard of my WPMU installation, but the widget is not showing in all other dashboards...

    I simply followed WP codex documentation about adding dashboard widgets: http://codex.wordpress.org/Dashboard_Widgets_API

    But I can't find anywhere any documentation on how to hook my plugin site wide to show in ALL blog's dashboards not only on the main blog :(

    Please, any help would be appreciated.

    PS. Of course the plugin is activated site wide...

  2. andrea_r
    Moderator
    Posted 14 years ago #

    Doesn't matter - widgets are blog-specific.

    You could edit the theme (if you're using one theme sitewide) to do this:

    <?php switch_to_blog(1); ?>

    regualr sidebar code here

    <?php restore_current_blog(); ?>

    Then every blog will show the main blog's sidebar. Might get resource intensive on a larger system because of the switch_to_blog.

  3. samuelaguilera
    Member
    Posted 14 years ago #

    Thank you Andrea, but I'm looking to do it with dashboard widgets, not sidebar widgets.

    So I cant use the sitewide theme for this :(

  4. tmoorewp
    Member
    Posted 14 years ago #

    Are you using the wp_dashboard_setup hook to get your widget registered in the dashboard?

    Also, you may try putting your plugin code in mu-plugins rather than regular plugins. That way it'll always be active no matter what blog you are on.

  5. samuelaguilera
    Member
    Posted 14 years ago #

    Thank you very much tmoorewp :)

    Moving the plugin to mu-plugins solves the problem.

    So it seems that is no completely the same behaviour for a plugin if enable sitewide "living" in the plugins dir than living in mu-plugins.

    PS. Yes, I'm using wp_dasboard_setup as explained in the WP codex. ;)

  6. DeannaS
    Member
    Posted 14 years ago #

    You can also take a look at the code in my simple dashboard plugin.

    http://wpmudevorg.wordpress.com/project/simple-dashboard

    That will show you how to customize the dashboard for all blogs, including newly created ones. (I don't add any custom widgets, but you'll get the idea if you look at the code.)

  7. samuelaguilera
    Member
    Posted 14 years ago #

    Thank you very much DeannaS! :)

    I'm sure it will bring me a closer look to the dashboard manipulation ;)

About this Topic

  • Started 14 years ago by samuelaguilera
  • Latest reply from samuelaguilera