Skip to content

[Bug] Admin bar Online header not shown after update from older version #146

@parhumm

Description

@parhumm

Problem Description

After updating WP Slimstat from an older version, the admin bar item (#wp-admin-bar-slimstat-header) showing "Online: X" does not appear — even though the new default for use_separate_menu is 'on'.

The root cause is in how settings are merged during updates. At wp-slimstat.php:173, array_merge(self::init_options(), self::$settings) gives priority to stored settings. If the previous version's default for use_separate_menu was 'no' (or the user never explicitly changed it), the stored 'no' value persists and overrides the new 'on' default.

The upgrade migration at admin/index.php:730 attempts to fix this:

if (empty(wp_slimstat::$settings['use_separate_menu'])) {
    wp_slimstat::$settings['use_separate_menu'] = 'on';
}

However, empty('no') returns false in PHP, so this guard never triggers for users whose stored value is 'no'.

Impact

New admin bar feature (with online visitors count, stats modal, and quick links) is invisible to users updating from older versions, reducing feature discoverability and perceived value of the update.

Steps to Reproduce

  1. Install an older version of WP Slimstat where use_separate_menu defaults to 'no'
  2. Update to the latest version
  3. Log in as an administrator
  4. Observe the WordPress admin bar — no Slimstat item appears

Expected Behavior

After updating, the admin bar item with "Online: X" should be visible by default, matching the behavior of a fresh install.

Actual Behavior

The admin bar item does not appear because the stored use_separate_menu = 'no' from the previous version is preserved.

Code References

File Lines Description
wp-slimstat.php 173 Settings merge — stored values override defaults
wp-slimstat.php 799 New default: 'use_separate_menu' => 'on'
admin/index.php 182 Condition that enables the admin bar menu
admin/index.php 729-731 Upgrade migration that fails for 'no' values
admin/index.php 1050-1062 add_menu_to_adminbar() capability check
admin/index.php 1196-1201 Admin bar parent node creation

Environment

Field Value
Tech Stack PHP / WordPress
Runtime PHP 8.5.0
OS Darwin 25.1.0 arm64
Branch main

Additional Context

A possible fix would be to change the upgrade migration condition from empty() to explicitly check for the old default:

// Force-enable admin bar for users upgrading (new feature in this version)
if (!isset(wp_slimstat::$settings['use_separate_menu']) || wp_slimstat::$settings['use_separate_menu'] === 'no') {
    wp_slimstat::$settings['use_separate_menu'] = 'on';
}

Alternatively, a version-gated migration (only for users updating from versions before the admin bar was redesigned) would avoid overriding users who intentionally disabled it.


Reported via: qa-issue-report skill (jaan.to plugin)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions