Admin Bar: Reformat the render methods.

The admin bar render methods use some cute tricks which don't come close to the WordPress coding standards. So that we can more easily apply automated code fixing to the codebase, these tricks need to be removed.

See #41057.



git-svn-id: https://develop.svn.wordpress.org/trunk@42128 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2017-11-08 08:34:41 +00:00
parent 9f77ec13ff
commit e9282049e8

View File

@ -434,11 +434,11 @@ class WP_Admin_Bar {
if ( $node->type != 'container' || empty( $node->children ) ) if ( $node->type != 'container' || empty( $node->children ) )
return; return;
?><div id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>" class="ab-group-container"><?php echo '<div id="' . esc_attr( 'wp-admin-bar-' . $node->id ) . '" class="ab-group-container">';
foreach ( $node->children as $group ) { foreach ( $node->children as $group ) {
$this->_render_group( $group ); $this->_render_group( $group );
} }
?></div><?php echo '</div>';
} }
/** /**
@ -457,11 +457,11 @@ class WP_Admin_Bar {
else else
$class = ''; $class = '';
?><ul id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>"<?php echo $class; ?>><?php echo "<ul id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$class>";
foreach ( $node->children as $item ) { foreach ( $node->children as $item ) {
$this->_render_item( $item ); $this->_render_item( $item );
} }
?></ul><?php echo '</ul>';
} }
/** /**
@ -491,65 +491,46 @@ class WP_Admin_Bar {
if ( $menuclass ) if ( $menuclass )
$menuclass = ' class="' . esc_attr( trim( $menuclass ) ) . '"'; $menuclass = ' class="' . esc_attr( trim( $menuclass ) ) . '"';
?> echo "<li id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$menuclass>";
<li id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>"<?php echo $menuclass; ?>><?php if ( $has_link ) {
if ( $has_link ): $attributes = array( 'onclick', 'target', 'title', 'rel', 'lang', 'dir' );
?><a class="ab-item"<?php echo $aria_attributes; ?> href="<?php echo esc_url( $node->href ) ?>"<?php echo "<a class='ab-item'$aria_attributes href='" . esc_url( $node->href ) . "'>";
if ( ! empty( $node->meta['onclick'] ) ) : if ( ! empty( $node->meta['onclick'] ) ) {
?> onclick="<?php echo esc_js( $node->meta['onclick'] ); ?>"<?php echo ' onclick="' . esc_js( $node->meta['onclick'] ) . '"';
endif; }
if ( ! empty( $node->meta['target'] ) ) : } else {
?> target="<?php echo esc_attr( $node->meta['target'] ); ?>"<?php $attributes = array( 'onclick', 'target', 'title', 'rel', 'lang', 'dir' );
endif; echo '<div class="ab-item ab-empty-item"' . $aria_attributes;
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; foreach ( $attributes as $attribute ) {
if ( ! empty( $node->meta[ $attribute ] ) ) {
echo " $attribute='" . esc_attr( $node->meta[ $attribute ] ) . '"';
}
}
if ( $has_link ) : echo ">{$node->title}";
?></a><?php
else:
?></div><?php
endif;
if ( $is_parent ) : if ( $has_link ) {
?><div class="ab-sub-wrapper"><?php echo '</a>';
foreach ( $node->children as $group ) { } else {
$this->_render_group( $group ); echo '</div>';
} }
?></div><?php
endif;
if ( ! empty( $node->meta['html'] ) ) if ( $is_parent ) {
echo $node->meta['html']; echo '<div class="ab-sub-wrapper">';
foreach ( $node->children as $group ) {
$this->_render_group( $group );
}
echo '</div>';
}
?> if ( ! empty( $node->meta['html'] ) ) {
</li><?php echo $node->meta['html'];
}
echo '</li>';
} }
/** /**