Shorten the length of the log file for Simple History plugin

Code Snippet Related Categories

Reason for needing the Code Snippet

The Simple History plugin default history period is 60 days. The log includes not only user initiated changes to the website, but all the automated updates to plugins, etc. This can make the log file pretty large.

(This post was viewed 207 times) in the last month.)

What the Code Snippet does

This Simple History plugin PHP code snippet for the functions.php file lets you choose how long the history log period is.

The size of the database table for the plugin will depend on how much activity your site has. So small site, not much activity = smaller db. Large size, lots of activity = larger db usage.

Here's the Code Snippet

If you want to limit the number of days the log is stored, you can change this using a filter.

This and more examples in the examples are in the php file:
https://github.com/bonny/WordPress-Simple-History/blob/30728f1561a36ee50820aa266e2d07a3a61c1354/examples/examples.php

Add this to your functions.php or similar:

// Clear items that are older than a 7 days (i.e. keep only the most recent 7 days in the log)
add_filter('simple_history/db_purge_days_interval', function ($days) {
$days = 7;
return $days;
});

Limit search for phrases by using " " around the phrase

Subscribe to Code Snippet updates

You will get an email the morning after we post a new Code Snippet

Something went wrong. Please check your entries and try again.

Other Recent Code Snippets

Post Format: Image (Caption) 1

Post Format: Image (Caption)

Posted in

(This post was viewed 45 times) in the last month.)

Read More

Post Format: Image (Linked)

Posted in

(This post was viewed 43 times) in the last month.)

Read More

Post Format: Audio

Posted in

Link: St. Louis Blues Audio shortcode: (This post was viewed 44 times) in the last month.)

Read More

Post Format: Video (WordPress.tv)

Posted in

Posted as per the instructions in the Codex. (This post was viewed 49 times) in the last month.)

Read More

Post Format: Video (VideoPress)

Posted in

VideoPress, especially as a video post format, usually provides some unique styling issues. You will need to install Jetpack or Slim Jetpack plugin to turn the shortcode into a viewable video. (This post was viewed 55 times) in the last month.)

Read More

Post Format: Video (YouTube)

Posted in

Learn more about WordPress Embeds. (This post was viewed 39 times) in the last month.)

Read More

Popular Posts


Pieter Hartsook

WordPress website coaching, design, implementation, support, and training. Background in Marketing Research and Communications. See my profile at: https://www.linkedin.com/in/hartsook/

Reader Interactions

Leave a Reply

Your email address will not be published.

Skip to content