v0.1.0
This commit is contained in:
commit
bc1cb5e00a
32 changed files with 4254 additions and 0 deletions
54
includes/class-robotstxt-manager-activator.php
Normal file
54
includes/class-robotstxt-manager-activator.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue