Guest
Public paste!

Jeremy Clarke

By: a guest | Jan 22nd, 2009 | Syntax: PHP | Size: 0.70 KB | Hits: 637 | Expires: Never
Copy text to clipboard
  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. }