-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.txt
210 lines (154 loc) · 10.2 KB
/
readme.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
=== Ringier-Bus ===
Contributors: ringier, wkhayrattee
Tags: ringier, bus, api, cde
Requires at least: 6.0
Tested up to: 6.6.2
Stable tag: 3.1.0
Requires PHP: 8.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
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/](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.
## CUSTOM FILTERS ##
The plugin exposes three 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);
```
## 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](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
== Installation ==
### PHP Version ###
This plugin requires *PHP version >= 8.1*.
### SETUP ###
1. The plugin is accessible from the WordPress admin via "Plugins > Add New > Search".
- Search for "Ringier Bus" and click on "Install Now".
2. Once you have installed the plugin, a Ringier Bus menu will appear. Please fill in the required fields to set up the plugin.
3. In order to get an Event Bus node id, username and password, please contact the bus team via Slack or by email at [email protected] to gain access to the Bus admin. You will be able to add a new node onto the bus and set up your event destinations.
4. Ensure that the WordPress cron is active. This plugin relies on the WordPress cron system for scheduling tasks. If your cron system is not active, please refer to the WordPress Codex or consult with your web hosting provider to enable it.
== Screenshots ==
1. The admin page
2. On article dashboard, you can select a value for "Article Lifetime"
== Changelog ==
### 3.1.0 (Oct 9, 2024) ###
* [NEW] Added Youtube videos to the event payload if there's any as part of the article
- see PR#8 for more details
* [UPDATE] When description is not set by author, it defaulted to the excerpt. As a consequence hellip was being added to the description. This has been fixed to remove the hellip, as well as any other html entities/tags that might be present in the excerpt.
### 3.0.0 (Jul 12, 2024) ###
* [BREAKING] PHP Version | The code base now requires a minimum version of PHP 8.1+
* [NEW] Added three new custom filters to allow for more flexibility in the plugin's behavior (see readme file):
- `ringier_bus_get_publication_reason` - allows you to filter the publication reason before it is sent to the BUS API
- `ringier_bus_get_article_lifetimez` - allows you to filter the article lifetime before it is sent to the BUS API
- `ringier_build_article_payload` - allows you to filter the entire article payload before it is sent to the BUS API
* [UPDATE]: Changed the way events are sent:
- on new article creation, an event will now be immediately sent (this is a requirement for internal CIET)
- the event will still be queued to run or re-run (in the case of an article update) after the default 1 minute
* [UPDATE]: Harmonised page title and menu
* [UPDATE]: Updated composer dependencies
* [UPDATE]: Cache nonce now defaults to the plugin version number for consistency
* [UPDATE]: Add more intuitive prompts to guide user, for e.g provide the STAGING and PROD endpoints right there in the UI to be handy for them
### 2.3.0 (Oct 9, 2023) ###
* [UPDATE]: Transitioned from relying on the rest_after_insert_post hook to the more universally available transition_post_status hook.
*Reason*:
We identified that some blogs were disabling the Gutenberg editor and as a result, not utilizing the new WordPress REST API. This meant that the rest_after_insert_post hook wasn't being triggered for those instances. To ensure consistent and robust post update handling across all blogs, regardless of their editor choice, we've shifted to the transition_post_status hook.
* [UPDATE]: Improved JSON handling and compression for Slack logging (see Changelog.md)
### 2.2.0 (Oct 9, 2023) ###
* [NEW] Introduction of the possibility to add a custom Top level primary category - can ENABLE/DISABLED when needed | See Changelog.md
* [UPDATE] Refactored the logic for saving custom fields (on gutenberg) to work as soon as the plugin is active, irrespective if the BUS sync is OFF
* [FIX] There was a bug that could prevent the primary category of an article from being fetched from the fallback method if the one from Yoast fails
### 2.1.0 (Jul 18, 2023) ###
* [UPDATE] General updates to the JSON structure to match the new BUS Specs - See Changelog.md
* [UPDATE] New widget for the new field publication reason on the Gutenberg editor
* [UPDATE] Updated composer dependencies
### 1.3.1 (Oct 18, 2022) ###
* [UPDATE] JSON | change page_type to content_type for sailthru vars
### 1.3.0 (Oct 12, 2022) ###
* [NEW] custom post_type event | handle triggering of events separately for custom post_type
* [NEW] custom fields on admin UI | allow showing of acf custom fields on custom post_type as well, excluding page for now
### 1.2.0 (Oct 04, 2022) ###
* [FIX] Events should not be triggered when "saving draft"
* [NEW] Logging | Add additional log message when an Event is not sent to know why
* [NEW] Addition of new logic for new field: primary_media_type
### 1.1.1 (Aug 16, 2022) ###
* [JSON Request] The API's field `description` field truncated to 2500 chars since the BUS API request will fail on more than 3000 chars.
* [Doc] The readme has been given some polishing
### 1.1.0 (Jul 27, 2022) ###
* [vendor] update ACF to v5.12.3
* Added Sailthru Tags & Vars to the JSON request
* Changes to BUS API
* update BUS API version to v2.0.0
* Main JSON - rename venture_config_id to node_id
* Article JSON - rename venture_config_id to from
* Article JSON rename venture_reference to reference
### 1.1.0 (Jul 27, 2022) ###
* update ACF to v5.12.2
### 1.0.3 (April 14, 2022) ###
* update ACF to v5.12.2
### 1.0.2 (December 06, 2021) ###
* update symfony/cache to v5.4.0 - we will stick to 5.x for now because v6.x focuses on php v8+
* update ACF to v5.11.4
### 1.0.1 (November 25, 2021) ###
* Update ACF to latest v5.11.3
### 1.0.0 (November 19, 2021) ###
* Initial release onto WordPress.org plugin repo with the initial code from phase 1 of this plugin
### 0.1.0 (September 26, 2021) ###
* Initial commit of working code for the benefit of everyone who needs this plugin