Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function example_add_dashboard_widgets() {
- wp_add_dashboard_widget('example_dashboard_widget', 'Example Dashboard Widget', 'example_dashboard_widget_function');
- // Globalize the metaboxes array, this holds all the widgets for wp-admin
- global $wp_meta_boxes;
- // Get the regular dashboard widgets array
- // (which has our new widget already but at the end)
- $normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
- // Backup and delete our new dashbaord widget from the end of the array
- $example_widget_backup = array('example_dashboard_widget' => $normal_dashboard['example_dashboard_widget']);
- unset($normal_dashboard['example_dashboard_widget']);
- // Merge the two arrays together so our widget is at the beginning
- $sorted_dashboard = array_merge($example_widget_backup, $normal_dashboard);
- // Save the sorted array back into the original metaboxes
- $wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement