Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 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-atom-comments.php

    r39613 r42343  
    66 */
    77
    8 header('Content-Type: ' . feed_content_type('atom') . '; charset=' . get_option('blog_charset'), true);
    9 echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '" ?' . '>';
     8header( 'Content-Type: ' . feed_content_type( 'atom' ) . '; charset=' . get_option( 'blog_charset' ), true );
     9echo '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '" ?' . '>';
    1010
    1111/** This action is documented in wp-includes/feed-rss2.php */
     
    2828    ?>
    2929>
    30     <title type="text"><?php
    31         if ( is_singular() ) {
    32             /* translators: Comments feed title. 1: Post title */
    33             printf( ent2ncr( __( 'Comments on %s' ) ), get_the_title_rss() );
    34         } elseif ( is_search() ) {
    35             /* translators: Comments feed title. 1: Site name, 2: Search query */
    36             printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() );
    37         } else {
    38             /* translators: Comments feed title. 1: Site name */
    39             printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() );
    40         }
    41     ?></title>
    42     <subtitle type="text"><?php bloginfo_rss('description'); ?></subtitle>
     30    <title type="text">
     31    <?php
     32    if ( is_singular() ) {
     33        /* translators: Comments feed title. 1: Post title */
     34        printf( ent2ncr( __( 'Comments on %s' ) ), get_the_title_rss() );
     35    } elseif ( is_search() ) {
     36        /* translators: Comments feed title. 1: Site name, 2: Search query */
     37        printf( ent2ncr( __( 'Comments for %1$s searching on %2$s' ) ), get_bloginfo_rss( 'name' ), get_search_query() );
     38    } else {
     39        /* translators: Comments feed title. 1: Site name */
     40        printf( ent2ncr( __( 'Comments for %s' ) ), get_wp_title_rss() );
     41    }
     42    ?>
     43    </title>
     44    <subtitle type="text"><?php bloginfo_rss( 'description' ); ?></subtitle>
    4345
    44     <updated><?php
     46    <updated>
     47    <?php
    4548        $date = get_lastcommentmodified( 'GMT' );
    4649        echo $date ? mysql2date( 'Y-m-d\TH:i:s\Z', $date, false ) : date( 'Y-m-d\TH:i:s\Z' );
    47     ?></updated>
     50    ?>
     51    </updated>
    4852
    4953<?php if ( is_singular() ) { ?>
    50     <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php comments_link_feed(); ?>" />
    51     <link rel="self" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link('', 'atom') ); ?>" />
    52     <id><?php echo esc_url( get_post_comments_feed_link('', 'atom') ); ?></id>
    53 <?php } elseif (is_search()) { ?>
    54     <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php echo home_url() . '?s=' . get_search_query(); ?>" />
    55     <link rel="self" type="application/atom+xml" href="<?php echo get_search_comments_feed_link('', 'atom'); ?>" />
    56     <id><?php echo get_search_comments_feed_link('', 'atom'); ?></id>
     54    <link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php comments_link_feed(); ?>" />
     55    <link rel="self" type="application/atom+xml" href="<?php echo esc_url( get_post_comments_feed_link( '', 'atom' ) ); ?>" />
     56    <id><?php echo esc_url( get_post_comments_feed_link( '', 'atom' ) ); ?></id>
     57<?php } elseif ( is_search() ) { ?>
     58    <link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php echo home_url() . '?s=' . get_search_query(); ?>" />
     59    <link rel="self" type="application/atom+xml" href="<?php echo get_search_comments_feed_link( '', 'atom' ); ?>" />
     60    <id><?php echo get_search_comments_feed_link( '', 'atom' ); ?></id>
    5761<?php } else { ?>
    58     <link rel="alternate" type="<?php bloginfo_rss('html_type'); ?>" href="<?php bloginfo_rss('url'); ?>" />
    59     <link rel="self" type="application/atom+xml" href="<?php bloginfo_rss('comments_atom_url'); ?>" />
    60     <id><?php bloginfo_rss('comments_atom_url'); ?></id>
     62    <link rel="alternate" type="<?php bloginfo_rss( 'html_type' ); ?>" href="<?php bloginfo_rss( 'url' ); ?>" />
     63    <link rel="self" type="application/atom+xml" href="<?php bloginfo_rss( 'comments_atom_url' ); ?>" />
     64    <id><?php bloginfo_rss( 'comments_atom_url' ); ?></id>
    6165<?php } ?>
    6266<?php
     
    6973?>
    7074<?php
    71 if ( have_comments() ) : while ( have_comments() ) : the_comment();
    72     $comment_post = $GLOBALS['post'] = get_post( $comment->comment_post_ID );
    73 ?>
     75if ( have_comments() ) :
     76    while ( have_comments() ) :
     77        the_comment();
     78        $comment_post = $GLOBALS['post'] = get_post( $comment->comment_post_ID );
     79    ?>
    7480    <entry>
    75         <title><?php
    76             if ( !is_singular() ) {
    77                 $title = get_the_title($comment_post->ID);
    78                 /** This filter is documented in wp-includes/feed.php */
    79                 $title = apply_filters( 'the_title_rss', $title );
    80                 /* translators: Individual comment title. 1: Post title, 2: Comment author name */
    81                 printf(ent2ncr(__('Comment on %1$s by %2$s')), $title, get_comment_author_rss());
    82             } else {
    83                 /* translators: Comment author title. 1: Comment author name */
    84                 printf(ent2ncr(__('By: %s')), get_comment_author_rss());
    85             }
    86         ?></title>
    87         <link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss('html_type'); ?>" />
     81        <title>
     82        <?php
     83        if ( ! is_singular() ) {
     84            $title = get_the_title( $comment_post->ID );
     85            /** This filter is documented in wp-includes/feed.php */
     86            $title = apply_filters( 'the_title_rss', $title );
     87            /* translators: Individual comment title. 1: Post title, 2: Comment author name */
     88            printf( ent2ncr( __( 'Comment on %1$s by %2$s' ) ), $title, get_comment_author_rss() );
     89        } else {
     90            /* translators: Comment author title. 1: Comment author name */
     91            printf( ent2ncr( __( 'By: %s' ) ), get_comment_author_rss() );
     92        }
     93            ?>
     94            </title>
     95            <link rel="alternate" href="<?php comment_link(); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" />
    8896
    8997        <author>
    9098            <name><?php comment_author_rss(); ?></name>
    91             <?php if (get_comment_author_url()) echo '<uri>' . get_comment_author_url() . '</uri>'; ?>
     99            <?php
     100            if ( get_comment_author_url() ) {
     101                echo '<uri>' . get_comment_author_url() . '</uri>';}
     102?>
    92103
    93104        </author>
    94105
    95106        <id><?php comment_guid(); ?></id>
    96         <updated><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true, false), false); ?></updated>
    97         <published><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_comment_time('Y-m-d H:i:s', true, false), false); ?></published>
    98 <?php if ( post_password_required($comment_post) ) : ?>
     107        <updated><?php echo mysql2date( 'Y-m-d\TH:i:s\Z', get_comment_time( 'Y-m-d H:i:s', true, false ), false ); ?></updated>
     108        <published><?php echo mysql2date( 'Y-m-d\TH:i:s\Z', get_comment_time( 'Y-m-d H:i:s', true, false ), false ); ?></published>
     109    <?php if ( post_password_required( $comment_post ) ) : ?>
    99110        <content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php echo get_the_password_form(); ?>]]></content>
    100 <?php else : // post pass ?>
     111    <?php else : // post pass ?>
    101112        <content type="html" xml:base="<?php comment_link(); ?>"><![CDATA[<?php comment_text(); ?>]]></content>
    102 <?php endif; // post pass
     113    <?php
     114    endif; // post pass
    103115    // Return comment threading information (https://www.ietf.org/rfc/rfc4685.txt)
    104     if ( $comment->comment_parent == 0 ) : // This comment is top level ?>
    105         <thr:in-reply-to ref="<?php the_guid(); ?>" href="<?php the_permalink_rss() ?>" type="<?php bloginfo_rss('html_type'); ?>" />
    106 <?php else : // This comment is in reply to another comment
    107     $parent_comment = get_comment($comment->comment_parent);
    108     // The rel attribute below and the id tag above should be GUIDs, but WP doesn't create them for comments (unlike posts). Either way, it's more important that they both use the same system
    109 ?>
    110         <thr:in-reply-to ref="<?php comment_guid($parent_comment) ?>" href="<?php echo get_comment_link($parent_comment) ?>" type="<?php bloginfo_rss('html_type'); ?>" />
    111 <?php endif;
     116if ( $comment->comment_parent == 0 ) : // This comment is top level
     117    ?>
     118    <thr:in-reply-to ref="<?php the_guid(); ?>" href="<?php the_permalink_rss(); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" />
     119    <?php
     120    else : // This comment is in reply to another comment
     121        $parent_comment = get_comment( $comment->comment_parent );
     122        // The rel attribute below and the id tag above should be GUIDs, but WP doesn't create them for comments (unlike posts). Either way, it's more important that they both use the same system
     123    ?>
     124        <thr:in-reply-to ref="<?php comment_guid( $parent_comment ); ?>" href="<?php echo get_comment_link( $parent_comment ); ?>" type="<?php bloginfo_rss( 'html_type' ); ?>" />
     125<?php
     126endif;
    112127    /**
    113128     * Fires at the end of each Atom comment feed item.
     
    119134     */
    120135    do_action( 'comment_atom_entry', $comment->comment_ID, $comment_post->ID );
     136    ?>
     137    </entry>
     138    <?php
     139    endwhile;
     140endif;
    121141?>
    122     </entry>
    123 <?php endwhile; endif; ?>
    124142</feed>
Note: See TracChangeset for help on using the changeset viewer.