Skip to content

Instantly share code, notes, and snippets.

@RiaanKnoetze
Created September 13, 2024 15:24
Show Gist options
  • Save RiaanKnoetze/5193516e172554b8871236351e666cf1 to your computer and use it in GitHub Desktop.
Save RiaanKnoetze/5193516e172554b8871236351e666cf1 to your computer and use it in GitHub Desktop.
Remove the site visibility badges (e.g. "Coming soon", "Store coming soon", and "Live") introduced by WooCommerce in version 9.1
<?php
add_action( 'admin_bar_menu', function( $wp_admin_bar ) {
if ( is_object( $wp_admin_bar ) && $wp_admin_bar->get_node( 'woocommerce-site-visibility-badge' ) ) {
$wp_admin_bar->remove_node( 'woocommerce-site-visibility-badge' );
}
}, 100 );
@shameemreza
Copy link

Nice, the insights you've shared are quite valuable. Indeed, the modern remove_node approach you've suggested is more efficient than the one I've shared.

@Peter-HVD
Copy link

@sybrew - thanks, but you've got a rogue comma after the 100 in that snippet.

@sybrew
Copy link

sybrew commented Sep 16, 2024

@Peter-HVD It's recommended behavior to reduce redundant line changes in Git and SVN. It's allowed since PHP 7.3 (2018) -- see https://wiki.php.net/rfc/trailing-comma-function-calls#:~:text=Status%3A%20Implemented%20(in%20PHP%207.3).

@Peter-HVD
Copy link

@Peter-HVD It's recommended behavior to reduce redundant line changes in Git and SVN. It's allowed since PHP 7.3 (2018) -- see https://wiki.php.net/rfc/trailing-comma-function-calls#:~:text=Status%3A%20Implemented%20(in%20PHP%207.3).

I did not know that - my IDE flags it as an error, and I've been battling with writing JSON files recently and they definitely doesn't like an extra comma, so I was in that headspace. Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment