Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/30/2010 09:29:17 PM (14 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/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.
Note: See TracChangeset for help on using the changeset viewer.