robotstxt-manager/includes/class-robotstxt-manager-activator.php
2026-08-12 13:18:40 +00:00

54 lines
1.2 KiB
PHP

<?php
/**
* Handles plugin activation and deactivation.
*
* @package Robotstxt_Manager
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class Robotstxt_Manager_Activator
*
* Activation stores plugin defaults. Deactivation clears the catalog
* transient only — no user data is removed.
*/
class Robotstxt_Manager_Activator {
/**
* Runs on plugin activation.
*
* @return void
*/
public static function activate(): void {
self::ensure_defaults();
}
/**
* Runs on plugin deactivation.
*
* Clears transient caches created by this plugin. No user data is removed.
*
* @return void
*/
public static function deactivate(): void {
delete_transient( 'robotstxt_manager_catalog' );
}
/**
* Ensures default option values are present without overwriting existing settings.
*
* @return void
*/
private static function ensure_defaults(): void {
if ( '' === get_option( 'robotstxt_manager_store_url', '' ) ) {
update_option( 'robotstxt_manager_store_url', 'https://plugins.robotstxt.es' );
}
if ( '' === get_option( 'robotstxt_manager_cache_ttl_minutes', '' ) ) {
update_option( 'robotstxt_manager_cache_ttl_minutes', 60 );
}
}
}