<?php
/**
 * Remove plugin data when the plugin is uninstalled.
 *
 * @link       https://dcatl.diviaccessories.com/
 * @since      1.0.0
 *
 * @package    display-category-and-taxonomy-list
 */

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

/**
 * Delete site-specific plugin data.
 *
 * @return void
 */
function dcatl_delete_site_data() {
	delete_option( 'dcatl_admin_style_settings' );
	delete_transient( 'dcatl_active_notice' );
	delete_transient( 'dcatl_dependency' );
	delete_metadata( 'term', 0, 'dcatl_term_image', '', true );
}

if ( is_multisite() ) {
	$site_ids = get_sites(
		array(
			'fields' => 'ids',
			'number' => 0,
		)
	);

	foreach ( $site_ids as $site_id ) {
		switch_to_blog( $site_id );
		dcatl_delete_site_data();
		restore_current_blog();
	}
} else {
	dcatl_delete_site_data();
}

delete_metadata( 'user', 0, 'dcatl_install_time', '', true );
