Toolbar: Allow adding lang and dir attributes to toolbar items.

This is useful from a multilingual and accessibility perspective.

Props Chouby, leemon.
Fixes #33513.

git-svn-id: https://develop.svn.wordpress.org/trunk@35795 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Pascal Birchler 2015-12-06 21:36:49 +00:00
parent b077af3e08
commit b09fd386fd

View File

@ -98,6 +98,8 @@ class WP_Admin_Bar {
/**
* Add a node to the menu.
*
* @since 4.5.0 Added the ability to pass 'lang' and 'dir' meta data.
*
* @param array $args {
* Arguments for adding a node.
*
@ -106,7 +108,7 @@ class WP_Admin_Bar {
* @type string $parent Optional. ID of the parent node.
* @type string $href Optional. Link for the item.
* @type bool $group Optional. Whether or not the node is a group. Default false.
* @type array $meta Meta data including the following keys: 'html', 'class', 'rel',
* @type array $meta Meta data including the following keys: 'html', 'class', 'rel', 'lang', 'dir',
* 'onclick', 'target', 'title', 'tabindex'. Default empty.
* }
*/
@ -506,12 +508,24 @@ class WP_Admin_Bar {
if ( ! empty( $node->meta['rel'] ) ) :
?> rel="<?php echo esc_attr( $node->meta['rel'] ); ?>"<?php
endif;
if ( ! empty( $node->meta['lang'] ) ) :
?> lang="<?php echo esc_attr( $node->meta['lang'] ); ?>"<?php
endif;
if ( ! empty( $node->meta['dir'] ) ) :
?> dir="<?php echo esc_attr( $node->meta['dir'] ); ?>"<?php
endif;
?>><?php
else:
?><div class="ab-item ab-empty-item" <?php echo $aria_attributes;
if ( ! empty( $node->meta['title'] ) ) :
?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php
endif;
if ( ! empty( $node->meta['lang'] ) ) :
?> lang="<?php echo esc_attr( $node->meta['lang'] ); ?>"<?php
endif;
if ( ! empty( $node->meta['dir'] ) ) :
?> dir="<?php echo esc_attr( $node->meta['dir'] ); ?>"<?php
endif;
?>><?php
endif;