Created
January 9, 2020 15:25
-
-
Save Inzman/781c6496b1167df8b567db7cadf61fc8 to your computer and use it in GitHub Desktop.
Wordpress - Delete auto-drafts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (is_admin()){ | |
| if ( !get_option('db_last_auto_cnl') || (get_option('db_last_auto_cnl') < time()- 86400) ) { | |
| global $wpdb; | |
| $del= $wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'auto-draft'"); | |
| $del= $wpdb->query("DELETE FROM $wpdb->posts WHERE post_type = 'revision'"); | |
| $del= $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_timeout_rss%'"); | |
| $del= $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_rss_%'"); | |
| $del= $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_timeout_feed_%'"); | |
| $del= $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_feed_%'"); | |
| //if you want, you can uncomment these too | |
| //$del= $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_dash_%'"); | |
| //$del= $wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_timeout_dash_%'"); | |
| update_option('db_last_auto_cnl',time()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment