哎哟,我想出来了。:)虽然我以前就知道了kaiser 回答了我的问题,我仍然要感谢他给出了清晰而令人敬畏的答案。下面是我为重新排序仪表板小部件而编写的代码。
<?php
/**
* Plugin Name: Custom Dashboard
* Description: Custom dashboard for Avare sites.
* Author: Avare
* Version: 1.0
*/
function sort_dashboard_widgets() {
// Global the $wp_meta_boxes variable (this will allow us to alter the array)
global $wp_meta_boxes;
// Then unset everything in the array
unset($wp_meta_boxes[\'dashboard\'][\'normal\'][\'core\']);
unset($wp_meta_boxes[\'dashboard\'][\'side\'][\'core\']);
// Add widgets to left column
add_meta_box(\'dashboard_right_now\', __(\'Right Now\'), \'wp_dashboard_right_now\', \'dashboard\', \'normal\', \'core\');
add_meta_box(\'dashboard_recent_comments\', __(\'Recent Comments\'), \'wp_dashboard_recent_comments\', \'dashboard\', \'normal\', \'core\');
// Add widgets to right column
add_meta_box(\'dashboard_quick_press\', __(\'QuickPress\'), \'wp_dashboard_quick_press\', \'dashboard\', \'side\', \'core\');
add_meta_box(\'dashboard_recent_drafts\', __(\'Recent Drafts\'), \'wp_dashboard_recent_drafts\', \'dashboard\', \'side\', \'core\');
}
add_action(\'wp_dashboard_setup\', \'sort_dashboard_widgets\');
请注意,此代码并没有使用所有可用的仪表板小部件。