#wp-admin-bar-wp-logo { display: none !important; }';
echo '';
});
add_action('wp_head', function() {
echo '';
echo '';
});
}
// Hide for frontend if enabled
if (get_option('atvm_disable_frontend', 'off') === 'on') {
add_filter('show_admin_bar', '__return_false');
return;
}
// Hide for all users if enabled
if (get_option('atvm_hide_all_users', 'off') === 'on') {
add_filter('show_admin_bar', '__return_false');
return;
}
// Hide for guests if enabled
if (!is_user_logged_in() && get_option('atvm_hide_all_guests', 'off') === 'on') {
add_filter('show_admin_bar', '__return_false');
return;
}
// Hide for specific roles
if (is_admin() && is_user_logged_in()) {
$roles = ['subscriber', 'contributor', 'author', 'editor', 'administrator'];
foreach ($roles as $role) {
if (current_user_can($role)) {
if (get_option("atvm_hide_toolbar_{$role}", 'off') === 'on') {
add_filter('show_admin_bar', '__return_false');
break;
}
}
}
}
}
// Customize admin bar appearance
add_action('admin_bar_menu', 'atvm_customize_admin_bar', 11);
function atvm_customize_admin_bar($wp_admin_bar)
{
// Replace WordPress logo
$custom_logo = get_option('atvm_custom_logo');
$custom_logo_url = get_option('atvm_custom_logo_url', home_url());
if ($custom_logo) {
// First remove all possible default logo nodes
$wp_admin_bar->remove_node('wp-logo');
$wp_admin_bar->remove_node('wp-admin-bar-wp-logo');
// Add custom logo
$wp_admin_bar->add_node(array(
'id' => 'custom-logo',
'title' => '
',
'href' => esc_url($custom_logo_url),
'parent' => false, // Top level item
'meta' => array(
'title' => get_bloginfo('name'),
'class' => 'custom-admin-bar-logo'
)
));
}
}
// Add custom CSS to admin bar
add_action('wp_head', 'atvm_admin_bar_styles');
add_action('admin_head', 'atvm_admin_bar_styles');
function atvm_admin_bar_styles()
{
if (!is_admin_bar_showing()) return;
$css = '';
// Position
$position = get_option('atvm_adminbar_position', 'top');
if ($position === 'bottom') {
$css .= '#wpadminbar { top: auto !important; bottom: 0; }';
$css .= 'html { margin-top: 0 !important; margin-bottom: 32px !important; }';
$css .= '@media screen and (max-width: 782px) { html { margin-bottom: 46px !important; } }';
}
// Background
$bg_type = get_option('atvm_bg_type', 'color');
$bg_color = get_option('atvm_bg_color', '#1d2327');
if ($bg_type === 'color') {
$css .= '#wpadminbar { background: ' . $bg_color . ' !important; }';
} else {
// Gradient would be handled here
}
// Text color
$text_color = get_option('atvm_text_color', '#f0f0f1');
$css .= '#wpadminbar .ab-item .ab-label, #wp-admin-bar-site-name .ab-item::before, #wpadminbar .ab-empty-item, #wpadminbar a.ab-item, #wpadminbar > #wp-toolbar > #wp-admin-bar-root-default .ab-icon:before { color: ' . $text_color . ' !important; }';
// Dropdown style
$dropdown_style = get_option('atvm_dropdown_style', 'default');
if ($dropdown_style === 'modern') {
$css .= '#wpadminbar .ab-submenu { background: rgba(0,0,0,0.8) !important; border-radius: 4px !important; }';
$css .= '#wpadminbar .ab-submenu .ab-item { color: #f0f0f1 !important; padding: 8px 10px !important; }';
}
// New button color
$new_btn_color = get_option('atvm_new_button_color', '#72aee6');
$css .= '#wpadminbar .ab-top-menu > li.menupop > .ab-item:after, #wpadminbar .ab-top-menu > li > .ab-item:after { border-top-color: ' . $new_btn_color . ' !important; }';
$css .= '#wp-admin-bar-root-default #wp-admin-bar-new-content .ab-item .ab-icon:before { color: ' . $new_btn_color . ' !important; }';
$css .= '#wp-admin-bar-root-default #wp-admin-bar-new-content .ab-item .ab-label { color: ' . $new_btn_color . ' !important; }';
if (!empty($css)) {
echo '';
}
}