diff --git a/app/theme/twentyseventeen/twentyseventeen.go b/app/theme/twentyseventeen/twentyseventeen.go
index 4ba4734..29c80d6 100644
--- a/app/theme/twentyseventeen/twentyseventeen.go
+++ b/app/theme/twentyseventeen/twentyseventeen.go
@@ -177,7 +177,7 @@ func calClass(h *wp.Handle, s string, _ ...any) string {
func videoHeader(h *wp.Handle) {
h.PushComponentFilterFn("videoSetting", videoPlay)
- wp.CustomVideo(h)
+ wp.CustomVideo(h, constraints.Home)
}
func videoPlay(h *wp.Handle, _ string, a ...any) string {
diff --git a/app/theme/wp/components.go b/app/theme/wp/components.go
index c225364..99d1904 100644
--- a/app/theme/wp/components.go
+++ b/app/theme/wp/components.go
@@ -35,7 +35,6 @@ func CalComponents(h *Handle) {
})
for k, components := range componentss {
key := str.Join("calComponents-", h.scene, "-", k)
- key = h.ComponentFilterFnHook("calComponents", key, k)
ss := reload.GetAnyValMapBy("calComponents", key, h, func(h *Handle) []Components[string] {
r := slice.FilterAndMap(components, func(t Components[string]) (Components[string], bool) {
fns, ok := h.componentHook[k]
@@ -88,15 +87,18 @@ func (h *Handle) PushComponents(scene, componentType string, components ...Compo
}
func (h *Handle) PushGroupComponentStr(scene, componentType, name string, order int, strs ...string) {
- var components []Components[string]
- for _, val := range strs {
- components = append(components, Components[string]{
- Val: val,
- Order: order,
- Name: name,
- })
+ var component = Components[string]{
+ Val: strings.Join(slice.FilterAndMap(strs, func(t string) (string, bool) {
+ t = strings.Trim(t, "\n\r\t\v\x00")
+ if t == "" {
+ return "", false
+ }
+ return t, true
+ }), "\n"),
+ Order: order,
+ Name: name,
}
- h.PushComponents(scene, componentType, components...)
+ h.PushComponents(scene, componentType, component)
}
func (h *Handle) PushCacheGroupHeadScript(scene, name string, order int, fns ...func(*Handle) string) {
diff --git a/app/theme/wp/customheader.go b/app/theme/wp/customheader.go
index f0a6249..fd56344 100644
--- a/app/theme/wp/customheader.go
+++ b/app/theme/wp/customheader.go
@@ -5,7 +5,6 @@ import (
"fmt"
"github.com/fthvgb1/wp-go/app/cmd/reload"
"github.com/fthvgb1/wp-go/app/pkg/cache"
- "github.com/fthvgb1/wp-go/app/pkg/constraints"
"github.com/fthvgb1/wp-go/app/pkg/logs"
"github.com/fthvgb1/wp-go/app/pkg/models"
"github.com/fthvgb1/wp-go/app/wpconfig"
@@ -96,7 +95,7 @@ func GetVideoSetting(h *Handle, u string) (string, error) {
return script, nil
}
-func CustomVideo(h *Handle) (ok bool) {
+func CustomVideo(h *Handle, scene ...string) (ok bool) {
mod, err := wpconfig.GetThemeMods(h.theme)
if err != nil {
logs.Error(err, "getThemeMods fail", h.theme)
@@ -144,7 +143,7 @@ func CustomVideo(h *Handle) (ok bool) {
{"wp-", ""},
}))
})
- h.PushGroupFooterScript(constraints.Home, "wp-custom-header", 10, scripts[0:len(scripts)-2]...)
+
var tr = `
@@ -157,11 +156,15 @@ wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ 'ltr' ] } );
`
- h.PushFooterScript(constraints.Home,
+ c := []Components[string]{
NewComponent("wp-a11y-js-translations", tr, true, 10, nil),
NewComponent("VideoSetting", hs, true, 10, nil),
NewComponent("header-script", scripts[len(scripts)-1], true, 10, nil),
- )
+ }
+ for _, s := range scene {
+ h.PushGroupFooterScript(s, "wp-custom-header", 10, scripts[0:len(scripts)-2]...)
+ h.PushFooterScript(s, c...)
+ }
ok = true
return
}
diff --git a/app/theme/wp/wp.go b/app/theme/wp/wp.go
index 0d6c807..2db0b4d 100644
--- a/app/theme/wp/wp.go
+++ b/app/theme/wp/wp.go
@@ -103,12 +103,12 @@ func InitHandle(fn func(*Handle), h *Handle) {
h.ginH = gin.H{}
fnMap = map[string]map[string]any{}
fnHook = map[string]map[string]any{}
+ fn(h)
v := apply.UsePlugins()
pluginFn, ok := v.(func(*Handle))
if ok {
pluginFn(h)
}
- fn(h)
h.C.Set("inited", true)
inited = true
return *h