/**
  * Find and delete attachments associated with a post ID.
  *
  * This function finds each attachment that is associated with a post ID
  * and deletes it completely from the site. This is to prevent leftover
  * random images from sitting on the site forever.
  *
  * @access private
  *
  * @see get_attached_media, wp_delete_attachment
  *
  * @param int $pid a custom post type ID.
  */
 private function delete_associated_media($pid)
 {
     $delete = new Delete();
     // Make sure that the current user is logged in & has full permissions.
     if (!$delete->user_can_delete()) {
         return;
     }
     // Make sure $pid is, in fact, an ID
     if (!is_int($pid)) {
         return;
     }
     // Get our images
     $media = get_attached_media('image', $pid);
     if (!empty($media)) {
         // Loop through the media & delete each one
         foreach ($media as $attachment) {
             wp_delete_attachment($attachment->ID, true);
         }
     }
 }
 /**
  * Delete test data terms.
  *
  * This function will search for all terms of a particular taxonomy ($slug)
  * and delete them all using a particular term_meta flag that we set when creating
  * the posts. Validates the user first.
  *
  * @see WP_Query, wp_delete_post
  *
  * @param string $slug a custom post type ID.
  */
 public function delete($slug)
 {
     $delete = new Delete();
     // Make sure that the current user is logged in & has full permissions.
     if (!$delete->user_can_delete()) {
         return;
     }
     // Check that $cptslg has a string.
     if (empty($slug)) {
         return;
     }
     // Query for our terms
     $args = array('hide_empty' => false, 'meta_query' => array(array('key' => 'evans_test_content', 'value' => '__test__', 'compare' => '=')));
     $terms = get_terms($slug, $args);
     if (!empty($terms)) {
         $events = array();
         foreach ($terms as $term) {
             $events[] = array('action' => 'deleted', 'oid' => $term->term_id, 'type' => $slug, 'link' => '');
             // Delete our term
             wp_delete_term($term->term_id, $slug);
         }
         $taxonomy = get_taxonomy($slug);
         $events[] = array('action' => 'general', 'message' => __('Deleted', 'otm-test-content') . ' ' . $taxonomy->labels->name);
         return $events;
     }
 }
<?php

use testContent as test;
// If uninstall is not called from WordPress, exit
if (!defined('WP_UNINSTALL_PLUGIN')) {
    exit;
}
// Check if the current user has priveledges to run this method
if (!current_user_can('activate_plugins')) {
    return;
}
require dirname(__FILE__) . '/includes/class-delete.php';
$delete = new test\Delete();
// Delete all the things
$delete->delete_all_test_data();