WordPress.org

Make WordPress Core

Changeset 33964


Ignore:
Timestamp:
09/09/2015 02:59:54 AM (6 years ago)
Author:
wonderboymusic
Message:

In WP_Comments_List_Table, favor passing WP_Comment instances instead of $comment_ID to template functions. This allows us to bypass unnecessary cache lookups and simply pass the object through when it is set.

See #33638.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-comments-list-table.php

    r33894 r33964  
    443443        global $post;
    444444
    445         $the_comment_class = wp_get_comment_status( $comment->comment_ID );
     445        $the_comment_class = wp_get_comment_status( $comment );
    446446        if ( ! $the_comment_class ) {
    447447            $the_comment_class = '';
    448448        }
    449         $the_comment_class = join( ' ', get_comment_class( $the_comment_class, $comment->comment_ID, $comment->comment_post_ID ) );
     449        $the_comment_class = join( ' ', get_comment_class( $the_comment_class, $comment, $comment->comment_post_ID ) );
    450450
    451451        $post = get_post( $comment->comment_post_ID );
     
    480480        }
    481481
    482         $the_comment_status = wp_get_comment_status( $comment->comment_ID );
     482        $the_comment_status = wp_get_comment_status( $comment );
    483483
    484484        $out = '';
     
    589589     */
    590590    public function column_comment( $comment ) {
    591         $comment_url = esc_url( get_comment_link( $comment->comment_ID ) );
     591        $comment_url = esc_url( get_comment_link( $comment ) );
    592592
    593593        echo '<div class="comment-author">';
     
    599599        printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ), $comment_url,
    600600            /* translators: comment date format. See http://php.net/date */
    601             get_comment_date( __( 'Y/m/d' ), $comment->comment_ID ),
    602             get_comment_date( get_option( 'time_format' ), $comment->comment_ID )
     601            get_comment_date( __( 'Y/m/d' ), $comment ),
     602            get_comment_date( get_option( 'time_format' ), $comment )
    603603        );
    604604
    605605        if ( $comment->comment_parent ) {
    606606            $parent = get_comment( $comment->comment_parent );
    607             $parent_link = esc_url( get_comment_link( $comment->comment_parent ) );
    608             $name = get_comment_author( $parent->comment_ID );
     607            $parent_link = esc_url( get_comment_link( $parent ) );
     608            $name = get_comment_author( $parent );
    609609            printf( ' | '.__( 'In reply to <a href="%1$s">%2$s</a>.' ), $parent_link, $name );
    610610        }
    611611
    612612        echo '</div>';
    613         comment_text( $comment->comment_ID );
     613        comment_text( $comment );
    614614        if ( $this->user_can ) { ?>
    615615        <div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
     
    636636        global $comment_status;
    637637
    638         $author_url = get_comment_author_url( $comment->comment_ID );
     638        $author_url = get_comment_author_url( $comment );
    639639
    640640        $author_url_display = untrailingslashit( preg_replace( '|^http(s)?://(www\.)?|i', '', $author_url ) );
     
    643643        }
    644644
    645         echo "<strong>"; comment_author( $comment->comment_ID ); echo '</strong><br />';
     645        echo "<strong>"; comment_author( $comment ); echo '</strong><br />';
    646646        if ( ! empty( $author_url_display ) ) {
    647647            printf( '<a href="%s">%s</a><br />', esc_url( $author_url ), esc_html( $author_url_display ) );
     
    658658            }
    659659
    660             $author_ip = get_comment_author_IP( $comment->comment_ID );
     660            $author_ip = get_comment_author_IP( $comment );
    661661            if ( $author_ip ) {
    662662                $author_ip_url = add_query_arg( array( 's' => $author_ip, 'mode' => 'detail' ), 'edit-comments.php' );
     
    674674     */
    675675    public function column_date( $comment ) {
    676         return get_comment_date( __( 'Y/m/d \a\t g:i a' ), $comment->comment_ID );
     676        return get_comment_date( __( 'Y/m/d \a\t g:i a' ), $comment );
    677677    }
    678678
  • trunk/src/wp-includes/comment-functions.php

    r33963 r33964  
    12031203 * @since 1.0.0
    12041204 *
    1205  * @param int $comment_id Comment ID
     1205 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object
    12061206 * @return false|string Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.
    12071207 */
Note: See TracChangeset for help on using the changeset viewer.