# woocommerce-pos/1.10.3/includes/Deactivator.php

WCPOS – Point of Sale (POS) plugin for WooCommerce, version 1.10.3. 108 lines.

- Page: https://pluginprobe.com/plugins/woocommerce-pos/1.10.3/code/includes/Deactivator.php
- Raw: https://pluginprobe.com/plugins/woocommerce-pos/1.10.3/raw/includes/Deactivator.php
- Modified: 2026-08-25T07:52:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/woocommerce-pos/1.10.3/code/includes/Deactivator.php#L10-L20`.

```php
<?php
/**
 * Fired during plugin deactivation.
 *
 * This class defines all code necessary to run during the plugin's deactivation.
 *
 * @author    Paul Kilmurray <paul@kilbot.com>
 *
 * @see      http://wcpos.com
 * @package   WooCommercePOS
 */

namespace WCPOS\WooCommercePOS;

/**
 * Fired during plugin deactivation.
 */
class Deactivator {
	/**
	 * Constructor.
	 */
	public function __construct() {
		register_deactivation_hook( PLUGIN_FILE, array( $this, 'deactivate' ) );
	}

	/**
	 * Fired when the plugin is deactivated.
	 *
	 * @param bool $network_wide Whether to deactivate network-wide.
	 */
	public function deactivate( bool $network_wide ): void {
		if ( \function_exists( 'is_multisite' ) && is_multisite() ) {
			if ( $network_wide ) {
				// Get all blog ids.
				$blog_ids = $this->get_blog_ids();

				foreach ( $blog_ids as $blog_id ) {
					switch_to_blog( $blog_id );
					$this->single_deactivate();

					restore_current_blog();
				}
			} else {
				$this->single_deactivate();
			}
		} else {
			$this->single_deactivate();
		}
	}

	/**
	 * Fired when the plugin is deactivated.
	 */
	public function single_deactivate(): void {
		// Report churn before tearing anything down, while settings (and so the
		// consent state) are still readable.
		$lifecycle = new \WCPOS\WooCommercePOS\Services\Lifecycle_Events();
		$lifecycle->report_deactivation();
		$lifecycle->clear_schedule();

		// remove pos capabilities.
		$this->remove_pos_capability();

		// stop the print-job retention purge.
		wp_clear_scheduled_hook( \WCPOS\WooCommercePOS\Services\Print_Job_Service::PURGE_HOOK );

		// stop the journal retention purge.
		wp_clear_scheduled_hook( \WCPOS\WooCommercePOS\Sync\Sync_Journal_Purge::PURGE_HOOK );

		// remove pos rewrite rule.
		flush_rewrite_rules( false ); // false will not overwrite .htaccess.
	}

	/**
	 * Get all blog ids of blogs in the current network that are:
	 * - not archived
	 * - not spam
	 * - not deleted.
	 */
	private static function get_blog_ids() {
		global $wpdb;

		// get an array of blog ids.
		$sql = "SELECT blog_id FROM $wpdb->blogs
      WHERE archived = '0' AND spam = '0'
      AND deleted = '0'";

		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Query contains no user input.
		return $wpdb->get_col( $sql );
	}

	/**
	 * Remove POS capabilities from all roles that received them during activation.
	 */
	private static function remove_pos_capability(): void {
		$roles = array( 'administrator', 'shop_manager', 'cashier' );
		$caps  = array( 'manage_woocommerce_pos', 'access_woocommerce_pos' );
		foreach ( $roles as $slug ) {
			$role = get_role( $slug );
			if ( $role ) {
				foreach ( $caps as $cap ) {
					$role->remove_cap( $cap );
				}
			}
		}
	}
}

```
