相關類:WP_Admin_Bar
Class: Core class used to implement the Toolbar API.核心類:用於執行工具欄API
global $wp_admin_bar;
WP_Admin_Bar::add_menu
add_action( 『admin_bar_menu』, 『modify_admin_bar』 );
function modify_admin_bar( $wp_admin_bar ){
// do something with $wp_admin_bar;
}
相關插件
- Hide Admin Bar
- Auto Hide Admin Bar
- Hide Admin Bar from Non-Admins
- Admin Bar & Dashboard Access Control
- Hide Admin Bar From Front End
- Always Show Admin Bar
- WP Admin Bar Control
舉例
例1:
add_action( 『admin_bar_menu』, 『modify_admin_bar』 );
function modify_admin_bar( $wp_admin_bar ){
// do something with $wp_admin_bar;
}
例2:Disable Admin Bar for All Users Except for Administrators關閉,所有用戶 除了管理員。
Paste this code in your theme』s functions.php file or your site-specific plugin.
add_action(『after_setup_theme』, 『remove_admin_bar』);
function remove_admin_bar() {
if (!current_user_can(『administrator』) && !is_admin()) {
show_admin_bar(false);
}
}
Disable Admin Bar for All Users
If you want to disable it for all users, then simply put use this code in your theme』s functions.php file or your site-specific plugin.
/* Disable WordPress Admin Bar for all users but admins. */
show_admin_bar(false);
相關函數
show_admin_bar:https://developer.wordpress.org/reference/functions/show_admin_bar/
舉例:
show_admin_bar( false );
說明:Placing the below line of code in theme』s function.php file will prevent the Toolbar from rendering on the front end of your site.
參考閱讀
10+關於WORDPRESS頂部工具欄(ADMINBAR)的小技巧
wordpress除去頂部煩人的工具條(admin bar)
How to Disable WordPress Admin Bar for All Users Except Administrators
發表評論
要發表評論,您必須先登錄。