[wp-trac] [WordPress Trac] #44363: Coding Standards: Assignments must be the first block of code on a line

WordPress Trac noreply at wordpress.org
Mon Jun 18 10:32:01 UTC 2018


#44363: Coding Standards: Assignments must be the first block of code on a line
-------------------------------------+-------------------------------
 Reporter:  subrataemfluence         |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  5.0
Component:  Plugins                  |     Version:  trunk
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:  coding-standards
-------------------------------------+-------------------------------
Changes (by subrataemfluence):

 * keywords:  has-patch => has-patch needs-testing


Comment:

 Thank you @johnbillion and @jrf for spotting and correcting the patch.
 However, I think the new patch has a logical issue.

 {{{#!php
 <?php
 $page_hook = get_plugin_page_hook( $plugin_page, $the_parent );
 if ( null !== $page_hook ) {
    $page_hook = get_plugin_page_hook( $plugin_page, $plugin_page );
    ...
 }
 }}}


 The above will generate error.

 We should only retrieve the plugin page hook sending current
 `$plugin_page` in both parameters if `null` is returned using
 `$the_parent`. Can this be the correct approach?

 {{{#!php
 <?php
 $page_hook = get_plugin_page_hook( $plugin_page, $the_parent );
 if ( null === $page_hook ) {
    $page_hook = get_plugin_page_hook( $plugin_page, $plugin_page );
 }
 ...
 }}}


 The entire code block looks like:

 {{{#!php
 <?php
 if ( isset( $plugin_page ) ) {
    if ( ! empty( $typenow ) ) {
       $the_parent = $pagenow . '?post_type=' . $typenow;
    } else {
       $the_parent = $pagenow;
    }

    $page_hook = get_plugin_page_hook( $plugin_page, $the_parent );
    if ( null === $page_hook ) {
       $page_hook = get_plugin_page_hook($plugin_page, $plugin_page);
    }

    // Back-compat for plugins using add_management_page().
    if ( empty( $page_hook ) && 'edit.php' == $pagenow && '' !=
 get_plugin_page_hook( $plugin_page, 'tools.php' ) ) {
       // There could be plugin specific params on the URL, so we need the
 whole query string
       if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
          $query_string = $_SERVER['QUERY_STRING'];
       } else {
          $query_string = 'page=' . $plugin_page;
       }
       wp_redirect( admin_url( 'tools.php?' . $query_string ) );
       exit;
    }

    unset( $the_parent );
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44363#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list