ping_status );
+
+ /**
+ * Filter whether the current post is open for pings.
+ *
+ * @since 2.5.0
+ *
+ * @param bool $open Whether the current post is open for pings.
+ * @param int|WP_Post $post_id The post ID or WP_Post object.
+ */
return apply_filters( 'pings_open', $open, $post_id );
}
@@ -1004,7 +1121,8 @@ function wp_comment_form_unfiltered_html_nonce() {
* @since 1.5.0
*
* @param string $file Optional. The file to load. Default '/comments.php'.
- * @param bool $separate_comments Optional. Whether to separate the comments by comment type. Default false.
+ * @param bool $separate_comments Optional. Whether to separate the comments by comment type.
+ * Default false.
* @return null Returns null if no comments appear.
*/
function comments_template( $file = '/comments.php', $separate_comments = false ) {
@@ -1018,45 +1136,50 @@ function comments_template( $file = '/comments.php', $separate_comments = false
$req = get_option('require_name_email');
- /**
+ /*
* Comment author information fetched from the comment cookies.
- *
- * @uses wp_get_current_commenter()
*/
$commenter = wp_get_current_commenter();
- /**
+ /*
* The name of the current comment author escaped for use in attributes.
+ * Escaped by sanitize_comment_cookies().
*/
- $comment_author = $commenter['comment_author']; // Escaped by sanitize_comment_cookies()
+ $comment_author = $commenter['comment_author'];
- /**
+ /*
* The email address of the current comment author escaped for use in attributes.
+ * Escaped by sanitize_comment_cookies().
*/
- $comment_author_email = $commenter['comment_author_email']; // Escaped by sanitize_comment_cookies()
+ $comment_author_email = $commenter['comment_author_email'];
- /**
+ /*
* The url of the current comment author escaped for use in attributes.
*/
$comment_author_url = esc_url($commenter['comment_author_url']);
- /** @todo Use API instead of SELECTs. */
- if ( $user_ID) {
- $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, $user_ID));
- } else if ( empty($comment_author) ) {
- $comments = get_comments( array('post_id' => $post->ID, 'status' => 'approve', 'order' => 'ASC') );
- } else {
- $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) ORDER BY comment_date_gmt", $post->ID, wp_specialchars_decode($comment_author,ENT_QUOTES), $comment_author_email));
+ $comment_args = array(
+ 'order' => 'ASC',
+ 'orderby' => 'comment_date_gmt',
+ 'status' => 'approve',
+ 'post_id' => $post->ID,
+ );
+
+ if ( $user_ID ) {
+ $comment_args['include_unapproved'] = array( $user_ID );
+ } elseif ( ! empty( $comment_author_email ) ) {
+ $comment_args['include_unapproved'] = array( $comment_author_email );
}
- // keep $comments for legacy's sake
+ $comments = get_comments( $comment_args );
+
/**
* Filter the comments array.
*
* @since 2.1.0
*
- * @param array $comments The array of comments supplied to the comments template.
- * @param int $post->ID The post ID.
+ * @param array $comments Array of comments supplied to the comments template.
+ * @param int $post_ID Post ID.
*/
$wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID );
$comments = &$wp_query->comments;
@@ -1081,7 +1204,7 @@ function comments_template( $file = '/comments.php', $separate_comments = false
/**
* Filter the path to the theme template file used for the comments template.
*
- * @since 1.5.2
+ * @since 1.5.1
*
* @param string $theme_template The path to the theme template file.
*/
@@ -1129,32 +1252,51 @@ function comments_popup_script( $width = 400, $height = 400, $file = '' ) {
/**
* Displays the link to the comments popup window for the current post ID.
*
- * Is not meant to be displayed on single posts and pages. Should be used on the
- * lists of posts
+ * Is not meant to be displayed on single posts and pages. Should be used
+ * on the lists of posts
*
* @global string $wpcommentspopupfile The URL to use for the popup window.
* @global int $wpcommentsjavascript Whether to use JavaScript. Set when function is called.
*
* @since 0.71
*
- * @param string $zero Optional. The string to display when no comments. Default false.
- * @param string $one Optional. The string to display when only one comment is available. Default false.
- * @param string $more Optional. The string to display when there are more than one comment. Default false.
- * @param string $css_class Optional. The CSS class to use for comments. Default empty.
- * @param string $none Optional. The string to display when comments have been turned off. Default false.
+ * @param string $zero Optional. String to display when no comments. Default false.
+ * @param string $one Optional. String to display when only one comment is available.
+ * Default false.
+ * @param string $more Optional. String to display when there are more than one comment.
+ * Default false.
+ * @param string $css_class Optional. CSS class to use for comments. Default empty.
+ * @param string $none Optional. String to display when comments have been turned off.
+ * Default false.
* @return null Returns null on single posts and pages.
*/
function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
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 . '';
@@ -1185,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 = '';
/**
@@ -1197,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 '';
}
@@ -1210,70 +1351,95 @@ function comments_popup_link( $zero = false, $one = false, $more = false, $css_c
* @param array $args {
* Optional. Override default arguments.
*
- * @type string 'add_below' The first part of the selector used to identify the comment to respond below. The resulting
- * value is passed as the first parameter to addComment.moveForm(), concatenated
- * as $add_below-$comment->comment_ID. Default 'comment'.
- * @type string 'respond_id' The selector identifying the responding comment. Passed as the third parameter to addComment.moveForm(),
- * and appended to the link URL as a hash value. Default 'respond'.
- * @type string 'reply_text' The text of the Reply link. Default 'Reply'.
- * @type string 'login_text' The text of the link to reply if logged out. Default 'Log in to Reply'.
- * @type int 'depth' The depth of the new comment. Must be greater than 0 and less than the value of the 'thread_comments_depth'
- * option set in Settings > Discussion.
- * Default 0.
- * @type string 'before' The text or HTML to add before the reply link. Default empty.
- * @type string 'after' The text or HTML to add after the reply link. Default empty.
+ * @type string $add_below The first part of the selector used to identify the comment to respond below.
+ * The resulting value is passed as the first parameter to addComment.moveForm(),
+ * concatenated as $add_below-$comment->comment_ID. Default 'comment'.
+ * @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
+ * to addComment.moveForm(), and appended to the link URL as a hash value.
+ * Default 'respond'.
+ * @type string $reply_text The text of the Reply link. Default 'Reply'.
+ * @type string $login_text The text of the link to reply if logged out. Default 'Log in to Reply'.
+ * @type int $depth' The depth of the new comment. Must be greater than 0 and less than the value
+ * of the 'thread_comments_depth' option set in Settings > Discussion. Default 0.
+ * @type string $before The text or HTML to add before the reply link. Default empty.
+ * @type string $after The text or HTML to add after the reply link. Default empty.
* }
- * @param int $comment Optional. Comment being replied to. Default current comment.
- * @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on. Default current post.
- * @return mixed Link to show comment form, if successful. False, if comments are closed.
+ * @param int $comment Comment being replied to. Default current comment.
+ * @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on.
+ * Default current post.
+ * @return null|false|string Link to show comment form, if successful. False, if comments are closed.
*/
-function get_comment_reply_link($args = array(), $comment = null, $post = null) {
+function get_comment_reply_link( $args = array(), $comment = null, $post = null ) {
$defaults = array(
- 'add_below' => 'comment',
- 'respond_id' => 'respond',
- 'reply_text' => __('Reply'),
- 'login_text' => __('Log in to Reply'),
- 'depth' => 0,
- 'before' => '',
- 'after' => ''
+ 'add_below' => 'comment',
+ 'respond_id' => 'respond',
+ 'reply_text' => __( 'Reply' ),
+ 'reply_to_text' => __( 'Reply to %s' ),
+ 'login_text' => __( 'Log in to Reply' ),
+ 'depth' => 0,
+ 'before' => '',
+ 'after' => ''
);
- $args = wp_parse_args($args, $defaults);
+ $args = wp_parse_args( $args, $defaults );
- if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] )
+ if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) {
return;
+ }
- extract($args, EXTR_SKIP);
+ $comment = get_comment( $comment );
- $comment = get_comment($comment);
- if ( empty($post) )
+ if ( empty( $post ) ) {
$post = $comment->comment_post_ID;
- $post = get_post($post);
+ }
- if ( !comments_open($post->ID) )
- return false;
+ $post = get_post( $post );
- $link = '';
+ if ( ! comments_open( $post->ID ) ) {
+ return false;
+ }
- if ( get_option('comment_registration') && ! is_user_logged_in() )
- $link = '';
- else
- $link = "";
+ /**
+ * Filter the comment reply link arguments.
+ *
+ * @since 4.1.0
+ *
+ * @param array $args Comment reply link arguments. See {@see get_comment_reply_link()}
+ * for more information on accepted arguments.
+ * @param object $comment The object of the comment being replied to.
+ * @param WP_Post $post The {@see WP_Post} object.
+ */
+ $args = apply_filters( 'comment_reply_link_args', $args, $comment, $post );
+ if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) {
+ $link = sprintf( '',
+ esc_url( wp_login_url( get_permalink() ) ),
+ $args['login_text']
+ );
+ } else {
+ $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )',
+ $args['add_below'], $comment->comment_ID, $args['respond_id'], $post->ID
+ );
+
+ $link = sprintf( "",
+ esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $args['respond_id'],
+ $onclick,
+ esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
+ $args['reply_text']
+ );
+ }
/**
* Filter the comment reply link.
*
* @since 2.7.0
*
- * @param string $before Text or HTML displayed before the reply link.
* @param string $link The HTML markup for the comment reply link.
- * @param string $after Text or HTML displayed after the reply link.
* @param array $args An array of arguments overriding the defaults.
* @param object $comment The object of the comment being replied.
* @param WP_Post $post The WP_Post object.
*/
- return apply_filters( 'comment_reply_link', $before . $link . $after, $args, $comment, $post );
+ return apply_filters( 'comment_reply_link', $args['before'] . $link . $args['after'], $args, $comment, $post );
}
/**
@@ -1281,9 +1447,12 @@ function get_comment_reply_link($args = array(), $comment = null, $post = null)
*
* @since 2.7.0
*
- * @param array $args Optional. Override default options, @see get_comment_reply_link()
- * @param int $comment Optional. Comment being replied to. Default current comment.
- * @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on. Default current post.
+ * @see get_comment_reply_link()
+ *
+ * @param array $args Optional. Override default options.
+ * @param int $comment Comment being replied to. Default current comment.
+ * @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on.
+ * Default current post.
* @return mixed Link to show comment form, if successful. False, if comments are closed.
*/
function comment_reply_link($args = array(), $comment = null, $post = null) {
@@ -1298,18 +1467,20 @@ function comment_reply_link($args = array(), $comment = null, $post = null) {
* @param array $args {
* Optional. Override default arguments.
*
- * @type string 'add_below' The first part of the selector used to identify the comment to respond below.
- * The resulting value is passed as the first parameter to addComment.moveForm(),
- * concatenated as $add_below-$comment->comment_ID. Default is 'post'.
- * @type string 'respond_id' The selector identifying the responding comment. Passed as the third parameter
- * to addComment.moveForm(), and appended to the link URL as a hash value. Default is 'respond'.
- * @type string 'reply_text' The text of the Reply link. Default is 'Leave a Comment'.
- * @type string 'login_text' The text of the link to reply if logged out. Default is 'Log in to leave a Comment'.
- * @type string 'before' The text or HTML to add before the reply link. Default empty.
- * @type string 'after' The text or HTML to add after the reply link. Default empty.
+ * @type string $add_below The first part of the selector used to identify the comment to respond below.
+ * The resulting value is passed as the first parameter to addComment.moveForm(),
+ * concatenated as $add_below-$comment->comment_ID. Default is 'post'.
+ * @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
+ * to addComment.moveForm(), and appended to the link URL as a hash value.
+ * Default 'respond'.
+ * @type string $reply_text Text of the Reply link. Default is 'Leave a Comment'.
+ * @type string $login_text Text of the link to reply if logged out. Default is 'Log in to leave a Comment'.
+ * @type string $before Text or HTML to add before the reply link. Default empty.
+ * @type string $after Text or HTML to add after the reply link. Default empty.
* }
- * @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on. Default current post.
- * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
+ * @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on.
+ * Default current post.
+ * @return false|null|string Link to show comment form, if successful. False, if comments are closed.
*/
function get_post_reply_link($args = array(), $post = null) {
$defaults = array(
@@ -1322,18 +1493,30 @@ function get_post_reply_link($args = array(), $post = null) {
);
$args = wp_parse_args($args, $defaults);
- extract($args, EXTR_SKIP);
+
$post = get_post($post);
- if ( !comments_open($post->ID) )
+ if ( ! comments_open( $post->ID ) ) {
return false;
+ }
- if ( get_option('comment_registration') && ! is_user_logged_in() )
- $link = '' . $login_text . '';
- else
- $link = "";
-
- $formatted_link = $before . $link . $after;
+ if ( get_option('comment_registration') && ! is_user_logged_in() ) {
+ $link = sprintf( '',
+ wp_login_url( get_permalink() ),
+ $args['login_text']
+ );
+ } else {
+ $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "0", "%3$s", "%2$s" )',
+ $args['add_below'], $post->ID, $args['respond_id']
+ );
+
+ $link = sprintf( "",
+ get_permalink( $post->ID ) . '#' . $args['respond_id'],
+ $onclick,
+ $args['reply_text']
+ );
+ }
+ $formatted_link = $args['before'] . $link . $args['after'];
/**
* Filter the formatted post comments link HTML.
*
@@ -1350,8 +1533,11 @@ function get_post_reply_link($args = array(), $post = null) {
*
* @since 2.7.0
*
- * @param array $args Optional. Override default options, @see get_post_reply_link()
- * @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on. Default current post.
+ * @see get_post_reply_link()
+ *
+ * @param array $args Optional. Override default options,
+ * @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on.
+ * Default current post.
* @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
*/
function post_reply_link($args = array(), $post = null) {
@@ -1379,8 +1565,8 @@ function get_cancel_comment_reply_link( $text = '' ) {
* @since 2.7.0
*
* @param string $formatted_link The HTML-formatted cancel comment reply link.
- * @param string $link The cancel comment reply link URL.
- * @param string $text The cancel comment reply link text.
+ * @param string $link Cancel comment reply link URL.
+ * @param string $text Cancel comment reply link text.
*/
return apply_filters( 'cancel_comment_reply_link', $formatted_link, $link, $text );
}
@@ -1438,14 +1624,17 @@ function comment_id_fields( $id = 0 ) {
/**
* Display text based on comment reply status.
*
- * Only affects users with Javascript disabled.
+ * Only affects users with JavaScript disabled.
*
* @since 2.7.0
*
- * @param string $noreplytext Optional. Text to display when not replying to a comment. Default false.
+ * @param string $noreplytext Optional. Text to display when not replying to a comment.
+ * Default false.
* @param string $replytext Optional. Text to display when replying to a comment.
- * Default false. Accepts "%s" for the author of the comment being replied to.
- * @param string $linktoparent Optional. Boolean to control making the author's name a link to their comment. Default true.
+ * Default false. Accepts "%s" for the author of the comment
+ * being replied to.
+ * @param string $linktoparent Optional. Boolean to control making the author's name a link
+ * to their comment. Default true.
*/
function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) {
global $comment;
@@ -1467,7 +1656,6 @@ function comment_form_title( $noreplytext = false, $replytext = false, $linktopa
/**
* HTML comment list class.
*
- * @package WordPress
* @uses Walker
* @since 2.7.0
*/
@@ -1480,7 +1668,7 @@ class Walker_Comment extends Walker {
* @since 2.7.0
* @var string
*/
- var $tree_type = 'comment';
+ public $tree_type = 'comment';
/**
* DB fields to use.
@@ -1490,7 +1678,7 @@ class Walker_Comment extends Walker {
* @since 2.7.0
* @var array
*/
- var $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID');
+ public $db_fields = array ('parent' => 'comment_parent', 'id' => 'comment_ID');
/**
* Start the list before the elements are added.
@@ -1503,18 +1691,18 @@ class Walker_Comment extends Walker {
* @param int $depth Depth of comment.
* @param array $args Uses 'style' argument for type of HTML list.
*/
- function start_lvl( &$output, $depth = 0, $args = array() ) {
+ public function start_lvl( &$output, $depth = 0, $args = array() ) {
$GLOBALS['comment_depth'] = $depth + 1;
switch ( $args['style'] ) {
case 'div':
break;
case 'ol':
- echo '' . "\n";
+ $output .= '' . "\n";
break;
- default:
case 'ul':
- echo '' . "\n";
+ default:
+ $output .= '' . "\n";
break;
}
}
@@ -1530,18 +1718,18 @@ class Walker_Comment extends Walker {
* @param int $depth Depth of comment.
* @param array $args Will only append content if style argument value is 'ol' or 'ul'.
*/
- function end_lvl( &$output, $depth = 0, $args = array() ) {
+ public function end_lvl( &$output, $depth = 0, $args = array() ) {
$GLOBALS['comment_depth'] = $depth + 1;
switch ( $args['style'] ) {
case 'div':
break;
case 'ol':
- echo "
\n";
+ $output .= "
\n";
break;
- default:
case 'ul':
- echo "\n";
+ default:
+ $output .= "\n";
break;
}
}
@@ -1566,6 +1754,7 @@ class Walker_Comment extends Walker {
* 2.2
*
* @see Walker::display_element()
+ * @see wp_list_comments()
*
* @since 2.7.0
*
@@ -1573,11 +1762,11 @@ class Walker_Comment extends Walker {
* @param array $children_elements List of elements to continue traversing.
* @param int $max_depth Max depth to traverse.
* @param int $depth Depth of current element.
- * @param array $args An array of arguments. @see wp_list_comments()
+ * @param array $args An array of arguments.
* @param string $output Passed by reference. Used to append additional content.
* @return null Null on failure with no changes to parameters.
*/
- function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
+ public function display_element( $element, &$children_elements, $max_depth, $depth, $args, &$output ) {
if ( !$element )
return;
@@ -1601,55 +1790,67 @@ class Walker_Comment extends Walker {
/**
* Start the element output.
*
- * @see Walker::start_el()
- *
* @since 2.7.0
*
+ * @see Walker::start_el()
+ * @see wp_list_comments()
+ *
* @param string $output Passed by reference. Used to append additional content.
* @param object $comment Comment data object.
* @param int $depth Depth of comment in reference to parents.
- * @param array $args An array of arguments. @see wp_list_comments()
+ * @param array $args An array of arguments.
*/
- function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) {
+ public function start_el( &$output, $comment, $depth = 0, $args = array(), $id = 0 ) {
$depth++;
$GLOBALS['comment_depth'] = $depth;
$GLOBALS['comment'] = $comment;
if ( !empty( $args['callback'] ) ) {
+ ob_start();
call_user_func( $args['callback'], $comment, $args, $depth );
+ $output .= ob_get_clean();
return;
}
if ( ( 'pingback' == $comment->comment_type || 'trackback' == $comment->comment_type ) && $args['short_ping'] ) {
+ ob_start();
$this->ping( $comment, $depth, $args );
+ $output .= ob_get_clean();
} elseif ( 'html5' === $args['format'] ) {
+ ob_start();
$this->html5_comment( $comment, $depth, $args );
+ $output .= ob_get_clean();
} else {
+ ob_start();
$this->comment( $comment, $depth, $args );
+ $output .= ob_get_clean();
}
}
/**
* Ends the element output, if needed.
*
- * @see Walker::end_el()
- *
* @since 2.7.0
*
+ * @see Walker::end_el()
+ * @see wp_list_comments()
+ *
* @param string $output Passed by reference. Used to append additional content.
* @param object $comment The comment object. Default current comment.
* @param int $depth Depth of comment.
- * @param array $args An array of arguments. @see wp_list_comments()
+ * @param array $args An array of arguments.
*/
- function end_el( &$output, $comment, $depth = 0, $args = array() ) {
+ public function end_el( &$output, $comment, $depth = 0, $args = array() ) {
if ( !empty( $args['end-callback'] ) ) {
+ ob_start();
call_user_func( $args['end-callback'], $comment, $args, $depth );
+ $output .= ob_get_clean();
return;
}
if ( 'div' == $args['style'] )
- echo "\n";
+ $output .= "\n";
else
- echo "\n";
+ $output .= "\n";
}
/**
@@ -1658,9 +1859,11 @@ class Walker_Comment extends Walker {
* @access protected
* @since 3.6.0
*
+ * @see wp_list_comments()
+ *
* @param object $comment The comment object.
* @param int $depth Depth of comment.
- * @param array $args An array of arguments. @see wp_list_comments()
+ * @param array $args An array of arguments.
*/
protected function ping( $comment, $depth, $args ) {
$tag = ( 'div' == $args['style'] ) ? 'div' : 'li';
@@ -1678,9 +1881,11 @@ class Walker_Comment extends Walker {
* @access protected
* @since 3.6.0
*
+ * @see wp_list_comments()
+ *
* @param object $comment Comment to display.
* @param int $depth Depth of comment.
- * @param array $args An array of arguments. @see wp_list_comments()
+ * @param array $args An array of arguments.
*/
protected function comment( $comment, $depth, $args ) {
if ( 'div' == $args['style'] ) {
@@ -1691,7 +1896,7 @@ class Walker_Comment extends Walker {
$add_below = 'div-comment';
}
?>
- < id="comment-">
+ < has_children ? 'parent' : '' ); ?> id="comment-">
@@ -1704,7 +1909,7 @@ class Walker_Comment extends Walker {
-
%1$s %2$s
' . ' ' . - '
', + '', 'email' => '' . - '
', + '', 'url' => '' . '
', ); @@ -1971,17 +2221,23 @@ function comment_form( $args = array(), $post_id = null ) { $fields = apply_filters( 'comment_form_default_fields', $fields ); $defaults = array( 'fields' => $fields, - 'comment_field' => '' . 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 */ 'logged_in_as' => '' . sprintf( __( 'Logged in as %2$s. Log out?' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '
', - 'comment_notes_before' => '' . __( 'Your email address will not be published.' ) . ( $req ? $required_text : '' ) . '
', - 'comment_notes_after' => '' . sprintf( __( 'You may use these HTML tags and attributes: %s' ), '
', + 'comment_notes_before' => '' . allowed_tags() . '
' ) . '' . __( 'Your email address will not be published.' ) . ''. ( $req ? $required_text : '' ) . '
', + 'comment_notes_after' => '' . sprintf( __( 'You may use these HTML tags and attributes: %s' ), '
', 'id_form' => 'commentform', 'id_submit' => 'submit', + 'class_submit' => 'submit', + 'name_submit' => 'submit', 'title_reply' => __( 'Leave a Reply' ), 'title_reply_to' => __( 'Leave a Reply to %s' ), 'cancel_reply_link' => __( 'Cancel reply' ), 'label_submit' => __( 'Post Comment' ), + 'submit_button' => '', + 'submit_field' => '' . allowed_tags() . '
' ) . '%1$s %2$s
', 'format' => 'xhtml', ); @@ -1996,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 ) ) : ?> " method="post" id="" class="comment-form"> tag. + * Fires at the top of the comment form, inside the form tag. * * @since 3.0.0 */ @@ -2035,9 +2293,11 @@ function comment_form( $args = array(), $post_id = null ) { * * @since 3.0.0 * - * @param string $args['logged_in_as'] The logged-in-as HTML-formatted message. - * @param array $commenter An array containing the comment author's username, email, and URL. - * @param string $user_identity If the commenter is a registered user, the display name, blank otherwise. + * @param string $args_logged_in The logged-in-as HTML-formatted message. + * @param array $commenter An array containing the comment author's + * username, email, and URL. + * @param string $user_identity If the commenter is a registered user, + * the display name, blank otherwise. */ echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); ?> @@ -2047,8 +2307,10 @@ function comment_form( $args = array(), $post_id = null ) { * * @since 3.0.0 * - * @param array $commenter An array containing the comment author's username, email, and URL. - * @param string $user_identity If the commenter is a registered user, the display name, blank otherwise. + * @param array $commenter An array containing the comment author's + * username, email, and URL. + * @param string $user_identity If the commenter is a registered user, + * the display name, blank otherwise. */ do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); ?> @@ -2065,7 +2327,7 @@ function comment_form( $args = array(), $post_id = null ) { /** * Filter a comment form field for display. * - * The dynamic portion of the filter hook, $name, refers to the name + * The dynamic portion of the filter hook, `$name`, refers to the name * of the comment form field. Such as 'author', 'email', or 'url'. * * @since 3.0.0 @@ -2088,20 +2350,54 @@ function comment_form( $args = array(), $post_id = null ) { * * @since 3.0.0 * - * @param string $args['comment_field'] The content of the comment textarea field. + * @param string $args_comment_field The content of the comment textarea field. */ echo apply_filters( 'comment_form_field_comment', $args['comment_field'] ); ?> -- - -
+ tag. * - * @since 1.5.2 + * @since 1.5.0 * * @param int $post_id The post ID. */