Advertisement
Guest User

Untitled

a guest
Jan 4th, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. function example_add_dashboard_widgets() {
  2. wp_add_dashboard_widget('example_dashboard_widget', 'Example Dashboard Widget', 'example_dashboard_widget_function');
  3.  
  4. // Globalize the metaboxes array, this holds all the widgets for wp-admin
  5.  
  6. global $wp_meta_boxes;
  7.  
  8. // Get the regular dashboard widgets array
  9. // (which has our new widget already but at the end)
  10.  
  11. $normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
  12.  
  13. // Backup and delete our new dashbaord widget from the end of the array
  14.  
  15. $example_widget_backup = array('example_dashboard_widget' => $normal_dashboard['example_dashboard_widget']);
  16. unset($normal_dashboard['example_dashboard_widget']);
  17.  
  18. // Merge the two arrays together so our widget is at the beginning
  19.  
  20. $sorted_dashboard = array_merge($example_widget_backup, $normal_dashboard);
  21.  
  22. // Save the sorted array back into the original metaboxes
  23.  
  24. $wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement