',
) ) );
?>
tag because of comment threading.
}
add_action( 'genesis_comment_form', 'genesis_do_comment_form' );
/**
* Optionally show the comment form.
*
* Genesis asks WP for the HTML5 version of the comment form - it uses {@link genesis_comment_form_args()} to revert to
* XHTML form fields when child theme does not support HTML5.
*
* @since 1.0.0
*
* @return void Return early if comments are closed via Genesis for this page or post.
*/
function genesis_do_comment_form() {
// Bail if comments are closed for this post type.
if ( ( is_page() && ! genesis_get_option( 'comments_pages' ) ) || ( is_single() && ! genesis_get_option( 'comments_posts' ) ) ) {
return;
}
comment_form( array(
'format' => 'html5',
) );
}
add_filter( 'comment_form_defaults', 'genesis_comment_form_args' );
/**
* Filter the default comment form arguments, used by `comment_form()`.
*
* Applies only to XHTML child themes, since Genesis uses default HTML5 comment form where possible.
*
* Applies `genesis_comment_form_args` filter.
*
* @since 1.8.0
*
* @global string $user_identity Display name of the user.
*
* @param array $defaults Comment form default arguments.
* @return array Filtered comment form default arguments.
*/
function genesis_comment_form_args( array $defaults ) {
// Use WordPress default HTML5 comment form if themes supports HTML5.
if ( genesis_html5() ) {
return $defaults;
}
global $user_identity;
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? ' aria-required="true"' : '' );
$author = '
' .
'' .
' ' .
( $req ? '*' : '' ) .
'
';
$email = '
' .
'' .
' ' .
( $req ? '*' : '' ) .
'
';
$url = '
' .
'' .
'' .
'
';
$comment_field = '
' .
'' .
'
';
$args = array(
'comment_field' => $comment_field,
'title_reply' => __( 'Speak Your Mind', 'genesis' ),
'comment_notes_before' => '',
'comment_notes_after' => '',
'fields' => array(
'author' => $author,
'email' => $email,
'url' => $url,
),
);
// Merge $args with $defaults.
$args = wp_parse_args( $args, $defaults );
// Return filterable array of $args, along with other optional variables.
return apply_filters( 'genesis_comment_form_args', $args, $user_identity, get_the_ID(), $commenter, $req, $aria_req );
}
add_filter( 'get_comments_link', 'genesis_comments_link_filter', 10, 2 );
/**
* Filter the comments link. If post has comments, link to #comments div. If no, link to #respond div.
*
* @since 2.0.1
*
* @param string $link Post comments permalink with '#comments' appended.
* @param int|WP_Post $post_id Post ID or WP_Post object.
* @return string URL to comments if they exist, otherwise URL to the comment form.
*/
function genesis_comments_link_filter( $link, $post_id ) {
if ( 0 == get_comments_number() ) {
return get_permalink( $post_id ) . '#respond';
}
return $link;
}