Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/30/2010 09:29:17 PM (16 years ago)
Author:
djpaul
Message:

Use comment_form() to comply with WP theme standards and improves code style in comments.php. Fixes #2978. Props denis.ogun (via Google Code In)

File:
1 edited

Legend:

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

    r3592 r3624  
    1         <?php
    2                 if ( post_password_required() ) :
    3                         echo '<h3 class="comments-header">' . __('Password Protected', 'buddypress') . '</h3>';
    4                         echo '<p class="alert password-protected">' . __('Enter the password to view comments.', 'buddypress') . '</p>';
    5                         return;
    6                 endif;
     1<?php
     2        if ( post_password_required() ) {
     3                echo '<h3 class="comments-header">' . __( 'Password Protected', 'buddypress' ) . '</h3>';
     4                echo '<p class="alert password-protected">' . __( 'Enter the password to view comments.', 'buddypress' ) . '</p>';
     5                return;
     6        }
    77
    8                 if ( is_page() && !have_comments() && !comments_open() && !pings_open() )
    9                         return;
    10         ?>
     8        if ( is_page() && !have_comments() && !comments_open() && !pings_open() )
     9                return;
    1110
    12         <?php if ( have_comments() ) : ?>
     11        if ( have_comments() ) :
     12                $num_comments = 0;
     13                $num_trackbacks = 0;
     14                foreach ( (array)$comments as $comment ) {
     15                        if ( 'comment' != get_comment_type() )
     16                                $num_trackbacks++;
     17                        else
     18                                $num_comments++;
     19                }
     20?>
     21        <div id="comments">
    1322
    14                 <div id="comments">
     23                <h3>
     24                        <?php printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', $num_comments, 'buddypress' ), number_format_i18n( $num_comments ), '<em>' . get_the_title() . '</em>' ) ?>
     25                </h3>
    1526
    16                         <?php
    17                                 // Only include comments
    18                                 $numTrackBacks = 0; $numComments = 0;
    19                                 foreach ( (array)$comments as $comment )
    20                                         if ( 'comment' != get_comment_type() )
    21                                                 $numTrackBacks++;
    22                                         else
    23                                                 $numComments++;
    24                         ?>
     27                <?php do_action( 'bp_before_blog_comment_list' ) ?>
    2528
    26                         <h3 id="comments">
    27                                 <?php
    28                                         printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', $numComments, 'buddypress' ),
    29                                         number_format_i18n( $numComments ), '<em>' . get_the_title() . '</em>' );
    30                                 ?>
    31                         </h3>
     29                <ol class="commentlist">
     30                        <?php wp_list_comments( array( 'callback' => 'bp_dtheme_blog_comments' ) ) ?>
     31                </ol><!-- .comment-list -->
    3232
    33                         <?php do_action( 'bp_before_blog_comment_list' ) ?>
     33                <?php do_action( 'bp_after_blog_comment_list' ) ?>
    3434
    35                         <ol class="commentlist">
    36                                 <?php wp_list_comments( array( 'callback' => 'bp_dtheme_blog_comments' ) ); ?>
    37                         </ol><!-- .comment-list -->
    38 
    39                         <?php do_action( 'bp_after_blog_comment_list' ) ?>
    40 
    41                         <?php if ( get_option( 'page_comments' ) ) : ?>
    42 
    43                                 <div class="comment-navigation paged-navigation">
    44 
    45                                         <?php paginate_comments_links(); ?>
    46 
    47                                 </div>
    48 
    49                         <?php endif; ?>
    50 
    51                 </div><!-- #comments -->
    52 
    53         <?php else : ?>
    54 
    55                 <?php if ( pings_open() && !comments_open() && is_single() ) : ?>
    56 
    57                         <p class="comments-closed pings-open">
    58                                 <?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' ) ); ?>
    59                         </p>
    60 
    61                 <?php elseif ( !comments_open() && is_single() ) : ?>
    62 
    63                         <p class="comments-closed">
    64                                 <?php _e('Comments are closed.', 'buddypress'); ?>
    65                         </p>
    66 
     35                <?php if ( get_option( 'page_comments' ) ) : ?>
     36                        <div class="comment-navigation paged-navigation">
     37                                <?php paginate_comments_links() ?>
     38                        </div>
    6739                <?php endif; ?>
    6840
     41        </div><!-- #comments -->
     42<?php else : ?>
     43
     44        <?php if ( pings_open() && !comments_open() && is_single() ) : ?>
     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() ) : ?>
     49                <p class="comments-closed">
     50                        <?php _e( 'Comments are closed.', 'buddypress' ) ?>
     51                </p>
    6952        <?php endif; ?>
    7053
    71                 <?php if ( comments_open() ) : ?>
     54<?php endif; ?>
    7255
    73                 <div id="respond">
     56<?php if ( comments_open() ) : ?>
     57        <div id="respond">
    7458
    75                         <div class="comment-avatar-box">
    76                                 <div class="avb">
    77                                         <?php if ( bp_loggedin_user_id() ) : ?>
    78                                                 <a href="<?php echo bp_loggedin_user_domain() ?>">
    79                                                         <?php echo get_avatar( bp_loggedin_user_id(), 50 ); ?>
    80                                                 </a>
    81                                         <?php else : ?>
    82                                                 <?php echo get_avatar( 0, 50 ); ?>
    83                                         <?php endif; ?>
    84                                 </div>
     59                <div class="comment-avatar-box">
     60                        <div class="avb">
     61                                <?php if ( bp_loggedin_user_id() ) : ?>
     62                                        <a href="<?php echo bp_loggedin_user_domain() ?>">
     63                                                <?php echo get_avatar( bp_loggedin_user_id(), 50 ) ?>
     64                                        </a>
     65                                <?php else : ?>
     66                                        <?php echo get_avatar( 0, 50 ) ?>
     67                                <?php endif; ?>
    8568                        </div>
     69                </div>
    8670
    87                         <div class="comment-content">
     71                <div class="comment-content standard-form">
     72                        <?php comment_form() ?>
     73                </div><!-- .comment-content -->
    8874
    89                                 <h3 id="reply" class="comments-header">
    90                                         <?php comment_form_title( __( 'Leave a Reply', 'buddypress' ), __( 'Leave a Reply to %s', 'buddypress' ), true ); ?>
    91                                 </h3>
     75        </div><!-- #respond -->
     76<?php endif; ?>
    9277
    93                                 <p id="cancel-comment-reply">
    94                                         <?php cancel_comment_reply_link( __( 'Click here to cancel reply.', 'buddypress' ) ); ?>
    95                                 </p>
     78<?php if ( !empty( $num_trackbacks ) ) : ?>
     79        <div id="trackbacks">
     80                <span class="title"><?php the_title() ?></span>
    9681
    97                                 <?php if ( get_option( 'comment_registration' ) && !$user_ID ) : ?>
     82                <h3>
     83                        <?php printf( _n( '%d Trackback', '%d Trackbacks', $num_trackbacks, 'buddypress' ), number_format_i18n( $num_trackbacks ) ) ?>
     84                </h3>
    9885
    99                                         <p class="alert">
    100                                                 <?php printf( __('You must be <a href="%1$s" title="Log in">logged in</a> to post a comment.', 'buddypress'), wp_login_url( get_permalink() ) ); ?>
    101                                         </p>
     86                <ul id="trackbacklist">
     87                        <?php foreach ( (array)$comments as $comment ) : ?>
    10288
    103                                 <?php else : ?>
     89                                <?php if ( 'comment' != get_comment_type() ) : ?>
     90                                        <li>
     91                                                <h5><?php comment_author_link() ?></h5>
     92                                                <em>on <?php comment_date() ?></em>
     93                                        </li>
     94                                <?php endif; ?>
    10495
    105                                         <?php do_action( 'bp_before_blog_comment_form' ) ?>
     96                        <?php endforeach; ?>
     97                </ul>
    10698
    107                                         <form action="<?php echo site_url( 'wp-comments-post.php' ) ?>" method="post" id="commentform" class="standard-form">
    108 
    109                                                 <?php if ( $user_ID ) : ?>
    110 
    111                                                         <p class="log-in-out">
    112                                                                 <?php printf( __('Logged in as <a href="%1$s" title="%2$s">%2$s</a>.', 'buddypress'), bp_loggedin_user_domain(), $user_identity ); ?> <a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="<?php _e('Log out of this account', 'buddypress'); ?>"><?php _e('Log out &rarr;', 'buddypress'); ?></a>
    113                                                         </p>
    114 
    115                                                 <?php else : ?>
    116 
    117                                                         <?php $req = get_option( 'require_name_email' ); ?>
    118 
    119                                                         <p class="form-author">
    120                                                                 <label for="author"><?php _e('Name', 'buddypress'); ?> <?php if ( $req ) : ?><span class="required"><?php _e('*', 'buddypress'); ?></span><?php endif; ?></label>
    121                                                                 <input type="text" class="text-input" name="author" id="author" value="<?php echo $comment_author; ?>" size="40" tabindex="1" />
    122                                                         </p>
    123 
    124                                                         <p class="form-email">
    125                                                                 <label for="email"><?php _e('Email', 'buddypress'); ?>  <?php if ( $req ) : ?><span class="required"><?php _e('*', 'buddypress'); ?></span><?php endif; ?></label>
    126                                                                 <input type="text" class="text-input" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="40" tabindex="2" />
    127                                                         </p>
    128 
    129                                                         <p class="form-url">
    130                                                                 <label for="url"><?php _e('Website', 'buddypress'); ?></label>
    131                                                                 <input type="text" class="text-input" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="40" tabindex="3" />
    132                                                         </p>
    133 
    134                                                 <?php endif; ?>
    135 
    136                                                 <p class="form-textarea">
    137                                                         <label for="comment"><?php _e('Comment', 'buddypress'); ?></label>
    138                                                         <textarea name="comment" id="comment" cols="60" rows="10" tabindex="4"></textarea>
    139                                                 </p>
    140 
    141                                                 <?php do_action( 'bp_blog_comment_form' ) ?>
    142 
    143                                                 <p class="form-submit">
    144                                                         <input class="submit-comment button" name="submit" type="submit" id="submit" tabindex="5" value="<?php _e('Submit', 'buddypress'); ?>" />
    145                                                         <?php comment_id_fields(); ?>
    146                                                 </p>
    147 
    148                                                 <div class="comment-action">
    149                                                         <?php do_action( 'comment_form', $post->ID ); ?>
    150                                                 </div>
    151 
    152                                         </form>
    153 
    154                                         <?php do_action( 'bp_after_blog_comment_form' ) ?>
    155 
    156                                 <?php endif; ?>
    157 
    158                         </div><!-- .comment-content -->
    159                 </div><!-- #respond -->
    160 
    161                 <?php endif; ?>
    162 
    163                 <?php if ( isset( $numTrackBacks ) && $numTrackBacks ) : ?>
    164                         <div id="trackbacks">
    165 
    166                                 <span class="title"><?php the_title() ?></span>
    167 
    168                                 <?php if ( 1 == $numTrackBacks ) : ?>
    169                                         <h3><?php printf( __( '%d Trackback', 'buddypress' ), $numTrackBacks ) ?></h3>
    170                                 <?php else : ?>
    171                                         <h3><?php printf( __( '%d Trackbacks', 'buddypress' ), $numTrackBacks ) ?></h3>
    172                                 <?php endif; ?>
    173 
    174                                 <ul id="trackbacklist">
    175                                         <?php foreach ( (array)$comments as $comment ) : ?>
    176 
    177                                                 <?php if ( get_comment_type() != 'comment' ) : ?>
    178                                                         <li><h5><?php comment_author_link() ?></h5><em>on <?php comment_date() ?></em></li>
    179                                                 <?php endif; ?>
    180                                         <?php endforeach; ?>
    181                                 </ul>
    182                         </div>
    183                 <?php endif; ?>
     99        </div>
     100<?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.