优化
This commit is contained in:
parent
ae20829209
commit
2ca1f10bfc
@ -78,6 +78,13 @@ func (b *Builder) WriteString(s ...string) (count int) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func Replace(s string, replace map[string]string) string {
|
||||
for k, v := range replace {
|
||||
s = strings.ReplaceAll(s, k, v)
|
||||
}
|
||||
return s
|
||||
}
|
||||
func (b *Builder) Sprintf(format string, a ...any) int {
|
||||
i, _ := fmt.Fprintf(b, format, a...)
|
||||
return i
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
str "github.com/fthvgb1/wp-go/helper/strings"
|
||||
"github.com/fthvgb1/wp-go/internal/theme/wp"
|
||||
"github.com/fthvgb1/wp-go/internal/wpconfig"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func colorScheme(h *wp.Handle) (r string) {
|
||||
@ -17,16 +16,13 @@ func colorScheme(h *wp.Handle) (r string) {
|
||||
hue := number.ToString(wpconfig.GetThemeModsVal[int64](ThemeName, "colorscheme_hue", 250))
|
||||
reducedSaturation := fmt.Sprintf("%d%%", int(.8*50))
|
||||
saturation := fmt.Sprintf("%d%%", 50)
|
||||
css := customCss
|
||||
for k, v := range map[string]string{
|
||||
css := str.Replace(customCss, map[string]string{
|
||||
"' . $hue . '": hue,
|
||||
"' . esc_attr( $hue ) . '": hue,
|
||||
"' . $saturation . '": saturation,
|
||||
"' . esc_attr( $saturation ) .' ": saturation,
|
||||
"' . $reduced_saturation . '": reducedSaturation,
|
||||
} {
|
||||
css = strings.ReplaceAll(css, k, v)
|
||||
}
|
||||
})
|
||||
s.Sprintf(`<style type="text/css" id="custom-theme-colors">%s</style>`, css)
|
||||
r = s.String()
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user