X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/849f15aeed7a5e39314057bdc0064d8edd60dd7d..46588ee871246a923d972538dbc93b26f4fda932:/wp-includes/comment-template.php diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 4e75e7bc..c5e5c5f2 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -420,15 +420,15 @@ function get_comment_class( $class = '', $comment_id = null, $post_id = null ) { // 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'; + } } } @@ -658,7 +658,7 @@ function get_comment_link( $comment = null, $args = array() ) { $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 { @@ -1138,7 +1138,6 @@ function comments_template( $file = '/comments.php', $separate_comments = false /* * Comment author information fetched from the comment cookies. - * Uuses wp_get_current_commenter(). */ $commenter = wp_get_current_commenter(); @@ -1168,7 +1167,7 @@ function comments_template( $file = '/comments.php', $separate_comments = false 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 ); } @@ -1275,13 +1274,29 @@ function comments_popup_link( $zero = false, $one = false, $more = false, $css_c 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 on %s' ), $title ); + } - $number = get_comments_number( $id ); + if ( false === $one ) { + /* translators: %s: post title */ + $one = sprintf( __( '1 Comment on %s' ), $title ); + } + + if ( false === $more ) { + /* translators: 1: Number of comments 2: post title */ + $more = _n( '%1$s Comment on %2$s', '%1$s Comments on %2$s', $number ); + $more = sprintf( $more, number_format_i18n( $number ), $title ); + } + + if ( false === $none ) { + /* translators: %s: post title */ + $none = sprintf( __( 'Comments Off on %s' ), $title ); + } if ( 0 == $number && !comments_open() && !pings_open() ) { echo '' . $none . ''; @@ -1312,7 +1327,6 @@ function comments_popup_link( $zero = false, $one = false, $more = false, $css_c if ( !empty( $css_class ) ) { echo ' class="'.$css_class.'" '; } - $title = the_title_attribute( array('echo' => 0 ) ); $attributes = ''; /** @@ -1324,7 +1338,7 @@ function comments_popup_link( $zero = false, $one = false, $more = false, $css_c */ echo apply_filters( 'comments_popup_link_attributes', $attributes ); - echo ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">'; + echo '>'; comments_number( $zero, $one, $more ); echo ''; } @@ -1487,7 +1501,7 @@ function get_post_reply_link($args = array(), $post = null) { } if ( get_option('comment_registration') && ! is_user_logged_in() ) { - $link = sprintf( '%s', + $link = sprintf( '%s', wp_login_url( get_permalink() ), $args['login_text'] ); @@ -2132,6 +2146,8 @@ function wp_list_comments( $args = array(), $comments = null ) { * 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. @@ -2159,6 +2175,11 @@ function wp_list_comments( $args = array(), $comments = null ) { * 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: ''. + * @type string $submit_field HTML format for the markup surrounding the Submit button and comment hidden + * fields. Default: '

%1$s %2$s', 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. @@ -2177,12 +2198,13 @@ function comment_form( $args = array(), $post_id = null ) { $req = get_option( 'require_name_email' ); $aria_req = ( $req ? " aria-required='true'" : '' ); + $html_req = ( $req ? " required='required'" : '' ); $html5 = 'html5' === $args['format']; $fields = array( 'author' => '

' . ' ' . - '

', + '

', 'email' => '

' . - '

', + '

', 'url' => '

' . '

', ); @@ -2199,7 +2221,7 @@ function comment_form( $args = array(), $post_id = null ) { $fields = apply_filters( 'comment_form_default_fields', $fields ); $defaults = array( 'fields' => $fields, - 'comment_field' => '

', + 'comment_field' => '

', /** This filter is documented in wp-includes/link-template.php */ 'must_log_in' => '

' . sprintf( __( 'You must be logged in to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '

', /** This filter is documented in wp-includes/link-template.php */ @@ -2214,6 +2236,8 @@ function comment_form( $args = array(), $post_id = null ) { 'title_reply_to' => __( 'Leave a Reply to %s' ), 'cancel_reply_link' => __( 'Cancel reply' ), 'label_submit' => __( 'Post Comment' ), + 'submit_button' => '', + 'submit_field' => '

%1$s %2$s

', 'format' => 'xhtml', ); @@ -2228,8 +2252,10 @@ function comment_form( $args = array(), $post_id = null ) { */ $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) ); - ?> - + // Ensure that the filtered args contain all required default values. + $args = array_merge( $defaults, $args ); + + if ( comments_open( $post_id ) ) : ?> -

- - -

+ tag. *