<?php
/**
 * Plugin deactivation handler for Author Kit.
 *
 * This file defines the deactivation logic executed when the plugin is deactivated,
 * such as removing roles and custom capabilities.
 *
 * @package    Author_Kit
 * @subpackage Author_Kit/includes
 * @since      1.0.0
 */

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

/**
 * Handles plugin deactivation tasks.
 *
 * This class is responsible for cleaning up roles and capabilities
 * when the plugin is deactivated.
 */
class Author_Kit_Deactivator {

	/**
	 * Runs on plugin deactivation.
	 *
	 * @since 1.0.0
	 */
	public static function deactivate() {
		self::remove_guest_role();
		self::author_kit_remove_custom_user_capability();
	}

	/**
	 * Removes the custom "guest" user role.
	 */
	public static function remove_guest_role() {
		remove_role( 'guest' );
	}

		/**
		 * Removes the custom capability from the administrator role.
		 *
		 * Specifically removes the 'author_kit_add_edit_user' capability.
		 */
	public static function author_kit_remove_custom_user_capability() {
		$role = get_role( 'administrator' );
		if ( $role ) {
			$role->remove_cap( 'author_kit_add_edit_user' );
		}
	}
}
