fix bug
This commit is contained in:
parent
68c345f928
commit
471a58658f
|
@ -1,5 +1,7 @@
|
||||||
package twentyfifteen
|
package twentyfifteen
|
||||||
|
|
||||||
|
import "github.com/fthvgb1/wp-go/app/wpconfig"
|
||||||
|
|
||||||
type themeSupport struct {
|
type themeSupport struct {
|
||||||
CustomBackground customBackground `json:"custom-background"`
|
CustomBackground customBackground `json:"custom-background"`
|
||||||
EditorColorPalette []EditorColorPalette `json:"editor-color-palette"`
|
EditorColorPalette []EditorColorPalette `json:"editor-color-palette"`
|
||||||
|
@ -227,3 +229,67 @@ var colorscheme = map[string]ColorScheme{
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ = func() struct{} {
|
||||||
|
v := wpconfig.ThemeSupport{
|
||||||
|
CoreBlockPatterns: true,
|
||||||
|
WidgetsBlockEditor: true,
|
||||||
|
AutomaticFeedLinks: true,
|
||||||
|
TitleTag: true,
|
||||||
|
PostThumbnails: true,
|
||||||
|
Menus: true,
|
||||||
|
HTML5: []string{
|
||||||
|
"search-form",
|
||||||
|
"comment-form",
|
||||||
|
"comment-list",
|
||||||
|
"gallery",
|
||||||
|
"caption",
|
||||||
|
"script",
|
||||||
|
"style",
|
||||||
|
"navigation-widgets",
|
||||||
|
},
|
||||||
|
PostFormats: []string{
|
||||||
|
"aside",
|
||||||
|
"image",
|
||||||
|
"video",
|
||||||
|
"quote",
|
||||||
|
"link",
|
||||||
|
"gallery",
|
||||||
|
"status",
|
||||||
|
"audio",
|
||||||
|
"chat",
|
||||||
|
},
|
||||||
|
CustomLogo: wpconfig.CustomLogo{
|
||||||
|
Width: 248,
|
||||||
|
Height: 248,
|
||||||
|
FlexWidth: false,
|
||||||
|
FlexHeight: true,
|
||||||
|
HeaderText: "",
|
||||||
|
UnlinkHomepageLogo: false,
|
||||||
|
},
|
||||||
|
CustomizeSelectiveRefreshWidgets: true,
|
||||||
|
EditorStyle: true,
|
||||||
|
EditorStyles: true,
|
||||||
|
WpBlockStyles: true,
|
||||||
|
ResponsiveEmbeds: true,
|
||||||
|
CustomHeader: wpconfig.CustomHeader{
|
||||||
|
DefaultImage: "",
|
||||||
|
RandomDefault: false,
|
||||||
|
Width: 954,
|
||||||
|
Height: 1300,
|
||||||
|
FlexHeight: false,
|
||||||
|
FlexWidth: false,
|
||||||
|
DefaultTextColor: "333333",
|
||||||
|
HeaderText: true,
|
||||||
|
Uploads: true,
|
||||||
|
WpHeadCallback: "twentyfifteen_header_style",
|
||||||
|
AdminHeadCallback: "",
|
||||||
|
AdminPreviewCallback: "",
|
||||||
|
Video: false,
|
||||||
|
VideoActiveCallback: "is_front_page",
|
||||||
|
},
|
||||||
|
Widgets: true,
|
||||||
|
}
|
||||||
|
wpconfig.SetThemeSupport(ThemeName, v)
|
||||||
|
return struct{}{}
|
||||||
|
}()
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package twentyseventeen
|
package twentyseventeen
|
||||||
|
|
||||||
|
import "github.com/fthvgb1/wp-go/app/wpconfig"
|
||||||
|
|
||||||
type themeSupport struct {
|
type themeSupport struct {
|
||||||
CustomLineHeight bool `json:"custom-line-height"`
|
CustomLineHeight bool `json:"custom-line-height"`
|
||||||
StarterContent StarterContent `json:"starter-content"`
|
StarterContent StarterContent `json:"starter-content"`
|
||||||
|
@ -147,3 +149,64 @@ var themesupport = themeSupport{
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ = func() struct{} {
|
||||||
|
v := wpconfig.ThemeSupport{
|
||||||
|
CoreBlockPatterns: true,
|
||||||
|
WidgetsBlockEditor: true,
|
||||||
|
AutomaticFeedLinks: true,
|
||||||
|
TitleTag: true,
|
||||||
|
PostThumbnails: true,
|
||||||
|
Menus: true,
|
||||||
|
HTML5: []string{
|
||||||
|
"comment-form",
|
||||||
|
"comment-list",
|
||||||
|
"gallery",
|
||||||
|
"caption",
|
||||||
|
"script",
|
||||||
|
"style",
|
||||||
|
"navigation-widgets",
|
||||||
|
},
|
||||||
|
PostFormats: []string{
|
||||||
|
"aside",
|
||||||
|
"image",
|
||||||
|
"video",
|
||||||
|
"quote",
|
||||||
|
"link",
|
||||||
|
"gallery",
|
||||||
|
"audio",
|
||||||
|
},
|
||||||
|
CustomLogo: wpconfig.CustomLogo{
|
||||||
|
Width: 250,
|
||||||
|
Height: 250,
|
||||||
|
FlexWidth: true,
|
||||||
|
FlexHeight: false,
|
||||||
|
HeaderText: "",
|
||||||
|
UnlinkHomepageLogo: false,
|
||||||
|
},
|
||||||
|
CustomizeSelectiveRefreshWidgets: true,
|
||||||
|
EditorStyle: true,
|
||||||
|
EditorStyles: true,
|
||||||
|
WpBlockStyles: true,
|
||||||
|
ResponsiveEmbeds: true,
|
||||||
|
CustomHeader: wpconfig.CustomHeader{
|
||||||
|
DefaultImage: "http://wp.test/wp-content/themes/twentyseventeen/assets/images/header.jpg",
|
||||||
|
RandomDefault: false,
|
||||||
|
Width: 2000,
|
||||||
|
Height: 1200,
|
||||||
|
FlexHeight: true,
|
||||||
|
FlexWidth: false,
|
||||||
|
DefaultTextColor: "",
|
||||||
|
HeaderText: true,
|
||||||
|
Uploads: true,
|
||||||
|
WpHeadCallback: "twentyseventeen_header_style",
|
||||||
|
AdminHeadCallback: "",
|
||||||
|
AdminPreviewCallback: "",
|
||||||
|
Video: true,
|
||||||
|
VideoActiveCallback: "is_front_page",
|
||||||
|
},
|
||||||
|
Widgets: true,
|
||||||
|
}
|
||||||
|
wpconfig.SetThemeSupport(ThemeName, v)
|
||||||
|
return struct{}{}
|
||||||
|
}()
|
||||||
|
|
|
@ -139,14 +139,14 @@ func MiddlewareKey(h *Handle, pipScene string) string {
|
||||||
func PipeMiddlewareHandle(h *Handle, middlewares map[string][]HandleCall, key string) (handlers []HandleCall) {
|
func PipeMiddlewareHandle(h *Handle, middlewares map[string][]HandleCall, key string) (handlers []HandleCall) {
|
||||||
handlers = append(handlers, middlewares[h.scene]...)
|
handlers = append(handlers, middlewares[h.scene]...)
|
||||||
handlers = append(handlers, middlewares[constraints.AllScene]...)
|
handlers = append(handlers, middlewares[constraints.AllScene]...)
|
||||||
handlers = h.PipeHandleHook("PipeMiddlewareHandle", handlers, key)
|
handlers = *h.PipeHandleHook("PipeMiddlewareHandle", &handlers, key)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func PipeDataHandle(h *Handle, dataHandlers map[string][]HandleCall, key string) (handlers []HandleCall) {
|
func PipeDataHandle(h *Handle, dataHandlers map[string][]HandleCall, key string) (handlers []HandleCall) {
|
||||||
handlers = append(handlers, dataHandlers[h.scene]...)
|
handlers = append(handlers, dataHandlers[h.scene]...)
|
||||||
handlers = append(handlers, dataHandlers[constraints.AllScene]...)
|
handlers = append(handlers, dataHandlers[constraints.AllScene]...)
|
||||||
handlers = h.PipeHandleHook("PipeDataHandle", handlers, key)
|
handlers = *h.PipeHandleHook("PipeDataHandle", &handlers, key)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ func PipeRender(h *Handle, renders map[string][]HandleCall, key string) (handler
|
||||||
handlers = append(handlers, renders[h.scene]...)
|
handlers = append(handlers, renders[h.scene]...)
|
||||||
handlers = append(handlers, renders[constraints.AllStats]...)
|
handlers = append(handlers, renders[constraints.AllStats]...)
|
||||||
handlers = append(handlers, renders[constraints.AllScene]...)
|
handlers = append(handlers, renders[constraints.AllScene]...)
|
||||||
handlers = h.PipeHandleHook("PipeRender", handlers, key)
|
handlers = *h.PipeHandleHook("PipeRender", &handlers, key)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,9 +185,9 @@ func (h *Handle) PushPipeHandleHook(name string, fn ...func([]HandleCall) []Hand
|
||||||
return PushFnHook("pipeHandleHook", name, fn...)
|
return PushFnHook("pipeHandleHook", name, fn...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handle) PipeHandleHook(name string, calls []HandleCall, key string) []HandleCall {
|
func (h *Handle) PipeHandleHook(name string, calls *[]HandleCall, key string) *[]HandleCall {
|
||||||
fn := GetFnHook[func(*Handle, []HandleCall, string) []HandleCall]("pipeHandleHook", name)
|
fn := GetFnHook[func(*Handle, *[]HandleCall, string) *[]HandleCall]("pipeHandleHook", name)
|
||||||
return slice.Reduce(fn, func(t func(*Handle, []HandleCall, string) []HandleCall, r []HandleCall) []HandleCall {
|
return slice.Reduce(fn, func(t func(*Handle, *[]HandleCall, string) *[]HandleCall, r *[]HandleCall) *[]HandleCall {
|
||||||
return t(h, r, key)
|
return t(h, r, key)
|
||||||
}, calls)
|
}, calls)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package wpconfig
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/fthvgb1/wp-go/app/cmd/reload"
|
"github.com/fthvgb1/wp-go/app/cmd/reload"
|
||||||
"github.com/fthvgb1/wp-go/app/phphelper"
|
"github.com/fthvgb1/wp-go/app/phphelper"
|
||||||
|
@ -122,6 +121,12 @@ var themeModes = func() *safety.Map[string, ThemeMods] {
|
||||||
|
|
||||||
var themeModsRaw *safety.Map[string, map[string]any]
|
var themeModsRaw *safety.Map[string, map[string]any]
|
||||||
|
|
||||||
|
var themeSupport = map[string]ThemeSupport{}
|
||||||
|
|
||||||
|
func SetThemeSupport(theme string, support ThemeSupport) {
|
||||||
|
themeSupport[theme] = support
|
||||||
|
}
|
||||||
|
|
||||||
func GetThemeModsVal[T any](theme, k string, defaults T) (r T) {
|
func GetThemeModsVal[T any](theme, k string, defaults T) (r T) {
|
||||||
m, ok := themeModsRaw.Load(theme)
|
m, ok := themeModsRaw.Load(theme)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -170,14 +175,11 @@ func IsCustomBackground(theme string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ThemeMods) setThemeSupport(themeName string) {
|
func (m *ThemeMods) setThemeSupport(themeName string) {
|
||||||
bytes, err := templateFs.ReadFile(filepath.Join(themeName, "themesupport.json"))
|
var v ThemeSupport
|
||||||
if err != nil {
|
vv, ok := themeSupport[themeName]
|
||||||
return
|
if ok {
|
||||||
|
m.ThemeSupport = vv
|
||||||
|
} else {
|
||||||
|
m.ThemeSupport = v
|
||||||
}
|
}
|
||||||
var themeSupport ThemeSupport
|
|
||||||
err = json.Unmarshal(bytes, &themeSupport)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.ThemeSupport = themeSupport
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user