wp-go/internal/theme/common/customcss.go

20 lines
440 B
Go
Raw Normal View History

2023-02-16 15:12:16 +00:00
package common
import (
"fmt"
"github.com/fthvgb1/wp-go/helper/html"
"github.com/fthvgb1/wp-go/internal/pkg/cache"
)
func (h *Handle) CalCustomCss() (r string) {
2023-02-18 15:35:39 +00:00
if h.ThemeMods.CustomCssPostId < 1 {
2023-02-16 15:12:16 +00:00
return
}
2023-02-18 15:35:39 +00:00
post, err := cache.GetPostById(h.C, uint64(h.ThemeMods.CustomCssPostId))
2023-02-16 15:12:16 +00:00
if err != nil || post.Id < 1 {
return
}
r = fmt.Sprintf(`<style id="wp-custom-css">%s</style>`, html.StripTags(post.PostContent, ""))
return
}