Skip to content

Commit

Permalink
Merge branch 'hotfix-3.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
chesio committed Apr 22, 2024
2 parents 7152b41 + 542290a commit 2b0dee0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# BC Cache Changelog

## Version 3.3.2 (2024-04-22)

### Fixed

* Display link to Cache Viewer in dashboard widget only if user can actually access Cache Viewer [#110](https://github.com/chesio/bc-cache/issues/110).

## Version 3.3.1 (2024-04-18)

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion bc-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: BC Cache
* Plugin URI: https://github.com/chesio/bc-cache
* Description: Simple full page cache plugin inspired by Cachify.
* Version: 3.3.1
* Version: 3.3.2
* Author: Česlav Przywara <ceslav@przywara.cz>
* Author URI: https://www.chesio.com
* Requires PHP: 8.1
Expand Down
8 changes: 6 additions & 2 deletions classes/BlueChip/Cache/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,12 @@ private function addDashboardInfo(array $items): array
// Label has ID, so we can target (update) it via JavaScript.
$label = '<span id="bc-cache-size">' . esc_html($cache_size) . '</span>';

// Wrap icon and label in a link to cache viewer.
$items[] = '<a class="bc-cache-size" href="' . $this->cache_viewer->getUrl() . '">' . $icon . ' ' . $label . '</a>';
// Wrap icon and label in a link to Cache Viewer if user can access it.
if (current_user_can(Viewer::REQUIRED_CAPABILITY)) {
$items[] = '<a class="bc-cache-size" href="' . $this->cache_viewer->getUrl() . '">' . $icon . ' ' . $label . '</a>';
} else {
$items[] = '<span class="bc-cache-size">' . $icon . ' ' . $label . '</span>';
}

return $items;
}
Expand Down
2 changes: 1 addition & 1 deletion classes/BlueChip/Cache/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static function canUserFlushCache(): bool
{
return apply_filters(
Hooks::FILTER_USER_CAN_FLUSH_CACHE,
current_user_can('manage_options')
current_user_can(Viewer::REQUIRED_CAPABILITY) // By default all users that can access Cache Viewer, can flush the cache as well.
);
}

Expand Down
2 changes: 1 addition & 1 deletion classes/BlueChip/Cache/Viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Viewer
/**
* @var string Capability required to view cache viewer
*/
private const REQUIRED_CAPABILITY = 'manage_options';
public const REQUIRED_CAPABILITY = 'manage_options';

/**
* @var string Name of nonce used for any custom actions on admin pages
Expand Down

0 comments on commit 2b0dee0

Please sign in to comment.