Changeset 369949
- Timestamp:
- 04/07/2011 07:15:50 AM (15 years ago)
- File:
-
- 1 edited
-
dashbar/branches/3.0/DashBar.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dashbar/branches/3.0/DashBar.php
r369934 r369949 38 38 var $domain = 'DashBar'; 39 39 var $version = '3.0'; 40 41 var $default = array( 'bgcolor' => '#464646' 42 ,'height' => '14px' 43 ,'color' => '#eee' 44 ,'fgcolor' => '#777' 45 ,'acolor' => '#eee' 46 ,'popup' => false 47 ); 48 var $values = array(); 49 var $user_menu = array(); 50 51 var $erreur = false; 52 53 function getInstallDir() { 54 return basename(dirname(__FILE__)); 55 } 56 57 function DashBar() { 58 // i18n : load texts 59 load_plugin_textdomain($this->domain,false,basename(dirname(__FILE__))); 60 // Load options to overwrite defaults 61 /* TODO: Cleanup 62 $c = get_option($this->prefixe); 63 foreach($this->default as $k => $v) { 64 if(($c === false) or (!isset($c[$k]))) { 65 $this->values[$k] = $this->default[$k]; 66 } else { 67 $this->values[$k] = $c[$k]; 68 } 69 } 70 // save options to database or create default for first time 71 update_option($this->prefixe, $this->values); 72 // WP init 73 */ 74 add_action('init', array(&$this, 'init')); 75 // WP admin hooks 76 // TODO: Cleanup 77 // add_action('admin_head', array(&$this, 'admin_page_header')); 78 // add_action('admin_menu', array(&$this, 'admin_pages')); 79 } 80 81 function __($str) { 82 return __($str, $this->domain); 83 } 84 85 function init() { 40 41 /** 42 * Constructor 43 */ 44 function DashBar() { 45 // WP init 46 add_action('init', array(&$this, 'init')); 47 } 48 49 /** 50 * Plugin init: mainly hook action to methods on WordPress init 51 */ 52 function init() { 86 53 add_action( 'admin_bar_menu', array(&$this, 'update_bar'), 31 ); 87 // add_action('wp_before_admin_bar_render', array(&$this, 'update_bar'));88 54 add_action( 'wp_before_admin_bar_render', array(&$this, 'add_network')); 89 }55 } 90 56 91 /* TODO: Cleanup 92 function admin_pages() { 93 add_options_page($this->__('DashBar'), $this->__('DashBar'), 'manage_options', basename(__FILE__), array(&$this, 'admin_page')); 94 } 95 /**/ 96 57 /** 58 * Add posts edit to an edit menu with the list of posts the user can edit 59 */ 97 60 function update_bar() { 98 61 global $wp_admin_bar; … … 103 66 if(current_user_can('edit_posts')) { 104 67 $id = 'dashbar_edit'; // Edit menu 105 $wp_admin_bar->add_menu(array('id' => $id, 'title' => $this->__('Edit'), 'href'=> admin_url('post.php')));68 $wp_admin_bar->add_menu(array('id' => $id, 'title' => __('Edit'), 'href'=> admin_url('post.php'))); 106 69 rewind_posts(); 107 70 global $post; … … 120 83 } 121 84 85 /** 86 * Add a link to network admin in the first menu (my account). 87 * The link should only be visible to Network admins in a multisite context outside of the network admin pages 88 */ 122 89 function add_network() { 123 90 if(is_multisite() && current_user_can('manage_network') && !is_network_admin()) { … … 136 103 $the_dashbar = new DashBar(); 137 104 138 139 105 ?>
Note: See TracChangeset
for help on using the changeset viewer.