-
Notifications
You must be signed in to change notification settings - Fork 22
Display notification badge in the admin menu when there are recommendations #3001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/GOOWOO-172-pmax-assets-improvements
Are you sure you want to change the base?
Display notification badge in the admin menu when there are recommendations #3001
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature/GOOWOO-172-pmax-assets-improvements #3001 +/- ##
================================================================================
- Coverage 66.4% 66.0% -0.4%
- Complexity 0 4849 +4849
================================================================================
Files 335 835 +500
Lines 5194 25894 +20700
Branches 1269 1291 +22
================================================================================
+ Hits 3449 17093 +13644
- Misses 1592 8647 +7055
- Partials 153 154 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Left some initial feedbacks
src/Menu/NotificationManager.php
Outdated
); | ||
|
||
$page_controller_pages = PageController::get_instance()->get_pages(); | ||
$marketing_menu_slug = 'woocommerce-marketing'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$marketing_menu_slug = 'woocommerce-marketing'; | |
$marketing_menu_slug = Dashboard::MARKETING_MENU_SLUG; |
src/Menu/NotificationManager.php
Outdated
|
||
$marketing_menu_pages = array_filter( | ||
$page_controller_pages, | ||
function ( $page ) use ( $marketing_menu_slug ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function ( $page ) use ( $marketing_menu_slug ) { | |
static function ( $page ) use ( $marketing_menu_slug ) { |
Use static
that improve performance.
src/Menu/NotificationManager.php
Outdated
const subMenu = document.querySelector('[href="admin.php?page=wc-admin&path=%2Fgoogle%2Fdashboard"]'); | ||
|
||
if (subMenu && !subMenu.contains(badge)) { | ||
// Ensure there is white space betweem the bade and menu title for visual consistency. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Ensure there is white space betweem the bade and menu title for visual consistency. | |
// Ensure there is white space between the badge and menu title for visual consistency. |
src/Menu/NotificationManager.php
Outdated
subMenu.textContent.trimEnd(); | ||
subMenu.textContent += ' '; | ||
|
||
// Move the bade to the correct location. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Move the bade to the correct location. | |
// Move the badge to the correct location. |
src/Menu/NotificationManager.php
Outdated
} | ||
} else { | ||
if (topMenu && !topMenu.contains(badge)) { | ||
// Ensure there is white space betweem the bade and menu title for visual consistency. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Ensure there is white space betweem the bade and menu title for visual consistency. | |
// Ensure there is white space between the badge and menu title for visual consistency. |
src/Menu/NotificationManager.php
Outdated
topMenu.textContent.trimEnd(); | ||
topMenu.textContent += ' '; | ||
|
||
// Move the bade to the correct location. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Move the bade to the correct location. | |
// Move the badge to the correct location. |
Changes proposed in this Pull Request:
Closes https://linear.app/a8c/issue/GOOWOO-182/display-notification-badge-in-the-admin-menu-when-there-are
google_for_woocommerce_admin_menu_notification_count
filter.Screenshots:
Marketing menu with notification badge.

Marketing sub-menu with notification badge.

Detailed test instructions:
google_for_woocommerce_admin_menu_notification_count
filter returns0
. This is the default behaviour.add_filter('google_for_woocommerce_admin_menu_notification_count', function() { return 1; }
7. When the Marketing menu is collapsed, the badge appears on the Marketing menu item.
8. When the Marketing menu is expanded, the badge appears on the Google for WooCommerce sub menu item.
Additional details:
Changelog entry