This commit is contained in:
xing 2023-04-19 15:50:22 +08:00
parent 8a9209196e
commit 023212ba7b

View File

@ -2,7 +2,6 @@ package components
import ( import (
"github.com/fthvgb1/wp-go/helper/slice" "github.com/fthvgb1/wp-go/helper/slice"
"github.com/fthvgb1/wp-go/internal/cmd/reload"
"github.com/fthvgb1/wp-go/internal/pkg/constraints" "github.com/fthvgb1/wp-go/internal/pkg/constraints"
"github.com/fthvgb1/wp-go/internal/theme/wp" "github.com/fthvgb1/wp-go/internal/theme/wp"
"github.com/fthvgb1/wp-go/internal/theme/wp/components/widget" "github.com/fthvgb1/wp-go/internal/theme/wp/components/widget"
@ -25,11 +24,10 @@ type widgetComponent struct {
} }
func WidgetArea(h *wp.Handle) { func WidgetArea(h *wp.Handle) {
sidebar := reload.GetAnyValBys("sidebarWidgets", h, sidebars) h.PushComponents(constraints.SidebarsWidgets, sidebars()...)
h.PushComponents(constraints.SidebarsWidgets, sidebar...)
} }
func sidebars(*wp.Handle) []wp.Components[string] { func sidebars() []wp.Components[string] {
v := wpconfig.GetPHPArrayVal("sidebars_widgets", []any{}, "sidebar-1") v := wpconfig.GetPHPArrayVal("sidebars_widgets", []any{}, "sidebar-1")
return slice.FilterAndMap(v, func(t any) (wp.Components[string], bool) { return slice.FilterAndMap(v, func(t any) (wp.Components[string], bool) {
vv := t.(string) vv := t.(string)