wp-go/internal/plugins/wphandle/handle.go
2023-05-03 23:57:49 +08:00

33 lines
767 B
Go

package wphandle
import (
"github.com/fthvgb1/wp-go/internal/pkg/config"
"github.com/fthvgb1/wp-go/internal/plugins/wphandle/enlightjs"
"github.com/fthvgb1/wp-go/internal/plugins/wphandle/hiddenlogin"
"github.com/fthvgb1/wp-go/internal/plugins/wphandle/tests"
"github.com/fthvgb1/wp-go/internal/theme/wp"
)
var plugins = wp.HandlePlugins{
"enlightjs": enlightjs.EnlighterJS,
"hiddenLogin": hiddenlogin.HiddenLogin,
"test": tests.Tt,
}
func RegisterPlugins(m wp.HandlePlugins) {
for k, v := range m {
if _, ok := plugins[k]; !ok {
plugins[k] = v
}
}
}
func UsePlugins(h *wp.Handle, calls ...string) {
calls = append(calls, config.GetConfig().Plugins...)
for _, call := range calls {
if fn, ok := plugins[call]; ok {
fn(h)
}
}
}