Make WordPress Core


Ignore:
Timestamp:
08/17/2018 01:50:26 AM (6 years ago)
Author:
pento
Message:

Coding Standards: Upgrade WPCS to 1.0.0

WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:

  • Multiline function calls must now put each parameter on a new line.
  • Auto-formatting files is now part of the grunt precommit script.
  • Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-tags.php

    r42719 r43571  
    5656
    5757add_screen_option(
    58     'per_page', array(
     58    'per_page',
     59    array(
    5960        'default' => 20,
    6061        'option'  => 'edit_' . $tax->name . '_per_page',
     
    9697                    'error'   => true,
    9798                    'message' => 4,
    98                 ), $referer
     99                ),
     100                $referer
    99101            );
    100102        }
     
    188190                    'error'   => true,
    189191                    'message' => 5,
    190                 ), $referer
     192                ),
     193                $referer
    191194            );
    192195        }
     
    338341<?php if ( $message ) : ?>
    339342<div id="message" class="<?php echo $class; ?> notice is-dismissible"><p><?php echo $message; ?></p></div>
    340 <?php
    341 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message', 'error' ), $_SERVER['REQUEST_URI'] );
     343    <?php
     344    $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message', 'error' ), $_SERVER['REQUEST_URI'] );
    342345endif;
    343346?>
     
    402405     */
    403406    do_action( "{$taxonomy}_pre_add_form", $taxonomy );
    404 ?>
     407    ?>
    405408
    406409<div class="form-wrap">
    407410<h2><?php echo $tax->labels->add_new_item; ?></h2>
    408411<form id="addtag" method="post" action="edit-tags.php" class="validate"
    409 <?php
    410 /**
    411  * Fires inside the Add Tag form tag.
    412  *
    413  * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
    414  *
    415  * @since 3.7.0
    416  */
    417 do_action( "{$taxonomy}_term_new_form_tag" );
    418 ?>
     412    <?php
     413    /**
     414    * Fires inside the Add Tag form tag.
     415    *
     416    * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
     417    *
     418    * @since 3.7.0
     419    */
     420    do_action( "{$taxonomy}_term_new_form_tag" );
     421    ?>
    419422>
    420423<input type="hidden" name="action" value="add-tag" />
     
    422425<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $taxonomy ); ?>" />
    423426<input type="hidden" name="post_type" value="<?php echo esc_attr( $post_type ); ?>" />
    424 <?php wp_nonce_field( 'add-tag', '_wpnonce_add-tag' ); ?>
     427    <?php wp_nonce_field( 'add-tag', '_wpnonce_add-tag' ); ?>
    425428
    426429<div class="form-field form-required term-name-wrap">
     
    429432    <p><?php _e( 'The name is how it appears on your site.' ); ?></p>
    430433</div>
    431 <?php if ( ! global_terms_enabled() ) : ?>
     434    <?php if ( ! global_terms_enabled() ) : ?>
    432435<div class="form-field term-slug-wrap">
    433436    <label for="tag-slug"><?php _e( 'Slug' ); ?></label>
     
    436439</div>
    437440<?php endif; // global_terms_enabled() ?>
    438 <?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
     441    <?php if ( is_taxonomy_hierarchical( $taxonomy ) ) : ?>
    439442<div class="form-field term-parent-wrap">
    440443    <label for="parent"><?php echo esc_html( $tax->labels->parent_item ); ?></label>
    441     <?php
    442     $dropdown_args = array(
    443         'hide_empty'       => 0,
    444         'hide_if_empty'    => false,
    445         'taxonomy'         => $taxonomy,
    446         'name'             => 'parent',
    447         'orderby'          => 'name',
    448         'hierarchical'     => true,
    449         'show_option_none' => __( 'None' ),
    450     );
    451 
    452     /**
    453     * Filters the taxonomy parent drop-down on the Edit Term page.
    454     *
    455     * @since 3.7.0
    456     * @since 4.2.0 Added `$context` parameter.
    457     *
    458     * @param array  $dropdown_args {
    459     *     An array of taxonomy parent drop-down arguments.
    460     *
    461     *     @type int|bool $hide_empty       Whether to hide terms not attached to any posts. Default 0|false.
    462     *     @type bool     $hide_if_empty    Whether to hide the drop-down if no terms exist. Default false.
    463     *     @type string   $taxonomy         The taxonomy slug.
    464     *     @type string   $name             Value of the name attribute to use for the drop-down select element.
    465     *                                      Default 'parent'.
    466     *     @type string   $orderby          The field to order by. Default 'name'.
    467     *     @type bool     $hierarchical     Whether the taxonomy is hierarchical. Default true.
    468     *     @type string   $show_option_none Label to display if there are no terms. Default 'None'.
    469     * }
    470     * @param string $taxonomy The taxonomy slug.
    471     * @param string $context  Filter context. Accepts 'new' or 'edit'.
    472     */
    473     $dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'new' );
    474 
    475     wp_dropdown_categories( $dropdown_args );
    476     ?>
    477     <?php if ( 'category' == $taxonomy ) : ?>
     444        <?php
     445        $dropdown_args = array(
     446            'hide_empty'       => 0,
     447            'hide_if_empty'    => false,
     448            'taxonomy'         => $taxonomy,
     449            'name'             => 'parent',
     450            'orderby'          => 'name',
     451            'hierarchical'     => true,
     452            'show_option_none' => __( 'None' ),
     453        );
     454
     455        /**
     456        * Filters the taxonomy parent drop-down on the Edit Term page.
     457        *
     458        * @since 3.7.0
     459        * @since 4.2.0 Added `$context` parameter.
     460        *
     461        * @param array  $dropdown_args {
     462        *     An array of taxonomy parent drop-down arguments.
     463        *
     464        *     @type int|bool $hide_empty       Whether to hide terms not attached to any posts. Default 0|false.
     465        *     @type bool     $hide_if_empty    Whether to hide the drop-down if no terms exist. Default false.
     466        *     @type string   $taxonomy         The taxonomy slug.
     467        *     @type string   $name             Value of the name attribute to use for the drop-down select element.
     468        *                                      Default 'parent'.
     469        *     @type string   $orderby          The field to order by. Default 'name'.
     470        *     @type bool     $hierarchical     Whether the taxonomy is hierarchical. Default true.
     471        *     @type string   $show_option_none Label to display if there are no terms. Default 'None'.
     472        * }
     473        * @param string $taxonomy The taxonomy slug.
     474        * @param string $context  Filter context. Accepts 'new' or 'edit'.
     475        */
     476        $dropdown_args = apply_filters( 'taxonomy_parent_dropdown_args', $dropdown_args, $taxonomy, 'new' );
     477
     478        wp_dropdown_categories( $dropdown_args );
     479        ?>
     480        <?php if ( 'category' == $taxonomy ) : ?>
    478481        <p><?php _e( 'Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.' ); ?></p>
    479482    <?php else : ?>
     
    481484    <?php endif; ?>
    482485</div>
    483 <?php endif; // is_taxonomy_hierarchical() ?>
     486    <?php endif; // is_taxonomy_hierarchical() ?>
    484487<div class="form-field term-description-wrap">
    485488    <label for="tag-description"><?php _e( 'Description' ); ?></label>
     
    488491</div>
    489492
    490 <?php
    491 if ( ! is_taxonomy_hierarchical( $taxonomy ) ) {
     493    <?php
     494    if ( ! is_taxonomy_hierarchical( $taxonomy ) ) {
     495        /**
     496         * Fires after the Add Tag form fields for non-hierarchical taxonomies.
     497         *
     498         * @since 3.0.0
     499         *
     500         * @param string $taxonomy The taxonomy slug.
     501         */
     502        do_action( 'add_tag_form_fields', $taxonomy );
     503    }
     504
    492505    /**
    493      * Fires after the Add Tag form fields for non-hierarchical taxonomies.
     506     * Fires after the Add Term form fields.
     507     *
     508     * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
    494509     *
    495510     * @since 3.0.0
     
    497512     * @param string $taxonomy The taxonomy slug.
    498513     */
    499     do_action( 'add_tag_form_fields', $taxonomy );
    500 }
    501 
    502 /**
    503  * Fires after the Add Term form fields.
    504  *
    505  * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
    506  *
    507  * @since 3.0.0
    508  *
    509  * @param string $taxonomy The taxonomy slug.
    510  */
    511 do_action( "{$taxonomy}_add_form_fields", $taxonomy );
    512 
    513 submit_button( $tax->labels->add_new_item );
    514 
    515 if ( 'category' == $taxonomy ) {
     514    do_action( "{$taxonomy}_add_form_fields", $taxonomy );
     515
     516    submit_button( $tax->labels->add_new_item );
     517
     518    if ( 'category' == $taxonomy ) {
     519        /**
     520         * Fires at the end of the Edit Category form.
     521         *
     522         * @since 2.1.0
     523         * @deprecated 3.0.0 Use {$taxonomy}_add_form instead.
     524         *
     525         * @param object $arg Optional arguments cast to an object.
     526         */
     527        do_action( 'edit_category_form', (object) array( 'parent' => 0 ) );
     528    } elseif ( 'link_category' == $taxonomy ) {
     529        /**
     530         * Fires at the end of the Edit Link form.
     531         *
     532         * @since 2.3.0
     533         * @deprecated 3.0.0 Use {$taxonomy}_add_form instead.
     534         *
     535         * @param object $arg Optional arguments cast to an object.
     536         */
     537        do_action( 'edit_link_category_form', (object) array( 'parent' => 0 ) );
     538    } else {
     539        /**
     540         * Fires at the end of the Add Tag form.
     541         *
     542         * @since 2.7.0
     543         * @deprecated 3.0.0 Use {$taxonomy}_add_form instead.
     544         *
     545         * @param string $taxonomy The taxonomy slug.
     546         */
     547        do_action( 'add_tag_form', $taxonomy );
     548    }
     549
    516550    /**
    517      * Fires at the end of the Edit Category form.
    518      *
    519      * @since 2.1.0
    520      * @deprecated 3.0.0 Use {$taxonomy}_add_form instead.
    521      *
    522      * @param object $arg Optional arguments cast to an object.
    523      */
    524     do_action( 'edit_category_form', (object) array( 'parent' => 0 ) );
    525 } elseif ( 'link_category' == $taxonomy ) {
    526     /**
    527      * Fires at the end of the Edit Link form.
    528      *
    529      * @since 2.3.0
    530      * @deprecated 3.0.0 Use {$taxonomy}_add_form instead.
    531      *
    532      * @param object $arg Optional arguments cast to an object.
    533      */
    534     do_action( 'edit_link_category_form', (object) array( 'parent' => 0 ) );
    535 } else {
    536     /**
    537      * Fires at the end of the Add Tag form.
    538      *
    539      * @since 2.7.0
    540      * @deprecated 3.0.0 Use {$taxonomy}_add_form instead.
     551     * Fires at the end of the Add Term form for all taxonomies.
     552     *
     553     * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
     554     *
     555     * @since 3.0.0
    541556     *
    542557     * @param string $taxonomy The taxonomy slug.
    543558     */
    544     do_action( 'add_tag_form', $taxonomy );
    545 }
    546 
    547 /**
    548  * Fires at the end of the Add Term form for all taxonomies.
    549  *
    550  * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
    551  *
    552  * @since 3.0.0
    553  *
    554  * @param string $taxonomy The taxonomy slug.
    555  */
    556 do_action( "{$taxonomy}_add_form", $taxonomy );
    557 ?>
     559    do_action( "{$taxonomy}_add_form", $taxonomy );
     560    ?>
    558561</form></div>
    559562<?php } ?>
     
    588591    ?>
    589592</p>
    590 <?php if ( current_user_can( 'import' ) ) : ?>
     593    <?php if ( current_user_can( 'import' ) ) : ?>
    591594<p><?php printf( __( 'Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.' ), esc_url( $import_link ) ); ?></p>
    592 <?php endif; ?>
     595    <?php endif; ?>
    593596</div>
    594597<?php elseif ( 'post_tag' == $taxonomy && current_user_can( 'import' ) ) : ?>
     
    596599<p><?php printf( __( 'Tags can be selectively converted to categories using the <a href="%s">tag to category converter</a>.' ), esc_url( $import_link ) ); ?></p>
    597600</div>
    598 <?php
     601    <?php
    599602endif;
    600603
     
    621624try{document.forms.addtag['tag-name'].focus();}catch(e){}
    622625</script>
    623 <?php
     626    <?php
    624627endif;
    625628
Note: See TracChangeset for help on using the changeset viewer.