mirror of
https://github.com/discourse/discourse.git
synced 2026-08-05 11:52:32 +08:00
Previously, affiliate link rewriting only ran via the `:post_process_cooked` event, which fires exclusively when baking a post's original cooked HTML — so readers viewing a translated post were served untagged links. This change subscribes the same rewrite to the `:post_process_localized_cooked` event fired by `LocalizedCookedPostProcessor`, so translated posts get affiliate links too. Existing localizations pick up the tags on their next rebake, since the recook path re-runs the localized post processor. Reported at https://meta.discourse.org/t/407688
19 lines
601 B
Ruby
Vendored
19 lines
601 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
# name: discourse-affiliate
|
|
# about: Allows the creation of Amazon affiliate links on your forum.
|
|
# meta_topic_id: 101937
|
|
# version: 0.2
|
|
# authors: Régis Hanol (zogstrip), Sam Saffron
|
|
# url: https://github.com/discourse/discourse/tree/main/plugins/discourse-affiliate
|
|
|
|
enabled_site_setting :affiliate_enabled
|
|
|
|
register_svg_icon "handshake"
|
|
|
|
after_initialize do
|
|
require_relative "lib/affiliate_processor"
|
|
|
|
on(:post_process_cooked) { |doc| AffiliateProcessor.apply_to_doc(doc) }
|
|
on(:post_process_localized_cooked) { |doc| AffiliateProcessor.apply_to_doc(doc) }
|
|
end
|