wp-go/internal/theme/hook.go

25 lines
531 B
Go
Raw Permalink Normal View History

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