<?php

/**
 * Trigger this file on Plugin uninstall
 *
 * @package EasyAnimatedPopup
 */

if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
	die;
};

// Clear database
$popups = get_posts( array( 'post_type' => EAPSGT, 'numberposts' => - 1 ) );

foreach ( $popups as $popup ) {
	wp_delete_post( $popup->ID, true );
}

// Access the database
global $wpdb;
$wpdb->query( "DELETE FROM wp_posts WHERE post_type = " . EAPSGT );
$wpdb->query( "DELETE FROM wp_postmeta WHERE post_id NOT IN (SELECT id FROM wp_posts)" );
$wpdb->query( "DELETE FROM wp_term_relationships WHERE object_id NOT IN (SELECT id FROM wp_posts)" );
