+
-comment_approved == '0') : ?>
-
+ comment_approved ) : ?>
+
-
+
-
@@ -1379,39 +1829,86 @@ class Walker_Comment extends Walker {
}
/**
- * @see Walker::end_el()
- * @since unknown
+ * Output a comment in the HTML5 format.
*
- * @param string $output Passed by reference. Used to append additional content.
- * @param object $comment
- * @param int $depth Depth of comment.
- * @param array $args
+ * @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.
*/
- function end_el(&$output, $comment, $depth, $args) {
- if ( !empty($args['end-callback']) ) {
- call_user_func($args['end-callback'], $comment, $args, $depth);
- return;
- }
- if ( 'div' == $args['style'] )
- echo "
\n";
- else
- echo "\n";
+ protected function html5_comment( $comment, $depth, $args ) {
+ $tag = ( 'div' === $args['style'] ) ? 'div' : 'li';
+?>
+ < id="comment-" has_children ? 'parent' : '' ); ?>>
+
+
+
+
+
+
+ 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
+
+
+comments
+ * @see WP_Query->comments
+ *
+ * @param string|array $args {
+ * Optional. Formatting options.
+ *
+ * @type object $walker Instance of a Walker class to list comments. Default null.
+ * @type int $max_depth The maximum comments depth. Default empty.
+ * @type string $style The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'.
+ * @type string $callback Callback function to use. Default null.
+ * @type string $end-callback Callback function to use at the end. Default null.
+ * @type string $type Type of comments to list.
+ * Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'.
+ * @type int $page Page ID to list comments for. Default empty.
+ * @type int $per_page Number of comments to list per page. Default empty.
+ * @type int $avatar_size Height and width dimensions of the avatar size. Default 32.
+ * @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'.
+ * @type bool $reverse_children Whether to reverse child comments in the list. Default null.
+ * @type string $format How to format the comments list.
+ * Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
+ * @type bool $short_ping Whether to output short pings. Default false.
+ * @type bool $echo Whether to echo the output or return it. Default true.
+ * }
+ * @param array $comments Optional. Array of comment objects.
*/
-function wp_list_comments($args = array(), $comments = null ) {
+function wp_list_comments( $args = array(), $comments = null ) {
global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop;
$in_comment_loop = true;
@@ -1419,18 +1916,43 @@ function wp_list_comments($args = array(), $comments = null ) {
$comment_alt = $comment_thread_alt = 0;
$comment_depth = 1;
- $defaults = array('walker' => null, 'max_depth' => '', 'style' => 'ul', 'callback' => null, 'end-callback' => null, 'type' => 'all',
- 'page' => '', 'per_page' => '', 'avatar_size' => 32, 'reverse_top_level' => null, 'reverse_children' => '');
+ $defaults = array(
+ 'walker' => null,
+ 'max_depth' => '',
+ 'style' => 'ul',
+ 'callback' => null,
+ 'end-callback' => null,
+ 'type' => 'all',
+ 'page' => '',
+ 'per_page' => '',
+ 'avatar_size' => 32,
+ 'reverse_top_level' => null,
+ 'reverse_children' => '',
+ 'format' => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml',
+ 'short_ping' => false,
+ 'echo' => true,
+ );
$r = wp_parse_args( $args, $defaults );
+ /**
+ * Filter the arguments used in retrieving the comment list.
+ *
+ * @since 4.0.0
+ *
+ * @see wp_list_comments()
+ *
+ * @param array $r An array of arguments for displaying comments.
+ */
+ $r = apply_filters( 'wp_list_comments_args', $r );
+
// Figure out what comments we'll be looping through ($_comments)
if ( null !== $comments ) {
$comments = (array) $comments;
if ( empty($comments) )
return;
if ( 'all' != $r['type'] ) {
- $comments_by_type = &separate_comments($comments);
+ $comments_by_type = separate_comments($comments);
if ( empty($comments_by_type[$r['type']]) )
return;
$_comments = $comments_by_type[$r['type']];
@@ -1442,7 +1964,7 @@ function wp_list_comments($args = array(), $comments = null ) {
return;
if ( 'all' != $r['type'] ) {
if ( empty($wp_query->comments_by_type) )
- $wp_query->comments_by_type = &separate_comments($wp_query->comments);
+ $wp_query->comments_by_type = separate_comments($wp_query->comments);
if ( empty($wp_query->comments_by_type[$r['type']]) )
return;
$_comments = $wp_query->comments_by_type[$r['type']];
@@ -1483,19 +2005,27 @@ function wp_list_comments($args = array(), $comments = null ) {
if ( null === $r['reverse_top_level'] )
$r['reverse_top_level'] = ( 'desc' == get_option('comment_order') );
- extract( $r, EXTR_SKIP );
-
- if ( empty($walker) )
+ if ( empty( $r['walker'] ) ) {
$walker = new Walker_Comment;
+ } else {
+ $walker = $r['walker'];
+ }
- $walker->paged_walk($_comments, $max_depth, $page, $per_page, $r);
+ $output = $walker->paged_walk( $_comments, $r['max_depth'], $r['page'], $r['per_page'], $r );
$wp_query->max_num_comment_pages = $walker->max_pages;
$in_comment_loop = false;
+
+ if ( $r['echo'] ) {
+ echo $output;
+ } else {
+ return $output;
+ }
}
/**
- * Outputs a complete commenting form for use within a template.
+ * Output a complete commenting form for use within a template.
+ *
* Most strings and form fields may be controlled through the $args array passed
* into the function, while you may also choose to use the comment_form_default_fields
* filter to modify the array of default fields if you'd just like to add a new
@@ -1504,88 +2034,231 @@ function wp_list_comments($args = array(), $comments = null ) {
* in the array of fields.
*
* @since 3.0.0
- * @param array $args Options for strings, fields etc in the form
- * @param mixed $post_id Post ID to generate the form for, uses the current post if null
- * @return void
+ *
+ * @param array $args {
+ * Optional. Default arguments and form fields to override.
+ *
+ * @type array $fields {
+ * Default comment fields, filterable by default via the 'comment_form_default_fields' hook.
+ *
+ * @type string $author Comment author field HTML.
+ * @type string $email Comment author email field HTML.
+ * @type string $url Comment author URL field HTML.
+ * }
+ * @type string $comment_field The comment textarea field HTML.
+ * @type string $must_log_in HTML element for a 'must be logged in to comment' message.
+ * @type string $logged_in_as HTML element for a 'logged in as
' message.
+ * @type string $comment_notes_before HTML element for a message displayed before the comment form.
+ * Default 'Your email address will not be published.'.
+ * @type string $comment_notes_after HTML element for a message displayed after the comment form.
+ * Default 'You may use these HTML tags and attributes ...'.
+ * @type string $id_form The comment form element id attribute. Default 'commentform'.
+ * @type string $id_submit The comment submit element id attribute. Default 'submit'.
+ * @type string $name_submit The comment submit element name attribute. Default 'submit'.
+ * @type string $title_reply The translatable 'reply' button label. Default 'Leave a Reply'.
+ * @type string $title_reply_to The translatable 'reply-to' button label. Default 'Leave a Reply to %s',
+ * 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 $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.
*/
function comment_form( $args = array(), $post_id = null ) {
- global $user_identity, $id;
-
if ( null === $post_id )
- $post_id = $id;
- else
- $id = $post_id;
+ $post_id = get_the_ID();
$commenter = wp_get_current_commenter();
+ $user = wp_get_current_user();
+ $user_identity = $user->exists() ? $user->display_name : '';
+
+ $args = wp_parse_args( $args );
+ if ( ! isset( $args['format'] ) )
+ $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml';
- $req = get_option( 'require_name_email' );
+ $req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
- $fields = array(
- 'author' => '',
- 'email' => '',
- 'url' => '',
+ 'email' => '',
+ 'url' => '',
);
$required_text = sprintf( ' ' . __('Required fields are marked %s'), '*' );
+
+ /**
+ * Filter the default comment form fields.
+ *
+ * @since 3.0.0
+ *
+ * @param array $fields The default comment fields.
+ */
+ $fields = apply_filters( 'comment_form_default_fields', $fields );
$defaults = array(
- 'fields' => apply_filters( 'comment_form_default_fields', $fields ),
- 'comment_field' => '',
- 'must_log_in' => '' . sprintf( __( 'You must be logged in to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '
',
- 'logged_in_as' => '' . sprintf( __( 'Logged in as %2$s. Log out?' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '
',
+ 'fields' => $fields,
+ '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 */
+ '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' => '',
'comment_notes_after' => '' . sprintf( __( 'You may use these HTML tags and attributes: %s' ), ' ' . allowed_tags() . '
' ) . '
',
'id_form' => 'commentform',
'id_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' ),
+ 'format' => 'xhtml',
);
+ /**
+ * Filter the comment form default arguments.
+ *
+ * Use 'comment_form_default_fields' to filter the comment fields.
+ *
+ * @since 3.0.0
+ *
+ * @param array $defaults The default comment form arguments.
+ */
$args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
?>
-
-
-
-
+
+
+
-
-
-
-
-