Betriebssysteme, Programme & Web

Links aus der WordPress Admin Bar entfernen

In der Admin Bar von WordPress findet man einige Links und Informationen, welche man gar nicht unbedingt benötigt.

WordPress Admin Bar
WordPress Admin Bar

Um die Informationen in der Admin Bar zu reduzieren, behelfen wir uns wieder einem kleinen Snippet, welches ich euch auch als Toolbox-Modul zur Verfügung stelle.

Admin Bar für alle Benutzer bearbeiten

Mit diesem Snippet bzw. Toolbox-Modul entfernt ihr die Links und Informationen für alle Benutzer eurer Seite. Ihr könnt den Code natürlich anpassen und somit beispielsweise die Updates und Kommentare stehen lassen.

Snippet für die functions.php eures Themes

function remove_admin_bar_links() {
 global $wp_admin_bar;
 $wp_admin_bar->remove_menu('wp-logo');   // Remove the WordPress logo
 $wp_admin_bar->remove_menu('about');   // Remove the about WordPress link
 $wp_admin_bar->remove_menu('wporg');   // Remove the WordPress.org link
 $wp_admin_bar->remove_menu('documentation'); // Remove the WordPress documentation link
 $wp_admin_bar->remove_menu('support-forums'); // Remove the support forums link
 $wp_admin_bar->remove_menu('feedback');   // Remove the feedback link
 $wp_admin_bar->remove_menu('site-name');  // Remove the site name menu
 $wp_admin_bar->remove_menu('view-site');  // Remove the view site link
 $wp_admin_bar->remove_menu('updates');   // Remove the updates link
 $wp_admin_bar->remove_menu('comments');   // Remove the comments link
 $wp_admin_bar->remove_menu('new-content');  // Remove the content link
 $wp_admin_bar->remove_menu('w3tc');    // If you use w3 total cache remove the performance link
 $wp_admin_bar->remove_menu('my-account');  // Remove the user details tab
}
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );

 Toolbox-Modul (als PHP-Datei speichern)

<?php
/*
Module Name: Adminbar-Links
Description: Links aus der Adminbar entfernen [Backend|Frontend]
Author: Simon Lüthje
Author URI: https://basic-tutorials.de
*/

/* Sicherheitsabfrage */
if ( !class_exists('Toolbox') ) {
 die();
}

/* Ab hier kann's los gehen */
function remove_admin_bar_links() {
 global $wp_admin_bar;
 $wp_admin_bar->remove_menu('wp-logo');   // Remove the WordPress logo
 $wp_admin_bar->remove_menu('about');   // Remove the about WordPress link
 $wp_admin_bar->remove_menu('wporg');   // Remove the WordPress.org link
 $wp_admin_bar->remove_menu('documentation'); // Remove the WordPress documentation link
 $wp_admin_bar->remove_menu('support-forums'); // Remove the support forums link
 $wp_admin_bar->remove_menu('feedback');   // Remove the feedback link
 $wp_admin_bar->remove_menu('site-name');  // Remove the site name menu
 $wp_admin_bar->remove_menu('view-site');  // Remove the view site link
 $wp_admin_bar->remove_menu('updates');   // Remove the updates link
 $wp_admin_bar->remove_menu('comments');   // Remove the comments link
 $wp_admin_bar->remove_menu('new-content');  // Remove the content link
 $wp_admin_bar->remove_menu('w3tc');    // If you use w3 total cache remove the performance link
 $wp_admin_bar->remove_menu('my-account');  // Remove the user details tab
}
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );

Admin Bar für alle Benutzer außer den Administrator bearbeiten

Mit diesem Code wird die Admin Bar für alle Benutzer außer den Benutzer mit der Benutzer-ID 1 geändert. Das ist in der Regel der Administrator und Inhaber des WordPress Blogs. Wenn ihr aus Sicherheitsgründen die ID geändert habt, müsst ihr diese auch in dem Code anpassen.

Snippet für die functions.php eures Themes

function remove_admin_bar_links() {
 global $wp_admin_bar, $current_user;
 if ($current_user->ID != 1) {
 $wp_admin_bar->remove_menu('wp-logo');   // Remove the WordPress logo
 $wp_admin_bar->remove_menu('about');   // Remove the about WordPress link
 $wp_admin_bar->remove_menu('wporg');   // Remove the WordPress.org link
 $wp_admin_bar->remove_menu('documentation'); // Remove the WordPress documentation link
 $wp_admin_bar->remove_menu('support-forums'); // Remove the support forums link
 $wp_admin_bar->remove_menu('feedback');   // Remove the feedback link
 $wp_admin_bar->remove_menu('site-name');  // Remove the site name menu
 $wp_admin_bar->remove_menu('view-site');  // Remove the view site link
 $wp_admin_bar->remove_menu('updates');   // Remove the updates link
 $wp_admin_bar->remove_menu('comments');   // Remove the comments link
 $wp_admin_bar->remove_menu('new-content');  // Remove the content link
 $wp_admin_bar->remove_menu('w3tc');    // If you use w3 total cache remove the performance link
 $wp_admin_bar->remove_menu('my-account');  // Remove the user details tab
 }
}
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );

 Toolbox-Modul (als PHP-Datei speichern)

<?php
/*
Module Name: Adminbar-Links
Description: Links aus der Adminbar entfernen (nicht für UserID 1) [Backend|Frontend]
Author: Simon Lüthje
Author URI: https://basic-tutorials.de
*/

/* Sicherheitsabfrage */
if ( !class_exists('Toolbox') ) {
 die();
}

/* Ab hier kann's los gehen */
function remove_admin_bar_links() {
 global $wp_admin_bar, $current_user;
 if ($current_user->ID != 1) {
 $wp_admin_bar->remove_menu('wp-logo');   // Remove the WordPress logo
 $wp_admin_bar->remove_menu('about');   // Remove the about WordPress link
 $wp_admin_bar->remove_menu('wporg');   // Remove the WordPress.org link
 $wp_admin_bar->remove_menu('documentation'); // Remove the WordPress documentation link
 $wp_admin_bar->remove_menu('support-forums'); // Remove the support forums link
 $wp_admin_bar->remove_menu('feedback');   // Remove the feedback link
 $wp_admin_bar->remove_menu('site-name');  // Remove the site name menu
 $wp_admin_bar->remove_menu('view-site');  // Remove the view site link
 $wp_admin_bar->remove_menu('updates');   // Remove the updates link
 $wp_admin_bar->remove_menu('comments');   // Remove the comments link
 $wp_admin_bar->remove_menu('new-content');  // Remove the content link
 $wp_admin_bar->remove_menu('w3tc');    // If you use w3 total cache remove the performance link
 $wp_admin_bar->remove_menu('my-account');  // Remove the user details tab
 }
}
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );

 

Viel Spaß beim Aufräumen eurer Admin Bar, was entfernt ihr denn alles?

Simon Lüthje

Ich bin der Gründer dieses Blogs und interessiere mich für alles was mit Technik zu tun hat, bin jedoch auch dem Zocken nicht abgeneigt. Geboren wurde ich in Hamburg, wohne nun jedoch in Bad Segeberg.

Ähnliche Artikel

Schreibe einen Kommentar

Schaltfläche "Zurück zum Anfang"