' . esc_html($message) . '

'; delete_transient('hithto_api_auth_error'); } if ($message = get_transient('hithto_api_auth_message')) { echo '

' . esc_html($message) . '

'; delete_transient('hithto_api_auth_message'); } } public static function enqueue_styles($hook) { if (!str_ends_with((string) $hook, '_page_api-authentication')) { return; } $css = ' .api-auth-section { margin-bottom: 20px; padding: 20px; border: 1px solid #ddd; background-color: #f9f9f9; border-radius: 5px; } .api-auth-section h2 { margin-top: 0; } .api-auth-section p { margin: 10px 0; } .api-auth-section label { display: block; font-weight: bold; } .api-auth-section input[type="number"], .api-auth-section input[type="text"] { width: 100%; padding: 5px; margin: 5px 0; } .api-auth-section .button-primary { margin-right: 10px; } '; wp_register_style('api-auth-admin', false, [], HITHTO_VERSION); wp_enqueue_style('api-auth-admin'); wp_add_inline_style('api-auth-admin', $css); } public static function display_api_authentication_page() { $master_token = self::get_master_token(); $expiry = get_option('hithto_api_transient_expiry', 10); $whitelist = self::get_whitelist(); $encryption_key_defined = self::get_encryption_key(); $encryption_available = self::is_encryption_available(); ?>

API Authentication

Generate Encryption Key

>

Encryption key is already defined.

Generate Master Token

>

Encryption key is not defined. Please generate the encryption key first.

Master Token:

Set Transient Token Expiry

Whitelist IP/Domain

Current Settings

Whitelist:

get_results( $wpdb->prepare( "SELECT option_name AS name FROM $wpdb->options WHERE option_name LIKE %s", '_transient_timeout_%hithto_api_auth_token%' ) ); $current_time = time(); foreach ($transients as $transient) { $transient_name = $transient->name; $transient_key = str_replace('_transient_timeout_', '', $transient_name); // Récupérer le timeout du transient $timeout = get_option($transient_name); // Si le transient a expiré, le supprimer ainsi que son pair if ($timeout !== false && $current_time > $timeout) { delete_transient($transient_key); delete_option($transient_name); } } } public static function deactivate() { wp_clear_scheduled_hook('hithto_api_auth_cleanup_expired_transients'); } }