{"id":16646894,"url":"https://github.com/stevegrunwell/revision-strike","last_synced_at":"2025-04-09T16:09:08.640Z","repository":{"id":139393070,"uuid":"39096120","full_name":"stevegrunwell/revision-strike","owner":"stevegrunwell","description":"Periodically purge old post revisions via WP Cron.","archived":false,"fork":false,"pushed_at":"2018-10-01T00:26:31.000Z","size":317,"stargazers_count":17,"open_issues_count":5,"forks_count":4,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-04-09T16:09:03.584Z","etag":null,"topics":["post-revisions","wordpress","wordpress-plugin","wp-cli","wp-cron"],"latest_commit_sha":null,"homepage":"http://wordpress.org/plugins/revision-strike","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stevegrunwell.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-07-14T19:30:02.000Z","updated_at":"2023-08-24T15:01:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"3a439911-d738-4081-b76e-ce5df4a53aca","html_url":"https://github.com/stevegrunwell/revision-strike","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevegrunwell%2Frevision-strike","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevegrunwell%2Frevision-strike/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevegrunwell%2Frevision-strike/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevegrunwell%2Frevision-strike/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stevegrunwell","download_url":"https://codeload.github.com/stevegrunwell/revision-strike/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248065283,"owners_count":21041871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["post-revisions","wordpress","wordpress-plugin","wp-cli","wp-cron"],"created_at":"2024-10-12T08:43:23.095Z","updated_at":"2025-04-09T16:09:08.633Z","avatar_url":"https://github.com/stevegrunwell.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Revision Strike\n\n[![Build Status](https://travis-ci.org/stevegrunwell/revision-strike.svg?branch=master)](https://travis-ci.org/stevegrunwell/revision-strike)\n[![Code Climate](https://codeclimate.com/github/stevegrunwell/revision-strike/badges/gpa.svg)](https://codeclimate.com/github/stevegrunwell/revision-strike)\n[![Test Coverage](https://codeclimate.com/github/stevegrunwell/revision-strike/badges/coverage.svg)](https://codeclimate.com/github/stevegrunwell/revision-strike/coverage)\n\nUnless post revisions are explicitly limited, WordPress will build up a hefty sum of revisions over time. While it's great to have revision history for some recent content, the chances that old revisions will be necessary diminish the longer a post has been published. Revision Strike is designed to automatically remove these unneeded revisions on older, published posts.\n\n**How does it work?**\n\nFirst, a threshold is set, with a default of 30 days. Once a day, Revision Strike will run and find any post revisions in the database attached to **published** posts with a post date of at least 30 (or your custom threshold) days ago, and \"strike\" (tear-down and remove) them from the WordPress database.\n\n\n## Usage\n\nThere are a number of ways to interact with Revision Strike:\n\n\n### WP Cron\n\nUpon plugin activation, a hook is registered to trigger the `revisionstrike_strike_old_revisions` action daily, which kicks off the striking process. This hook is then automatically removed upon plugin deactivation.\n\nThe WP Cron method is great for ongoing maintenance, but when you manually need to purge larger amounts of revisions\u0026hellip;\n\n\n### Tools \u0026rsaquo; Revision Strike\n\n![The Tools \u003e Revision Strike page](plugin-repo-assets/screenshot-1.png)\n\nYou can manually trigger a revision strike by logging into WordPress and visiting the Tools \u0026rsaquo; Revision Strike page.\n\n\u003e **Note:** You must have the \"edit_others_posts\" capability (typically \"Editor\"-level and above) in order to see this page.\n\n\n### WP-CLI\n\nIf you make use of [WP-CLI](http://wp-cli.org/) on your site you may trigger Revision Strike with the following commands:\n\n```bash\n$ wp revision-strike \u003ccommand\u003e\n```\n\n\n#### clean\n\nManually runs an instance of Revision Strike, removing revisions matching the passed arguments or defaulting to the values declared on the Settings \u0026rsaquo; Writing page.\n\n##### Arguments\n\n\u003cdl\u003e\n\t\u003cdt\u003e--days=\u0026lt;days\u0026gt;\u003c/dt\u003e\n\t\u003cdd\u003eRemove revisions on posts published at least \u0026lt;days\u0026gt; day(s) ago. This is determined by the value set on Settings \u0026rsaquo; Writing or a default of 30.\u003c/dd\u003e\n\t\u003cdt\u003e--limit=\u0026lt;limit\u0026gt;\u003c/dt\u003e\n\t\u003cdd\u003eThe maximum number of revisions to remove. This is determined by the value set on Settings \u0026rsaquo; Writing or a default value of 50.\u003c/dd\u003e\n\t\u003cdt\u003e--post_type=\u0026lt;post_type\u0026gt;\u003c/dt\u003e\n\t\u003cdd\u003eOne or more post types (comma-separated) for which revisions should be struck. Default value is 'post'.\u003c/dd\u003e\n\t\u003cdt\u003e--verbose\u003c/dt\u003e\n\t\u003cdd\u003eEnable verbose logging of deleted revisions.\u003c/dd\u003e\n\u003c/dl\u003e\n\n\n#### clean-all\n\nIf you have a large number of revisions, it can take Revision Strike some time to work its way through your post history to clean up revisions on a daily basis. The `clean-all` command is like spring cleaning, systematically removing eligible post revisions all at once, giving you a nice, clean revision history to start from, making it easy for the daily cron runner to maintain.\n\nUnder the hood, this command just determines how many eligible revisions are in the database, then calls the `clean` command with your arguments and a limit equal to the number of revisions in the database. Thanks to the revision chunking ([#17](https://github.com/stevegrunwell/revision-strike/issues/17)), no more than 50 post revisions are being handled in memory at any given time, ensuring minimal performance impact on your site.\n\n##### Arguments\n\n\u003cdl\u003e\n\t\u003cdt\u003e--days=\u0026lt;days\u0026gt;\u003c/dt\u003e\n\t\u003cdd\u003eRemove revisions on posts published at least \u0026lt;days\u0026gt; day(s) ago. This is determined by the value set on Settings \u0026rsaquo; Writing or a default of 30.\u003c/dd\u003e\n\t\u003cdt\u003e--post_type=\u0026lt;post_type\u0026gt;\u003c/dt\u003e\n\t\u003cdd\u003eOne or more post types (comma-separated) for which revisions should be struck. Default value is 'post'.\u003c/dd\u003e\n\t\u003cdt\u003e--verbose\u003c/dt\u003e\n\t\u003cdd\u003eEnable verbose logging of deleted revisions.\u003c/dd\u003e\n\u003c/dl\u003e\n\n\n## Hooks\n\nRevision Strike leverages the [WordPress Plugin API](https://codex.wordpress.org/Plugin_API) to let you customize its behavior without editing the codebase directly.\n\n### Filter: `revisionstrike_post_types`\n\nControls the post types for which revisions should be automatically be purged.\n\n\u003cdl\u003e\n\t\u003cdt\u003e(string) \u003ccode\u003e$post_types\u003c/code\u003e\u003c/dt\u003e\n\t\u003cdd\u003eA comma-separated list of post types.\u003c/dd\u003e\n\u003c/dl\u003e\n\n#### Example\n\nBy default, Revision Strike only works against posts of the \"Post\" post type. If you'd like to include other post types (pages, custom post types, etc.), this filter will allow you do so.\n\n```php\n/**\n * Include the \"page\" and \"book\" custom post type in Revision Strike.\n *\n * @param string $post_type A comma-separated list of post types.\n */\nfunction theme_set_post_types( $post_types ) {\n\treturn 'post,page,book';\n}\nadd_filter( 'revisionstrike_post_types', 'theme_set_post_types' );\n```\n\n### Filter: `revisionstrike_get_revision_ids`\n\nFilter the list of eligible revision IDs.\n\n\u003cdl\u003e\n\t\u003cdt\u003e(array) \u003ccode\u003e$revision_ids\u003c/code\u003e\u003c/dt\u003e\n\t\u003cdd\u003eRevision IDs to be struck.\u003c/dd\u003e\n\t\u003cdt\u003e(int) \u003ccode\u003e$days\u003c/code\u003e\u003c/dt\u003e\n\t\u003cdd\u003eThe number of days since a post's publish date that must pass before we can purge the post revisions.\u003c/dd\u003e\n\t\u003cdt\u003e(int) \u003ccode\u003e$limit\u003c/code\u003e\u003c/dt\u003e\n\t\u003cdd\u003eThe maximum number of revision IDs to retrieve.\u003c/dd\u003e\n\t\u003cdt\u003e(array) \u003ccode\u003e$post_type\u003c/code\u003e\u003c/dt\u003e\n\t\u003cdd\u003eThe post types for which revisions should be located.\u003c/dd\u003e\n\u003c/dl\u003e\n\n### Filter: `revisionstrike_capabilities`\n\nSets capabilities to access Revision Strike managment page.\n\n#### Example\n\nBy default, Revision Strike sets required capabilities to access plugin managment page as `edit_others_posts`. You can use this filter to change this in order to have more control on who can access it.\n\n```php\n/**\n * Sets capabilities to access Revision Strike settings page.\n */\nfunction rs_capabilities() {\n\treturn 'manage_options';\n}\nadd_filter( 'revisionstrike_capabilities', 'rs_capabilities' );\n```\n\n\n## Contributing\n\nAll development dependencies for the plugin are installed via [Composer](https://getcomposer.org/). After installing Composer on your system, navigate your terminal session to the plugin directory and run:\n\n\t$ composer install\n\nPull requests on this plugin are welcome, but I ask that you please follow these guidelines:\n\n* Every PR that touches code should include a corresponding test. This plugin uses [PHPUnit](https://phpunit.de/), [WP_Mock](https://github.com/10up/wp_mock), [Mockery](http://docs.mockery.io/en/latest/), and [Behat](http://behat.org). Every PR should [generate a passing build in Travis CI](https://travis-ci.org/stevegrunwell/revision-strike) before being considered for merger.\n* Please follow the [WordPress Coding Standards](https://codex.wordpress.org/WordPress_Coding_Standards). If you have any doubts, you can run your PHP through [PHP_CodeSniffer](https://www.squizlabs.com/php-codesniffer) using the **RevisionStrike** ruleset:\n\n\t\t$ vendor/bin/phpcs\n\n\tThis CodeSniffer ruleset combines the \"WordPress-Extra\" and \"WordPress-Docs\" rulesets for a *very* specific level of coverage; beyond the coding standards, contributed inline documentation will be checked against the [WordPress Inline Documentation Standards](https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/).\n\n### Integration tests\n\nThere are a few integration tests for the plugin, written using [Behat](http://behat.org) and scaffolded using [`wp scaffold package-tests`](http://wp-cli.org/commands/scaffold/package-tests/). If you'd like to contribute to these tests, please install the WP CLI Testing framework:\n\n```bash\n$ bin/install-package-tests.sh\n$ vendor/bin/behat\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevegrunwell%2Frevision-strike","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevegrunwell%2Frevision-strike","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevegrunwell%2Frevision-strike/lists"}