Created
December 18, 2012 23:33
Revisions
-
norcross revised this gist
Dec 19, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ <?php // add filter to allow for new weekly schedule add_filter( 'cron_schedules', 'rkv_weekly_cron' ); -
norcross revised this gist
Dec 19, 2012 . 1 changed file with 41 additions and 42 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,42 +1,41 @@ // add filter to allow for new weekly schedule add_filter( 'cron_schedules', 'rkv_weekly_cron' ); function rkv_weekly_cron( $schedules ) { // Adds once weekly to the existing schedules. $schedules['weekly'] = array( 'interval' => 604800, 'display' => __( 'Once Weekly' ) ); return $schedules; } add_action('rkv_revision_cron', 'rkv_revision_delete'); // set cron schedule function rkv_revision_schedule() { if ( !wp_next_scheduled( 'rkv_revision_cron' ) ) { wp_schedule_event( time(), 'weekly', 'rkv_revision_cron'); } } add_action('wp', 'rkv_revision_schedule'); // run deletion on revisions function rkv_revision_delete() { // query revisions and get array of IDs $args = array( 'fields' => 'ids', 'post_type' => 'revision', 'numberposts' => -1 ); $revisions = get_posts($args); // loop through and delete each foreach ($revisions as $revision): wp_delete_post( $revision ); endforeach; } -
norcross revised this gist
Dec 19, 2012 . 1 changed file with 14 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,21 @@ // add filter to allow for new weekly schedule add_filter( 'cron_schedules', 'rkv_weekly_cron' ); function rkv_weekly_cron( $schedules ) { // Adds once weekly to the existing schedules. $schedules['weekly'] = array( 'interval' => 604800, 'display' => __( 'Once Weekly' ) ); return $schedules; } add_action('rkv_revision_cron', 'rkv_revision_delete'); // set cron schedule function rkv_revision_schedule() { if ( !wp_next_scheduled( 'rkv_revision_cron' ) ) { wp_schedule_event( time(), 'weekly', 'rkv_revision_cron'); } } add_action('wp', 'rkv_revision_schedule'); @@ -18,6 +30,7 @@ function rkv_revision_delete() { 'numberposts' => -1 ); $revisions = get_posts($args); // loop through and delete each -
norcross created this gist
Dec 18, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ add_action('rkv_revision_cron', 'rkv_revision_delete'); // set cron schedule function rkv_revision_schedule() { if ( !wp_next_scheduled( 'rkv_revision_cron' ) ) { wp_schedule_event( time(), 'daily', 'rkv_revision_cron'); } } add_action('wp', 'rkv_revision_schedule'); // run deletion on revisions function rkv_revision_delete() { // query revisions and get array of IDs $args = array( 'fields' => 'ids', 'post_type' => 'revision', 'numberposts' => -1 ); $revisions = get_posts($args); // loop through and delete each foreach ($revisions as $revision): wp_delete_post( $revision ); endforeach; }