Last active
June 20, 2016 22:19
-
-
Save curtismchale/3940979 to your computer and use it in GitHub Desktop.
Adds required inside labels
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
/** | |
* Changes the default WordPress comment form fields to match the way I like them, with the required * inside | |
* the label. | |
* | |
* @param array $fields req The default fields for WordPress comment forms | |
* @return array The fields the way we want them to look | |
* | |
* @uses wp_get_current_user | |
* @uses get_option | |
* | |
* @since 1.0 | |
* @author SFNdesign, Curtis McHale | |
* | |
*/ | |
function wp_theme_t_change_default_comment_fields( $fields ){ | |
$commenter = wp_get_current_commenter(); | |
$req = get_option( 'require_name_email' ); | |
$aria_req = ( $req ? " aria-required='true'" : '' ); | |
$fields = array( | |
'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name', 'domainreference' ) .''. ( $req ? '<span class="required">*</span>' : '' ) . '</label> <input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>', | |
'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email', 'domainreference' ) .''. ( $req ? '<span class="required">*</span>' : '' ) . '</label> <input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>', | |
'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website', 'domainreference' ) . '</label>' . | |
'<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>', | |
); | |
return $fields; | |
} | |
add_filter( 'comment_form_default_fields', 'wp_theme_t_change_default_comment_fields' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment