| 1 |
<?php |
| 2 |
/** |
| 3 |
* Runs on plugin deactivation. |
| 4 |
* |
| 5 |
* @package WordPress\AI\Admin |
| 6 |
* @since 1.1.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
declare( strict_types=1 ); |
| 10 |
|
| 11 |
namespace WordPress\AI\Admin; |
| 12 |
|
| 13 |
use WordPress\AI\Experiments\Key_Encryption\Key_Encryption; |
| 14 |
|
| 15 |
// Exit if accessed directly. |
| 16 |
defined( 'ABSPATH' ) || exit; |
| 17 |
|
| 18 |
/** |
| 19 |
* Deactivation routines. |
| 20 |
* |
| 21 |
* @internal |
| 22 |
* |
| 23 |
* @since 1.1.0 |
| 24 |
*/ |
| 25 |
final class Deactivation { |
| 26 |
/** |
| 27 |
* Runs on plugin deactivation. |
| 28 |
* |
| 29 |
* Reverses the Key Encryption experiment when it is |
| 30 |
* currently enabled so the user is never locked out of |
| 31 |
* their API keys after deactivating the plugin. |
| 32 |
* |
| 33 |
* @since 1.1.0 |
| 34 |
*/ |
| 35 |
public static function deactivation_callback(): void { |
| 36 |
if ( ! Key_Encryption::is_effectively_enabled() ) { |
| 37 |
return; |
| 38 |
} |
| 39 |
|
| 40 |
Key_Encryption::get_bridge()->decrypt_all(); |
| 41 |
} |
| 42 |
} |
| 43 |
|