Plugin Directory

Changeset 369949


Ignore:
Timestamp:
04/07/2011 07:15:50 AM (15 years ago)
Author:
z720
Message:

Cleanup and documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • dashbar/branches/3.0/DashBar.php

    r369934 r369949  
    3838        var $domain = 'DashBar';
    3939        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() {
    8653            add_action( 'admin_bar_menu', array(&$this, 'update_bar'), 31 );
    87             // add_action('wp_before_admin_bar_render', array(&$this, 'update_bar'));
    8854            add_action( 'wp_before_admin_bar_render', array(&$this, 'add_network'));
    89         }
     55        }
    9056
    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         */
    9760        function update_bar() {
    9861            global $wp_admin_bar;
     
    10366                if(current_user_can('edit_posts')) {
    10467                    $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')));
    10669                    rewind_posts();
    10770                    global $post;
     
    12083        }
    12184       
     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         */
    12289        function add_network() {
    12390            if(is_multisite() && current_user_can('manage_network') && !is_network_admin()) {
     
    136103$the_dashbar = new DashBar();
    137104
    138 
    139105?>
Note: See TracChangeset for help on using the changeset viewer.