Created
February 16, 2017 08:58
-
-
Save tankbar/b4cec8976866e130a5db0d48e6861a96 to your computer and use it in GitHub Desktop.
WordPress Stop long comments
This file contains hidden or 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
/* | |
Plugin Name: Stop long comments | |
Description: A security precaution to stop comments that are too long. | |
Version: 0.0.4 | |
Author: WPEngine | |
Author URI: wpengine.com | |
License: GPLv2 | |
*/ | |
add_filter( 'pre_comment_content', 'wpengine_die_on_long_comment', 9999 ); | |
function wpengine_die_on_long_comment( $text ) { | |
if ( strlen($text) > 13000 ) { | |
wp_die( | |
/*message*/ 'This comment is longer than the maximum allowed size and has been dropped.', | |
/*title*/ 'Comment Declined', | |
/*args*/ array( 'response' => 413 ) | |
); | |
} | |
return $text; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment