Get rid of dashboard widget...

What is the specific code to disable the WPMU DEV SEO dashboard widget? I have an administrative plugin that I created to customize the back end, but I can't get rid of this widget. I do not want to edit the core plugin files. I want to add it to my plugin.

  • mmedia

    No, I want it removed on the code level. I do not want it showing up at all.

    For example, to get rid of all the WordPress ones and add my own I use...

    function custom_dashboard_widgets() {
    	global $wp_meta_boxes;
    
    	// remove unnecessary widgets
    	// var_dump( $wp_meta_boxes['dashboard'] ); // use to get all the widget IDs
    	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
    	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
    	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
    	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
    	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
    
    	//custom dashboard widgets
    	//wp_add_dashboard_widget('dashboard_custom_feed', 'News from Elite', 'dashboard_custom_feed_output'); //add new rss feed output
    	wp_add_dashboard_widget('custom_help_widget', 'Help and Support', 'custom_dashboard_help'); // add a new custom widget for help and support
    }
  • mmedia

    I am asking for assistance with this. Their has to be a way to get it removed without editing the plugin, I just need to know what the code is. It can be done with standard WP dashboard widgets, it can be done with any dashboard widgets.

    It should be something like this...

    unset($wp_meta_boxes['dashboard']['normal']['core']['wds_seomoz_dashboard_widget']);

    But it is not working.

    This plugin should really have a way to entirely disable SEOmoz because it's not required to run the other features of the plugin and some (myself included) have no plans to use it.

  • Barry

    It can be done externally, but you'll need to move the priority of your custom_dashboard_widgets to a higher level (higher than the default of 10) so you are sure that it is being run *after* the SEO plugin has run and added it's widget to the dashboard.

    If you run it at priority 10 or lower then SEO may not have run yet, so you would be removing something that doesn't exist and then SEO would be called and would add it back in later.

  • mmedia

    Sounds like we're finally getting somewhere here! :slight_smile:

    What you're saying makes sense, but I'm not sure how to execute it.

    This is the entire code for my administration plugin:

    <?php
    /*
    Plugin Name: Company Administration
    Description: Company WordPress Administration
    Author: Company
    Version: 1.0
    Author URI: http://domain.com
    */
    
    add_action( 'login_head', 'custom_login_css' );
    
    function custom_login_css()
    {
    	echo '<link rel="stylesheet" href="' . get_bloginfo('stylesheet_directory') . '/login.css" type="text/css" media="all" />';
    }
    
    if ( is_admin() ) : 
    
    add_action( 'admin_print_styles', 'load_custom_admin_css' );
    
    function load_custom_admin_css()
    {
    	wp_enqueue_style( 'custom_admin_css', 'http://ts4.triplemoonsdesign.com/wp-content/plugins/company-admin/wp-admin.css' );
    } 
    
    add_filter( 'admin_footer_text', 'custom_footer_text' );
    
    function custom_footer_text($default_text)
    {
    	return '<span id="footer-thankyou">Website created by <a href="http://www.domain.com">domain.com</a><span>';
    }
    
    add_action('wp_dashboard_setup', 'custom_dashboard_widgets');
    
    function custom_dashboard_widgets() {
    	global $wp_meta_boxes;
    
    	// remove unnecessary widgets
    	// var_dump( $wp_meta_boxes['dashboard'] ); // use to get all the widget IDs
    	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
    	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
    	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
    	unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
    	unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
    	unset($wp_meta_boxes['dashboard']['normal']['core']['wds_seomoz_dashboard_widget']);
    
    	//custom dashboard widgets
    	wp_add_dashboard_widget('dashboard_custom_feed', 'News from Company', 'dashboard_custom_feed_output'); //add new rss feed output
    	wp_add_dashboard_widget('custom_help_widget', 'Help and Support', 'custom_dashboard_help'); // add a new custom widget for help and support
    }
    
    function dashboard_custom_feed_output()
    {
    	echo '<div class="rss-widget">';
    	wp_widget_rss_output(array(
    		'url' => 'http://www.domain.com/feed',
    		'title' => 'News from Company',
    		'items' => 2,
    		'show_summary' => 1,
    		'show_author' => 0,
    		'show_date' => 1
    	));
    	echo "</div>";
    }
    
    function custom_dashboard_help() {
    	echo '<p>For technical support please email <a href="mailto:support@domain.com">support@domain.com</a> or call 1-800-469-1871.<p>';
    }
    
    add_filter( 'contextual_help', 'custom_help_support', 100 );
    
    function custom_help_support($help)
    {
    	$help = '<p>For technical support please email <a href="mailto:support@domain.com">support@domain.com</a> or call 1-800-469-1871.<p>';
    	return $help;
    }
    
    endif;
    ?>
  • Barry

    Like i said change
    add_action('wp_dashboard_setup', 'custom_dashboard_widgets');
    to something like
    add_action('wp_dashboard_setup', 'custom_dashboard_widgets', 15);
    to ensure it runs after SEO does so you are removing something that is there, and not before it is added.
    The number (15 in this case) is the priority. WP defaults to everything having a priority of 10 and processed in the order they are added to the action queue. Forcing a larger number moves your processing down the queue - a lower number moves you up the queue. So a 15 will be processed after all the actions with a priority number lower than 15, but before all those with a priority number greater than 15 - so in effect after all the actions running on the default level.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.