删除Wordpress管理栏徽标上的链接

问题描述 投票:1回答:2

我设法用我的functions.php文件中的自定义图标替换了管理栏中的Wordpress图标/徽标,并删除了链接到Wordpress文档,支持论坛,反馈等的下拉菜单。我正在尝试要做的是禁用徽标上的链接,该链接会将您带到管理员的“关于Wordpress”页面,该页面解释了您当前正在运行的版本的功能。

我想在functions.php文件中执行此操作。这可能吗?

这是我到目前为止使用的代码:

    // Replace Wordpress logo with custom Logo
function my_custom_logo() {
    echo '
    <style type="text/css">
    #wp-admin-bar-wp-logo > .ab-item .ab-icon:before {
        background-position: 0 0;
        content: url(' . get_bloginfo('stylesheet_directory') . '/assets/img/my-logo.png)!important;
        top: 2px;
        display: block;
        width: 15px;
        height: 20px;
        pointer-events: none!important;
        cursor: default;
    }
    #wp-admin-bar-wp-logo.hover > .ab-item .ab-icon {
        background-position: 0 0;
    }
     </style>
    ';
}
add_action('admin_head', 'my_custom_logo');
add_action('wp_head', 'my_custom_logo');

//disable a few items on the admin bar
function remove_admin_bar_links() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('new-content');      // Remove the 'add new' button
$wp_admin_bar->remove_menu('comments');         // Remove the comments bubble
$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
}
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );
php wordpress admin graphical-logo
2个回答
1
投票
也许您应该只覆盖CSS,然后用您自己的图像替换它,这样功能才能保持原样!

这是原始CSS:


0
投票
我前一段时间有这个问题。最简单的解决方案不是使用CSS,而是使用从管理栏中删除该菜单项的功能。然后,只需添加带有徽标图像的新菜单项即可。我会这样做,而不是用css将图标替换为您的徽标。
© www.soinside.com 2019 - 2024. All rights reserved.