diff --git a/internal/theme/common/customlogo.go b/internal/theme/common/customlogo.go index b2f6831..5702cd3 100644 --- a/internal/theme/common/customlogo.go +++ b/internal/theme/common/customlogo.go @@ -3,6 +3,7 @@ package common import ( "fmt" "github.com/fthvgb1/wp-go/helper/maps" + str "github.com/fthvgb1/wp-go/helper/strings" "github.com/fthvgb1/wp-go/internal/pkg/cache" "github.com/fthvgb1/wp-go/internal/wpconfig" "github.com/fthvgb1/wp-go/safety" @@ -17,7 +18,10 @@ func (h *Handle) CalCustomLogo() (r string) { } id := uint64(mods.CustomLogo) if id < 1 { - return + id = str.ToInteger[uint64](wpconfig.Options.Value("site_logo"), 0) + if id < 1 { + return + } } logo, err := cache.GetPostById(h.C, id) if err != nil || logo.AttachmentMetadata.File == "" { diff --git a/internal/theme/common/template.gohtml b/internal/theme/common/template.gohtml new file mode 100644 index 0000000..be79074 --- /dev/null +++ b/internal/theme/common/template.gohtml @@ -0,0 +1,21 @@ +{{define "common/head"}} + {{if .customBackground}} + {{.customBackground|unescaped}} + {{end}} + {{if .customHeader}} + {{.customHeader|unescaped}} + {{end}} + + {{if .siteIcon}} + {{.siteIcon|unescaped}} + {{end}} + {{if .customCss}} + {{.customCss|unescaped}} + {{end}} +{{end}} + +{{define "common/customLogo"}} + {{if .customLogo}} + {{.customLogo|unescaped}} + {{end}} +{{end}} \ No newline at end of file diff --git a/internal/theme/fs.go b/internal/theme/fs.go index b84499a..55ba6bb 100644 --- a/internal/theme/fs.go +++ b/internal/theme/fs.go @@ -33,7 +33,7 @@ func commonTemplate(t *multipTemplate.MultipleFsTemplate) { for _, main := range m { file := filepath.Base(main) dir := strings.Split(main, "/")[0] - templ := template.Must(template.New(file).Funcs(t.FuncMap).ParseFS(t.Fs, main, filepath.Join(dir, "layout/*.gohtml"))) + templ := template.Must(template.New(file).Funcs(t.FuncMap).ParseFS(t.Fs, main, filepath.Join(dir, "layout/*.gohtml"), "common/template.gohtml")) t.SetTemplate(main, templ) } } diff --git a/internal/theme/twentyfifteen/layout/base.gohtml b/internal/theme/twentyfifteen/layout/base.gohtml index 3e9531e..9c5558f 100644 --- a/internal/theme/twentyfifteen/layout/base.gohtml +++ b/internal/theme/twentyfifteen/layout/base.gohtml @@ -16,9 +16,7 @@