[WordPress] 外掛分享: Notifications

首頁外掛目錄 › Notifications
WordPress 外掛 Notifications 的封面圖片
30+
安裝啟用
★★★★★
5/5 分(2 則評價)
4304 天前
最後更新
問題解決
WordPress 3.0+ v1.1.3 上架:2013-02-03

內容簡介

你是否曾經需要在網站上顯示通知?如果問我,那一定是太多次了。我寫這個外掛是因為目前市面上的通知欄插件要麼選項太多,要麼選項太少,要麼沒有我需要的選項。而且,創建一個通知並不容易,你必須前往某個奇怪的頁面並設置該插件獨有的選項。

這個外掛使用自訂文章類型,因此通知像我們所知道和喜愛的迷你文章那樣設置。多個控制選項以及內置過濾器使開發者和普通用戶都可以輕鬆自定義通知欄。

更新:此外掛現在支援Theme Hook Alliance tha_body_top 動作。如果你在你的子佈景主題中使用了 body_open 動作,請將其更改為 tha_body_top,例如:

do_action( 'tha_body_top' );

使用方法

通知欄尋找 body_open 勾子。這個勾子最初是由Andrew Nacin在 Trac 上提出的一個方式,可以鉤入在代碼中 <body> 標籤之後立即觸發的動作。

想要過濾輸出以自定義通知的顯示方式嗎?在你的外掛程式或佈景主題中使用 notf_notification_filter 過濾器,像這樣:

function my_test_filter( $output ) {
$output = '<span class="whoops-i-did-it-again" style="color: red;">'.notf_message().'</span>';
return $output;
}
add_filter( 'notf_notification_filter', 'my_test_filter' );

重要提示:在你的過濾器中使用 notf_message 函數返回實際通知。

開發者團隊

⬇ 下載最新版 (v1.1.3) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Notifications」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

How many times have you needed to display a notice across your site? Too many, if you ask me. I wrote this plugin because many of the notification bar plugins out there leave much to be desired. Either there are too many options or not enough or not the ones that I want. Plus, it’s not easy to create a notice — you have to go to some crazy screen and set options unique to that plugin.
This plugin uses custom post types, so notifications are set up like mini-posts that we all know and love. Multiple controls, as well as a built-in filter, enable developers and casual users alike to easily customize the notification bar to your heart’s content.
Update: This plugin now supports the Theme Hook Alliance tha_body_top action. If you are using the body_open action in your child theme, please change this to tha_body_top, e.g.
do_action( 'tha_body_top' );

Usage
Notifications looks for the body_open hook. This hook was first proposed on Trac by Andrew Nacin as a way to hook into an action that fires immediately after the tag in the code.
Want to filter the output to customize how the notification gets displayed? Use the notf_notification_filter filter in your plugin or theme, like this:
function my_test_filter( $output ) {
$output = ''.notf_message().'';
return $output;
}
add_filter( 'notf_notification_filter', 'my_test_filter' );

Important: Use the notf_message function in your filter to return the actual notification.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon