Created
August 7, 2026 17:29
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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