Coding Standards: Use Yoda conditions where appropriate.
See #49222. Built from https://develop.svn.wordpress.org/trunk@47219 git-svn-id: http://core.svn.wordpress.org/trunk@47019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -318,7 +318,7 @@ class WP_Admin_Bar {
|
||||
}
|
||||
|
||||
foreach ( $this->_get_nodes() as $node ) {
|
||||
if ( 'root' == $node->id ) {
|
||||
if ( 'root' === $node->id ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -329,9 +329,9 @@ class WP_Admin_Bar {
|
||||
}
|
||||
|
||||
// Generate the group class (we distinguish between top level and other level groups).
|
||||
$group_class = ( $node->parent == 'root' ) ? 'ab-top-menu' : 'ab-submenu';
|
||||
$group_class = ( 'root' === $node->parent ) ? 'ab-top-menu' : 'ab-submenu';
|
||||
|
||||
if ( $node->type == 'group' ) {
|
||||
if ( 'group' === $node->type ) {
|
||||
if ( empty( $node->meta['class'] ) ) {
|
||||
$node->meta['class'] = $group_class;
|
||||
} else {
|
||||
@@ -340,7 +340,7 @@ class WP_Admin_Bar {
|
||||
}
|
||||
|
||||
// Items in items aren't allowed. Wrap nested items in 'default' groups.
|
||||
if ( $parent->type == 'item' && $node->type == 'item' ) {
|
||||
if ( 'item' === $parent->type && 'item' === $node->type ) {
|
||||
$default_id = $parent->id . '-default';
|
||||
$default = $this->_get_node( $default_id );
|
||||
|
||||
@@ -369,7 +369,7 @@ class WP_Admin_Bar {
|
||||
|
||||
// Groups in groups aren't allowed. Add a special 'container' node.
|
||||
// The container will invisibly wrap both groups.
|
||||
} elseif ( $parent->type == 'group' && $node->type == 'group' ) {
|
||||
} elseif ( 'group' === $parent->type && 'group' === $node->type ) {
|
||||
$container_id = $parent->id . '-container';
|
||||
$container = $this->_get_node( $container_id );
|
||||
|
||||
@@ -398,7 +398,7 @@ class WP_Admin_Bar {
|
||||
$container->parent = $grandparent->id;
|
||||
|
||||
$index = array_search( $parent, $grandparent->children, true );
|
||||
if ( $index === false ) {
|
||||
if ( false === $index ) {
|
||||
$grandparent->children[] = $container;
|
||||
} else {
|
||||
array_splice( $grandparent->children, $index, 1, array( $container ) );
|
||||
@@ -469,7 +469,7 @@ class WP_Admin_Bar {
|
||||
* @param object $node
|
||||
*/
|
||||
final protected function _render_container( $node ) {
|
||||
if ( $node->type != 'container' || empty( $node->children ) ) {
|
||||
if ( 'container' !== $node->type || empty( $node->children ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -484,11 +484,11 @@ class WP_Admin_Bar {
|
||||
* @param object $node
|
||||
*/
|
||||
final protected function _render_group( $node ) {
|
||||
if ( $node->type == 'container' ) {
|
||||
if ( 'container' === $node->type ) {
|
||||
$this->_render_container( $node );
|
||||
return;
|
||||
}
|
||||
if ( $node->type != 'group' || empty( $node->children ) ) {
|
||||
if ( 'group' !== $node->type || empty( $node->children ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -509,7 +509,7 @@ class WP_Admin_Bar {
|
||||
* @param object $node
|
||||
*/
|
||||
final protected function _render_item( $node ) {
|
||||
if ( $node->type != 'item' ) {
|
||||
if ( 'item' !== $node->type ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user