Skip to content

Instantly share code, notes, and snippets.

@bacoords
Created August 7, 2026 17:29
Show Gist options
  • Select an option

  • Save bacoords/2565e6728e3c1f48623b69ddee1ce54b to your computer and use it in GitHub Desktop.

Select an option

Save bacoords/2565e6728e3c1f48623b69ddee1ce54b to your computer and use it in GitHub Desktop.
Update the live/coming soon badge on Woo to reflect local/staging modes.
<?php
add_action(
'admin_bar_menu',
function ( $wp_admin_bar ) {
$environment = wp_get_environment_type();
if ( ! in_array( $environment, array( 'local', 'staging' ), true ) ) {
return;
}
$node = $wp_admin_bar->get_node(
'woocommerce-site-visibility-badge'
);
if ( ! $node ) {
return;
}
$node->title = ucfirst( $environment );
$node->meta['class'] = 'woocommerce-site-status-badge-' . sanitize_html_class( $environment );
$wp_admin_bar->add_node( (array) $node );
},
100
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment