diff --git a/README.md b/README.md index 2529781..515220f 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,33 @@ -# My Definitive SPAM Fucker +# No links please! Anti-spam WordPress plugin This astonishing-simple and really-effective anti-SPAM system just works. It definitively protects your WordPress site from SPAM without imposing annoying CAPTCHAs, configurations, third-party services, blockchains, artificial intelligence or unicorns. Oh, just avoid URLs in comments when not logged-in :^) ## Features * It prevent anonymous spammers from flooding your website with comments with links -* Politically correct and anyway completly customizable error message (e.g. as default without any "fuck") * It's astonishingly lightweight * It's impressively not full of crapware * It automagically works ## Antifeatures * It provides an unuseful Dashboard widget -* It provides an unuseful shortcode (`[spammers_fucked]`) +* It provides an unuseful shortcode (`[no_links_please_spammers_counter]`) * It prevents URLs in comments from anonymous users ## Installation As every WordPress plugin: -1. Download this repository as `.zip` file ([master.zip](https://github.com/valerio-bozzolan/wp-my-definitive-spam-fucker/archive/master.zip)) +1. Download this repository as `.zip` file ([master.zip](https://github.com/valerio-bozzolan/wordpress-please-no-links-please-anti-spam-plugin/archive/master.zip)) 2. Place it in your `/wp-content/plugins/` directory 3. Activate the plugin 4. Do not put URLs into your comments when not logged-in :^) ## Customization To customize the error message put this somewhere in the `functions.php` of your WordPress theme: - add_filter( 'my_definitive_spam_fucker_message', function () { + add_filter( 'no_links_please_anti_spam_message', function () { return "Error: Fuck you, and your URLs!"; } ); diff --git a/my-definitive-spam-fucker.php b/my-definitive-spam-fucker.php deleted file mode 100644 index bdd2798..0000000 --- a/my-definitive-spam-fucker.php +++ /dev/null @@ -1,100 +0,0 @@ - 400, - 'back_link' => true, - ] ); - } - } - return $approved; -} -add_filter( 'pre_comment_approved', 'my_definitive_spam_fucker_handler', '99', 2 ); - -/** - * Remove the author URL from the comment form for anonymous users - */ -function my_definitive_spam_fucker_form_default_fields( $fields ) { - if( ! is_user_logged_in() ) { - unset( $fields[ 'url' ] ); - } - return $fields; -} -add_filter( 'comment_form_default_fields', 'my_definitive_spam_fucker_form_default_fields' ); - -/** - * Unuseful callback fired when the shortcode is used - */ -function my_definitive_spam_fucker_counter() { - return get_option( 'my_definitive_spam_fucker_count', 0 ); -} -add_shortcode( 'spammers_fucked', 'my_definitive_spam_fucker_counter' ); - -/** - * Register the unuseful Dashboard widget - */ -function my_definitive_spam_fucker_dashboard_widget() { - wp_add_dashboard_widget( 'my_definitive_spam_fucker_dashboard_widget', __( "My Definitive SPAM Fucker", 'my-definitive-spam-fucker' ), 'my_definitive_spam_fucker_dashboard_widget_content' ); -} - -/** - * Register the unuseful Dashboard widget content - */ -function my_definitive_spam_fucker_dashboard_widget_content() { - echo '
'; - printf( - __( "Spammers fucked since activation: %s and counting!", 'my-definitive-spam-fucker' ), - '' . my_definitive_spam_fucker_counter() . '' - ); - echo '
'; -} -add_action( 'wp_dashboard_setup', 'my_definitive_spam_fucker_dashboard_widget' ); - -// allow shortcodes to be used in widgets -add_filter( 'widget_text', 'do_shortcode' ); - -/** - * Unuseful callback fired when the plugin is activated - */ -function my_definitive_spam_fucker_activation() { - add_option( 'my_definitive_spam_fucker_init', date('U') ); - add_option( 'my_definitive_spam_fucker_count', 0 ); -} -register_uninstall_hook( __FILE__, 'my_definitive_spam_fucker_activation' ); - -/** - * Unuseful callback fired when the plugin is uninstalled - */ -function my_definitive_spam_fucker_uninstall() { - delete_option( 'my_definitive_spam_fucker_init' ); - delete_option( 'my_definitive_spam_fucker_count' ); -} -register_uninstall_hook( __FILE__, 'my_definitive_spam_fucker_uninstall' ); diff --git a/no-links-please.php b/no-links-please.php new file mode 100644 index 0000000..df7775a --- /dev/null +++ b/no-links-please.php @@ -0,0 +1,100 @@ + 400, + 'back_link' => true, + ] ); + } + } + return $approved; +} +add_filter( 'pre_comment_approved', 'no_links_please_anti_spam_handler', '99', 2 ); + +/** + * Remove the author URL from the comment form for anonymous users + */ +function no_links_please_anti_spam_form_default_fields( $fields ) { + if( ! is_user_logged_in() ) { + unset( $fields[ 'url' ] ); + } + return $fields; +} +add_filter( 'comment_form_default_fields', 'no_links_please_anti_spam_form_default_fields' ); + +/** + * Unuseful callback fired when the shortcode is used + */ +function no_links_please_anti_spam_counter() { + return get_option( 'no_links_please_anti_spam_count', 0 ); +} +add_shortcode( 'no_links_please_spammers_counter', 'no_links_please_anti_spam_counter' ); + +/** + * Register the unuseful Dashboard widget + */ +function no_links_please_anti_spam_dashboard_widget() { + wp_add_dashboard_widget( 'no_links_please_anti_spam_dashboard_widget', __( "Anti-spam stats from \"No links, please!\"", 'no-links-please-anti-spam' ), 'no_links_please_anti_spam_dashboard_widget_content' ); +} + +/** + * Register the unuseful Dashboard widget content + */ +function no_links_please_anti_spam_dashboard_widget_content() { + echo ''; + printf( + __( "Spammers blocked since activation: %s and counting!", 'no-links-please-anti-spam' ), + '' . no_links_please_anti_spam_counter() . '' + ); + echo '
'; +} +add_action( 'wp_dashboard_setup', 'no_links_please_anti_spam_dashboard_widget' ); + +// allow shortcodes to be used in widgets +add_filter( 'widget_text', 'do_shortcode' ); + +/** + * Unuseful callback fired when the plugin is activated + */ +function no_links_please_anti_spam_activation() { + add_option( 'no_links_please_anti_spam_init', date('U') ); + add_option( 'no_links_please_anti_spam_count', 0 ); +} +register_uninstall_hook( __FILE__, 'no_links_please_anti_spam_activation' ); + +/** + * Unuseful callback fired when the plugin is uninstalled + */ +function no_links_please_anti_spam_uninstall() { + delete_option( 'no_links_please_anti_spam_init' ); + delete_option( 'no_links_please_anti_spam_count' ); +} +register_uninstall_hook( __FILE__, 'no_links_please_anti_spam_uninstall' );