Skip to content

Instantly share code, notes, and snippets.

@joecue
Last active February 4, 2016 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joecue/d09c57f380aac876d25b to your computer and use it in GitHub Desktop.
Save joecue/d09c57f380aac876d25b to your computer and use it in GitHub Desktop.
Useful WordPress Snippets
//Remove Autolinking Comment Hyperlink
remove_filter('comment_text', 'make_clickable', 9);
//Require Minimum Comment Length
add_filter( 'preprocess_comment', 'minimal_comment_length' );
function minimal_comment_length( $commentdata ) {
$minimalCommentLength = 20;
if ( strlen( trim( $commentdata['comment_content'] ) ) < $minimalCommentLength ){
wp_die( 'All comments must be at least ' . $minimalCommentLength . ' characters long.' );
}
return $commentdata;
}
//Remove the URL Field from WordPress Comments Form
function remove_comment_fields($fields) {
unset($fields['url']);
return $fields;
}
add_filter('comment_form_default_fields','remove_comment_fields');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment