🤮🤮 todo .....
This commit is contained in:
parent
6137502ef9
commit
74c88b1385
|
@ -21,9 +21,9 @@ func pushScripts(h *wp.Handle) {
|
|||
[]string{"twentyseventeen-style"}, "20191025", "")
|
||||
}
|
||||
|
||||
scriptloader.AddData("twentyseventeen-ie8", "conditional", "lt IE 9")
|
||||
scriptloader.AddScriptData("twentyseventeen-ie8", "conditional", "lt IE 9")
|
||||
scriptloader.EnqueueScripts("html5", "/assets/js/html5.js", nil, "20161020", false)
|
||||
scriptloader.AddData("html5", "conditional", "lt IE 9")
|
||||
scriptloader.AddScriptData("html5", "conditional", "lt IE 9")
|
||||
|
||||
scriptloader.EnqueueScripts("twentyseventeen-skip-link-focus-fix", "/assets/js/skip-link-focus-fix.js",
|
||||
nil, "20161114", true)
|
||||
|
|
|
@ -43,7 +43,7 @@ func configs(h *wp.Handle) {
|
|||
components.WidgetArea(h)
|
||||
pushScripts(h)
|
||||
h.PushRender(constraints.AllStats, wp.NewHandleFn(calCustomHeader, 10.005, "calCustomHeader"))
|
||||
h.SetComponentsArgs(widgets.Widget, map[string]string{
|
||||
wp.SetComponentsArgs(h, widgets.Widget, map[string]string{
|
||||
"{$before_widget}": `<section id="%s" class="%s">`,
|
||||
"{$after_widget}": `</section>`,
|
||||
})
|
||||
|
|
|
@ -190,7 +190,7 @@ func MergeComponentsArgsForMap[K comparable, V any](h *Handle, name string, m ma
|
|||
}
|
||||
}
|
||||
|
||||
func (h *Handle) SetComponentsArgs(key string, value any) {
|
||||
func SetComponentsArgs(h *Handle, key string, value any) {
|
||||
h.componentsArgs[key] = value
|
||||
}
|
||||
|
||||
|
|
|
@ -366,121 +366,121 @@ func defaultTranslate() {
|
|||
}
|
||||
|
||||
func defaultAddData() {
|
||||
AddData("json2", "conditional", `lt IE 8`)
|
||||
AddData("wp-embed-template-ie", "conditional", `lte IE 8`)
|
||||
AddData("wp-block-library-theme", "path", `wp-includes/css/dist/block-library/theme.min.css`)
|
||||
AddData("wp-block-editor", "path", `/wp-includes/css/dist/block-editor/style.min.css`)
|
||||
AddData("wp-block-library", "path", `/wp-includes/css/dist/block-library/style.min.css`)
|
||||
AddData("wp-block-directory", "path", `/wp-includes/css/dist/block-directory/style.min.css`)
|
||||
AddData("wp-components", "path", `/wp-includes/css/dist/components/style.min.css`)
|
||||
AddData("wp-edit-post", "path", `/wp-includes/css/dist/edit-post/style.min.css`)
|
||||
AddData("wp-editor", "path", `/wp-includes/css/dist/editor/style.min.css`)
|
||||
AddData("wp-format-library", "path", `/wp-includes/css/dist/format-library/style.min.css`)
|
||||
AddData("wp-list-reusable-blocks", "path", `/wp-includes/css/dist/list-reusable-blocks/style.min.css`)
|
||||
AddData("wp-reusable-blocks", "path", `/wp-includes/css/dist/reusable-blocks/style.min.css`)
|
||||
AddData("wp-nux", "path", `/wp-includes/css/dist/nux/style.min.css`)
|
||||
AddData("wp-widgets", "path", `/wp-includes/css/dist/widgets/style.min.css`)
|
||||
AddData("wp-edit-widgets", "path", `/wp-includes/css/dist/edit-widgets/style.min.css`)
|
||||
AddData("wp-customize-widgets", "path", `/wp-includes/css/dist/customize-widgets/style.min.css`)
|
||||
AddData("wp-edit-site", "path", `/wp-includes/css/dist/edit-site/style.min.css`)
|
||||
AddData("common", "rtl", `replace`)
|
||||
AddData("common", "suffix", `.min`)
|
||||
AddData("forms", "rtl", `replace`)
|
||||
AddData("forms", "suffix", `.min`)
|
||||
AddData("admin-menu", "rtl", `replace`)
|
||||
AddData("admin-menu", "suffix", `.min`)
|
||||
AddData("dashboard", "rtl", `replace`)
|
||||
AddData("dashboard", "suffix", `.min`)
|
||||
AddData("list-tables", "rtl", `replace`)
|
||||
AddData("list-tables", "suffix", `.min`)
|
||||
AddData("edit", "rtl", `replace`)
|
||||
AddData("edit", "suffix", `.min`)
|
||||
AddData("revisions", "rtl", `replace`)
|
||||
AddData("revisions", "suffix", `.min`)
|
||||
AddData("media", "rtl", `replace`)
|
||||
AddData("media", "suffix", `.min`)
|
||||
AddData("themes", "rtl", `replace`)
|
||||
AddData("themes", "suffix", `.min`)
|
||||
AddData("about", "rtl", `replace`)
|
||||
AddData("about", "suffix", `.min`)
|
||||
AddData("nav-menus", "rtl", `replace`)
|
||||
AddData("nav-menus", "suffix", `.min`)
|
||||
AddData("widgets", "rtl", `replace`)
|
||||
AddData("widgets", "suffix", `.min`)
|
||||
AddData("site-icon", "rtl", `replace`)
|
||||
AddData("site-icon", "suffix", `.min`)
|
||||
AddData("l10n", "rtl", `replace`)
|
||||
AddData("l10n", "suffix", `.min`)
|
||||
AddData("install", "rtl", `replace`)
|
||||
AddData("install", "suffix", `.min`)
|
||||
AddData("wp-color-picker", "rtl", `replace`)
|
||||
AddData("wp-color-picker", "suffix", `.min`)
|
||||
AddData("customize-controls", "rtl", `replace`)
|
||||
AddData("customize-controls", "suffix", `.min`)
|
||||
AddData("customize-widgets", "rtl", `replace`)
|
||||
AddData("customize-widgets", "suffix", `.min`)
|
||||
AddData("customize-nav-menus", "rtl", `replace`)
|
||||
AddData("customize-nav-menus", "suffix", `.min`)
|
||||
AddData("customize-preview", "rtl", `replace`)
|
||||
AddData("customize-preview", "suffix", `.min`)
|
||||
AddData("login", "rtl", `replace`)
|
||||
AddData("login", "suffix", `.min`)
|
||||
AddData("site-health", "rtl", `replace`)
|
||||
AddData("site-health", "suffix", `.min`)
|
||||
AddData("buttons", "rtl", `replace`)
|
||||
AddData("buttons", "suffix", `.min`)
|
||||
AddData("admin-bar", "rtl", `replace`)
|
||||
AddData("admin-bar", "suffix", `.min`)
|
||||
AddData("wp-auth-check", "rtl", `replace`)
|
||||
AddData("wp-auth-check", "suffix", `.min`)
|
||||
AddData("editor-buttons", "rtl", `replace`)
|
||||
AddData("editor-buttons", "suffix", `.min`)
|
||||
AddData("media-views", "rtl", `replace`)
|
||||
AddData("media-views", "suffix", `.min`)
|
||||
AddData("wp-pointer", "rtl", `replace`)
|
||||
AddData("wp-pointer", "suffix", `.min`)
|
||||
AddData("wp-jquery-ui-dialog", "rtl", `replace`)
|
||||
AddData("wp-jquery-ui-dialog", "suffix", `.min`)
|
||||
AddData("wp-reset-editor-styles", "rtl", `replace`)
|
||||
AddData("wp-reset-editor-styles", "suffix", `.min`)
|
||||
AddData("wp-editor-classic-layout-styles", "rtl", `replace`)
|
||||
AddData("wp-editor-classic-layout-styles", "suffix", `.min`)
|
||||
AddData("wp-block-library-theme", "rtl", `replace`)
|
||||
AddData("wp-block-library-theme", "suffix", `.min`)
|
||||
AddData("wp-edit-blocks", "rtl", `replace`)
|
||||
AddData("wp-edit-blocks", "suffix", `.min`)
|
||||
AddData("wp-block-editor", "rtl", `replace`)
|
||||
AddData("wp-block-editor", "suffix", `.min`)
|
||||
AddData("wp-block-library", "rtl", `replace`)
|
||||
AddData("wp-block-library", "suffix", `.min`)
|
||||
AddData("wp-block-directory", "rtl", `replace`)
|
||||
AddData("wp-block-directory", "suffix", `.min`)
|
||||
AddData("wp-components", "rtl", `replace`)
|
||||
AddData("wp-components", "suffix", `.min`)
|
||||
AddData("wp-customize-widgets", "rtl", `replace`)
|
||||
AddData("wp-customize-widgets", "suffix", `.min`)
|
||||
AddData("wp-edit-post", "rtl", `replace`)
|
||||
AddData("wp-edit-post", "suffix", `.min`)
|
||||
AddData("wp-edit-site", "rtl", `replace`)
|
||||
AddData("wp-edit-site", "suffix", `.min`)
|
||||
AddData("wp-edit-widgets", "rtl", `replace`)
|
||||
AddData("wp-edit-widgets", "suffix", `.min`)
|
||||
AddData("wp-editor", "rtl", `replace`)
|
||||
AddData("wp-editor", "suffix", `.min`)
|
||||
AddData("wp-format-library", "rtl", `replace`)
|
||||
AddData("wp-format-library", "suffix", `.min`)
|
||||
AddData("wp-list-reusable-blocks", "rtl", `replace`)
|
||||
AddData("wp-list-reusable-blocks", "suffix", `.min`)
|
||||
AddData("wp-reusable-blocks", "rtl", `replace`)
|
||||
AddData("wp-reusable-blocks", "suffix", `.min`)
|
||||
AddData("wp-nux", "rtl", `replace`)
|
||||
AddData("wp-nux", "suffix", `.min`)
|
||||
AddData("wp-widgets", "rtl", `replace`)
|
||||
AddData("wp-widgets", "suffix", `.min`)
|
||||
AddData("deprecated-media", "rtl", `replace`)
|
||||
AddData("deprecated-media", "suffix", `.min`)
|
||||
AddData("farbtastic", "rtl", `replace`)
|
||||
AddData("farbtastic", "suffix", `.min`)
|
||||
AddScriptData("json2", "conditional", `lt IE 8`)
|
||||
AddScriptData("wp-embed-template-ie", "conditional", `lte IE 8`)
|
||||
AddScriptData("wp-block-library-theme", "path", `wp-includes/css/dist/block-library/theme.min.css`)
|
||||
AddScriptData("wp-block-editor", "path", `/wp-includes/css/dist/block-editor/style.min.css`)
|
||||
AddScriptData("wp-block-library", "path", `/wp-includes/css/dist/block-library/style.min.css`)
|
||||
AddScriptData("wp-block-directory", "path", `/wp-includes/css/dist/block-directory/style.min.css`)
|
||||
AddScriptData("wp-components", "path", `/wp-includes/css/dist/components/style.min.css`)
|
||||
AddScriptData("wp-edit-post", "path", `/wp-includes/css/dist/edit-post/style.min.css`)
|
||||
AddScriptData("wp-editor", "path", `/wp-includes/css/dist/editor/style.min.css`)
|
||||
AddScriptData("wp-format-library", "path", `/wp-includes/css/dist/format-library/style.min.css`)
|
||||
AddScriptData("wp-list-reusable-blocks", "path", `/wp-includes/css/dist/list-reusable-blocks/style.min.css`)
|
||||
AddScriptData("wp-reusable-blocks", "path", `/wp-includes/css/dist/reusable-blocks/style.min.css`)
|
||||
AddScriptData("wp-nux", "path", `/wp-includes/css/dist/nux/style.min.css`)
|
||||
AddScriptData("wp-widgets", "path", `/wp-includes/css/dist/widgets/style.min.css`)
|
||||
AddScriptData("wp-edit-widgets", "path", `/wp-includes/css/dist/edit-widgets/style.min.css`)
|
||||
AddScriptData("wp-customize-widgets", "path", `/wp-includes/css/dist/customize-widgets/style.min.css`)
|
||||
AddScriptData("wp-edit-site", "path", `/wp-includes/css/dist/edit-site/style.min.css`)
|
||||
AddScriptData("common", "rtl", `replace`)
|
||||
AddScriptData("common", "suffix", `.min`)
|
||||
AddScriptData("forms", "rtl", `replace`)
|
||||
AddScriptData("forms", "suffix", `.min`)
|
||||
AddScriptData("admin-menu", "rtl", `replace`)
|
||||
AddScriptData("admin-menu", "suffix", `.min`)
|
||||
AddScriptData("dashboard", "rtl", `replace`)
|
||||
AddScriptData("dashboard", "suffix", `.min`)
|
||||
AddScriptData("list-tables", "rtl", `replace`)
|
||||
AddScriptData("list-tables", "suffix", `.min`)
|
||||
AddScriptData("edit", "rtl", `replace`)
|
||||
AddScriptData("edit", "suffix", `.min`)
|
||||
AddScriptData("revisions", "rtl", `replace`)
|
||||
AddScriptData("revisions", "suffix", `.min`)
|
||||
AddScriptData("media", "rtl", `replace`)
|
||||
AddScriptData("media", "suffix", `.min`)
|
||||
AddScriptData("themes", "rtl", `replace`)
|
||||
AddScriptData("themes", "suffix", `.min`)
|
||||
AddScriptData("about", "rtl", `replace`)
|
||||
AddScriptData("about", "suffix", `.min`)
|
||||
AddScriptData("nav-menus", "rtl", `replace`)
|
||||
AddScriptData("nav-menus", "suffix", `.min`)
|
||||
AddScriptData("widgets", "rtl", `replace`)
|
||||
AddScriptData("widgets", "suffix", `.min`)
|
||||
AddScriptData("site-icon", "rtl", `replace`)
|
||||
AddScriptData("site-icon", "suffix", `.min`)
|
||||
AddScriptData("l10n", "rtl", `replace`)
|
||||
AddScriptData("l10n", "suffix", `.min`)
|
||||
AddScriptData("install", "rtl", `replace`)
|
||||
AddScriptData("install", "suffix", `.min`)
|
||||
AddScriptData("wp-color-picker", "rtl", `replace`)
|
||||
AddScriptData("wp-color-picker", "suffix", `.min`)
|
||||
AddScriptData("customize-controls", "rtl", `replace`)
|
||||
AddScriptData("customize-controls", "suffix", `.min`)
|
||||
AddScriptData("customize-widgets", "rtl", `replace`)
|
||||
AddScriptData("customize-widgets", "suffix", `.min`)
|
||||
AddScriptData("customize-nav-menus", "rtl", `replace`)
|
||||
AddScriptData("customize-nav-menus", "suffix", `.min`)
|
||||
AddScriptData("customize-preview", "rtl", `replace`)
|
||||
AddScriptData("customize-preview", "suffix", `.min`)
|
||||
AddScriptData("login", "rtl", `replace`)
|
||||
AddScriptData("login", "suffix", `.min`)
|
||||
AddScriptData("site-health", "rtl", `replace`)
|
||||
AddScriptData("site-health", "suffix", `.min`)
|
||||
AddScriptData("buttons", "rtl", `replace`)
|
||||
AddScriptData("buttons", "suffix", `.min`)
|
||||
AddScriptData("admin-bar", "rtl", `replace`)
|
||||
AddScriptData("admin-bar", "suffix", `.min`)
|
||||
AddScriptData("wp-auth-check", "rtl", `replace`)
|
||||
AddScriptData("wp-auth-check", "suffix", `.min`)
|
||||
AddScriptData("editor-buttons", "rtl", `replace`)
|
||||
AddScriptData("editor-buttons", "suffix", `.min`)
|
||||
AddScriptData("media-views", "rtl", `replace`)
|
||||
AddScriptData("media-views", "suffix", `.min`)
|
||||
AddScriptData("wp-pointer", "rtl", `replace`)
|
||||
AddScriptData("wp-pointer", "suffix", `.min`)
|
||||
AddScriptData("wp-jquery-ui-dialog", "rtl", `replace`)
|
||||
AddScriptData("wp-jquery-ui-dialog", "suffix", `.min`)
|
||||
AddScriptData("wp-reset-editor-styles", "rtl", `replace`)
|
||||
AddScriptData("wp-reset-editor-styles", "suffix", `.min`)
|
||||
AddScriptData("wp-editor-classic-layout-styles", "rtl", `replace`)
|
||||
AddScriptData("wp-editor-classic-layout-styles", "suffix", `.min`)
|
||||
AddScriptData("wp-block-library-theme", "rtl", `replace`)
|
||||
AddScriptData("wp-block-library-theme", "suffix", `.min`)
|
||||
AddScriptData("wp-edit-blocks", "rtl", `replace`)
|
||||
AddScriptData("wp-edit-blocks", "suffix", `.min`)
|
||||
AddScriptData("wp-block-editor", "rtl", `replace`)
|
||||
AddScriptData("wp-block-editor", "suffix", `.min`)
|
||||
AddScriptData("wp-block-library", "rtl", `replace`)
|
||||
AddScriptData("wp-block-library", "suffix", `.min`)
|
||||
AddScriptData("wp-block-directory", "rtl", `replace`)
|
||||
AddScriptData("wp-block-directory", "suffix", `.min`)
|
||||
AddScriptData("wp-components", "rtl", `replace`)
|
||||
AddScriptData("wp-components", "suffix", `.min`)
|
||||
AddScriptData("wp-customize-widgets", "rtl", `replace`)
|
||||
AddScriptData("wp-customize-widgets", "suffix", `.min`)
|
||||
AddScriptData("wp-edit-post", "rtl", `replace`)
|
||||
AddScriptData("wp-edit-post", "suffix", `.min`)
|
||||
AddScriptData("wp-edit-site", "rtl", `replace`)
|
||||
AddScriptData("wp-edit-site", "suffix", `.min`)
|
||||
AddScriptData("wp-edit-widgets", "rtl", `replace`)
|
||||
AddScriptData("wp-edit-widgets", "suffix", `.min`)
|
||||
AddScriptData("wp-editor", "rtl", `replace`)
|
||||
AddScriptData("wp-editor", "suffix", `.min`)
|
||||
AddScriptData("wp-format-library", "rtl", `replace`)
|
||||
AddScriptData("wp-format-library", "suffix", `.min`)
|
||||
AddScriptData("wp-list-reusable-blocks", "rtl", `replace`)
|
||||
AddScriptData("wp-list-reusable-blocks", "suffix", `.min`)
|
||||
AddScriptData("wp-reusable-blocks", "rtl", `replace`)
|
||||
AddScriptData("wp-reusable-blocks", "suffix", `.min`)
|
||||
AddScriptData("wp-nux", "rtl", `replace`)
|
||||
AddScriptData("wp-nux", "suffix", `.min`)
|
||||
AddScriptData("wp-widgets", "rtl", `replace`)
|
||||
AddScriptData("wp-widgets", "suffix", `.min`)
|
||||
AddScriptData("deprecated-media", "rtl", `replace`)
|
||||
AddScriptData("deprecated-media", "suffix", `.min`)
|
||||
AddScriptData("farbtastic", "rtl", `replace`)
|
||||
AddScriptData("farbtastic", "suffix", `.min`)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,6 @@ package scriptloader
|
|||
|
||||
import "github.com/fthvgb1/wp-go/safety"
|
||||
|
||||
func defaultStyles(m *safety.Map[string, *Script], suffix string) {
|
||||
func defaultStyles(m *safety.Map[string, *Style], suffix string) {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
package scriptloader
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/fthvgb1/wp-go/app/cmd/reload"
|
||||
"github.com/fthvgb1/wp-go/app/pkg/config"
|
||||
"github.com/fthvgb1/wp-go/app/pkg/logs"
|
||||
"github.com/fthvgb1/wp-go/app/theme/wp"
|
||||
"github.com/fthvgb1/wp-go/helper/slice"
|
||||
str "github.com/fthvgb1/wp-go/helper/strings"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type _style struct {
|
||||
|
@ -50,13 +55,62 @@ func MaybeInlineStyles(h *wp.Handle) {
|
|||
if totalInlineSize+i.size > totalInlineLimit {
|
||||
break
|
||||
}
|
||||
css, err := os.ReadFile(i.path)
|
||||
if err != nil {
|
||||
logs.Error(err, "read file ", i.path)
|
||||
continue
|
||||
}
|
||||
path := filepath.Join(i.path)
|
||||
css := reload.GetAnyValMapBy("script-loader-MaybeInlineStyles", i.handle, path, func(a string) string {
|
||||
css, err := os.ReadFile(i.path)
|
||||
if err != nil {
|
||||
logs.Error(err, "read file ", i.path)
|
||||
return ""
|
||||
}
|
||||
return string(css)
|
||||
})
|
||||
|
||||
s, _ := __styles.Load(i.handle)
|
||||
s.Src = ""
|
||||
s.Extra["after"] = append(s.Extra["after"], string(css))
|
||||
a := s.Extra["after"]
|
||||
if a == nil {
|
||||
a = []string{}
|
||||
}
|
||||
slice.Unshift(&a, css)
|
||||
s.Extra["after"] = a
|
||||
}
|
||||
}
|
||||
|
||||
func emojiDetectionScript(h *wp.Handle) {
|
||||
settings := map[string]any{
|
||||
"baseUrl": "https://s.w.org/images/core/emoji/14.0.0/72x72/",
|
||||
"ext": ".png",
|
||||
"svgUrl": "https://s.w.org/images/core/emoji/14.0.0/svg/", "svgExt": ".svg",
|
||||
"source": map[string]any{
|
||||
"concatemoji": "/wp-includes/js/wp-emoji-release.min.js?ver=6.2.2",
|
||||
},
|
||||
}
|
||||
setting, _ := json.Marshal(settings)
|
||||
dir := config.GetConfig().WpDir
|
||||
emotion := reload.GetAnyValBys("script-loader-emoji", struct{}{}, func(_ struct{}) string {
|
||||
f, err := os.ReadFile(dir)
|
||||
if err != nil {
|
||||
logs.Error(err, "load emoji css fail", dir)
|
||||
return ""
|
||||
}
|
||||
return string(f)
|
||||
})
|
||||
s := str.Join("window._wpemojiSettings = ", string(setting), "\n", emotion)
|
||||
PrintInlineScriptTag(h, s, nil)
|
||||
}
|
||||
|
||||
func PrintInlineScriptTag(h *wp.Handle, script string, attr map[string]string) {
|
||||
ss := wp.GetComponentsArgs(h, "inlineScript", "")
|
||||
s := str.NewBuilder()
|
||||
s.WriteString(ss)
|
||||
s.WriteString("<script")
|
||||
for k, v := range attr {
|
||||
s.Sprintf(` %s="%s"`, k, v)
|
||||
}
|
||||
s.Sprintf(">%s</script>\n", script)
|
||||
wp.SetComponentsArgs(h, "inlineScript", s.String())
|
||||
}
|
||||
|
||||
func PrintStyles(h *wp.Handle) {
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
1011
app/theme/wp/scriptloader/wtf.go
Normal file
1011
app/theme/wp/scriptloader/wtf.go
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -390,6 +390,15 @@ func (m *Map[K, V]) Range(f func(key K, value V) bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func (m *Map[K, V]) Keys() []K {
|
||||
var r []K
|
||||
m.Range(func(key K, _ V) bool {
|
||||
r = append(r, key)
|
||||
return true
|
||||
})
|
||||
return r
|
||||
}
|
||||
|
||||
func (m *Map[K, V]) missLocked() {
|
||||
m.misses++
|
||||
if m.misses < len(m.dirty) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user