INVP::delete_all_data()

delete_all_data


Description Description

This function will operate as an uninstall utility. Removes all the data we have added to the database including vehicle posts, their attachments, the option that holds settings, and terms in custom taxonomies.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/class-invp.php

	public static function delete_all_data() {
		// delete all the vehicles
		self::delete_all_inventory();

		// delete unattached photos with meta keys that identify them as vehicle photos
		self::delete_attachment_orphans();

		// delete pages created during activation
		// uninstall.php doesn't load the whole plugin but calls this method
		if ( ! class_exists( 'Inventory_Presser_Allow_Inventory_As_Home_Page' ) ) {
			include_once 'class-allow-inventory-as-home-page.php';
		}
		Inventory_Presser_Allow_Inventory_As_Home_Page::delete_pages();

		// delete all terms
		if ( ! is_multisite() ) {
			self::delete_all_terms_on_blog();

			// delete the option where all this plugin's settings are stored
			delete_option( self::OPTION_NAME );
		} else {
			$sites = get_sites(
				array(
					'network' => 1,
					'limit'   => 1000,
				)
			);
			foreach ( $sites as $site ) {
				switch_to_blog( $site->blog_id );

				self::delete_all_terms_on_blog();

				// delete the option where all this plugin's settings are stored
				delete_option( self::OPTION_NAME );

				restore_current_blog();
			}
		}

		do_action( 'invp_delete_all_data' );
	}