wp-go/internal/plugins/wphandle/handle.go

33 lines
767 B
Go
Raw Normal View History

2023-03-02 15:49:28 +00:00
package wphandle
import (
2023-04-25 12:58:22 +00:00
"github.com/fthvgb1/wp-go/internal/pkg/config"
2023-03-02 15:49:28 +00:00
"github.com/fthvgb1/wp-go/internal/plugins/wphandle/enlightjs"
"github.com/fthvgb1/wp-go/internal/plugins/wphandle/hiddenlogin"
2023-05-03 15:57:49 +00:00
"github.com/fthvgb1/wp-go/internal/plugins/wphandle/tests"
2023-03-02 15:49:28 +00:00
"github.com/fthvgb1/wp-go/internal/theme/wp"
)
var plugins = wp.HandlePlugins{
"enlightjs": enlightjs.EnlighterJS,
"hiddenLogin": hiddenlogin.HiddenLogin,
2023-05-03 15:57:49 +00:00
"test": tests.Tt,
2023-03-02 15:49:28 +00:00
}
2023-04-25 12:58:22 +00:00
func RegisterPlugins(m wp.HandlePlugins) {
for k, v := range m {
if _, ok := plugins[k]; !ok {
plugins[k] = v
}
}
2023-03-02 15:49:28 +00:00
}
2023-04-25 12:58:22 +00:00
func UsePlugins(h *wp.Handle, calls ...string) {
calls = append(calls, config.GetConfig().Plugins...)
2023-03-02 15:49:28 +00:00
for _, call := range calls {
if fn, ok := plugins[call]; ok {
fn(h)
}
}
}