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