Last active
December 25, 2015 16:59
-
-
Save trovster/7010390 to your computer and use it in GitHub Desktop.
Make the default comment_form more Gravity Form-like, with class names and wrappers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* _site_comment_form_top | |
* @desc Wrap the comment form fields (not submit) in a <div> (open) | |
*/ | |
function _site_comment_form_top() { | |
echo '<div class="gform_body">'; | |
} | |
add_action('comment_form_top', '_site_comment_form_top'); | |
/** | |
* _site_comment_form_after_fields | |
* @desc Wrap the comment form fields in a <div> (close) | |
*/ | |
function _site_comment_form_field_comment($field) { | |
return $field . '<!-- end of div .gform_body --></div>'; | |
} | |
add_filter('comment_form_field_comment', '_site_comment_form_field_comment'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$commenter = wp_get_current_commenter(); | |
comment_form(array( | |
'comment_notes_before' => '', | |
'comment_notes_after' => '', | |
'format' => 'html5', | |
'label_submit' => 'Submit', | |
'fields' => array( | |
'author' => '<div class="gfield gfield_contains_required field-author">' . "\r\n" . | |
'<label for="author gfield_label">Name <abbr class="gfield_required" title="Required">*</abbr></label> ' . "\r\n" . | |
'<div class="ginput_container">' . "\r\n" . | |
'<input id="author" name="author" type="text" value="' . esc_attr($commenter['comment_author']) . '" size="30" aria-required="true" />' . "\r\n" . | |
'</div>' . "\r\n" . | |
'</div>', | |
'email' => '<div class="gfield gfield_contains_required field-email">' . "\r\n" . | |
'<label for="email" gfield_label>Email <abbr class="gfield_required" title="Required">*</abbr></label> ' . "\r\n" . | |
'<div class="ginput_container">' . "\r\n" . | |
'<input id="email" name="email" type="email" value="' . esc_attr($commenter['comment_author_email']) . '" size="30" aria-required="true" />' . "\r\n" . | |
'</div>' . "\r\n" . | |
'</div>', | |
'url' => '<div class="gfield field-url">' . "\r\n" . | |
'<label for="url gfield_label">Website</label> ' . "\r\n" . | |
'<div class="ginput_container">' . "\r\n" . | |
'<input id="url" name="url" type="url" value="' . esc_attr($commenter['comment_author_url']) . '" size="30" />' . "\r\n" . | |
'</div>' . "\r\n" . | |
'</div>', | |
), | |
'comment_field' => '<div class="gfield gfield_contains_required field-comment">' . "\r\n" . | |
'<label for="comment gfield_label">Comment <abbr class="gfield_required" title="Required">*</abbr></label> ' . "\r\n" . | |
'<div class="ginput_container">' . "\r\n" . | |
'<textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" placeholder="Leave a comment"></textarea>' . "\r\n" . | |
'</div>' . "\r\n" . | |
'</div>', | |
)); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment