Skip to content

Commit b590b12

Browse files
committed
Fixed: show CE notice when $self_hosted_domain is set, otherwise show Cloud notice.
1 parent 6627d16 commit b590b12

1 file changed

Lines changed: 11 additions & 27 deletions

File tree

src/Admin/Upgrades.php

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ public function run() {
9494
$this->upgrade_to_251();
9595
}
9696

97-
if ( version_compare( $plausible_analytics_version, '2.5.3', '<' ) ) {
98-
$this->upgrade_to_253();
99-
}
100-
10197
if ( version_compare( $plausible_analytics_version, '2.5.4', '<' ) ) {
10298
$this->upgrade_to_254();
10399
}
@@ -356,41 +352,29 @@ public function upgrade_to_251() {
356352
}
357353

358354
/**
359-
* Show an admin-wide notice to CE users that haven't entered an API token yet.
355+
* Show an admin-wide notice to CE or Cloud users that haven't entered an API token yet.
360356
*
361357
* @return void
362358
*/
363-
public function upgrade_to_253() {
359+
public function upgrade_to_254() {
364360
$self_hosted_domain = Helpers::get_settings()['self_hosted_domain'];
365361
$api_token = Helpers::get_settings()['api_token'];
366362

367-
// Not a CE user or a CE user already using the Plugins API.
368-
if ( empty( $self_hosted_domain ) || ! empty( $api_token ) ) {
369-
update_option( 'plausible_analytics_version', '2.5.3' );
363+
// API token already entered, no notice needed.
364+
if ( ! empty( $api_token ) ) {
365+
update_option( 'plausible_analytics_version', '2.5.4' );
370366

371367
return;
372368
}
373369

374-
add_action( 'admin_notices', [ $this, 'show_ce_api_token_notice' ] );
375-
}
376-
377-
/**
378-
* Show an admin-wide notice to Cloud users that haven't entered an API token yet.
379-
*
380-
* @return void
381-
*/
382-
public function upgrade_to_254() {
383-
$self_hosted_domain = Helpers::get_settings()['self_hosted_domain'];
384-
$api_token = Helpers::get_settings()['api_token'];
385-
386-
// This user apparently hasn't entered an API token yet.
387-
if ( empty( $api_token ) && empty ( $self_hosted_domain ) ) {
388-
update_option( 'plausible_analytics_version', '2.5.4' );
370+
// Show CE notice if self-hosted domain is set, otherwise show Cloud notice.
371+
if ( ! empty( $self_hosted_domain ) ) {
372+
add_action( 'admin_notices', [ $this, 'show_ce_api_token_notice' ] );
389373

390374
return;
391375
}
392376

393-
add_action( 'admin_notices', [ $this, 'show_api_token_notice' ] );
377+
add_action( 'admin_notices', [ $this, 'show_cloud_api_token_notice' ] );
394378
}
395379

396380
/**
@@ -409,11 +393,11 @@ public function show_ce_api_token_notice() {
409393
}
410394

411395
/**
412-
* Display a notice to CE users that haven't entered an API token yet.
396+
* Display a notice to Cloud users that haven't entered an API token yet.
413397
*
414398
* @return void
415399
*/
416-
public function show_api_token_notice() {
400+
public function show_cloud_api_token_notice() {
417401
$url = admin_url( 'options-general.php?page=plausible_analytics' );
418402

419403
?>

0 commit comments

Comments
 (0)