Plugin zur Veränderung der Admin-Toolbar:
- Das WordPress-Logo, das Profil-Menü und die reguläre Suchfunktion im Frontend werden entfernt
- Eine Suchfunktion im Frontend und Backend, ein „Abmelden“-Link und ein „Profil bearbeiten“-Link unter „Meine Seiten“ werden hinzugefügt
<?php
/*
Plugin Name: Custom Adminbar
Plugin URI: https://wpdoc.de/?p=214
Description: Benutzerdefinierte Adminbar mit Abmelde-Link und Suche im Backend.
Author: Johannes Ries
Author URI: http://johannesries.de
Version: 1.0
*/
function custom_admin_bar() {
$form = '<form action="' .esc_url( admin_url('edit.php') ). '" method="get" id="adminbarsearch">';
$form .= '<input name="s" tabindex="1" type="text" value="" maxlength="54" />';
$form .= '<input type="submit" value="' .__('Search'). '"/>';
$form .= '</form>';
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
$wp_admin_bar->remove_menu('my-account');
$wp_admin_bar->remove_menu('search');
$wp_admin_bar->add_menu( array(
'id' => 'wp-custom-edit-profile',
'title' => 'Mein Profil bearbeiten',
'parent'=>'my-sites',
'href' => self_admin_url('profile.php'),
'meta' => array('title' => 'Passwort, E-Mail-Adresse und weitere Details ändern')
));
$wp_admin_bar->add_node( array(
'parent' => 'top-secondary',
'id' => 'custom-logout',
'title' => 'Abmelden',
'href' => wp_logout_url(),
'meta' => array('title' => 'Abmelden')
) );
$wp_admin_bar->add_menu(
array(
'parent' => 'top-secondary',
'id' => 'custom-search',
'title' => $form,
'meta' => array('class' => 'admin-bar-search')
)
);
}
add_action(
'plugins_loaded',
function () {
if ( is_admin_bar_showing() ) {
add_action('wp_before_admin_bar_render','custom_admin_bar');
}
}
);
?>
- Codex: WP_Admin_Bar