Skip to content

Commit

Permalink
Coding Standards: Use strict comparison in `wp-includes/class-wp-walk…
Browse files Browse the repository at this point in the history
…er.php`.

Follow-up to [6384], [6456], [6858], [8494], [8961].

Props aristath, poena, afercia, SergeyBiryukov.
See #60700.

git-svn-id: https://develop.svn.wordpress.org/trunk@57848 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Mar 17, 2024
1 parent 47d2675 commit 17415a7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/wp-includes/class-wp-walker.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function display_element( $element, &$children_elements, $max_depth, $dep
$this->start_el( $output, $element, $depth, ...array_values( $args ) );

// Descend only when the depth is right and there are children for this element.
if ( ( 0 == $max_depth || $max_depth > $depth + 1 ) && isset( $children_elements[ $id ] ) ) {
if ( ( 0 === $max_depth || $max_depth > $depth + 1 ) && isset( $children_elements[ $id ] ) ) {

foreach ( $children_elements[ $id ] as $child ) {

Expand Down Expand Up @@ -199,7 +199,7 @@ public function walk( $elements, $max_depth, ...$args ) {
$parent_field = $this->db_fields['parent'];

// Flat display.
if ( -1 == $max_depth ) {
if ( -1 === $max_depth ) {
$empty_array = array();
foreach ( $elements as $e ) {
$this->display_element( $e, $empty_array, 1, 0, $args, $output );
Expand Down Expand Up @@ -235,7 +235,7 @@ public function walk( $elements, $max_depth, ...$args ) {
$top_level_elements = array();
$children_elements = array();
foreach ( $elements as $e ) {
if ( $root->$parent_field == $e->$parent_field ) {
if ( $root->$parent_field === $e->$parent_field ) {
$top_level_elements[] = $e;
} else {
$children_elements[ $e->$parent_field ][] = $e;
Expand All @@ -251,7 +251,7 @@ public function walk( $elements, $max_depth, ...$args ) {
* If we are displaying all levels, and remaining children_elements is not empty,
* then we got orphans, which should be displayed regardless.
*/
if ( ( 0 == $max_depth ) && count( $children_elements ) > 0 ) {
if ( ( 0 === $max_depth ) && count( $children_elements ) > 0 ) {
$empty_array = array();
foreach ( $children_elements as $orphans ) {
foreach ( $orphans as $op ) {
Expand Down Expand Up @@ -294,28 +294,28 @@ public function paged_walk( $elements, $max_depth, $page_num, $per_page, ...$arg
$parent_field = $this->db_fields['parent'];

$count = -1;
if ( -1 == $max_depth ) {
if ( -1 === $max_depth ) {
$total_top = count( $elements );
}
if ( $page_num < 1 || $per_page < 0 ) {
// No paging.
$paging = false;
$start = 0;
if ( -1 == $max_depth ) {
if ( -1 === $max_depth ) {
$end = $total_top;
}
$this->max_pages = 1;
} else {
$paging = true;
$start = ( (int) $page_num - 1 ) * (int) $per_page;
$end = $start + $per_page;
if ( -1 == $max_depth ) {
if ( -1 === $max_depth ) {
$this->max_pages = (int) ceil( $total_top / $per_page );
}
}

// Flat display.
if ( -1 == $max_depth ) {
if ( -1 === $max_depth ) {
if ( ! empty( $args[0]['reverse_top_level'] ) ) {
$elements = array_reverse( $elements );
$oldstart = $start;
Expand Down

0 comments on commit 17415a7

Please sign in to comment.