I have been using the Discourage Search Engines Notifier WordPress plugin on a lot of sites.
I wanted to extend it, so that is what I did.
I went to ChatGPT and asked for the following:
- Show an eye icon to the top black admin bar. Green for a search engine allowed or red for discouraged.
- Change the admin color scheme for the currently logged-in user:
- blue when discourage search engines is ON (red eye)
- fresh (default) when discourage is OFF (green eye)
- Add a standard WordPress snackbar mention with a note saying: “
⚠️ This is a staging site — search engines are discouraged.
“
Below one can see the eye in the top is red and the color scheme is light blue. There is also a WP snackbar notification.

The PHP Code snippet result.
// 1. Add eye icon in admin bar with red/green color
add_action('admin_bar_menu', function ($wp_admin_bar) {
if (!current_user_can('manage_options')) {
return;
}
$discouraged = get_option('blog_public') === '0';
$class = $discouraged ? 'seo-discouraged' : 'seo-allowed';
$title = $discouraged
? 'Search engines are discouraged from indexing this site.'
: 'Search engines are allowed to index this site.';
$wp_admin_bar->add_node([
'id' => 'se-visibility',
'title' => '<span class="ab-icon dashicons dashicons-visibility"></span>',
'href' => admin_url('options-reading.php'),
'meta' => [
'title' => $title,
'class' => $class,
],
]);
}, 100);
// 2. Load Dashicons on frontend and admin
add_action('wp_enqueue_scripts', function () {
if (is_user_logged_in() && is_admin_bar_showing()) {
wp_enqueue_style('dashicons');
}
}, 1);
add_action('admin_enqueue_scripts', function () {
wp_enqueue_style('dashicons');
});
// 3. Output CSS for icon colors
add_action('wp_head', 'se_visibility_icon_styles', 1);
add_action('admin_head', 'se_visibility_icon_styles', 1);
function se_visibility_icon_styles() {
?>
<style>
/* Icon colors */
#wpadminbar #wp-admin-bar-se-visibility.seo-discouraged .ab-icon:before {
color: #dc3232 !important; /* red */
}
#wpadminbar #wp-admin-bar-se-visibility.seo-allowed .ab-icon:before {
color: #46b450 !important; /* green */
}
#wpadminbar #wp-admin-bar-se-visibility .ab-icon {
font: normal 20px/1 'dashicons';
display: inline-block;
}
</style>
<?php
}
// 4. Show persistent top admin notice for discourage ON, dismissible by user
add_action('admin_notices', function() {
if (!current_user_can('manage_options')) {
return;
}
if (get_option('blog_public') !== '0') {
return;
}
?>
<div class="notice notice-warning is-dismissible" style="position:relative;">
<p><strong>⚠️ This is a staging site — search engines are discouraged.</strong></p>
</div>
<?php
});
// 5. Change admin color scheme for current logged-in user based on discourage setting
add_action('admin_init', function() {
if (!is_user_logged_in()) {
return;
}
$user_id = get_current_user_id();
$discouraged = get_option('blog_public') === '0';
$desired_color = $discouraged ? 'blue' : 'fresh';
$current_color = get_user_meta($user_id, 'admin_color', true);
if ($current_color !== $desired_color) {
update_user_meta($user_id, 'admin_color', $desired_color);
}
});