內容簡介
Admin Notice 是一個非常簡單的外掛,允許你在 WordPress 後台顯示自定義公告,對所有使用者都可見。
你可以從外掛的設定頁面控制公告文字和樣式。
開發人員可以使用 admin_notice_enable hook 更精確地控制公告的可見性。以下示例演示如何僅在後台的「文章」區域中顯示公告。
add_filter('admin_notice_enable', function($enabled) {
$screen = get_current_screen();
if (isset($screen->post_type) && $screen->post_type !== 'post') {
$enabled = false;
}
return $enabled;
}, 10, 1);
外掛標籤
開發者團隊
原文外掛簡介
Admin Notice is a very simple plugin that allows you to display custom notices in the WordPress admin that is visible to all users.
Control over the notice text and styling is available from the plugin’s settings page.
Developers can use the admin_notice_enable hook to control the notice’s visibility on a more granular level. The following example demonstrates how to show the notice only in the “Posts” area of the admin.
add_filter('admin_notice_enable', function($enabled) {
$screen = get_current_screen();
if (isset($screen->post_type) && $screen->post_type !== 'post') {
$enabled = false;
}
return $enabled;
}, 10, 1);
