From f1badbc13219c97530c38c53897a08b8a74d84ff Mon Sep 17 00:00:00 2001 From: Daan van den Bergh <18595395+Dan0sz@users.noreply.github.com> Date: Fri, 6 Feb 2026 12:30:16 +0100 Subject: [PATCH] Improved: display a notice to CE users that haven't entered an API token yet. --- src/Admin/Upgrades.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/Admin/Upgrades.php b/src/Admin/Upgrades.php index b6aaf50b..b7379153 100644 --- a/src/Admin/Upgrades.php +++ b/src/Admin/Upgrades.php @@ -94,6 +94,10 @@ public function run() { $this->upgrade_to_251(); } + if ( version_compare( $plausible_analytics_version, '2.5.3', '<' ) ) { + $this->upgrade_to_253(); + } + // Add required upgrade routines for future versions here. } @@ -346,4 +350,40 @@ public function upgrade_to_251() { update_option( 'plausible_analytics_version', '2.5.1' ); } + + /** + * Show an admin-wide notice to CE users that haven't entered an API token yet. + * + * @return void + */ + public function upgrade_to_253() { + $self_hosted_domain = Helpers::get_settings()['self_hosted_domain']; + $api_token = Helpers::get_settings()['api_token']; + + // Not a CE user or a CE user already using the Plugins API. + if ( empty( $self_hosted_domain ) || ! empty( $api_token ) ) { + update_option( 'plausible_analytics_version', '2.5.3' ); + + return; + } + + add_action( 'admin_notices', [ $this, 'show_api_token_notice' ] ); + } + + /** + * Display a notice to CE users that haven't entered an API token yet. + * + * @return void + */ + public function show_api_token_notice() { + $url = admin_url( 'options-general.php?page=plausible_analytics' ); + + ?> +
Settings screen and upgrade Plausible CE if necessary.', + 'plausible-analytics' ) + , $url ); ?>
+