Skip to content

Instantly share code, notes, and snippets.

@GeoffEW
Last active August 30, 2016 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GeoffEW/5ca8736e9969dba7908622f31b932321 to your computer and use it in GitHub Desktop.
Save GeoffEW/5ca8736e9969dba7908622f31b932321 to your computer and use it in GitHub Desktop.
Deletes the saved copy of "deleted" events generated by iCal Importer
<?php
/*
* Deletes the saved copy of "deleted" events generated by iCal Importer
* This allows you to re-import events. The script deletes 50 instances per page load
* Code by Nico; enhancement by Andras
*/
function del_deleted_events () {
$posts = get_posts( array( 'post_type'=>'deleted_event', "posts_per_page" => 50, 'post_status' => 'trash', ) );
if (!empty($posts)) {
foreach ($posts as $post) {
wp_delete_post( $post->ID, true);
}
echo '<p style="background-color:yellow;z-index:1;text-align:right;">50 deleted events removed, refresh again</p>';
} else {
echo '<p style="background-color:yellow;z-index:1;text-align:right;">Done deleting!</p>';
}
}
add_action( 'admin_init', 'del_deleted_events' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment