WP_Admin_Bar::_render_item( object $node )
Parameters
- $node
-
(Required)
Source
File: wp-includes/class-wp-admin-bar.php
final protected function _render_item( $node ) {
if ( $node->type != 'item' )
return;
$is_parent = ! empty( $node->children );
$has_link = ! empty( $node->href );
// Allow only numeric values, then casted to integers, and allow a tabindex value of `0` for a11y.
$tabindex = ( isset( $node->meta['tabindex'] ) && is_numeric( $node->meta['tabindex'] ) ) ? (int) $node->meta['tabindex'] : '';
$aria_attributes = ( '' !== $tabindex ) ? ' tabindex="' . $tabindex . '"' : '';
$menuclass = '';
if ( $is_parent ) {
$menuclass = 'menupop ';
$aria_attributes .= ' aria-haspopup="true"';
}
if ( ! empty( $node->meta['class'] ) )
$menuclass .= $node->meta['class'];
if ( $menuclass )
$menuclass = ' class="' . esc_attr( trim( $menuclass ) ) . '"';
?>
<li id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>"<?php echo $menuclass; ?>><?php
if ( $has_link ):
?><a class="ab-item"<?php echo $aria_attributes; ?> href="<?php echo esc_url( $node->href ) ?>"<?php
if ( ! empty( $node->meta['onclick'] ) ) :
?> onclick="<?php echo esc_js( $node->meta['onclick'] ); ?>"<?php
endif;
if ( ! empty( $node->meta['target'] ) ) :
?> target="<?php echo esc_attr( $node->meta['target'] ); ?>"<?php
endif;
if ( ! empty( $node->meta['title'] ) ) :
?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php
endif;
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;
echo $node->title;
if ( $has_link ) :
?></a><?php
else:
?></div><?php
endif;
if ( $is_parent ) :
?><div class="ab-sub-wrapper"><?php
foreach ( $node->children as $group ) {
$this->_render_group( $group );
}
?></div><?php
endif;
if ( ! empty( $node->meta['html'] ) )
echo $node->meta['html'];
?>
</li><?php
}