Easy Blogging, don't hide my custom dashboard widget

Hiya, I’m in the process of writing my own custom dashboard widget. Is there a way to prevent the Easy Blogging plugin from removing it?

I notice that you can set easyblogging not to hide the Right Now widget so I’m assuming that there is some functionality for this.

(I know that you can add a custom widget in the easyblogging settings, but my widget isn’t simple text/html and needs to be written in php.)

Thanks

Jack

  • aecnu
    • WP Unicorn

    Greetings Jack,

    Thank you for this great question!

    I’m in the process of writing my own custom dashboard widget. Is there a way to prevent the Easy Blogging plugin from removing it?

    Though it probably is not a large amount of coding to do this task, prevent removal that is, I do not know how to advise you.

    Therefore i am going to reach out to the invaluable insight of the Easy Blogging plugin lead developer seeking his advice/advise us on how this can be done.

    Though this may take longer then a normal ticket, I will try to get him in here asap.

    Thank you for being a WPMU Dev Member!

    Cheers, Joe

  • Vladislav
    • Dead Eye Dev

    Hello,

    Since v3.1.9, the plugin comes with “Dashboard widgets setup” add-on, which you can use to control which dashboard widgets should appear. However, the plugin also exposes a quick way to enable your dashboard widget using a hook – since you’re already coding your widget, this might be a quicker solution for you. Basically, you can do something like this:

    function myprefix_allow_my_dashboard_widget ($widgets) {
    $widgets[] = "MY_DASHBOARD_WIDGET_ID";
    return $widgets;
    }
    add_filter('wdeb_allowed_dashboard_metaboxes', 'myprefix_allow_my_dashboard_widget');

    … where, of course, “MY_DASHBOARD_WIDGET_ID” is your widget’s actual ID.

  • Creative Blogs
    • Site Builder, Child of Zeus

    Thanks, that code worked great! Thanks

    Although there’s one more thing. For my widget I’m using a css file to customise it and that appears to be being stripped out on the easy admin interface. I’m adding it using:

    function schblogs_dashboard_welcome_css_function() {
    echo '<link rel="stylesheet" type="text/css" href="' .plugins_url('schblogs-custom-dashboard-widget.css', __FILE__). '">';
    }
    add_action('admin_head', 'schblogs_dashboard_welcome_css_function');

    When I use Firebug to see whether the css file is being reference it doesn’t seem to be. Does easyblogging strip out all other css files and add in it’s own? Is there any way of getting this whitelisted too?

    Thanks

    Jack

  • Vladislav
    • Dead Eye Dev

    Hi,

    I’m happy to hear the snipped worked well for you on the first go :slight_smile:

    As for the stylesheet, we’re actually hooking up to admin_head and doing all kinds of things to replace and inject our stuff (if you’re interested in gory details, check the lib/class_wdeb_admin_pages.php file). Have you tried hooking up to “admin_print_styles” hook instead? Something like this should do the trick:

    function schblogs_dashboard_welcome_css_function () {
    wp_enqueue_style('schblogs-custom-dashboard-widget', plugins_url('schblogs-custom-dashboard-widget.css', __FILE__));
    }
    add_action('admin_print_styles-index.php', "schblogs_dashboard_welcome_css_function");

    An added benefit of this kind of style inclusion is that it’s easily scoped – the action is limited to “index.php”, so all your other pages won’t be including the stylehseet that’s needed just on dashboard. However, if you do need the style on other pages, just use the basic, non-scoped “admin_print_styles” hook instead. Here’s some more in-depth reference, should you need it:

    http://codex.wordpress.org/Plugin_API/Action_Reference#Administrative_Actions

    http://codex.wordpress.org/Function_Reference/wp_enqueue_style

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.