Skip to:
Content

BuddyPress.org

Changeset 6256


Ignore:
Timestamp:
08/14/2012 08:49:51 PM (9 years ago)
Author:
johnjamesjacoby
Message:

Comments:

  • Clean up comments.php
  • Bail early if post type does not support comments.
  • Improves handling of comments and form when not supported, or have no reason to appear.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-themes/bp-default/comments.php

    r5737 r6256  
    11<?php
     2
     3    // Bail if post type doesn't support comments
     4    if ( ! post_type_supports( get_post_type(), 'comments' ) )
     5        return;
     6
     7    // Bail if is a page, and comments are not open
     8    if ( is_page() && ! have_comments() && ! comments_open() && ! pings_open() )
     9        return;
     10
    211    if ( post_password_required() ) {
    312        echo '<h3 class="comments-header">' . __( 'Password Protected', 'buddypress' ) . '</h3>';
     
    615    }
    716
    8     if ( is_page() && !have_comments() && !comments_open() && !pings_open() )
    9         return;
    10 
    1117    if ( have_comments() ) :
    12         $num_comments = 0;
     18        $num_comments   = 0;
    1319        $num_trackbacks = 0;
    1420        foreach ( (array) $comments as $comment ) {
    15             if ( 'comment' != get_comment_type() )
     21            if ( 'comment' != get_comment_type() ) {
    1622                $num_trackbacks++;
    17             else
     23            } else {
    1824                $num_comments++;
     25            }
    1926        }
    2027?>
     
    4047
    4148    </div><!-- #comments -->
     49
    4250<?php else : ?>
    4351
    44     <?php if ( pings_open() && !comments_open() && ( is_single() || is_page() ) ) : ?>
    45         <p class="comments-closed pings-open">
    46             <?php printf( __( 'Comments are closed, but <a href="%1$s" title="Trackback URL for this post">trackbacks</a> and pingbacks are open.', 'buddypress' ), trackback_url( '0' ) ); ?>
    47         </p>
    48     <?php elseif ( !comments_open() && ( is_single() || is_page() ) ) : ?>
    49         <p class="comments-closed">
    50             <?php _e( 'Comments are closed.', 'buddypress' ); ?>
    51         </p>
     52    <?php if ( ! comments_open() ) : ?>
     53        <?php if ( pings_open() ) : ?>
     54            <p class="comments-closed pings-open">
     55                <?php printf( __( 'Comments are closed, but <a href="%1$s" title="Trackback URL for this post">trackbacks</a> and pingbacks are open.', 'buddypress' ), trackback_url( '0' ) ); ?>
     56            </p>
     57        <?php else : ?>
     58            <p class="comments-closed">
     59                <?php _e( 'Comments are closed.', 'buddypress' ); ?>
     60            </p>
     61        <?php endif; ?>
    5262    <?php endif; ?>
    5363
    5464<?php endif; ?>
    5565
    56 <?php if ( comments_open() ) : ?>
    57     <?php comment_form(); ?>
    58 <?php endif; ?>
     66<?php if ( comments_open() ) comment_form(); ?>
    5967
    6068<?php if ( !empty( $num_trackbacks ) ) : ?>
Note: See TracChangeset for help on using the changeset viewer.