• For @fudgeminers and @fabioperri and all others who requested it. Here is code to delete the ping logs on a schedule. I put this in the mu-plugins folder, but you can put it in the regular plugins folder if you wish:

    <?php
    /*
    Plugin Name: Empty Ping Optimizer Logs every 72 Hours
    Plugin URI: 
    Description: Removes log entries older than 72 hours in the WordPress Ping Optimizer Plugin
    Author: Brian Brown, Ph.D.
    Version: 2020.12.16.15.18
    Author URI:
    */
    defined( 'ABSPATH'  ) or die( 'No script kiddies please!' );
    add_action('init','bjb_delete_ping_optimizer');
    add_action('bjb_ping_optimizer','bjb_ping_optimizer_func');
    
    function bjb_ping_optimizer_func() {
        global $wpdb;
        $sql = 'DELETE FROM '.$wpdb->prefix.'cbnetpo_ping_optimizer WHERE date_time < DATE_ADD( NOW(), INTERVAL -72 HOUR )';
        $wpdb->query( $sql );
    
    }
    
    function bjb_delete_ping_optimizer(){
      if(!wp_next_scheduled('bjb_ping_optimizer_trim_logs')) {
           wp_schedule_event (time(), 'daily', 'bjb_ping_optimizer_trim_logs');
        }
    }

    I save it as mt-ping-logs.php but you can name it anything that you want.
    I should also add that this does NOT reset the ping count (stored in the options table), since that value is there whether it is zero or 10,000 or whatever, so it takes up nearly the same ‘space’ (bit count) for all practical purposes.
    Cheers!
    @brianbrown

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Ping log clean up script’ is closed to new replies.