Skip to content

Commit

Permalink
Version 3.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Browar committed Feb 16, 2018
1 parent 9a3b818 commit f6d3a5b
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).


## 3.1.5 - 2018-02-16
### Fixed
- Removed padding that caused a vertical scrollbar to appear
- Fixed an order of operations error (thanks to @sbossarte)


## 3.1.4 - 2018-02-10
### Added
- An Admin Bar Widget can now be invalidated using PHP via an Event that's called before widgets are loaded
Expand Down
34 changes: 18 additions & 16 deletions README.md
Expand Up @@ -214,23 +214,25 @@ If no useful content is provided by a widget, it can be removed from Admin Bar u
use wbrowar\adminbar\events\AdminBarRenderEvent;
use wbrowar\adminbar\services\Bar;

Event::on(Bar::class, Bar::EVENT_ADMIN_BAR_BEFORE_RENDER, function(AdminBarRenderEvent $event) {
// Get the entry from the $event var
$entry = $event->entry;

if ($event->entry ?? false) {
// Check for a Content Guide for this entry
$total = Guide::$plugin->guide->getUserGuides([
'sectionId' => $entry->sectionId,
'typeId' => $entry->sectionId,
], 'count');

// If no guide exists, disable the widget
if ($total < 1) {
$this->adminBarWidgets[0]['enabled'] = false;
if (class_exists(Bar::class)) {
Event::on(Bar::class, Bar::EVENT_ADMIN_BAR_BEFORE_RENDER, function(AdminBarRenderEvent $event) {
// Get the entry from the $event var
$entry = $event->entry;

if ($entry) {
// Check for a Content Guide for this entry
$total = Guide::$plugin->guide->getUserGuides([
'sectionId' => $entry->sectionId,
'typeId' => $entry->sectionId,
], 'count');

// If no guide exists, disable the widget
if ($total < 1) {
$this->adminBarWidgets[0]['enabled'] = false;
}
}
}
});
});
}
```

If the widget needs the page to be fully rendered before validating it, the `adminBarRemoveWidget` Javascript function can be used after doing some client-side validation. This requires that the widget's `id` be passed in to remove the widget.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -2,7 +2,7 @@
"name": "wbrowar/adminbar",
"description": "Front-end shortcuts for clients logged into Craft CMS.",
"type": "craft-plugin",
"version": "3.1.4",
"version": "3.1.5",
"keywords": [
"craft",
"cms",
Expand Down
2 changes: 1 addition & 1 deletion src/assetbundles/adminbar/dist/css/AdminBar.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/assetbundles/adminbar/dist/css/bar.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/assetbundles/adminbar/dist/css/editlinks.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f6d3a5b

Please sign in to comment.