wp-go/internal/theme/hook.go
2023-02-24 19:34:19 +08:00

25 lines
524 B
Go

package theme
import (
"github.com/fthvgb1/wp-go/internal/theme/common"
"github.com/fthvgb1/wp-go/internal/theme/twentyfifteen"
)
var themeMap = map[string]func(*common.Handle){}
func addThemeHookFunc(name string, fn func(handle *common.Handle)) {
if _, ok := themeMap[name]; ok {
panic("exists same name theme")
}
themeMap[name] = fn
}
func Hook(themeName string, handle *common.Handle) {
fn, ok := themeMap[themeName]
if ok && fn != nil {
fn(handle)
return
}
themeMap[twentyfifteen.ThemeName](handle)
}