Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/feed-rss2-comments.php

    r39613 r42343  
    66 */
    77
    8 header('Content-Type: ' . feed_content_type('rss2') . '; charset=' . get_option('blog_charset'), true);
     8header( 'Content-Type: ' . feed_content_type( 'rss2' ) . '; charset=' . get_option( 'blog_charset' ), true );
    99
    10 echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
     10echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?' . '>';
    1111
    1212/** This action is documented in wp-includes/feed-rss2.php */
     
    3333>
    3434<channel>
    35     <title><?php
    36         if ( is_singular() ) {
    37             /* translators: Comments feed title. 1: Post title */
    38             printf( ent2ncr( __( 'Comments on: %s' ) ), get_the_title_rss() );
    39         } elseif ( is_search() ) {
    40             /* translators: Comments feed title. 1: Site name, 2: Search query */
    41             printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() );
    42         } else {
    43             /* translators: Comments feed title. 1: Site name */
    44             printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() );
    45         }
    46     ?></title>
     35    <title>
     36    <?php
     37    if ( is_singular() ) {
     38        /* translators: Comments feed title. 1: Post title */
     39        printf( ent2ncr( __( 'Comments on: %s' ) ), get_the_title_rss() );
     40    } elseif ( is_search() ) {
     41        /* translators: Comments feed title. 1: Site name, 2: Search query */
     42        printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() );
     43    } else {
     44        /* translators: Comments feed title. 1: Site name */
     45        printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() );
     46    }
     47    ?>
     48    </title>
    4749    <atom:link href="<?php self_link(); ?>" rel="self" type="application/rss+xml" />
    48     <link><?php (is_single()) ? the_permalink_rss() : bloginfo_rss("url") ?></link>
    49     <description><?php bloginfo_rss("description") ?></description>
    50     <lastBuildDate><?php
     50    <link><?php ( is_single() ) ? the_permalink_rss() : bloginfo_rss( 'url' ); ?></link>
     51    <description><?php bloginfo_rss( 'description' ); ?></description>
     52    <lastBuildDate>
     53    <?php
    5154        $date = get_lastcommentmodified( 'GMT' );
    5255        echo $date ? mysql2date( 'r', $date, false ) : date( 'r' );
    53     ?></lastBuildDate>
    54     <sy:updatePeriod><?php
     56    ?>
     57    </lastBuildDate>
     58    <sy:updatePeriod>
     59    <?php
    5560        /** This filter is documented in wp-includes/feed-rss2.php */
    5661        echo apply_filters( 'rss_update_period', 'hourly' );
    57     ?></sy:updatePeriod>
    58     <sy:updateFrequency><?php
     62    ?>
     63    </sy:updatePeriod>
     64    <sy:updateFrequency>
     65    <?php
    5966        /** This filter is documented in wp-includes/feed-rss2.php */
    6067        echo apply_filters( 'rss_update_frequency', '1' );
    61     ?></sy:updateFrequency>
     68    ?>
     69    </sy:updateFrequency>
    6270    <?php
    6371    /**
     
    6876    do_action( 'commentsrss2_head' );
    6977
    70     if ( have_comments() ) : while ( have_comments() ) : the_comment();
    71         $comment_post = $GLOBALS['post'] = get_post( $comment->comment_post_ID );
    72     ?>
    73     <item>
    74         <title><?php
    75             if ( !is_singular() ) {
    76                 $title = get_the_title($comment_post->ID);
    77                 /** This filter is documented in wp-includes/feed.php */
    78                 $title = apply_filters( 'the_title_rss', $title );
    79                 /* translators: Individual comment title. 1: Post title, 2: Comment author name */
    80                 printf(ent2ncr(__('Comment on %1$s by %2$s')), $title, get_comment_author_rss());
    81             } else {
    82                 /* translators: Comment author title. 1: Comment author name */
    83                 printf(ent2ncr(__('By: %s')), get_comment_author_rss());
    84             }
    85         ?></title>
    86         <link><?php comment_link() ?></link>
    87         <dc:creator><![CDATA[<?php echo get_comment_author_rss() ?>]]></dc:creator>
    88         <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_comment_time('Y-m-d H:i:s', true, false), false); ?></pubDate>
    89         <guid isPermaLink="false"><?php comment_guid() ?></guid>
    90 <?php if ( post_password_required($comment_post) ) : ?>
    91         <description><?php echo ent2ncr(__('Protected Comments: Please enter your password to view comments.')); ?></description>
    92         <content:encoded><![CDATA[<?php echo get_the_password_form() ?>]]></content:encoded>
    93 <?php else : // post pass ?>
    94         <description><![CDATA[<?php comment_text_rss() ?>]]></description>
    95         <content:encoded><![CDATA[<?php comment_text() ?>]]></content:encoded>
    96 <?php endif; // post pass
    97     /**
    98      * Fires at the end of each RSS2 comment feed item.
    99      *
    100      * @since 2.1.0
    101      *
    102      * @param int $comment->comment_ID The ID of the comment being displayed.
    103      * @param int $comment_post->ID    The ID of the post the comment is connected to.
    104      */
    105     do_action( 'commentrss2_item', $comment->comment_ID, $comment_post->ID );
     78    if ( have_comments() ) :
     79        while ( have_comments() ) :
     80            the_comment();
     81            $comment_post = $GLOBALS['post'] = get_post( $comment->comment_post_ID );
     82            ?>
     83            <item>
     84                <title>
     85                <?php
     86                if ( ! is_singular() ) {
     87                    $title = get_the_title( $comment_post->ID );
     88                    /** This filter is documented in wp-includes/feed.php */
     89                    $title = apply_filters( 'the_title_rss', $title );
     90                    /* translators: Individual comment title. 1: Post title, 2: Comment author name */
     91                    printf( ent2ncr( __( 'Comment on %1$s by %2$s' ) ), $title, get_comment_author_rss() );
     92                } else {
     93                    /* translators: Comment author title. 1: Comment author name */
     94                    printf( ent2ncr( __( 'By: %s' ) ), get_comment_author_rss() );
     95                }
     96                ?>
     97                </title>
     98                <link><?php comment_link(); ?></link>
     99        <dc:creator><![CDATA[<?php echo get_comment_author_rss(); ?>]]></dc:creator>
     100        <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_comment_time( 'Y-m-d H:i:s', true, false ), false ); ?></pubDate>
     101        <guid isPermaLink="false"><?php comment_guid(); ?></guid>
     102        <?php if ( post_password_required( $comment_post ) ) : ?>
     103        <description><?php echo ent2ncr( __( 'Protected Comments: Please enter your password to view comments.' ) ); ?></description>
     104        <content:encoded><![CDATA[<?php echo get_the_password_form(); ?>]]></content:encoded>
     105        <?php else : // post pass ?>
     106        <description><![CDATA[<?php comment_text_rss(); ?>]]></description>
     107        <content:encoded><![CDATA[<?php comment_text(); ?>]]></content:encoded>
     108        <?php
     109        endif; // post pass
     110            /**
     111             * Fires at the end of each RSS2 comment feed item.
     112             *
     113             * @since 2.1.0
     114             *
     115             * @param int $comment->comment_ID The ID of the comment being displayed.
     116             * @param int $comment_post->ID    The ID of the post the comment is connected to.
     117             */
     118            do_action( 'commentrss2_item', $comment->comment_ID, $comment_post->ID );
     119        ?>
     120            </item>
     121        <?php
     122        endwhile;
     123endif;
    106124?>
    107     </item>
    108 <?php endwhile; endif; ?>
    109125</channel>
    110126</rss>
Note: See TracChangeset for help on using the changeset viewer.