Created
June 6, 2026 08:24
-
-
Save adeel-raza/24a67e35512a998931e069c06ee85bcd to your computer and use it in GitHub Desktop.
WordPress staging site admin bar indicator — orange background + staging label
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
| // Enqueue custom CSS for the admin bar if on a staging site | |
| function eevolve_custom_admin_bar_css() { | |
| if ( strpos( get_site_url(), 'staging' ) !== false ) { | |
| wp_register_style( 'eevolve-admin-bar-css', false ); | |
| wp_enqueue_style( 'eevolve-admin-bar-css' ); | |
| wp_add_inline_style( | |
| 'eevolve-admin-bar-css', | |
| ' | |
| #wpadminbar { background-color: #cc8400; } | |
| #wp-admin-bar-woocommerce-site-visibility-badge { display: none; } | |
| ' | |
| ); | |
| } | |
| } | |
| add_action( 'admin_enqueue_scripts', 'eevolve_custom_admin_bar_css' ); | |
| add_action( 'wp_enqueue_scripts', 'eevolve_custom_admin_bar_css' ); | |
| // Add "Staging" label to the admin bar | |
| function eevolve_add_staging_label( $wp_admin_bar ) { | |
| if ( strpos( get_site_url(), 'staging' ) !== false ) { | |
| $wp_admin_bar->add_node( | |
| array( | |
| 'id' => 'staging_label', | |
| 'title' => 'Reminder: This is the Staging Site', | |
| 'href' => '#', | |
| 'meta' => array( | |
| 'title' => 'This is a staging site', | |
| 'class' => 'staging-label', | |
| ), | |
| ) | |
| ); | |
| } | |
| } | |
| add_action( 'admin_bar_menu', 'eevolve_add_staging_label', 999 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment