When in doubt use the API.
Let’s say the structure of $wp_meta_boxes
will change or go away one day.
remove_meta_box()
will still work, because the API is a contract between core and developers. Unsetting some keys in a global variable might break.
unset()
is easier to write when you want to remove a whole group: unset($wp_meta_boxes['dashboard'])
is clearly simpler than running through each separate box. But shorter code is not always better, so this should not be used in public code.
Note, both methods actually work differently: unset()
removes an element from the array, while remove_meta_box()
set the elements value to FALSE
:
foreach ( array('high', 'core', 'default', 'low') as $priority )
$wp_meta_boxes[$page][$context][$priority][$id] = false;
Other plugins might rely on the existence of that element – and break after you have used unset()
.