[WordPress] 外掛分享: AsynCRONous bbPress Subscriptions

前言介紹

  • 這款 WordPress 外掛「AsynCRONous bbPress Subscriptions」是 2015-03-10 上架。
  • 目前有 100 個安裝啟用數。
  • 上一次更新是 2020-07-06,距離現在已有 1763 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.6 以上版本才可以安裝。
  • 有 8 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

mechter |

外掛標籤

cron | email | bbPress | subscription | Notifications |

內容簡介

預設情況下,bbPress 會透過一封包含大量 BCC 的郵件發送訂閱通知電子郵件。有諸多原因可以說明發送獨立郵件會更為合理。此外,此外掛會在 WP 計劃序列背景中安靜地執行,不會減慢頁面載入時間。此外,它還可以提高通知性能,減少大型網站的資料庫負載。

@mauriciogarofalo 和 @mechter 的翻譯

預設值

如果您沒有自訂此外掛,以下是您將會得到的預設值:

以 "MyBlog " 的名義發送郵件 (包含您的 Blog 名稱和管理員電子郵件)
發送郵件至 "Markus " (名稱為用戶在論壇上的顯示名稱,而不是他們的用戶名)
標題和內容具有更友好的預設值,使用可用的篩選器(請參閱下文)將其變成自己的。

自訂方式

您可以安裝和啟用此外掛,然後就可以使用了,但如果您希望獲得更多控制,以下是一些篩選器和代碼片段可供使用。 如果您尚未直接使用過程式碼,請參閱本頁底部的範例。

可用篩選器
bbp_subscription_email_from( $from ) // $from 可以是一個字串或陣列('name'=>string, 'address'=>string)
bbp_subscription_email_recipients( $recipients ) // $recipients 是陣列的陣列('name'=>string, 'address'=>string)
bbp_subscription_email_headers( $headers )
bbp_forum_subscription_email_subject( $subject, $forum_id, $topic_id )
bbp_forum_subscription_email_message( $message, $forum_id, $topic_id )
bbp_topic_subscription_email_subject( $subject, $forum_id, $topic_id, $reply_id )
bbp_topic_subscription_email_message( $message, $forum_id, $topic_id, $reply_id )

bbp_bounce_address( $bounce_address )

bbp_subscription_disable_async( false )
bbp_forum_subscription_disable_async( false )
bbp_topic_subscription_disable_async( false )
bbp_forum_subscription_notify_author( false )
bbp_topic_subscription_notify_author( false )

幫助程式碼片段

以下是一些提供通知所需數據的程式碼片段:

$blog_name = get_bloginfo( 'name' );

$forum_title = bbp_get_forum_title( $forum_id );

$topic_author_user_id = bbp_get_topic_author_id( $topic_id );
$topic_author_display_name = bbp_get_topic_author_display_name( $topic_id );
$topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES );
$topic_content = wp_specialchars_decode( strip_tags( bbp_get_topic_content( $topic_id ) ), ENT_QUOTES );
$topic_url = get_permalink( $topic_id );

$reply_author_user_id = bbp_get_reply_author_id( $reply_id );
$reply_author_display_name = bbp_get_topic_author_display_name( $reply_id );
$reply_content = strip_tags( bbp_get_reply_content( $reply_id ) );
$reply_url = bbp_get_reply_url( $reply_id ); // 請注意它不是使用 get_permalink() ,而是 bbp_get_reply_url()

範例

以下是一個範例,讓您新的主題通知郵件有一個好的標題。將以下內容添加到主題的functions.php 文件中。如果您的主題不具備此文件,您可以簡單地創建它,系統會自動載入。 請注意範例基本上只是上面的某個篩選器,再加上一些片段和返回語句。很簡單。

add_filter( 'bbp_forum_subscription_email_subject', function( $subject, $forum_id, $topic_id ) {
$blog_name = get_bloginfo( 'name' );
$topic_author_display_name = bbp_get_topic_author_display_name( $topic_id );
$topic_title = wp_spec

原文外掛簡介

Per default, bbPress is sending subscription notification emails as one email with a bunch of BCCs. There are various reasons why it would make more sense to send individual emails. This plugin does that, quietly in the background via WP cron, without slowing down page load times. Also increases notification performance and reduces database load on large sites.
Translations by @mauriciogarofalo and @mechter
Defaults
If you don’t customize this plugin, this is what you’ll get:

Sends mails from "MyBlog " (with your Blog’s name and admin email)
Sends mail to "Markus " (with the name being the user’s display name on the forums, not their username)
Subject and Message have more user friendly defaults, use the available filters (see below) to make them your own.

Customization
You can install and activate this plugin and it just works, but you have full control over the details if you want to. Below are some filters and code snippets that help you do what you want. If you’re new to working directly with code, please see the example at the bottom of this page.
Available filters
bbp_subscription_email_from( $from ) // $from can be a string or array('name'=>string, 'address'=>string)
bbp_subscription_email_recipients( $recipients ) // $recipients is array of array('name'=>string, 'address'=>string)
bbp_subscription_email_headers( $headers )
bbp_forum_subscription_email_subject( $subject, $forum_id, $topic_id )
bbp_forum_subscription_email_message( $message, $forum_id, $topic_id )
bbp_topic_subscription_email_subject( $subject, $forum_id, $topic_id, $reply_id )
bbp_topic_subscription_email_message( $message, $forum_id, $topic_id, $reply_id )

bbp_bounce_address( $bounce_address )

bbp_subscription_disable_async( false )
bbp_forum_subscription_disable_async( false )
bbp_topic_subscription_disable_async( false )
bbp_forum_subscription_notify_author( false )
bbp_topic_subscription_notify_author( false )

Helpful Snippets
Here are some pointers to get the data you might want in your notifications:
$blog_name = get_bloginfo( 'name' );

$forum_title = bbp_get_forum_title( $forum_id );

$topic_author_user_id = bbp_get_topic_author_id( $topic_id );
$topic_author_display_name = bbp_get_topic_author_display_name( $topic_id );
$topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES );
$topic_content = wp_specialchars_decode( strip_tags( bbp_get_topic_content( $topic_id ) ), ENT_QUOTES );
$topic_url = get_permalink( $topic_id );

$reply_author_user_id = bbp_get_reply_author_id( $reply_id );
$reply_author_display_name = bbp_get_topic_author_display_name( $reply_id );
$reply_content = strip_tags( bbp_get_reply_content( $reply_id ) );
$reply_url = bbp_get_reply_url( $reply_id ); // note that it's not get_permalink()

Example
To have a nice subject line for new topic notifications, add this to your theme’s functions.php. If your theme does not have this file, you can simply create it and it will be loaded automatically. Note how the example is basically just one of the filters above, mixed with some of the snippets and a return statement. It’s that simple.
add_filter( 'bbp_forum_subscription_email_subject', function( $subject, $forum_id, $topic_id ) {
$blog_name = get_bloginfo( 'name' );
$topic_author_display_name = bbp_get_topic_author_display_name( $topic_id );
$topic_title = wp_specialchars_decode( strip_tags( bbp_get_topic_title( $topic_id ) ), ENT_QUOTES );
return "[$blog_name] $topic_author_display_name created a new topic: $topic_title";
}, 10, 3); // first is priority (10 is default and just fine), second is number of arguments your filter expects

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「AsynCRONous bbPress Subscriptions」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.0 | 1.1 | 1.2 | 1.3 | 1.4 | 1.5 | 2.0 | 2.1 | 2.2 | 2.3 | 3.0 | 3.1 | 3.2 | 3.3 | 3.4 | 3.5 | 3.6 | 3.7 | trunk |

延伸相關外掛(你可能也想知道)

文章
Filter
Apply Filters
Mastodon