Changeset 3718572
- Timestamp:
- 09/29/2026 08:48:37 AM (3 weeks ago)
- Location:
- automatic-spam-eraser
- Files:
-
- 4 edited
- 1 copied
-
tags/1.1 (copied) (copied from automatic-spam-eraser/trunk )
-
tags/1.1/automatic-spam-eraser.php (modified) (2 diffs)
-
tags/1.1/readme.txt (modified) (3 diffs)
-
trunk/automatic-spam-eraser.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
automatic-spam-eraser/tags/1.1/automatic-spam-eraser.php
r833801 r3718572 3 3 * Plugin Name: Automatic SPAM Eraser 4 4 * Plugin URI: http://wordpress.org/plugins/automatic-spam-eraser/ 5 * Description: The plugin is adding a new WP-Cron event which automatically removes all <a href="edit-comments.php?comment_status=spam">spam</a> comments older than 7 days .6 * Version: 1. 05 * Description: The plugin is adding a new WP-Cron event which automatically removes all <a href="edit-comments.php?comment_status=spam">spam</a> comments older than 7 days (configurable in <a href="options-discussion.php#automatic_spam_eraser_days">Settings → Discussion</a>). 6 * Version: 1.1 7 7 * Author: Piotr Prądzyński 8 8 * Author URI: http://prondzyn.com 9 9 * License: GPL2 10 * Text Domain: automatic-spam-eraser 10 11 */ 12 13 define( 'AUTOMATIC_SPAM_ERASER_DEFAULT_DAYS', 7 ); 11 14 12 15 register_activation_hook(__FILE__, 'on_activation'); … … 15 18 wp_schedule_event( time(), 'daily', 'automatic_spam_eraser_event' ); 16 19 } 17 20 18 21 add_action( 'automatic_spam_eraser_event', 'delete_spam_from_db' ); 19 22 23 function automatic_spam_eraser_get_days() { 24 return automatic_spam_eraser_sanitize_days( get_option( 'automatic_spam_eraser_days', AUTOMATIC_SPAM_ERASER_DEFAULT_DAYS ) ); 25 } 26 27 function automatic_spam_eraser_sanitize_days( $days ) { 28 $days = intval( $days ); 29 return $days >= 1 ? $days : AUTOMATIC_SPAM_ERASER_DEFAULT_DAYS; 30 } 31 20 32 function delete_spam_from_db() { 21 33 global $wpdb; 22 $wpdb->query( 34 // spam from N or more calendar days ago, i.e. before midnight N-1 days ago; 35 // computed in PHP instead of DATEDIFF() to work on non-MySQL databases (e.g. SQLite) 36 $cutoff = gmdate( 'Y-m-d', strtotime( '-' . ( automatic_spam_eraser_get_days() - 1 ) . ' days' ) ); 37 $wpdb->query( 23 38 $wpdb->prepare( 24 "DELETE FROM $wpdb->comments WHERE comment_approved = %s AND DATEDIFF(DATE(%s), comment_date) >= %d",39 "DELETE FROM $wpdb->comments WHERE comment_approved = %s AND comment_date < %s", 25 40 'spam', 26 date('Y-m-d'), 741 $cutoff 27 42 ) 28 43 ); 29 44 } 30 45 46 add_action( 'admin_init', 'automatic_spam_eraser_register_settings' ); 47 48 function automatic_spam_eraser_register_settings() { 49 register_setting( 'discussion', 'automatic_spam_eraser_days', 'automatic_spam_eraser_sanitize_days' ); 50 add_settings_field( 51 'automatic_spam_eraser_days', 52 __( 'Automatic SPAM Eraser', 'automatic-spam-eraser' ), 53 'automatic_spam_eraser_render_days_field', 54 'discussion' 55 ); 56 } 57 58 function automatic_spam_eraser_render_days_field() { 59 printf( 60 '<label for="automatic_spam_eraser_days">%s</label>', 61 sprintf( 62 /* translators: %s: number input */ 63 __( 'Delete spam comments older than %s days', 'automatic-spam-eraser' ), 64 sprintf( 65 '<input name="automatic_spam_eraser_days" type="number" step="1" min="1" id="automatic_spam_eraser_days" value="%d" class="small-text" />', 66 automatic_spam_eraser_get_days() 67 ) 68 ) 69 ); 70 } 71 72 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'automatic_spam_eraser_action_links' ); 73 74 function automatic_spam_eraser_action_links( $links ) { 75 array_unshift( $links, sprintf( 76 '<a href="%s">%s</a>', 77 esc_url( admin_url( 'options-discussion.php#automatic_spam_eraser_days' ) ), 78 __( 'Settings', 'automatic-spam-eraser' ) 79 ) ); 80 return $links; 81 } 82 31 83 register_deactivation_hook(__FILE__, 'on_deactivation'); 32 84 33 85 function on_deactivation() { 34 86 wp_clear_scheduled_hook( 'automatic_spam_eraser_event' ); 35 87 } 88 89 register_uninstall_hook( __FILE__, 'automatic_spam_eraser_uninstall' ); 90 91 function automatic_spam_eraser_uninstall() { 92 delete_option( 'automatic_spam_eraser_days' ); 93 } 36 94 ?> -
automatic-spam-eraser/tags/1.1/readme.txt
r3070454 r3718572 3 3 Tags: comments, spam, eraser, cleaner, cron 4 4 Requires at least: 3.0.1 5 Tested up to: 6.5.26 Stable tag: 1. 05 Tested up to: 7.1 6 Stable tag: 1.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 14 14 The plugin is adding a new WP-Cron event which automatically removes all spam comments older than 7 days. 15 15 16 The number of days can be changed in Settings > Discussion (default: 7). 17 16 18 **For the proper functioning requires a properly working WP-Cron. If the plugin does not work please check you have WP-Cron correctly working.** 17 19 … … 20 22 1. Upload `automatic-spam-eraser.php` to the `/wp-content/plugins/` directory 21 23 2. Activate the plugin through the 'Plugins' menu in WordPress 24 25 == Changelog == 26 27 = 1.1 = 28 * Added: the number of days is now configurable in Settings > Discussion (default: 7). 29 * Fixed: on SQLite databases all spam comments were removed regardless of their age. 30 * Tested up to WordPress 7.1. 31 32 = 1.0 = 33 * Initial release. -
automatic-spam-eraser/trunk/automatic-spam-eraser.php
r833801 r3718572 3 3 * Plugin Name: Automatic SPAM Eraser 4 4 * Plugin URI: http://wordpress.org/plugins/automatic-spam-eraser/ 5 * Description: The plugin is adding a new WP-Cron event which automatically removes all <a href="edit-comments.php?comment_status=spam">spam</a> comments older than 7 days .6 * Version: 1. 05 * Description: The plugin is adding a new WP-Cron event which automatically removes all <a href="edit-comments.php?comment_status=spam">spam</a> comments older than 7 days (configurable in <a href="options-discussion.php#automatic_spam_eraser_days">Settings → Discussion</a>). 6 * Version: 1.1 7 7 * Author: Piotr Prądzyński 8 8 * Author URI: http://prondzyn.com 9 9 * License: GPL2 10 * Text Domain: automatic-spam-eraser 10 11 */ 12 13 define( 'AUTOMATIC_SPAM_ERASER_DEFAULT_DAYS', 7 ); 11 14 12 15 register_activation_hook(__FILE__, 'on_activation'); … … 15 18 wp_schedule_event( time(), 'daily', 'automatic_spam_eraser_event' ); 16 19 } 17 20 18 21 add_action( 'automatic_spam_eraser_event', 'delete_spam_from_db' ); 19 22 23 function automatic_spam_eraser_get_days() { 24 return automatic_spam_eraser_sanitize_days( get_option( 'automatic_spam_eraser_days', AUTOMATIC_SPAM_ERASER_DEFAULT_DAYS ) ); 25 } 26 27 function automatic_spam_eraser_sanitize_days( $days ) { 28 $days = intval( $days ); 29 return $days >= 1 ? $days : AUTOMATIC_SPAM_ERASER_DEFAULT_DAYS; 30 } 31 20 32 function delete_spam_from_db() { 21 33 global $wpdb; 22 $wpdb->query( 34 // spam from N or more calendar days ago, i.e. before midnight N-1 days ago; 35 // computed in PHP instead of DATEDIFF() to work on non-MySQL databases (e.g. SQLite) 36 $cutoff = gmdate( 'Y-m-d', strtotime( '-' . ( automatic_spam_eraser_get_days() - 1 ) . ' days' ) ); 37 $wpdb->query( 23 38 $wpdb->prepare( 24 "DELETE FROM $wpdb->comments WHERE comment_approved = %s AND DATEDIFF(DATE(%s), comment_date) >= %d",39 "DELETE FROM $wpdb->comments WHERE comment_approved = %s AND comment_date < %s", 25 40 'spam', 26 date('Y-m-d'), 741 $cutoff 27 42 ) 28 43 ); 29 44 } 30 45 46 add_action( 'admin_init', 'automatic_spam_eraser_register_settings' ); 47 48 function automatic_spam_eraser_register_settings() { 49 register_setting( 'discussion', 'automatic_spam_eraser_days', 'automatic_spam_eraser_sanitize_days' ); 50 add_settings_field( 51 'automatic_spam_eraser_days', 52 __( 'Automatic SPAM Eraser', 'automatic-spam-eraser' ), 53 'automatic_spam_eraser_render_days_field', 54 'discussion' 55 ); 56 } 57 58 function automatic_spam_eraser_render_days_field() { 59 printf( 60 '<label for="automatic_spam_eraser_days">%s</label>', 61 sprintf( 62 /* translators: %s: number input */ 63 __( 'Delete spam comments older than %s days', 'automatic-spam-eraser' ), 64 sprintf( 65 '<input name="automatic_spam_eraser_days" type="number" step="1" min="1" id="automatic_spam_eraser_days" value="%d" class="small-text" />', 66 automatic_spam_eraser_get_days() 67 ) 68 ) 69 ); 70 } 71 72 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'automatic_spam_eraser_action_links' ); 73 74 function automatic_spam_eraser_action_links( $links ) { 75 array_unshift( $links, sprintf( 76 '<a href="%s">%s</a>', 77 esc_url( admin_url( 'options-discussion.php#automatic_spam_eraser_days' ) ), 78 __( 'Settings', 'automatic-spam-eraser' ) 79 ) ); 80 return $links; 81 } 82 31 83 register_deactivation_hook(__FILE__, 'on_deactivation'); 32 84 33 85 function on_deactivation() { 34 86 wp_clear_scheduled_hook( 'automatic_spam_eraser_event' ); 35 87 } 88 89 register_uninstall_hook( __FILE__, 'automatic_spam_eraser_uninstall' ); 90 91 function automatic_spam_eraser_uninstall() { 92 delete_option( 'automatic_spam_eraser_days' ); 93 } 36 94 ?> -
automatic-spam-eraser/trunk/readme.txt
r3070454 r3718572 3 3 Tags: comments, spam, eraser, cleaner, cron 4 4 Requires at least: 3.0.1 5 Tested up to: 6.5.26 Stable tag: 1. 05 Tested up to: 7.1 6 Stable tag: 1.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 14 14 The plugin is adding a new WP-Cron event which automatically removes all spam comments older than 7 days. 15 15 16 The number of days can be changed in Settings > Discussion (default: 7). 17 16 18 **For the proper functioning requires a properly working WP-Cron. If the plugin does not work please check you have WP-Cron correctly working.** 17 19 … … 20 22 1. Upload `automatic-spam-eraser.php` to the `/wp-content/plugins/` directory 21 23 2. Activate the plugin through the 'Plugins' menu in WordPress 24 25 == Changelog == 26 27 = 1.1 = 28 * Added: the number of days is now configurable in Settings > Discussion (default: 7). 29 * Fixed: on SQLite databases all spam comments were removed regardless of their age. 30 * Tested up to WordPress 7.1. 31 32 = 1.0 = 33 * Initial release.
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)