No don’t touch core files..
Your theme’s functions.php would be the most simple approach..
I would like to point out one minor flaw with the above code. Code assumes the widgets are still in their default positions, if a user has moved any, then the above will miss the moved boxes.
I use some code much like the above to remove unwanted meta boxes (widgets really), but i run a simple check to determine where they are first..
For the sake of saving time, i’m just going to paste the areas i’m talking about from my file, fondalashay you need not pay attention here, this is more for the jedi ?? …
// Determines where particular meta boxes are, side or normal
$pos = array();
$pos['rss'] = ( !isset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary'] ) ) ? 'normal' : 'side';
$pos['incoming'] = ( !isset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_incoming_links'] ) ) ? 'normal' : 'side';
$pos['comments'] = ( !isset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_comments'] ) ) ? 'normal' : 'side';
$pos['drafts'] = ( !isset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts'] ) ) ? 'normal' : 'side';
$pos['dev_blog'] = ( !isset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_primary'] ) ) ? 'normal' : 'side';
$pos['plugins'] = ( !isset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_plugins'] ) ) ? 'normal' : 'side';
$pos['quickpress'] = ( !isset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press'] ) ) ? 'normal' : 'side';
// Unset the unwanted widgets using the above array to target the necessary positions
unset(
$wp_meta_boxes['dashboard'][$pos['rss']]['core']['dashboard_secondary'] ,
$wp_meta_boxes['dashboard'][$pos['incoming']]['core']['dashboard_incoming_links'] ,
$wp_meta_boxes['dashboard'][$pos['comments']]['core']['dashboard_recent_comments'] ,
$wp_meta_boxes['dashboard'][$pos['drafts']]['core']['dashboard_recent_drafts'] ,
$wp_meta_boxes['dashboard'][$pos['dev_blog']]['core']['dashboard_primary'] ,
$wp_meta_boxes['dashboard'][$pos['plugins']]['core']['dashboard_plugins']
);
unset( $pos );
// Create a comma seperated string out of the leftover widgets - for debug
$leftovers =
implode( ', ' ,
array_merge(
array_keys( $wp_meta_boxes['dashboard']['side']['core'] ) ,
array_keys( $wp_meta_boxes['dashboard']['normal']['core'] )
)
);
// Print the leftover widget titles/references
// print $leftovers;
Used isset because it’s much faster then array_key_exists (which is what i initially used).
Of course this is not a catch all, i’m sure, but it will determine a side or normal position and unset appropriately this way..