Plugin Directory

Changeset 466701


Ignore:
Timestamp:
11/23/2011 08:31:50 PM (14 years ago)
Author:
dilbert4life
Message:

Fixing bug with custom menus

Location:
wordpress-admin-bar-improved/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wordpress-admin-bar-improved/trunk/readme.txt

    r436815 r466701  
    33Tags: admin bar, top, login form, 3.1+, ajax, search
    44Requires at least: 3.1
    5 Tested up to: 3.3-aortic-dissection
    6 Stable tag: 3.3.3
     5Tested up to: 3.3-beta3
     6Stable tag: 3.3.4
    77
    88A set of custom tweaks to the WordPress Admin Bar that was introduced in WP3.1.
     
    7575== ChangeLog ==
    7676
     77= 3.3.4 =
     78* Bugfix - custom menu not showing up on Appearance -> Menus page in themes that did not support them natively.
     79
    7780= 3.3.3 =
    7881* Bugfix - login from and other features now functions properly on 3.2.1 and WP Trunk (beta versions of upcoming release)
  • wordpress-admin-bar-improved/trunk/wpabi.php

    r436815 r466701  
    66Plugin URI:   http://www.electriceasel.com/wpabi
    77Description:  A set of custom tweaks to the WordPress Admin Bar that was introduced in WP3.1
    8 Version:      3.3.3
     8Version:      3.3.4
    99Author:       dilbert4life, electriceasel
    1010Author URI:   http://www.electriceasel.com/team-member/don-gilbert
     
    3030
    3131class WPAdminBarImproved {
    32     private static $version = '3.3.3';
     32    private static $version = '3.3.4';
    3333    private $textdomain = 'wpabi';
    3434    private $css_file;
     
    8282        wp_enqueue_style('wpabi_css', plugins_url('wpabi.css', __FILE__), '', '2.0', 'all');
    8383       
     84        if($this->options['custom_menu'])
     85        {
     86            $this->add_custom_menu();
     87        }
     88       
    8489        add_action('admin_bar_menu', array( &$this, 'manage_menu_items' ), 9998);
    8590       
     
    103108        else
    104109        {
    105             $this->login_form_start = '<div id="wpadminbar" class="nojq">';
     110            $this->login_form_start = '<div id="wpadminbar" class="nojq nojs">';
    106111        }
    107112    }
     
    122127                'custom_menu' => 0,
    123128                'default_items' => array(
     129                    'wp-logo' => 1,
     130                    'blog-name' => 1,
    124131                    'my-account-with-avatar' => 1,
    125132                    'view-site' => 1,
     
    131138                    'edit' => 1,
    132139                    'get-shortlink' => 1,
    133                     'updates' => 1
     140                    'updates' => 1,
     141                    'search' => 1
    134142                )
    135143            );
     
    150158    public function wpabi_options_validate($input)
    151159    {
     160        // TODO: Validate the inputs, just for fun…. :(
    152161        return $input;
    153162    }
    154163   
    155164    public function manage_menu_items($wp_admin_bar)
    156     {       
     165    {              
    157166        foreach( (array) $this->options['default_items'] as $menu => $enabled)
    158167        {
     
    166175                $wp_admin_bar->remove_menu('my-account');
    167176            }
    168         }
    169        
    170         if($this->options['custom_menu'])
    171         {
    172             $this->add_custom_menu();
    173177        }
    174178    }
     
    201205            }
    202206            $wp_admin_bar->add_menu($args);
     207        }
     208        // Little trick to keep search at the end of the menu
     209        if(isset($wp_admin_bar->menu->search))
     210        {
     211            $tmp_search = $wp_admin_bar->menu->search;
     212            unset($wp_admin_bar->menu->search);
     213            $tmp_search = array_merge($tmp_search, array('id' => 'search'));
     214            $wp_admin_bar->add_menu($tmp_search);
     215            unset($tmp_search);
    203216        }
    204217    }
     
    459472                <p><em><?php _e('When you enable this option, you will get a new location added to your "Theme Locations" box on your Appearance -> Menus admin page called "Admin Bar Improved." Use this as you would any other menu location for your site. Create a new menu on the Menus admin page, and name it whatever you\'d like, just keep it easy to identify. Add whatever items to that menu that you want. Nested menu items will work as expected. When you\'re finished, select the menu you created from the select list under the "Admin Bar Improved" theme location. Once completed, (and once you refresh the page, or navigate to another page) you will see that the items you added are now in your admin bar. Good job!', $this->textdomain); ?></em></p>
    460473            </li>
    461            
     474                   
    462475            <li><h3>Default Menu Items:</h3></li>
     476           
     477            <li class="wp-logo">
     478                <label for="wp-logo"><?php _e('WP Logo', $this->textdomain); ?>:</label>
     479                <select name="wpabi_options[default_items][wp-logo]" id="wp-logo">
     480                    <option value="1" <?php selected($this->options['default_items']['wp-logo'], '1') ?>>Enabled</option>
     481                    <option value="0" <?php selected($this->options['default_items']['wp-logo'], '0') ?>>Disabled</option>
     482                </select>
     483            </li>
     484           
     485           
     486            <li class="blog-name">
     487                <label for="blog-name"><?php _e('Blog Name', $this->textdomain); ?>:</label>
     488                <select name="wpabi_options[default_items][blog-name]" id="blog-name">
     489                    <option value="1" <?php selected($this->options['default_items']['blog-name'], '1') ?>>Enabled</option>
     490                    <option value="0" <?php selected($this->options['default_items']['blog-name'], '0') ?>>Disabled</option>
     491                </select>
     492            </li>
     493           
    463494            <li class="my-account-with-avatar">
    464495                <label for="my-account-with-avatar"><?php _e('My Account', $this->textdomain); ?>:</label>
     
    538569                    <option value="1" <?php selected($this->options['default_items']['updates'], '1') ?>>Enabled</option>
    539570                    <option value="0" <?php selected($this->options['default_items']['updates'], '0') ?>>Disabled</option>
     571                </select>
     572            </li>
     573           
     574            <li class="search-field">
     575                <label for="search"><?php _e('Search Field', $this->textdomain); ?>:</label>
     576                <select name="wpabi_options[default_items][search]" id="search">
     577                    <option value="1" <?php selected($this->options['default_items']['search'], '1') ?>>Enabled</option>
     578                    <option value="0" <?php selected($this->options['default_items']['search'], '0') ?>>Disabled</option>
    540579                </select>
    541580            </li>
Note: See TracChangeset for help on using the changeset viewer.