Advertisement
BakerMan

Remove all FB events

Sep 28th, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. /**
  2.  * This is a quick and straightforward utility that attempts to
  3.  * purge all Facebook events from your The Events Calendar installation.
  4.  *
  5.  * Before use, please backup your database and ensure you know how to
  6.  * restore that backup!
  7.  *
  8.  * Easiest usage is to copy and paste in to your theme's functions.php
  9.  * file, then login and view the list of events: you may need to refresh
  10.  * the page a couple of times or more but you should ultimately find
  11.  * that FB-related events are dropped altogether. With that done, PLEASE
  12.  * DELETE THIS CODE - especially if you intend to start importing more
  13.  * FB events!
  14.  *
  15.  * (This is provided as a convenience, use at your own risk!)
  16.  */
  17. class Kill_Tribe_FB_Events
  18. {
  19.     protected $matches = array();
  20.  
  21.  
  22.     public function __construct() {
  23.         $this->find_matches();
  24.         $this->destroy_matches();
  25.     }
  26.  
  27.     protected function find_matches() {
  28.         $this->matches = get_posts(array(
  29.             'meta_key' => '_FacebookID',
  30.             'post_type' => TribeEvents::POSTTYPE,
  31.             'posts_per_page' => -1
  32.         ));
  33.     }
  34.  
  35.     protected function destroy_matches() {
  36.         foreach ($this->matches as $fb_event)
  37.             wp_delete_post($fb_event->ID, true);
  38.     }
  39. }
  40.  
  41. // Set things in motion
  42. new Kill_Tribe_FB_Events;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement