wp/wp-includes/class-wp-admin-bar.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    14 
    14 
    15 	public function __get( $name ) {
    15 	public function __get( $name ) {
    16 		switch ( $name ) {
    16 		switch ( $name ) {
    17 			case 'proto' :
    17 			case 'proto' :
    18 				return is_ssl() ? 'https://' : 'http://';
    18 				return is_ssl() ? 'https://' : 'http://';
    19 				break;
    19 
    20 			case 'menu' :
    20 			case 'menu' :
    21 				_deprecated_argument( 'WP_Admin_Bar', '3.3', 'Modify admin bar nodes with WP_Admin_Bar::get_node(), WP_Admin_Bar::add_node(), and WP_Admin_Bar::remove_node(), not the <code>menu</code> property.' );
    21 				_deprecated_argument( 'WP_Admin_Bar', '3.3', 'Modify admin bar nodes with WP_Admin_Bar::get_node(), WP_Admin_Bar::add_node(), and WP_Admin_Bar::remove_node(), not the <code>menu</code> property.' );
    22 				return array(); // Sorry, folks.
    22 				return array(); // Sorry, folks.
    23 				break;
       
    24 		}
    23 		}
    25 	}
    24 	}
    26 
    25 
    27 	public function initialize() {
    26 	public function initialize() {
    28 		$this->user = new stdClass;
    27 		$this->user = new stdClass;
    79 	}
    78 	}
    80 
    79 
    81 	/**
    80 	/**
    82 	 * Add a node to the menu.
    81 	 * Add a node to the menu.
    83 	 *
    82 	 *
    84 	 * @param array $args - The arguments for each node.
    83 	 * @param array $args {
    85 	 * - id         - string    - The ID of the item.
    84 	 *     Arguments for adding a node.
    86 	 * - title      - string    - The title of the node.
    85 	 *
    87 	 * - parent     - string    - The ID of the parent node. Optional.
    86 	 *     @type string $id     ID of the item.
    88 	 * - href       - string    - The link for the item. Optional.
    87 	 *     @type string $title  Title of the node.
    89 	 * - group      - boolean   - If the node is a group. Optional. Default false.
    88 	 *     @type string $parent Optional. ID of the parent node.
    90 	 * - meta       - array     - Meta data including the following keys: html, class, onclick, target, title, tabindex.
    89 	 *     @type string $href   Optional. Link for the item.
       
    90 	 *     @type bool   $group  Optional. Whether or not the node is a group. Default false.
       
    91 	 *     @type array  $meta   Meta data including the following keys: 'html', 'class', 'rel',
       
    92 	 *                          'onclick', 'target', 'title', 'tabindex'. Default empty.
       
    93 	 * }
    91 	 */
    94 	 */
    92 	public function add_node( $args ) {
    95 	public function add_node( $args ) {
    93 		// Shim for old method signature: add_node( $parent_id, $menu_obj, $args )
    96 		// Shim for old method signature: add_node( $parent_id, $menu_obj, $args )
    94 		if ( func_num_args() >= 3 && is_string( func_get_arg(0) ) )
    97 		if ( func_num_args() >= 3 && is_string( func_get_arg(0) ) )
    95 			$args = array_merge( array( 'parent' => func_get_arg(0) ), func_get_arg(2) );
    98 			$args = array_merge( array( 'parent' => func_get_arg(0) ), func_get_arg(2) );
   185 	/**
   188 	/**
   186 	 * Add a group to a menu node.
   189 	 * Add a group to a menu node.
   187 	 *
   190 	 *
   188 	 * @since 3.3.0
   191 	 * @since 3.3.0
   189 	 *
   192 	 *
   190 	 * @param array $args - The arguments for each node.
   193 	 * @param array $args {
   191 	 * - id         - string    - The ID of the item.
   194 	 *     Array of arguments for adding a group.
   192 	 * - parent     - string    - The ID of the parent node. Optional. Default root.
   195 	 *
   193 	 * - meta       - array     - Meta data including the following keys: class, onclick, target, title.
   196 	 *     @type string $id     ID of the item.
       
   197 	 *     @type string $parent Optional. ID of the parent node. Default 'root'.
       
   198 	 *     @type array  $meta   Meta data for the group including the following keys:
       
   199 	 *                         'class', 'onclick', 'target', and 'title'.
       
   200 	 * }
   194 	 */
   201 	 */
   195 	final public function add_group( $args ) {
   202 	final public function add_group( $args ) {
   196 		$args['group'] = true;
   203 		$args['group'] = true;
   197 
   204 
   198 		$this->add_node( $args );
   205 		$this->add_node( $args );
   354 		} elseif ( wp_is_mobile() ) {
   361 		} elseif ( wp_is_mobile() ) {
   355 			$class .= ' mobile';
   362 			$class .= ' mobile';
   356 		}
   363 		}
   357 
   364 
   358 		?>
   365 		?>
   359 		<div id="wpadminbar" class="<?php echo $class; ?>" role="navigation">
   366 		<div id="wpadminbar" class="<?php echo $class; ?>">
   360 			<a class="screen-reader-shortcut" href="#wp-toolbar" tabindex="1"><?php _e('Skip to toolbar'); ?></a>
   367 			<?php if ( ! is_admin() ) { ?>
   361 			<div class="quicklinks" id="wp-toolbar" role="navigation" aria-label="<?php esc_attr_e('Top navigation toolbar.'); ?>" tabindex="0">
   368 				<a class="screen-reader-shortcut" href="#wp-toolbar" tabindex="1"><?php _e( 'Skip to toolbar' ); ?></a>
       
   369 			<?php } ?>
       
   370 			<div class="quicklinks" id="wp-toolbar" role="navigation" aria-label="<?php esc_attr_e( 'Toolbar' ); ?>" tabindex="0">
   362 				<?php foreach ( $root->children as $group ) {
   371 				<?php foreach ( $root->children as $group ) {
   363 					$this->_render_group( $group );
   372 					$this->_render_group( $group );
   364 				} ?>
   373 				} ?>
   365 			</div>
   374 			</div>
   366 			<?php if ( is_user_logged_in() ) : ?>
   375 			<?php if ( is_user_logged_in() ) : ?>
   436 					?> target="<?php echo esc_attr( $node->meta['target'] ); ?>"<?php
   445 					?> target="<?php echo esc_attr( $node->meta['target'] ); ?>"<?php
   437 				endif;
   446 				endif;
   438 				if ( ! empty( $node->meta['title'] ) ) :
   447 				if ( ! empty( $node->meta['title'] ) ) :
   439 					?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php
   448 					?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php
   440 				endif;
   449 				endif;
       
   450 				if ( ! empty( $node->meta['rel'] ) ) :
       
   451 					?> rel="<?php echo esc_attr( $node->meta['rel'] ); ?>"<?php
       
   452 				endif;
   441 				?>><?php
   453 				?>><?php
   442 			else:
   454 			else:
   443 				?><div class="ab-item ab-empty-item" <?php echo $aria_attributes;
   455 				?><div class="ab-item ab-empty-item" <?php echo $aria_attributes;
   444 				if ( ! empty( $node->meta['title'] ) ) :
   456 				if ( ! empty( $node->meta['title'] ) ) :
   445 					?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php
   457 					?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php
   480 		add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 0 );
   492 		add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 0 );
   481 		add_action( 'admin_bar_menu', 'wp_admin_bar_search_menu', 4 );
   493 		add_action( 'admin_bar_menu', 'wp_admin_bar_search_menu', 4 );
   482 		add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_item', 7 );
   494 		add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_item', 7 );
   483 
   495 
   484 		// Site related.
   496 		// Site related.
       
   497 		add_action( 'admin_bar_menu', 'wp_admin_bar_sidebar_toggle', 0 );
   485 		add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );
   498 		add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 );
   486 		add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 );
   499 		add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 );
   487 		add_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 );
   500 		add_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 );
   488 		add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 40 );
   501 		add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 40 );
   489 
   502