mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Add new plugin API to allow plugins to extend Site#categories (#13773)
This commit is contained in:
committed by
GitHub
parent
8de8989576
commit
a1047f5ef4
@@ -7,6 +7,14 @@ class Site
|
||||
cattr_accessor :preloaded_category_custom_fields
|
||||
self.preloaded_category_custom_fields = Set.new
|
||||
|
||||
def self.add_categories_callbacks(&block)
|
||||
categories_callbacks << block
|
||||
end
|
||||
|
||||
def self.categories_callbacks
|
||||
@categories_callbacks ||= []
|
||||
end
|
||||
|
||||
def initialize(guardian)
|
||||
@guardian = guardian
|
||||
end
|
||||
@@ -104,6 +112,11 @@ class Site
|
||||
end
|
||||
|
||||
categories.reject! { |c| c[:parent_category_id] && !by_id[c[:parent_category_id]] }
|
||||
|
||||
self.class.categories_callbacks.each do |callback|
|
||||
callback.call(categories)
|
||||
end
|
||||
|
||||
categories
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user