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/includes/export.php

    r42875 r43571  
    446446<!--    contained in this file into your site. -->
    447447
    448 <?php the_generator( 'export' ); ?>
     448    <?php the_generator( 'export' ); ?>
    449449<rss version="2.0"
    450450    xmlns:excerpt="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/excerpt/"
     
    465465    <wp:base_blog_url><?php bloginfo_rss( 'url' ); ?></wp:base_blog_url>
    466466
    467 <?php wxr_authors_list( $post_ids ); ?>
    468 
    469 <?php foreach ( $cats as $c ) : ?>
     467    <?php wxr_authors_list( $post_ids ); ?>
     468
     469    <?php foreach ( $cats as $c ) : ?>
    470470    <wp:category>
    471471        <wp:term_id><?php echo intval( $c->term_id ); ?></wp:term_id>
     
    478478        ?>
    479479    </wp:category>
    480 <?php endforeach; ?>
    481 <?php foreach ( $tags as $t ) : ?>
     480    <?php endforeach; ?>
     481    <?php foreach ( $tags as $t ) : ?>
    482482    <wp:tag>
    483483        <wp:term_id><?php echo intval( $t->term_id ); ?></wp:term_id>
     
    489489        ?>
    490490    </wp:tag>
    491 <?php endforeach; ?>
    492 <?php foreach ( $terms as $t ) : ?>
     491    <?php endforeach; ?>
     492    <?php foreach ( $terms as $t ) : ?>
    493493    <wp:term>
    494494        <wp:term_id><?php echo wxr_cdata( $t->term_id ); ?></wp:term_id>
     
    502502        ?>
    503503    </wp:term>
    504 <?php endforeach; ?>
    505 <?php
    506 if ( 'all' == $args['content'] ) {
    507     wxr_nav_menu_terms();}
    508 ?>
     504    <?php endforeach; ?>
     505    <?php
     506    if ( 'all' == $args['content'] ) {
     507        wxr_nav_menu_terms();}
     508    ?>
    509509
    510510    <?php
     
    513513    ?>
    514514
    515 <?php
    516 if ( $post_ids ) {
    517     /**
    518     * @global WP_Query $wp_query
    519     */
    520     global $wp_query;
    521 
    522     // Fake being in the loop.
    523     $wp_query->in_the_loop = true;
    524 
    525     // Fetch 20 posts at a time rather than loading the entire table into memory.
    526     while ( $next_posts = array_splice( $post_ids, 0, 20 ) ) {
    527         $where = 'WHERE ID IN (' . join( ',', $next_posts ) . ')';
    528         $posts = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} $where" );
    529 
    530         // Begin Loop.
    531         foreach ( $posts as $post ) {
    532             setup_postdata( $post );
    533             $is_sticky = is_sticky( $post->ID ) ? 1 : 0;
    534     ?>
     515    <?php
     516    if ( $post_ids ) {
     517        /**
     518        * @global WP_Query $wp_query
     519        */
     520        global $wp_query;
     521
     522        // Fake being in the loop.
     523        $wp_query->in_the_loop = true;
     524
     525        // Fetch 20 posts at a time rather than loading the entire table into memory.
     526        while ( $next_posts = array_splice( $post_ids, 0, 20 ) ) {
     527            $where = 'WHERE ID IN (' . join( ',', $next_posts ) . ')';
     528            $posts = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} $where" );
     529
     530            // Begin Loop.
     531            foreach ( $posts as $post ) {
     532                setup_postdata( $post );
     533                $is_sticky = is_sticky( $post->ID ) ? 1 : 0;
     534                ?>
    535535    <item>
    536536        <title>
    537         <?php
    538             /** This filter is documented in wp-includes/feed.php */
    539             echo apply_filters( 'the_title_rss', $post->post_title );
    540         ?>
     537                <?php
     538                /** This filter is documented in wp-includes/feed.php */
     539                echo apply_filters( 'the_title_rss', $post->post_title );
     540                ?>
    541541        </title>
    542542        <link><?php the_permalink_rss(); ?></link>
     
    546546        <description></description>
    547547        <content:encoded>
    548         <?php
    549             /**
    550             * Filters the post content used for WXR exports.
    551             *
    552             * @since 2.5.0
    553             *
    554             * @param string $post_content Content of the current post.
    555             */
    556             echo wxr_cdata( apply_filters( 'the_content_export', $post->post_content ) );
    557         ?>
     548                <?php
     549                /**
     550                * Filters the post content used for WXR exports.
     551                *
     552                * @since 2.5.0
     553                *
     554                * @param string $post_content Content of the current post.
     555                */
     556                echo wxr_cdata( apply_filters( 'the_content_export', $post->post_content ) );
     557                ?>
    558558        </content:encoded>
    559559        <excerpt:encoded>
    560         <?php
    561             /**
    562             * Filters the post excerpt used for WXR exports.
    563             *
    564             * @since 2.6.0
    565             *
    566             * @param string $post_excerpt Excerpt for the current post.
    567             */
    568             echo wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) );
    569         ?>
     560                <?php
     561                /**
     562                * Filters the post excerpt used for WXR exports.
     563                *
     564                * @since 2.6.0
     565                *
     566                * @param string $post_excerpt Excerpt for the current post.
     567                */
     568                echo wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) );
     569                ?>
    570570        </excerpt:encoded>
    571571        <wp:post_id><?php echo intval( $post->ID ); ?></wp:post_id>
     
    581581        <wp:post_password><?php echo wxr_cdata( $post->post_password ); ?></wp:post_password>
    582582        <wp:is_sticky><?php echo intval( $is_sticky ); ?></wp:is_sticky>
    583     <?php   if ( $post->post_type == 'attachment' ) : ?>
     583                <?php   if ( $post->post_type == 'attachment' ) : ?>
    584584        <wp:attachment_url><?php echo wxr_cdata( wp_get_attachment_url( $post->ID ) ); ?></wp:attachment_url>
    585585    <?php endif; ?>
    586     <?php wxr_post_taxonomy(); ?>
    587     <?php
    588     $postmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) );
    589     foreach ( $postmeta as $meta ) :
    590         /**
    591         * Filters whether to selectively skip post meta used for WXR exports.
    592         *
    593         * Returning a truthy value to the filter will skip the current meta
    594         * object from being exported.
    595         *
    596         * @since 3.3.0
    597         *
    598         * @param bool   $skip     Whether to skip the current post meta. Default false.
    599         * @param string $meta_key Current meta key.
    600         * @param object $meta     Current meta object.
    601         */
    602         if ( apply_filters( 'wxr_export_skip_postmeta', false, $meta->meta_key, $meta ) ) {
    603             continue;
    604         }
    605         ?>
     586                <?php wxr_post_taxonomy(); ?>
     587                <?php
     588                $postmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) );
     589                foreach ( $postmeta as $meta ) :
     590                    /**
     591                    * Filters whether to selectively skip post meta used for WXR exports.
     592                    *
     593                    * Returning a truthy value to the filter will skip the current meta
     594                    * object from being exported.
     595                    *
     596                    * @since 3.3.0
     597                    *
     598                    * @param bool   $skip     Whether to skip the current post meta. Default false.
     599                    * @param string $meta_key Current meta key.
     600                    * @param object $meta     Current meta object.
     601                    */
     602                    if ( apply_filters( 'wxr_export_skip_postmeta', false, $meta->meta_key, $meta ) ) {
     603                        continue;
     604                    }
     605                    ?>
    606606        <wp:postmeta>
    607607        <wp:meta_key><?php echo wxr_cdata( $meta->meta_key ); ?></wp:meta_key>
    608608        <wp:meta_value><?php echo wxr_cdata( $meta->meta_value ); ?></wp:meta_value>
    609609        </wp:postmeta>
    610 <?php
    611 endforeach;
    612 
    613         $_comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
    614         $comments  = array_map( 'get_comment', $_comments );
    615     foreach ( $comments as $c ) :
    616         ?>
     610                    <?php
     611    endforeach;
     612
     613                $_comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
     614                $comments  = array_map( 'get_comment', $_comments );
     615                foreach ( $comments as $c ) :
     616                    ?>
    617617        <wp:comment>
    618618            <wp:comment_id><?php echo intval( $c->comment_ID ); ?></wp:comment_id>
     
    628628            <wp:comment_parent><?php echo intval( $c->comment_parent ); ?></wp:comment_parent>
    629629            <wp:comment_user_id><?php echo intval( $c->user_id ); ?></wp:comment_user_id>
    630 <?php
    631   $c_meta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID ) );
    632 foreach ( $c_meta as $meta ) :
    633     /**
    634     * Filters whether to selectively skip comment meta used for WXR exports.
    635     *
    636     * Returning a truthy value to the filter will skip the current meta
    637     * object from being exported.
    638     *
    639     * @since 4.0.0
    640     *
    641     * @param bool   $skip     Whether to skip the current comment meta. Default false.
    642     * @param string $meta_key Current meta key.
    643     * @param object $meta     Current meta object.
    644     */
    645     if ( apply_filters( 'wxr_export_skip_commentmeta', false, $meta->meta_key, $meta ) ) {
    646         continue;
    647     }
    648     ?>
     630                    <?php
     631                    $c_meta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID ) );
     632                    foreach ( $c_meta as $meta ) :
     633                        /**
     634                        * Filters whether to selectively skip comment meta used for WXR exports.
     635                        *
     636                        * Returning a truthy value to the filter will skip the current meta
     637                        * object from being exported.
     638                        *
     639                        * @since 4.0.0
     640                        *
     641                        * @param bool   $skip     Whether to skip the current comment meta. Default false.
     642                        * @param string $meta_key Current meta key.
     643                        * @param object $meta     Current meta object.
     644                        */
     645                        if ( apply_filters( 'wxr_export_skip_commentmeta', false, $meta->meta_key, $meta ) ) {
     646                            continue;
     647                        }
     648                        ?>
    649649    <wp:commentmeta>
    650650    <wp:meta_key><?php echo wxr_cdata( $meta->meta_key ); ?></wp:meta_key>
    651651            <wp:meta_value><?php echo wxr_cdata( $meta->meta_value ); ?></wp:meta_value>
    652652            </wp:commentmeta>
    653 <?php   endforeach; ?>
     653                    <?php   endforeach; ?>
    654654        </wp:comment>
    655 <?php   endforeach; ?>
     655            <?php   endforeach; ?>
    656656        </item>
    657     <?php
    658         }
    659     }
    660 }
    661 ?>
     657                <?php
     658            }
     659        }
     660    }
     661    ?>
    662662</channel>
    663663</rss>
    664 <?php
     664    <?php
    665665}
Note: See TracChangeset for help on using the changeset viewer.