[WordPress] 外掛分享: Ringier-Bus

首頁 › 外掛目錄 › Ringier-Bus
WordPress 外掛 Ringier-Bus 的封面圖片
10+
安裝啟用
—
尚無評分
37 天前
最後更新
—
問題解決
WordPress 6.0+ PHP 8.1+ v4.0.2 上架:2021-11-18

內容簡介

Ringier-Bus 外掛可在文章創建、更新或刪除時,將事件推送至 Ringier Event Bus,協助使用 WordPress 的 Ringier 企業整合 Hexagon 解決方案,提升內容管理效率。

【主要功能】
• 自動觸發文章事件
• 支援文章與 Sailthru 媒體庫同步
• 儲存文章事件至 Ringier Datalake
• 提供事件日誌與監控功能
• 自訂文章生命週期與發佈原因

外掛標籤

開發者團隊

⬇ 下載最新版 (v4.0.2) 或搜尋安裝

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

原文外掛簡介

A plugin to push events to the Ringier Event Bus when articles are created, updated or deleted.
AUDIENCE
This plugin is made for Ringier businesses using WordPress and wanting to benefit from Hexagon solutions available via the Ringier Event Bus. It can be implemented by developers and non-developers.
BENEFITS
The Hexagon solutions available via the Ringier Event Bus and compatible with this plugin include:
– The syncing of articles with Sailthru media library,
– The storage of article events in Ringier Datalake, from which they are retrieved by the Content Distribution Engine (CDE).
You can also benefit from the Bus tooling such as event logging, event monitoring and alerting.
To learn more about Hexagon services, visit https://hexagon.ringier.com/services/business-agility/.
HOW IT WORKS
The plugin automatically triggers events when articles are created, updated and deleted.
Event names: ArticleCreated, ArticleUpdated and ArticleDeleted.
The events are scheduled to be sent to the Bus within a 1-minute delay. This is to allow WordPress to process the changes and update custom fields in the database, which is done asynchronously. You can view scheduled events by making use of the plugin “Advanced Cron Manager”.
Here is a summary of the events sent to the Bus:
– If the article is newly created, we send it INSTANTLY – sent as ArticleCreated
– But then we schedule it to run again after the normal 1 minute so that all custom data are sent properly – sent as ArticleUpdated
– For all existing articles that undergo an update, we schedule the event to run after the 1 minute interval
The plugin also creates two mandatory custom fields, available on the article editor page under “Event Bus” widget:
– The article lifetime (lifetime)
– The publication reason (publication_reason)
We also expose custom filters to help you adjust these two fields and the payload sent to the BUS endpoint, see below.
LOGS
This plugin creates a log file (ringier_bus_plugin_error_log), saved inside the wp-content/ folder:
The error messages are viewable via the admin UI by clicking on the submenu “LOG”.
You also have the flexibility to clear the log file via the UI itself.
To inspect what is actually being sent, add define('RINGIER_BUS_DEBUG_PAYLOAD', true); to wp-config.php. Each dispatch then writes its exact JSON body to wp-content/buslog/payload--.json, before the request goes out. Off entirely without the constant.
CUSTOM FILTERS
The plugin exposes five custom filters to help you adjust the plugin’s JSON Payload that is sent to the BUS endpoint.
1. Modifying the Publication Reason
You can customize the publication reason for an article by using the ringier_bus_get_publication_reason filter. This filter allows you to modify the publication reason before it is sent to the Ringier Event Bus.
Example:
php
function custom_publication_reason(string $publication_reason, int $post_ID): string
{
// Your custom logic goes here
return 'Custom Publication Reason';
}
add_filter('ringier_bus_get_publication_reason', 'custom_publication_reason', 10, 2);
2. Modifying the Article Lifetime Payload
You can customize the article lifetime for an article by using the ringier_bus_get_article_lifetime filter. This filter allows you to modify the article lifetime before it is sent to the Ringier Event Bus.
Example:
php
function custom_article_lifetime(string $article_lifetime, int $post_ID): string
{
// Your custom logic goes here
return 'Custom Article Lifetime';
}
add_filter('ringier_bus_get_article_lifetime', 'custom_article_lifetime', 10, 2);
3. Modifying the Article Payload Data
You can customize the payload data for an article by using the ringier_bus_build_article_payload filter. This filter allows you to modify the payload data before it is sent to the Ringier Event Bus.
Example:
`php
function custom_build_article_payload(array $payload_array, int $post_ID, WP_Post $post): array
{
// Add a custom field to the payload for example
$payload_array[‘custom_field’] = ‘Custom Value’;
return $payload_array;

}
add_filter(‘ringier_bus_build_article_payload’, ‘custom_build_article_payload’, 10, 3);
`
4. Controlling Author Event Dispatch
You can control whether the Ringier Bus plugin should dispatch Author events for a specific user by using the ringier_bus_should_dispatch_author_event filter.
This filter allows you to override the default logic to force enablement or disablement based on your own custom logic – when you want full control over which authors get sent to the Event Bus.
Example:
`php
/**
* Example: Prevent event dispatch for a specific user ID.
*/
add_filter(‘ringier_bus_should_dispatch_author_event’, function (bool $should_dispatch, int $user_id): bool {
// Example: Always send events for Administrators, ignoring the "Show Profile" checkbox
if (user_can($user_id, 'administrator')) {
return true;
}

// Example condition: never sync user ID 1234
if ($user_id === 1234) {
return false;
}

// Otherwise, use the default logic
return $should_dispatch;

}, 10, 2);
`
This filter gives you full flexibility to:
– Disable syncing for certain authors
– Force syncing regardless of profile visibility
– Apply environment-specific rules (e.g., staging vs production)
– Implement client-specific dispatch policies
5. Modifying the Article Images
You can adjust which images an article dispatches by using the ringier_bus_article_image_ids filter.
The plugin resolves the non-hero images of an article from the article body, identifying each by the that shows it. This filter receives those attachment IDs just before they become payload entries.
The featured image is not in this list — it is dispatched separately as the hero entry.
Example:
`
add_filter(‘ringier_bus_article_image_ids’, function (array $image_id_list, int $post_ID, string $content): array {
// Example: never dispatch a specific attachment
$image_id_list = array_diff($image_id_list, [1234]);

// Example: append an image the body does not reference
$image_id_list[] = (int) get_post_meta($post_ID, 'my_extra_image_id', true);

return $image_id_list;

}, 10, 3);
`
Anything returned is re-sanitised — non-numeric values, zeros and duplicates are dropped, and each remaining ID must still be an image attachment. The featured image is deliberately not re-excluded, so this hook can add an image the body does not reference.
Contributing
There are many ways you can contribute:
– Raise an issue if you found one,
– Provide us with your feedback and suggestions for improvement,
– Create a Pull Request with your bug fixes and/or new features. GitHub repository: https://github.com/RingierIMU/mkt-plugin-wordpress-bus
Credits/Thanks
1) Wasseem Khayrattee – for creating and maintaining the plugin
2) Mishka Rasool – for conceiving/creating the banner and logo asset files

文章
Filter
Mastodon