Don't like ads? PRO users don't see any ads ;-)
Guest

Jeremy Clarke

By: a guest on Jan 22nd, 2009  |  syntax: PHP  |  size: 0.70 KB  |  hits: 680  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.         global $wp_meta_boxes;
  6.  
  7.         // Get the array for your widget from $wp_metaboxes and manually add it to the 'sorted' portion
  8.         // This pre-empts the sorting system to make sure you are at the top
  9.         // CAVEAT: your widget is no longer sortable. it will always be at the top.    
  10.         $example_widget = $wp_meta_boxes['dashboard']['normal']['core']['example_dashboard_widget'];
  11.         $wp_meta_boxes['dashboard']['normal']['sorted']['example_dashboard_widget'] = $example_widget_backup;          
  12. }