WordPress.org

Make WordPress Core

Opened 5 weeks ago

Last modified 5 weeks ago

#44365 reopened enhancement

Coding Standards: Yoda condition check is not present

Reported by: subrataemfluence Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
Component: General Keywords:
Focuses: coding-standards Cc:

Description

In wp-admin/admin.php between line nos. 358 and 372, Yoda conditions are not met according to the sniffer.

Here is the code we have now:

<?php
if ( $typenow == 'page' ) {
   if ( $pagenow == 'post-new.php' ) {
     do_action( 'load-page-new.php' );
   } elseif ( $pagenow == 'post.php' ) {
     do_action( 'load-page.php' );
   }
} elseif ( $pagenow == 'edit-tags.php' ) {
   if ( $taxnow == 'category' ) {
     do_action( 'load-categories.php' );
   } elseif ( $taxnow == 'link_category' ) {
     do_action( 'load-edit-link-categories.php' );
   }
} elseif ( 'term.php' === $pagenow ) {
   do_action( 'load-edit-tags.php' );
}

One thing to notice at the end of the above code block. We have a Yoda condition checked. I am not sure why it used only at one place. Is this done in purpose?

<?php
...
} elseif ( 'term.php' === $pagenow ) {
   do_action( 'load-edit-tags.php' );
}

Can we re-write the block of code and make it consistent as proposed in my patch?

Attachments (1)

44365.diff (1002 bytes) - added by subrataemfluence 5 weeks ago.

Download all attachments as: .zip

Change History (3)

#1 @abdullahramzan
5 weeks ago

  • Keywords 2nd-opinion removed
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #44028.

#2 @subrataemfluence
5 weeks ago

  • Resolution duplicate deleted
  • Status changed from closed to reopened

Thank you for looking into it. But as far as I have seen there is no patch for admin.php in #44208. Should I upload the patch there?

Note: See TracTickets for help on using tickets.