// Get the comment type (comment, trackback),
$classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;
- // If the comment author has an id (registered), then print the log in name
- if ( $comment->user_id > 0 && $user = get_userdata($comment->user_id) ) {
- // For all registered users, 'byuser'
+ // Add classes for comment authors that are registered users.
+ if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) ) {
$classes[] = 'byuser';
- $classes[] = 'comment-author-' . sanitize_html_class($user->user_nicename, $comment->user_id);
+ $classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id );
// For comment authors who are the author of the post
if ( $post = get_post($post_id) ) {
- if ( $comment->user_id === $post->post_author )
+ if ( $comment->user_id === $post->post_author ) {
$classes[] = 'bypostauthor';
+ }
}
}
$args['page'] = ( !empty($in_comment_loop) ) ? get_query_var('cpage') : get_page_of_comment( $comment->comment_ID, $args );
if ( $wp_rewrite->using_permalinks() )
- $link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . 'comment-page-' . $args['page'], 'comment' );
+ $link = user_trailingslashit( trailingslashit( get_permalink( $comment->comment_post_ID ) ) . $wp_rewrite->comments_pagination_base . '-' . $args['page'], 'comment' );
else
$link = add_query_arg( 'cpage', $args['page'], get_permalink( $comment->comment_post_ID ) );
} else {
/*
* Comment author information fetched from the comment cookies.
- * Uuses wp_get_current_commenter().
*/
$commenter = wp_get_current_commenter();
if ( $user_ID ) {
$comment_args['include_unapproved'] = array( $user_ID );
- } else if ( ! empty( $comment_author_email ) ) {
+ } elseif ( ! empty( $comment_author_email ) ) {
$comment_args['include_unapproved'] = array( $comment_author_email );
}
global $wpcommentspopupfile, $wpcommentsjavascript;
$id = get_the_ID();
+ $title = get_the_title();
+ $number = get_comments_number( $id );
- if ( false === $zero ) $zero = __( 'No Comments' );
- if ( false === $one ) $one = __( '1 Comment' );
- if ( false === $more ) $more = __( '% Comments' );
- if ( false === $none ) $none = __( 'Comments Off' );
+ if ( false === $zero ) {
+ /* translators: %s: post title */
+ $zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $title );
+ }
- $number = get_comments_number( $id );
+ if ( false === $one ) {
+ /* translators: %s: post title */
+ $one = sprintf( __( '1 Comment<span class="screen-reader-text"> on %s</span>' ), $title );
+ }
+
+ if ( false === $more ) {
+ /* translators: 1: Number of comments 2: post title */
+ $more = _n( '%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number );
+ $more = sprintf( $more, number_format_i18n( $number ), $title );
+ }
+
+ if ( false === $none ) {
+ /* translators: %s: post title */
+ $none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $title );
+ }
if ( 0 == $number && !comments_open() && !pings_open() ) {
echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>';
if ( !empty( $css_class ) ) {
echo ' class="'.$css_class.'" ';
}
- $title = the_title_attribute( array('echo' => 0 ) );
$attributes = '';
/**
*/
echo apply_filters( 'comments_popup_link_attributes', $attributes );
- echo ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">';
+ echo '>';
comments_number( $zero, $one, $more );
echo '</a>';
}
}
if ( get_option('comment_registration') && ! is_user_logged_in() ) {
- $link = sprintf( '<a rel="nofollow" href="%s">%s</a>',
+ $link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>',
wp_login_url( get_permalink() ),
$args['login_text']
);
* in the array of fields.
*
* @since 3.0.0
+ * @since 4.1.0 Introduced the 'class_submit' argument.
+ * @since 4.2.0 Introduced 'submit_button' and 'submit_fields' arguments.
*
* @param array $args {
* Optional. Default arguments and form fields to override.
* where %s is the author of the comment being replied to.
* @type string $cancel_reply_link The translatable 'cancel reply' button label. Default 'Cancel reply'.
* @type string $label_submit The translatable 'submit' button label. Default 'Post a comment'.
+ * @type string $submit_button HTML format for the Submit button.
+ * Default: '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />'.
+ * @type string $submit_field HTML format for the markup surrounding the Submit button and comment hidden
+ * fields. Default: '<p class="form-submit">%1$s %2$s</a>', where %1$s is the
+ * submit button markup and %2$s is the comment hidden fields.
* @type string $format The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'.
* }
* @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post.
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
+ $html_req = ( $req ? " required='required'" : '' );
$html5 = 'html5' === $args['format'];
$fields = array(
'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
- '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
+ '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . $html_req . ' /></p>',
'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
- '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" aria-describedby="email-notes"' . $aria_req . ' /></p>',
+ '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" aria-describedby="email-notes"' . $aria_req . $html_req . ' /></p>',
'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' .
'<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
);
$fields = apply_filters( 'comment_form_default_fields', $fields );
$defaults = array(
'fields' => $fields,
- 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" aria-describedby="form-allowed-tags" aria-required="true"></textarea></p>',
+ 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" aria-describedby="form-allowed-tags" aria-required="true" required="required"></textarea></p>',
/** This filter is documented in wp-includes/link-template.php */
'must_log_in' => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
/** This filter is documented in wp-includes/link-template.php */
'title_reply_to' => __( 'Leave a Reply to %s' ),
'cancel_reply_link' => __( 'Cancel reply' ),
'label_submit' => __( 'Post Comment' ),
+ 'submit_button' => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />',
+ 'submit_field' => '<p class="form-submit">%1$s %2$s</p>',
'format' => 'xhtml',
);
*/
$args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
- ?>
- <?php if ( comments_open( $post_id ) ) : ?>
+ if ( comments_open( $post_id ) ) : ?>
<?php
/**
* Fires before the comment form.
echo apply_filters( 'comment_form_field_comment', $args['comment_field'] );
?>
<?php echo $args['comment_notes_after']; ?>
- <p class="form-submit">
- <input name="<?php echo esc_attr( $args['name_submit'] ); ?>" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>" class="<?php echo esc_attr( $args['class_submit'] ); ?>" value="<?php echo esc_attr( $args['label_submit'] ); ?>" />
- <?php comment_id_fields( $post_id ); ?>
- </p>
+
<?php
+ $submit_button = sprintf(
+ $args['submit_button'],
+ esc_attr( $args['name_submit'] ),
+ esc_attr( $args['id_submit'] ),
+ esc_attr( $args['class_submit'] ),
+ esc_attr( $args['label_submit'] )
+ );
+
+ /**
+ * Filter the submit button for the comment form to display.
+ *
+ * @since 4.2.0
+ *
+ * @param string $submit_button HTML markup for the submit button.
+ * @param array $args Arguments passed to `comment_form()`.
+ */
+ $submit_button = apply_filters( 'comment_form_submit_button', $submit_button, $args );
+
+ $submit_field = sprintf(
+ $args['submit_field'],
+ $submit_button,
+ get_comment_id_fields( $post_id )
+ );
+
+ /**
+ * Filter the submit field for the comment form to display.
+ *
+ * The submit field includes the submit button, hidden fields for the
+ * comment form, and any wrapper markup.
+ *
+ * @since 4.2.0
+ *
+ * @param string $submit_field HTML markup for the submit field.
+ * @param array $args Arguments passed to comment_form().
+ */
+ echo apply_filters( 'comment_form_submit_field', $submit_field, $args );
+
/**
* Fires at the bottom of the comment form, inside the closing </form> tag.
*