Last active
August 30, 2016 02:53
-
-
Save GeoffEW/5ca8736e9969dba7908622f31b932321 to your computer and use it in GitHub Desktop.
Deletes the saved copy of "deleted" events generated by iCal Importer
This file contains 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
<?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