This commit is contained in:
Javier Casares 2026-08-18 10:48:13 +00:00
commit 5589c54b9b
13 changed files with 138 additions and 58 deletions

View file

@ -34,7 +34,7 @@ class Robotstxt_Manager_Activator {
* @return void
*/
public static function deactivate(): void {
delete_transient( 'robotstxt_manager_catalog' );
delete_site_transient( 'robotstxt_manager_catalog' );
}
/**
@ -43,12 +43,12 @@ class Robotstxt_Manager_Activator {
* @return void
*/
private static function ensure_defaults(): void {
if ( '' === get_option( 'robotstxt_manager_store_url', '' ) ) {
update_option( 'robotstxt_manager_store_url', 'https://www.robotstxt.software' );
if ( '' === get_site_option( 'robotstxt_manager_store_url', '' ) ) {
update_site_option( 'robotstxt_manager_store_url', 'https://www.robotstxt.software' );
}
if ( '' === get_option( 'robotstxt_manager_cache_ttl_minutes', '' ) ) {
update_option( 'robotstxt_manager_cache_ttl_minutes', 60 );
if ( '' === get_site_option( 'robotstxt_manager_cache_ttl_minutes', '' ) ) {
update_site_option( 'robotstxt_manager_cache_ttl_minutes', 60 );
}
}
}

View file

@ -79,8 +79,8 @@ class Robotstxt_Manager_Core_Client {
* @return self
*/
public static function from_options(): self {
$store_url_raw = get_option( 'robotstxt_manager_store_url', '' );
$api_key_raw = get_option( 'robotstxt_manager_api_key', '' );
$store_url_raw = get_site_option( 'robotstxt_manager_store_url', '' );
$api_key_raw = get_site_option( 'robotstxt_manager_api_key', '' );
$store_url = is_string( $store_url_raw ) ? $store_url_raw : '';
$api_key = is_string( $api_key_raw )
@ -197,7 +197,7 @@ class Robotstxt_Manager_Core_Client {
}
$cache_key = 'robotstxt_manager_catalog';
$cached = get_transient( $cache_key );
$cached = get_site_transient( $cache_key );
if ( is_array( $cached ) ) {
$typed = array();
@ -248,7 +248,7 @@ class Robotstxt_Manager_Core_Client {
}
$ttl = $this->get_catalog_ttl();
set_transient( $cache_key, $catalog, $ttl );
set_site_transient( $cache_key, $catalog, $ttl );
return $catalog;
}
@ -260,7 +260,7 @@ class Robotstxt_Manager_Core_Client {
* @return void
*/
public function clear_catalog_cache(): void {
delete_transient( 'robotstxt_manager_catalog' );
delete_site_transient( 'robotstxt_manager_catalog' );
}
/**
@ -269,7 +269,7 @@ class Robotstxt_Manager_Core_Client {
* @return int
*/
private function get_catalog_ttl(): int {
$raw = get_option( 'robotstxt_manager_cache_ttl_minutes', 60 );
$raw = get_site_option( 'robotstxt_manager_cache_ttl_minutes', 60 );
$min = is_numeric( $raw ) ? (int) $raw : 60;
if ( $min < 1 ) {
@ -316,7 +316,7 @@ class Robotstxt_Manager_Core_Client {
}
$cache_key = 'robotstxt_manager_subscriptions';
$cached = get_transient( $cache_key );
$cached = get_site_transient( $cache_key );
if ( is_array( $cached ) ) {
$typed = array();
@ -363,7 +363,7 @@ class Robotstxt_Manager_Core_Client {
);
}
set_transient( $cache_key, $rows, HOUR_IN_SECONDS );
set_site_transient( $cache_key, $rows, HOUR_IN_SECONDS );
return $rows;
}
@ -413,6 +413,6 @@ class Robotstxt_Manager_Core_Client {
* @return void
*/
public function clear_subscriptions_cache(): void {
delete_transient( 'robotstxt_manager_subscriptions' );
delete_site_transient( 'robotstxt_manager_subscriptions' );
}
}

View file

@ -273,7 +273,7 @@ class Robotstxt_Manager_Updater {
* @return bool True when a usable key exists.
*/
private function has_api_key(): bool {
$api_key_raw = get_option( 'robotstxt_manager_api_key', '' );
$api_key_raw = get_site_option( 'robotstxt_manager_api_key', '' );
$api_key = is_string( $api_key_raw ) ? Robotstxt_Manager_Encryption::decrypt( $api_key_raw ) : '';
return '' !== $api_key;
@ -308,7 +308,7 @@ class Robotstxt_Manager_Updater {
$args['token'] = $token;
} else {
// Fallback (older Core): the API key itself.
$api_key_raw = get_option( 'robotstxt_manager_api_key', '' );
$api_key_raw = get_site_option( 'robotstxt_manager_api_key', '' );
$api_key = is_string( $api_key_raw ) ? Robotstxt_Manager_Encryption::decrypt( $api_key_raw ) : '';
if ( '' !== $api_key ) {