HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/ippmt.kauko.lt/wp-content/plugins/host-analyticsjs-local/includes/class-uninstall.php
<?php
/* * * * * * * * * * * * * * * * * * * *
 *  ██████╗ █████╗  ██████╗ ███████╗
 * ██╔════╝██╔══██╗██╔═══██╗██╔════╝
 * ██║     ███████║██║   ██║███████╗
 * ██║     ██╔══██║██║   ██║╚════██║
 * ╚██████╗██║  ██║╚██████╔╝███████║
 *  ╚═════╝╚═╝  ╚═╝ ╚═════╝ ╚══════╝
 *
 * @author   : Daan van den Bergh
 * @url      : https://daan.dev/wordpress/caos/
 * @copyright: © 2021 - 2024 Daan van den Bergh
 * @license  : GPL2v2 or later
 * * * * * * * * * * * * * * * * * * * */

class CAOS_Uninstall {
	/** @var array $options */
	private $options;

	/** @var string $cache_dir */
	private $cache_dir;

	/**
	 * CAOS_Uninstall constructor.
	 *
	 * @throws ReflectionException
	 */
	public function __construct() {
		if ( CAOS::get( CAOS_Admin_Settings::CAOS_ADV_SETTING_UNINSTALL_SETTINGS ) !== 'on' ) {
			return;
		}

		$settings        = new CAOS_Admin_Settings();
		$this->options   = $settings->get_settings();
		$this->cache_dir = CAOS::get_local_dir();

		$this->remove_db_entries();
		$this->delete_files();
		$this->delete_dir();
	}

	/**
	 * Remove all options from the database.
	 */
	private function remove_db_entries() {
		foreach ( $this->options as $constant => $option ) {
			delete_option( $option );
		}
	}

	/**
	 * Delete all files in the cache directory.
	 *
	 * @return array
	 */
	private function delete_files() {
		return array_map( 'unlink', glob( $this->cache_dir . '*.*' ) );
	}

	/**
	 * Delete the cache directory.
	 *
	 * @return bool
	 */
	private function delete_dir() {
		return rmdir( $this->cache_dir );
	}
}