Skip to content

Instantly share code, notes, and snippets.

@joshuafredrickson
Last active December 18, 2015 11:48
Show Gist options
  • Save joshuafredrickson/5777770 to your computer and use it in GitHub Desktop.
Save joshuafredrickson/5777770 to your computer and use it in GitHub Desktop.
WordPress - Genesis: Modify comment form
// Modify the Genesis Default Comment Form
add_filter('genesis_comment_form_args','op_email_note');
function op_email_note() {
global $user_identity, $id;
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? ' aria-required="true"' : '' );
$commenter = wp_get_current_commenter();
if (empty($commenter['comment_author_email'])) {
$commenter['comment_author'] = 'Your Name';
$commenter['comment_author_email'] = 'Email Address';
}
$args = array(
'fields' => array(
'author' => '<p class="comment-form-author">' .
'<input x-autocompletetype="name-full" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" onblur="if (this.value == \'\') {this.value = \'Your Name\';}" onfocus="if (this.value == \'Your Name\') {this.value = \'\';}" size="30" tabindex="1"' . $aria_req . ' />' .
( $req ? '<span class="required">*</span>' : '' ) .
'</p><!-- #form-section-author .form-section -->',
'email' => '<p class="comment-form-email">' .
'<input x-autocompletetype="email" id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" onblur="if (this.value == \'\') {this.value = \'Email Address\';}" onfocus="if (this.value == \'Email Address\') {this.value = \'\';}" size="30" tabindex="2"' . $aria_req . ' />' .
( $req ? '<span class="required">*</span>' : '' ) .
' (will remain private)</p><!-- #form-section-email .form-section -->',
'url' => ''
),
'comment_field' => '<p class="comment-form-comment">' .
'<textarea id="comment" name="comment" cols="45" rows="8" tabindex="3" aria-required="true"></textarea>' .
'</p><!-- #form-section-comment .form-section -->',
'title_reply' => __( 'Add Your Comment', 'genesis' ),
'label_submit' => __( 'Post Comment', 'genesis' ),
'comment_notes_before' => '',
'comment_notes_after' => ''
);
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment