Skip to content

Commit

Permalink
Fix double indicators showing under Payments tab (#7201)
Browse files Browse the repository at this point in the history
  • Loading branch information
oaratovskyi authored Sep 16, 2023
1 parent 6ba6fab commit 3695514
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions changelog/fix-7042-double-payments-badge
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix double indicators showing under Payments tab
7 changes: 5 additions & 2 deletions includes/admin/class-wc-payments-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -954,9 +954,12 @@ public function add_menu_notification_badge() {
return;
}

$badge = self::MENU_NOTIFICATION_BADGE;
foreach ( $menu as $index => $menu_item ) {
if ( 'wc-admin&path=/payments/connect' === $menu_item[2] ) {
$menu[ $index ][0] .= self::MENU_NOTIFICATION_BADGE; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
if ( false === strpos( $menu_item[0], $badge ) && ( 'wc-admin&path=/payments/connect' === $menu_item[2] ) ) {
$menu[ $index ][0] .= $badge; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited

// One menu item with a badge is more than enough.
break;
}
}
Expand Down
7 changes: 5 additions & 2 deletions includes/class-wc-payments-incentives-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ public function add_payments_menu_badge(): void {
return;
}

$badge = WC_Payments_Admin::MENU_NOTIFICATION_BADGE;
foreach ( $menu as $index => $menu_item ) {
if ( 'wc-admin&path=/payments/connect' === $menu_item[2] ) {
$menu[ $index ][0] .= WC_Payments_Admin::MENU_NOTIFICATION_BADGE; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
if ( false === strpos( $menu_item[0], $badge ) && ( 'wc-admin&path=/payments/connect' === $menu_item[2] ) ) {
$menu[ $index ][0] .= $badge; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited

// One menu item with a badge is more than enough.
break;
}
}
Expand Down

0 comments on commit 3695514

Please sign in to comment.