Skip to:
Content

BuddyPress.org

Changeset 3624


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)

Location:
trunk/bp-themes/bp-default
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-themes/bp-default/_inc/css/default.css

    r3606 r3624  
    873873}
    874874
    875 form.standard-form#signup_form div div.error {
     875.standard-form#signup_form div div.error {
    876876        color: #fff;
    877877        background: #e41717;
    … …  
    968968-------------------------------------------------------------- */
    969969
    970 form.standard-form textarea,
    971 form.standard-form input[type=text],
    972 form.standard-form select,
    973 form.standard-form input[type=password],
     970.standard-form textarea,
     971.standard-form input[type=text],
     972.standard-form select,
     973.standard-form input[type=password],
    974974.dir-search input[type=text] {
    975975        border: 1px inset #ccc;
    … …  
    983983}
    984984
    985 form.standard-form select {
     985.standard-form select {
    986986        padding: 3px;
    987987}
    988988
    989 form.standard-form input[type=password] {
     989.standard-form input[type=password] {
    990990        margin-bottom: 5px;
    991991}
    992992
    993 form.standard-form label,
    994 form.standard-form span.label {
     993.standard-form label,
     994.standard-form span.label {
    995995        display: block;
    996996        font-weight: bold;
    … …  
    998998}
    999999
    1000 form.standard-form div.checkbox label,
    1001 form.standard-form div.radio label {
     1000.standard-form div.checkbox label,
     1001.standard-form div.radio label {
    10021002        font-weight: normal;
    10031003        margin: 5px 0 0 0;
    … …  
    10061006}
    10071007
    1008 form.standard-form#sidebar-login-form label {
     1008.standard-form#sidebar-login-form label {
    10091009        margin-top: 5px;
    10101010}
    10111011
    1012 form.standard-form input[type=text] {
     1012.standard-form input[type=text] {
    10131013        width: 75%;
    10141014}
    10151015
    1016 form.standard-form#sidebar-login-form input[type=text],
    1017 form.standard-form#sidebar-login-form input[type=password] {
     1016.standard-form#sidebar-login-form input[type=text],
     1017.standard-form#sidebar-login-form input[type=password] {
    10181018        padding: 4px;
    10191019        width: 95%;
    10201020}
    10211021
    1022 form.standard-form #basic-details-section input[type=password],
    1023 form.standard-form #blog-details-section input#signup_blog_url {
     1022.standard-form #basic-details-section input[type=password],
     1023.standard-form #blog-details-section input#signup_blog_url {
    10241024        width: 35%;
    10251025}
    10261026
    1027 form.standard-form#signup_form input[type=text],
    1028 form.standard-form#signup_form textarea {
     1027.standard-form#signup_form input[type=text],
     1028.standard-form#signup_form textarea {
    10291029        width: 90%;
    10301030}
    10311031
    1032 form.standard-form#signup_form div.submit {
     1032.standard-form#signup_form div.submit {
    10331033        float: right;
    10341034}
    … …  
    10381038}
    10391039
    1040 form.standard-form textarea {
     1040.standard-form textarea {
    10411041        width: 75%;
    10421042        height: 120px;
    10431043}
    10441044
    1045 form.standard-form textarea#message_content {
     1045.standard-form textarea#message_content {
    10461046        height: 200px;
    10471047}
    10481048
    1049 form.standard-form#send-reply textarea {
     1049.standard-form#send-reply textarea {
    10501050        width: 97.5%;
    10511051}
    10521052
    1053 form.standard-form p.description {
     1053.standard-form p.description {
    10541054        font-size: 11px;
    10551055        color: #888;
    … …  
    10571057}
    10581058
    1059 form.standard-form div.submit {
     1059.standard-form div.submit {
    10601060        padding: 15px 0;
    10611061        clear: both;
    10621062}
    10631063
    1064 form.standard-form div.submit input {
     1064.standard-form div.submit input {
    10651065        margin-right: 15px;
    10661066}
    10671067
    1068 form.standard-form div.radio ul {
     1068.standard-form div.radio ul {
    10691069        margin: 10px 0 15px 38px;
    10701070        list-style: disc;
    10711071}
    10721072
    1073 form.standard-form div.radio ul li {
     1073.standard-form div.radio ul li {
    10741074        margin-bottom: 5px;
    10751075}
    10761076
    1077 form.standard-form a.clear-value {
     1077.standard-form a.clear-value {
    10781078        display: block;
    10791079        margin-top: 5px;
    … …  
    10811081}
    10821082
    1083 form.standard-form #basic-details-section,
    1084 form.standard-form #blog-details-section,
    1085 form.standard-form #profile-details-section {
     1083.standard-form #basic-details-section,
     1084.standard-form #blog-details-section,
     1085.standard-form #profile-details-section {
    10861086        float: left;
    10871087        width: 48%;
    10881088}
    10891089
    1090 form.standard-form #profile-details-section {
     1090.standard-form #profile-details-section {
    10911091        float: right;
    10921092}
    10931093
    1094 form.standard-form #blog-details-section {
     1094.standard-form #blog-details-section {
    10951095        clear: left;
    10961096}
    10971097
    1098 form.standard-form input:focus,
    1099 form.standard-form textarea:focus,
    1100 form.standard-form select:focus {
     1098.standard-form input:focus,
     1099.standard-form textarea:focus,
     1100.standard-form select:focus {
    11011101        background: #fafafa;
    11021102        color: #555;
  • 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; ?>
  • trunk/bp-themes/bp-default/functions.php

    r3614 r3624  
    478478 * @since 1.3
    479479 */
    480 function bp_dtheme_main_nav( $args ) {
    481 ?>
     480function bp_dtheme_main_nav( $args ) { ?>
    482481        <ul id="nav">
    483482                <li<?php if ( is_front_page() ) : ?> class="selected"<?php endif; ?>>
    … …  
    490489<?php
    491490}
     491
     492/**
     493 * Applies BuddyPress customisations to the post comment form.
     494 *
     495 * @global string $user_identity The display name of the user
     496 * @param array $default_labels The default options for strings, fields etc in the form
     497 * @see comment_form()
     498 * @since 1.3
     499 */
     500function bp_dtheme_comment_form( $default_labels ) {
     501        global $user_identity;
     502
     503        $commenter = wp_get_current_commenter();
     504        $req = get_option( 'require_name_email' );
     505        $aria_req = ( $req ? " aria-required='true'" : '' );
     506        $fields =  array(
     507                'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? '<span class="required"> *</span>' : '' ) . '</label> ' .
     508                            '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
     509                'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? '<span class="required"> *</span>' : '' ) . '</label> ' .
     510                            '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
     511                'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' .
     512                            '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
     513        );
     514
     515        $new_labels = array(
     516                'cancel_reply_link'    => '<p id="cancel-comment-reply">' . __( 'Cancel reply', 'buddypress' ) . '</p>',
     517                'comment_field'        => '<p class="form-textarea"><label for="comment">' . __( 'Comment', 'buddypress' ) . '</label><textarea name="comment" id="comment" cols="60" rows="10" aria-required="true"></textarea></p>',
     518                'comment_notes_after'  => '',
     519                'comment_notes_before' => '',
     520                'fields'               => apply_filters( 'comment_form_default_fields', $fields ),
     521                'logged_in_as'         => '<p class="log-in-out">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s">Log out?</a>', 'buddypress' ), bp_loggedin_user_domain(), $user_identity, wp_logout_url( get_permalink() ) ) . '</p>',
     522                'must_log_in'          => '<p class="alert">' . sprintf( __( 'You must be <a href="%1$s">logged in</a> to post a comment.', 'buddypress' ), wp_login_url( get_permalink() ) )   . '</p>',
     523                'title_reply'          => '<h3 id="reply" class="comments-header">' . __( 'Leave a reply', 'buddypress' ) . '</h3>',
     524                'title_reply_to'       => '<h3 id="reply" class="comments-header">' . __( 'Leave a reply to %s', 'buddypress' ) . '</h3>'
     525        );
     526
     527        return apply_filters( 'bp_dtheme_comment_form', array_merge( $default_labels, $new_labels ) );
     528}
     529add_filter( 'comment_form_defaults', 'bp_dtheme_comment_form', 10 );
     530
    492531
    493532// Everything beyond this point is deprecated as of BuddyPress 1.3. This will be removed in a future version.
  • trunk/bp-themes/bp-default/rtl.css

    r3606 r3624  
    345345-------------------------------------------------------------- */
    346346
    347 form.standard-form#signup_form div.submit {
    348         float: left;
    349 }
    350 
    351 form.standard-form#signup_form div.signup-avatar {
     347.standard-form#signup_form div.submit {
     348        float: left;
     349}
     350
     351.standard-form#signup_form div.signup-avatar {
    352352        margin-left: 15px;
    353353        margin-right: 0;
    354354}
    355355
    356 form.standard-form div.submit input {
     356.standard-form div.submit input {
    357357        margin-left: 15px;
    358358        margin-right: 0;
    359359}
    360360
    361 form.standard-form div.radio ul {
     361.standard-form div.radio ul {
    362362        margin: 10px 38px 15px 0;
    363363}
    364364
    365 form.standard-form #basic-details-section,
    366 form.standard-form #blog-details-section,
    367 form.standard-form #profile-details-section {
    368         float: right;
    369 }
    370 
    371 form.standard-form #profile-details-section {
    372         float: left;
    373 }
    374 
    375 form.standard-form #blog-details-section {
     365.standard-form #basic-details-section,
     366.standard-form #blog-details-section,
     367.standard-form #profile-details-section {
     368        float: right;
     369}
     370
     371.standard-form #profile-details-section {
     372        float: left;
     373}
     374
     375.standard-form #blog-details-section {
    376376        clear: right;
    377377}
Note: See TracChangeset for help on using the changeset viewer.