Last active
October 17, 2017 08:42
-
-
Save SanjeevMohindra/2b06eda07da10680aaddbe813792695b to your computer and use it in GitHub Desktop.
Change Comment Form in Genesis 2.0
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 | |
// Do not copy the above php tag in your function.php | |
/** | |
* Change Comment Form | |
* | |
* This function will modify the comment form in genesis 2.0 | |
* Add this to your function.php | |
* | |
* @author MetaBlogue | |
* @license GPL-2.0+ | |
* @link https://metablogue.com/modify-comment-form-genesis-themes/ | |
*/ | |
//** Customise Comment Form | |
function mb_custom_comment_form ($fields) { | |
$fields['comment_notes_before'] = '<p class="comment-notes">Please read our <a href="http://comment=policy-url" title="comment-policy-title">comment policy</a> before submitting your comment. Your email address will not be used or publish anywhere. You will only receive comment notifications if you opt to subscribe below. </p>'; | |
$fields['title_reply'] = __( 'Join The Discussion:', 'mbcustom' ); //Changes The Form Headline | |
$fields['label_submit'] = __( 'Start Discussion', 'mbcustom' ); //Changes The Submit Button Text | |
$fields['comment_field'] = '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label><textarea id="comment" name="comment" cols="45" rows="8" placeholder="If you just want to appreciate the content, use social media share buttons. Use this section for any questions or valuable suggestions." aria-required="true"></textarea></p>'; | |
return $fields; | |
} | |
add_filter( 'comment_form_defaults', 'mb_custom_comment_form' ); | |
//Customize the form default fields - author, email and URL | |
function mb_custom_comment_form_defaults ($fields) { | |
$fields['author'] = '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . | |
'<input id="author" name="author" type="text" placeholder="Real Name, No Keyword Spamming" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $aria_req . $html_req . ' /></p>'; | |
$fields['email'] = '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . | |
'<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text" placeholder="Preferably Gravatar Enabled"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $aria_req . $html_req . ' /></p>'; | |
$fields['url'] = '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' . | |
'<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' placeholder="Your Own Domain Address" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>'; | |
return $fields; | |
} | |
add_filter( 'comment_form_default_fields', 'mb_custom_comment_form_defaults' ); | |
// Modify comments title text in comments | |
add_filter( 'genesis_title_comments', 'mb_genesis_title_comments' ); | |
function mb_genesis_title_comments() { | |
$title = '<h3>Discussion</h3>'; | |
return $title; | |
} | |
//Remove dates from published comment | |
add_filter( 'genesis_show_comment_date', '__return_false' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment