2023-01-18 15:04:12 +00:00
|
|
|
package theme
|
|
|
|
|
|
|
|
import (
|
2023-02-08 15:49:48 +00:00
|
|
|
"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
|
|
|
)
|
|
|
|
|
2023-02-24 11:34:19 +00:00
|
|
|
var themeMap = map[string]func(*common.Handle){}
|
2023-01-18 15:04:12 +00:00
|
|
|
|
2023-02-11 15:51:07 +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
|
|
|
|
}
|
|
|
|
|
2023-02-11 15:51:07 +00:00
|
|
|
func Hook(themeName string, handle *common.Handle) {
|
2023-01-18 15:04:12 +00:00
|
|
|
fn, ok := themeMap[themeName]
|
|
|
|
if ok && fn != nil {
|
2023-02-08 15:49:48 +00:00
|
|
|
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
|
|
|
}
|