scriptloader half init

This commit is contained in:
xing 2023-07-04 23:36:25 +08:00
parent a4274b74dd
commit 1d837d4bf8
16 changed files with 3314 additions and 26 deletions

View File

@ -169,6 +169,19 @@ func VarsBy[T any](fn func() T) *safety.Var[T] {
})
return ss
}
func MapBy[K comparable, T any](fn func(*safety.Map[K, T])) *safety.Map[K, T] {
m := safety.NewMap[K, T]()
if fn != nil {
fn(m)
}
calls = append(calls, func() {
m.Flush()
if fn != nil {
fn(m)
}
})
return m
}
func Push(fn ...func()) {
calls = append(calls, fn...)

View File

@ -6,7 +6,6 @@ import (
"github.com/fthvgb1/wp-go/helper/slice"
str "github.com/fthvgb1/wp-go/helper/strings"
"github.com/gin-gonic/gin"
"net/url"
"strconv"
"strings"
)
@ -32,13 +31,12 @@ type CommentHtml interface {
func FormatComments(c *gin.Context, i CommentHtml, comments []models.Comments, maxDepth int) string {
tree := treeComments(comments)
u := c.Request.Header.Get("Referer")
var isTls bool
if u != "" {
uu, _ := url.Parse(u)
if uu.Scheme == "https" {
if c.Request.TLS != nil {
isTls = true
}
} else {
isTls = "https" == strings.ToLower(c.Request.Header.Get("X-Forwarded-Proto"))
}
h := CommentHandler{
Context: c,

View File

@ -8,6 +8,21 @@ import (
)
func pushScripts(h *wp.Handle) {
wp.AddStaticLocalize("twentyseventeen-skip-link-focus-fix", "twentyseventeenScreenReaderText", map[string]any{
"quote": `<svg class="icon icon-quote-right" aria-hidden="true" role="img"> <use href="#icon-quote-right" xlink:href="#icon-quote-right"></use> </svg>`,
})
wp.AddStaticLocalize("wp-custom-header", "_wpCustomHeaderSettings", map[string]any{
"mimeType": `video/mp4`,
"posterUrl": `/wp-content/uploads/2023/01/cropped-wallhaven-9dm7dd-1.png`,
"videoUrl": `/wp-content/uploads/2023/06/BloodMoon_GettyRM_495644264_1080_HD_ZH-CN.mp4`,
"width": `2000`,
"height": `1199`,
"minWidth": `900`,
"minHeight": `500`,
"l10n": map[string]any{
"pause": `<span class="screen-reader-text">暂停背景视频</span><svg class="icon icon-pause" aria-hidden="true" role="img"> <use href="#icon-pause" xlink:href="#icon-pause"></use> </svg>`, "play": `<span class="screen-reader-text">播放背景视频</span><svg class="icon icon-play" aria-hidden="true" role="img"> <use href="#icon-play" xlink:href="#icon-play"></use> </svg>`, "pauseSpeak": `视频已暂停。`, "playSpeak": `视频正在播放。`,
},
})
h.PushCacheGroupHeadScript(constraints.AllScene, "{theme}.head", 30, func(h *wp.Handle) string {
head := headScript
if "dark" == wpconfig.GetThemeModsVal(ThemeName, "colorscheme", "light") {

View File

@ -134,14 +134,9 @@ func CustomVideo(h *Handle, scene ...string) (ok bool) {
}
scripts = slice.Map(scripts, func(t string) string {
return fmt.Sprintf(`<script src="%s" id="wp-%s-js"></script>
`, t, str.Replaces(t, [][]string{
{"/wp-includes/js/dist/vendor/"},
{"/wp-includes/js/dist/"},
{"/wp-includes/js/"},
{".min.js"},
{".js"},
{"wp-", ""},
}))
`, t, str.Replaces(t, [][]string{{
"/wp-includes/js/dist/vendor/", "/wp-includes/js/dist/", "/wp-includes/js/", ".min.js", ".js", "wp-", "",
}}))
})
var tr = `<script id="wp-i18n-js-after">

View File

@ -0,0 +1,106 @@
<?php
/**
* wordpress/wp-includes/script-loader.php:632
* @var $scripts
*/
$con = 'package wp
import "github.com/fthvgb1/wp-go/safety"
func defaultScripts(m *safety.Map[string, *Script], suffix string){
';
foreach ($scripts->registered as $handle => $h) {
$dep = 'nil';
if ($h->deps) {
$dep = '[]string{';
$dep .= implode(',', array_map(fn($v) => '"' . $v . '"', $h->deps));
$dep .= '}';
}
$con .= sprintf('m.Store("%s", NewScript("%s", "%s"+suffix+".js", %s, "%s", %s))
', $handle, $h->handle, str_replace('.min.js', '', $h->src), $dep, $h->ver, $h->args ?: 'nil');
}
$con .= '}';
file_put_contents('/tmp/scriptLoad.go', $con);
/**
* put code to wordpress/wp-includes/class-wp-scripts.php:504
* @param $handle
* @param $object_name
* @param $l10n
* @return void
*/
function parseLocalize($handle, $object_name, $l10n): void
{
if ('utils' != $handle) {
$s = array_map('parseArr', array_keys($l10n), array_values($l10n));
$m = implode("\n", $s);
$x = sprintf('AddStaticLocalize("%s","%s",map[string]any{
%s
})
', $handle, $object_name, $m);
file_put_contents('/tmp/bb.go', $x, FILE_APPEND);
}
}
function parseArr($k, $v): string
{
/**
* @var $this object
*/
if (is_array($v)) {
if (array_diff_key(array_values($v), $v)) {
$x = '';
foreach ($v as $kk => $vv) {
$x .= parseArr($kk, $vv);
}
return sprintf('"%s":map[string]any{
%s
},', $k, $x);
} else {
$s = array_map(fn($ss) => sprintf('"%s"', $ss), $v);
return sprintf('"%s":[]string{%s},', $k, implode(',', $s));
}
} else {
return sprintf('"%s":`%s`,', $k, $v);
}
}
/**
* /var/www/html/wordpress/wp-includes/class-wp-theme-json.php:1712
* @return void
*/
function presetsMetadata()
{
$ss = <<<go
{
path: []string{%s},
preventOverride: []string{%s},
useDefaultNames: %s,
valueKey: "%s",
valueFunc: %s,
cssVars: "%s",
classes: map[string]string{
%s
},
properties: []string{%s},
},
go;
$s = '';
foreach (static::PRESETS_METADATA as $val) {
$arr = [];
$arr[] = implode(',', array_map(fn($v) => '"' . $v . '"', $val['path']));
$arr[] = (!$val['prevent_override']) ? '' : implode(',', array_map(fn($v) => '"' . $v . '"', $val['prevent_override']));
$arr[] = $val['use_default_names'] ? 'true' : 'false';
$arr[] = $val['value_key'] ?? '';
$arr[] = $val['value_func'] ?? 'nil';
$arr[] = $val['css_vars'];
$arr[] = implode(",\n", array_map(fn($k, $v) => sprintf('"%s":"%s"', $k, $v), array_keys($val['classes']), array_values($val['classes'])));
$arr[] = implode(',', array_map(fn($v) => '"' . $v . '"', $val['properties']));
$s .= sprintf($ss, ...$arr);
}
echo $s;
}

View File

@ -0,0 +1,731 @@
package wp
import (
"encoding/json"
"github.com/fthvgb1/wp-go/app/pkg/logs"
"github.com/fthvgb1/wp-go/helper/maps"
"github.com/fthvgb1/wp-go/helper/number"
str "github.com/fthvgb1/wp-go/helper/strings"
"github.com/fthvgb1/wp-go/safety"
"os"
"path/filepath"
"regexp"
"strings"
"time"
)
func defaultScripts(m *safety.Map[string, *Script], suffix string) {
m.Store("utils", NewScript("utils", "/wp-includes/js/utils"+suffix+".js", nil, "", nil))
m.Store("common", NewScript("common", "/wp-admin/js/common"+suffix+".js", []string{"jquery", "hoverIntent", "utils", "wp-i18n"}, "", 1))
m.Store("wp-sanitize", NewScript("wp-sanitize", "/wp-includes/js/wp-sanitize"+suffix+".js", nil, "", 1))
m.Store("sack", NewScript("sack", "/wp-includes/js/tw-sack"+suffix+".js", nil, "1.6.1", 1))
m.Store("quicktags", NewScript("quicktags", "/wp-includes/js/quicktags"+suffix+".js", nil, "", 1))
m.Store("colorpicker", NewScript("colorpicker", "/wp-includes/js/colorpicker"+suffix+".js", []string{"prototype"}, "3517m", nil))
m.Store("editor", NewScript("editor", "/wp-admin/js/editor"+suffix+".js", []string{"utils", "jquery"}, "", 1))
m.Store("clipboard", NewScript("clipboard", "/wp-includes/js/clipboard"+suffix+".js", nil, "2.0.11", 1))
m.Store("wp-ajax-response", NewScript("wp-ajax-response", "/wp-includes/js/wp-ajax-response"+suffix+".js", []string{"jquery", "wp-a11y"}, "", 1))
m.Store("wp-api-request", NewScript("wp-api-request", "/wp-includes/js/api-request"+suffix+".js", []string{"jquery"}, "", 1))
m.Store("wp-pointer", NewScript("wp-pointer", "/wp-includes/js/wp-pointer"+suffix+".js", []string{"jquery-ui-core", "wp-i18n"}, "", 1))
m.Store("autosave", NewScript("autosave", "/wp-includes/js/autosave"+suffix+".js", []string{"heartbeat"}, "", 1))
m.Store("heartbeat", NewScript("heartbeat", "/wp-includes/js/heartbeat"+suffix+".js", []string{"jquery", "wp-hooks"}, "", 1))
m.Store("wp-auth-check", NewScript("wp-auth-check", "/wp-includes/js/wp-auth-check"+suffix+".js", []string{"heartbeat", "wp-i18n"}, "", 1))
m.Store("wp-lists", NewScript("wp-lists", "/wp-includes/js/wp-lists"+suffix+".js", []string{"wp-ajax-response", "jquery-color"}, "", 1))
m.Store("prototype", NewScript("prototype", "https://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js"+suffix+".js", nil, "1.7.1", nil))
m.Store("scriptaculous-root", NewScript("scriptaculous-root", "https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/scriptaculous.js"+suffix+".js", []string{"prototype"}, "1.9.0", nil))
m.Store("scriptaculous-builder", NewScript("scriptaculous-builder", "https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/builder.js"+suffix+".js", []string{"scriptaculous-root"}, "1.9.0", nil))
m.Store("scriptaculous-dragdrop", NewScript("scriptaculous-dragdrop", "https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/dragdrop.js"+suffix+".js", []string{"scriptaculous-builder", "scriptaculous-effects"}, "1.9.0", nil))
m.Store("scriptaculous-effects", NewScript("scriptaculous-effects", "https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/effects.js"+suffix+".js", []string{"scriptaculous-root"}, "1.9.0", nil))
m.Store("scriptaculous-slider", NewScript("scriptaculous-slider", "https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/slider.js"+suffix+".js", []string{"scriptaculous-effects"}, "1.9.0", nil))
m.Store("scriptaculous-sound", NewScript("scriptaculous-sound", "https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/sound.js"+suffix+".js", []string{"scriptaculous-root"}, "1.9.0", nil))
m.Store("scriptaculous-controls", NewScript("scriptaculous-controls", "https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0/controls.js"+suffix+".js", []string{"scriptaculous-root"}, "1.9.0", nil))
m.Store("scriptaculous", NewScript("scriptaculous", ""+suffix+".js", []string{"scriptaculous-dragdrop", "scriptaculous-slider", "scriptaculous-controls"}, "", nil))
m.Store("cropper", NewScript("cropper", "/wp-includes/js/crop/cropper.js"+suffix+".js", []string{"scriptaculous-dragdrop"}, "", nil))
m.Store("jquery", NewScript("jquery", ""+suffix+".js", []string{"jquery-core", "jquery-migrate"}, "3.6.4", nil))
m.Store("jquery-core", NewScript("jquery-core", "/wp-includes/js/jquery/jquery"+suffix+".js", nil, "3.6.4", nil))
m.Store("jquery-migrate", NewScript("jquery-migrate", "/wp-includes/js/jquery/jquery-migrate"+suffix+".js", nil, "3.4.0", nil))
m.Store("jquery-ui-core", NewScript("jquery-ui-core", "/wp-includes/js/jquery/ui/core"+suffix+".js", []string{"jquery"}, "1.13.2", 1))
m.Store("jquery-effects-core", NewScript("jquery-effects-core", "/wp-includes/js/jquery/ui/effect"+suffix+".js", []string{"jquery"}, "1.13.2", 1))
m.Store("jquery-effects-blind", NewScript("jquery-effects-blind", "/wp-includes/js/jquery/ui/effect-blind"+suffix+".js", []string{"jquery-effects-core"}, "1.13.2", 1))
m.Store("jquery-effects-bounce", NewScript("jquery-effects-bounce", "/wp-includes/js/jquery/ui/effect-bounce"+suffix+".js", []string{"jquery-effects-core"}, "1.13.2", 1))
m.Store("jquery-effects-clip", NewScript("jquery-effects-clip", "/wp-includes/js/jquery/ui/effect-clip"+suffix+".js", []string{"jquery-effects-core"}, "1.13.2", 1))
m.Store("jquery-effects-drop", NewScript("jquery-effects-drop", "/wp-includes/js/jquery/ui/effect-drop"+suffix+".js", []string{"jquery-effects-core"}, "1.13.2", 1))
m.Store("jquery-effects-explode", NewScript("jquery-effects-explode", "/wp-includes/js/jquery/ui/effect-explode"+suffix+".js", []string{"jquery-effects-core"}, "1.13.2", 1))
m.Store("jquery-effects-fade", NewScript("jquery-effects-fade", "/wp-includes/js/jquery/ui/effect-fade"+suffix+".js", []string{"jquery-effects-core"}, "1.13.2", 1))
m.Store("jquery-effects-fold", NewScript("jquery-effects-fold", "/wp-includes/js/jquery/ui/effect-fold"+suffix+".js", []string{"jquery-effects-core"}, "1.13.2", 1))
m.Store("jquery-effects-highlight", NewScript("jquery-effects-highlight", "/wp-includes/js/jquery/ui/effect-highlight"+suffix+".js", []string{"jquery-effects-core"}, "1.13.2", 1))
m.Store("jquery-effects-puff", NewScript("jquery-effects-puff", "/wp-includes/js/jquery/ui/effect-puff"+suffix+".js", []string{"jquery-effects-core", "jquery-effects-scale"}, "1.13.2", 1))
m.Store("jquery-effects-pulsate", NewScript("jquery-effects-pulsate", "/wp-includes/js/jquery/ui/effect-pulsate"+suffix+".js", []string{"jquery-effects-core"}, "1.13.2", 1))
m.Store("jquery-effects-scale", NewScript("jquery-effects-scale", "/wp-includes/js/jquery/ui/effect-scale"+suffix+".js", []string{"jquery-effects-core", "jquery-effects-size"}, "1.13.2", 1))
m.Store("jquery-effects-shake", NewScript("jquery-effects-shake", "/wp-includes/js/jquery/ui/effect-shake"+suffix+".js", []string{"jquery-effects-core"}, "1.13.2", 1))
m.Store("jquery-effects-size", NewScript("jquery-effects-size", "/wp-includes/js/jquery/ui/effect-size"+suffix+".js", []string{"jquery-effects-core"}, "1.13.2", 1))
m.Store("jquery-effects-slide", NewScript("jquery-effects-slide", "/wp-includes/js/jquery/ui/effect-slide"+suffix+".js", []string{"jquery-effects-core"}, "1.13.2", 1))
m.Store("jquery-effects-transfer", NewScript("jquery-effects-transfer", "/wp-includes/js/jquery/ui/effect-transfer"+suffix+".js", []string{"jquery-effects-core"}, "1.13.2", 1))
m.Store("jquery-ui-accordion", NewScript("jquery-ui-accordion", "/wp-includes/js/jquery/ui/accordion"+suffix+".js", []string{"jquery-ui-core"}, "1.13.2", 1))
m.Store("jquery-ui-autocomplete", NewScript("jquery-ui-autocomplete", "/wp-includes/js/jquery/ui/autocomplete"+suffix+".js", []string{"jquery-ui-menu", "wp-a11y"}, "1.13.2", 1))
m.Store("jquery-ui-button", NewScript("jquery-ui-button", "/wp-includes/js/jquery/ui/button"+suffix+".js", []string{"jquery-ui-core", "jquery-ui-controlgroup", "jquery-ui-checkboxradio"}, "1.13.2", 1))
m.Store("jquery-ui-datepicker", NewScript("jquery-ui-datepicker", "/wp-includes/js/jquery/ui/datepicker"+suffix+".js", []string{"jquery-ui-core"}, "1.13.2", 1))
m.Store("jquery-ui-dialog", NewScript("jquery-ui-dialog", "/wp-includes/js/jquery/ui/dialog"+suffix+".js", []string{"jquery-ui-resizable", "jquery-ui-draggable", "jquery-ui-button"}, "1.13.2", 1))
m.Store("jquery-ui-menu", NewScript("jquery-ui-menu", "/wp-includes/js/jquery/ui/menu"+suffix+".js", []string{"jquery-ui-core"}, "1.13.2", 1))
m.Store("jquery-ui-mouse", NewScript("jquery-ui-mouse", "/wp-includes/js/jquery/ui/mouse"+suffix+".js", []string{"jquery-ui-core"}, "1.13.2", 1))
m.Store("jquery-ui-progressbar", NewScript("jquery-ui-progressbar", "/wp-includes/js/jquery/ui/progressbar"+suffix+".js", []string{"jquery-ui-core"}, "1.13.2", 1))
m.Store("jquery-ui-selectmenu", NewScript("jquery-ui-selectmenu", "/wp-includes/js/jquery/ui/selectmenu"+suffix+".js", []string{"jquery-ui-menu"}, "1.13.2", 1))
m.Store("jquery-ui-slider", NewScript("jquery-ui-slider", "/wp-includes/js/jquery/ui/slider"+suffix+".js", []string{"jquery-ui-mouse"}, "1.13.2", 1))
m.Store("jquery-ui-spinner", NewScript("jquery-ui-spinner", "/wp-includes/js/jquery/ui/spinner"+suffix+".js", []string{"jquery-ui-button"}, "1.13.2", 1))
m.Store("jquery-ui-tabs", NewScript("jquery-ui-tabs", "/wp-includes/js/jquery/ui/tabs"+suffix+".js", []string{"jquery-ui-core"}, "1.13.2", 1))
m.Store("jquery-ui-tooltip", NewScript("jquery-ui-tooltip", "/wp-includes/js/jquery/ui/tooltip"+suffix+".js", []string{"jquery-ui-core"}, "1.13.2", 1))
m.Store("jquery-ui-checkboxradio", NewScript("jquery-ui-checkboxradio", "/wp-includes/js/jquery/ui/checkboxradio"+suffix+".js", []string{"jquery-ui-core"}, "1.13.2", 1))
m.Store("jquery-ui-controlgroup", NewScript("jquery-ui-controlgroup", "/wp-includes/js/jquery/ui/controlgroup"+suffix+".js", []string{"jquery-ui-core"}, "1.13.2", 1))
m.Store("jquery-ui-draggable", NewScript("jquery-ui-draggable", "/wp-includes/js/jquery/ui/draggable"+suffix+".js", []string{"jquery-ui-mouse"}, "1.13.2", 1))
m.Store("jquery-ui-droppable", NewScript("jquery-ui-droppable", "/wp-includes/js/jquery/ui/droppable"+suffix+".js", []string{"jquery-ui-draggable"}, "1.13.2", 1))
m.Store("jquery-ui-resizable", NewScript("jquery-ui-resizable", "/wp-includes/js/jquery/ui/resizable"+suffix+".js", []string{"jquery-ui-mouse"}, "1.13.2", 1))
m.Store("jquery-ui-selectable", NewScript("jquery-ui-selectable", "/wp-includes/js/jquery/ui/selectable"+suffix+".js", []string{"jquery-ui-mouse"}, "1.13.2", 1))
m.Store("jquery-ui-sortable", NewScript("jquery-ui-sortable", "/wp-includes/js/jquery/ui/sortable"+suffix+".js", []string{"jquery-ui-mouse"}, "1.13.2", 1))
m.Store("jquery-ui-position", NewScript("jquery-ui-position", ""+suffix+".js", []string{"jquery-ui-core"}, "1.13.2", 1))
m.Store("jquery-ui-widget", NewScript("jquery-ui-widget", ""+suffix+".js", []string{"jquery-ui-core"}, "1.13.2", 1))
m.Store("jquery-form", NewScript("jquery-form", "/wp-includes/js/jquery/jquery.form"+suffix+".js", []string{"jquery"}, "4.3.0", 1))
m.Store("jquery-color", NewScript("jquery-color", "/wp-includes/js/jquery/jquery.color"+suffix+".js", []string{"jquery"}, "2.2.0", 1))
m.Store("schedule", NewScript("schedule", "/wp-includes/js/jquery/jquery.schedule.js"+suffix+".js", []string{"jquery"}, "20m", 1))
m.Store("jquery-query", NewScript("jquery-query", "/wp-includes/js/jquery/jquery.query.js"+suffix+".js", []string{"jquery"}, "2.2.3", 1))
m.Store("jquery-serialize-object", NewScript("jquery-serialize-object", "/wp-includes/js/jquery/jquery.serialize-object.js"+suffix+".js", []string{"jquery"}, "0.2-wp", 1))
m.Store("jquery-hotkeys", NewScript("jquery-hotkeys", "/wp-includes/js/jquery/jquery.hotkeys"+suffix+".js", []string{"jquery"}, "0.0.2m", 1))
m.Store("jquery-table-hotkeys", NewScript("jquery-table-hotkeys", "/wp-includes/js/jquery/jquery.table-hotkeys"+suffix+".js", []string{"jquery", "jquery-hotkeys"}, "", 1))
m.Store("jquery-touch-punch", NewScript("jquery-touch-punch", "/wp-includes/js/jquery/jquery.ui.touch-punch.js"+suffix+".js", []string{"jquery-ui-core", "jquery-ui-mouse"}, "0.2.2", 1))
m.Store("suggest", NewScript("suggest", "/wp-includes/js/jquery/suggest"+suffix+".js", []string{"jquery"}, "1.1-20110113", 1))
m.Store("imagesloaded", NewScript("imagesloaded", "/wp-includes/js/imagesloaded"+suffix+".js", nil, "4.1.4", 1))
m.Store("masonry", NewScript("masonry", "/wp-includes/js/masonry"+suffix+".js", []string{"imagesloaded"}, "4.2.2", 1))
m.Store("jquery-masonry", NewScript("jquery-masonry", "/wp-includes/js/jquery/jquery.masonry"+suffix+".js", []string{"jquery", "masonry"}, "3.1.2b", 1))
m.Store("thickbox", NewScript("thickbox", "/wp-includes/js/thickbox/thickbox.js"+suffix+".js", []string{"jquery"}, "3.1-20121105", 1))
m.Store("jcrop", NewScript("jcrop", "/wp-includes/js/jcrop/jquery.Jcrop"+suffix+".js", []string{"jquery"}, "0.9.15", nil))
m.Store("swfobject", NewScript("swfobject", "/wp-includes/js/swfobject.js"+suffix+".js", nil, "2.2-20120417", nil))
m.Store("moxiejs", NewScript("moxiejs", "/wp-includes/js/plupload/moxie"+suffix+".js", nil, "1.3.5", nil))
m.Store("plupload", NewScript("plupload", "/wp-includes/js/plupload/plupload"+suffix+".js", []string{"moxiejs"}, "2.1.9", nil))
m.Store("plupload-all", NewScript("plupload-all", ""+suffix+".js", []string{"plupload"}, "2.1.1", nil))
m.Store("plupload-html5", NewScript("plupload-html5", ""+suffix+".js", []string{"plupload"}, "2.1.1", nil))
m.Store("plupload-flash", NewScript("plupload-flash", ""+suffix+".js", []string{"plupload"}, "2.1.1", nil))
m.Store("plupload-silverlight", NewScript("plupload-silverlight", ""+suffix+".js", []string{"plupload"}, "2.1.1", nil))
m.Store("plupload-html4", NewScript("plupload-html4", ""+suffix+".js", []string{"plupload"}, "2.1.1", nil))
m.Store("plupload-handlers", NewScript("plupload-handlers", "/wp-includes/js/plupload/handlers"+suffix+".js", []string{"clipboard", "jquery", "plupload", "underscore", "wp-a11y", "wp-i18n"}, "", nil))
m.Store("wp-plupload", NewScript("wp-plupload", "/wp-includes/js/plupload/wp-plupload"+suffix+".js", []string{"plupload", "jquery", "json2", "media-models"}, "", 1))
m.Store("swfupload", NewScript("swfupload", "/wp-includes/js/swfupload/swfupload.js"+suffix+".js", nil, "2201-20110113", nil))
m.Store("swfupload-all", NewScript("swfupload-all", ""+suffix+".js", []string{"swfupload"}, "2201", nil))
m.Store("swfupload-handlers", NewScript("swfupload-handlers", "/wp-includes/js/swfupload/handlers"+suffix+".js", []string{"swfupload-all", "jquery"}, "2201-20110524", nil))
m.Store("comment-reply", NewScript("comment-reply", "/wp-includes/js/comment-reply"+suffix+".js", nil, "", 1))
m.Store("json2", NewScript("json2", "/wp-includes/js/json2"+suffix+".js", nil, "2015-05-03", nil))
m.Store("underscore", NewScript("underscore", "/wp-includes/js/underscore"+suffix+".js", nil, "1.13.4", 1))
m.Store("backbone", NewScript("backbone", "/wp-includes/js/backbone"+suffix+".js", []string{"underscore", "jquery"}, "1.4.1", 1))
m.Store("wp-util", NewScript("wp-util", "/wp-includes/js/wp-util"+suffix+".js", []string{"underscore", "jquery"}, "", 1))
m.Store("wp-backbone", NewScript("wp-backbone", "/wp-includes/js/wp-backbone"+suffix+".js", []string{"backbone", "wp-util"}, "", 1))
m.Store("revisions", NewScript("revisions", "/wp-admin/js/revisions"+suffix+".js", []string{"wp-backbone", "jquery-ui-slider", "hoverIntent"}, "", 1))
m.Store("imgareaselect", NewScript("imgareaselect", "/wp-includes/js/imgareaselect/jquery.imgareaselect"+suffix+".js", []string{"jquery"}, "", 1))
m.Store("mediaelement", NewScript("mediaelement", ""+suffix+".js", []string{"jquery", "mediaelement-core", "mediaelement-migrate"}, "4.2.17", 1))
m.Store("mediaelement-core", NewScript("mediaelement-core", "/wp-includes/js/mediaelement/mediaelement-and-player"+suffix+".js", nil, "4.2.17", 1))
m.Store("mediaelement-migrate", NewScript("mediaelement-migrate", "/wp-includes/js/mediaelement/mediaelement-migrate"+suffix+".js", nil, "", 1))
m.Store("mediaelement-vimeo", NewScript("mediaelement-vimeo", "/wp-includes/js/mediaelement/renderers/vimeo"+suffix+".js", []string{"mediaelement"}, "4.2.17", 1))
m.Store("wp-mediaelement", NewScript("wp-mediaelement", "/wp-includes/js/mediaelement/wp-mediaelement"+suffix+".js", []string{"mediaelement"}, "", 1))
m.Store("wp-codemirror", NewScript("wp-codemirror", "/wp-includes/js/codemirror/codemirror"+suffix+".js", nil, "5.29.1-alpha-ee20357", nil))
m.Store("csslint", NewScript("csslint", "/wp-includes/js/codemirror/csslint.js"+suffix+".js", nil, "1.0.5", nil))
m.Store("esprima", NewScript("esprima", "/wp-includes/js/codemirror/esprima.js"+suffix+".js", nil, "4.0.0", nil))
m.Store("jshint", NewScript("jshint", "/wp-includes/js/codemirror/fakejshint.js"+suffix+".js", []string{"esprima"}, "2.9.5", nil))
m.Store("jsonlint", NewScript("jsonlint", "/wp-includes/js/codemirror/jsonlint.js"+suffix+".js", nil, "1.6.2", nil))
m.Store("htmlhint", NewScript("htmlhint", "/wp-includes/js/codemirror/htmlhint.js"+suffix+".js", nil, "0.9.14-xwp", nil))
m.Store("htmlhint-kses", NewScript("htmlhint-kses", "/wp-includes/js/codemirror/htmlhint-kses.js"+suffix+".js", []string{"htmlhint"}, "", nil))
m.Store("code-editor", NewScript("code-editor", "/wp-admin/js/code-editor"+suffix+".js", []string{"jquery", "wp-codemirror", "underscore"}, "", nil))
m.Store("wp-theme-plugin-editor", NewScript("wp-theme-plugin-editor", "/wp-admin/js/theme-plugin-editor"+suffix+".js", []string{"common", "wp-util", "wp-sanitize", "jquery", "jquery-ui-core", "wp-a11y", "underscore", "wp-i18n"}, "", 1))
m.Store("wp-playlist", NewScript("wp-playlist", "/wp-includes/js/mediaelement/wp-playlist"+suffix+".js", []string{"wp-util", "backbone", "mediaelement"}, "", 1))
m.Store("zxcvbn-async", NewScript("zxcvbn-async", "/wp-includes/js/zxcvbn-async"+suffix+".js", nil, "1.0", nil))
m.Store("password-strength-meter", NewScript("password-strength-meter", "/wp-admin/js/password-strength-meter"+suffix+".js", []string{"jquery", "zxcvbn-async", "wp-i18n"}, "", 1))
m.Store("application-passwords", NewScript("application-passwords", "/wp-admin/js/application-passwords"+suffix+".js", []string{"jquery", "wp-util", "wp-api-request", "wp-date", "wp-i18n", "wp-hooks"}, "", 1))
m.Store("auth-app", NewScript("auth-app", "/wp-admin/js/auth-app"+suffix+".js", []string{"jquery", "wp-api-request", "wp-i18n", "wp-hooks"}, "", 1))
m.Store("user-profile", NewScript("user-profile", "/wp-admin/js/user-profile"+suffix+".js", []string{"jquery", "password-strength-meter", "wp-util", "wp-i18n"}, "", 1))
m.Store("language-chooser", NewScript("language-chooser", "/wp-admin/js/language-chooser"+suffix+".js", []string{"jquery"}, "", 1))
m.Store("user-suggest", NewScript("user-suggest", "/wp-admin/js/user-suggest"+suffix+".js", []string{"jquery-ui-autocomplete"}, "", 1))
m.Store("admin-bar", NewScript("admin-bar", "/wp-includes/js/admin-bar"+suffix+".js", []string{"hoverintent-js"}, "", 1))
m.Store("wplink", NewScript("wplink", "/wp-includes/js/wplink"+suffix+".js", []string{"jquery", "wp-a11y"}, "", 1))
m.Store("wpdialogs", NewScript("wpdialogs", "/wp-includes/js/wpdialog"+suffix+".js", []string{"jquery-ui-dialog"}, "", 1))
m.Store("word-count", NewScript("word-count", "/wp-admin/js/word-count"+suffix+".js", nil, "", 1))
m.Store("media-upload", NewScript("media-upload", "/wp-admin/js/media-upload"+suffix+".js", []string{"thickbox", "shortcode"}, "", 1))
m.Store("hoverIntent", NewScript("hoverIntent", "/wp-includes/js/hoverIntent"+suffix+".js", []string{"jquery"}, "1.10.2", 1))
m.Store("hoverintent-js", NewScript("hoverintent-js", "/wp-includes/js/hoverintent-js"+suffix+".js", nil, "2.2.1", 1))
m.Store("customize-base", NewScript("customize-base", "/wp-includes/js/customize-base"+suffix+".js", []string{"jquery", "json2", "underscore"}, "", 1))
m.Store("customize-loader", NewScript("customize-loader", "/wp-includes/js/customize-loader"+suffix+".js", []string{"customize-base"}, "", 1))
m.Store("customize-preview", NewScript("customize-preview", "/wp-includes/js/customize-preview"+suffix+".js", []string{"wp-a11y", "customize-base"}, "", 1))
m.Store("customize-models", NewScript("customize-models", "/wp-includes/js/customize-models.js"+suffix+".js", []string{"underscore", "backbone"}, "", 1))
m.Store("customize-views", NewScript("customize-views", "/wp-includes/js/customize-views.js"+suffix+".js", []string{"jquery", "underscore", "imgareaselect", "customize-models", "media-editor", "media-views"}, "", 1))
m.Store("customize-controls", NewScript("customize-controls", "/wp-admin/js/customize-controls"+suffix+".js", []string{"customize-base", "wp-a11y", "wp-util", "jquery-ui-core"}, "", 1))
m.Store("customize-selective-refresh", NewScript("customize-selective-refresh", "/wp-includes/js/customize-selective-refresh"+suffix+".js", []string{"jquery", "wp-util", "customize-preview"}, "", 1))
m.Store("customize-widgets", NewScript("customize-widgets", "/wp-admin/js/customize-widgets"+suffix+".js", []string{"jquery", "jquery-ui-sortable", "jquery-ui-droppable", "wp-backbone", "customize-controls"}, "", 1))
m.Store("customize-preview-widgets", NewScript("customize-preview-widgets", "/wp-includes/js/customize-preview-widgets"+suffix+".js", []string{"jquery", "wp-util", "customize-preview", "customize-selective-refresh"}, "", 1))
m.Store("customize-nav-menus", NewScript("customize-nav-menus", "/wp-admin/js/customize-nav-menus"+suffix+".js", []string{"jquery", "wp-backbone", "customize-controls", "accordion", "nav-menu", "wp-sanitize"}, "", 1))
m.Store("customize-preview-nav-menus", NewScript("customize-preview-nav-menus", "/wp-includes/js/customize-preview-nav-menus"+suffix+".js", []string{"jquery", "wp-util", "customize-preview", "customize-selective-refresh"}, "", 1))
m.Store("wp-custom-header", NewScript("wp-custom-header", "/wp-includes/js/wp-custom-header"+suffix+".js", []string{"wp-a11y"}, "", 1))
m.Store("accordion", NewScript("accordion", "/wp-admin/js/accordion"+suffix+".js", []string{"jquery"}, "", 1))
m.Store("shortcode", NewScript("shortcode", "/wp-includes/js/shortcode"+suffix+".js", []string{"underscore"}, "", 1))
m.Store("media-models", NewScript("media-models", "/wp-includes/js/media-models"+suffix+".js", []string{"wp-backbone"}, "", 1))
m.Store("wp-embed", NewScript("wp-embed", "/wp-includes/js/wp-embed"+suffix+".js", nil, "", 1))
m.Store("media-views", NewScript("media-views", "/wp-includes/js/media-views"+suffix+".js", []string{"utils", "media-models", "wp-plupload", "jquery-ui-sortable", "wp-mediaelement", "wp-api-request", "wp-a11y", "clipboard", "wp-i18n"}, "", 1))
m.Store("media-editor", NewScript("media-editor", "/wp-includes/js/media-editor"+suffix+".js", []string{"shortcode", "media-views", "wp-i18n"}, "", 1))
m.Store("media-audiovideo", NewScript("media-audiovideo", "/wp-includes/js/media-audiovideo"+suffix+".js", []string{"media-editor"}, "", 1))
m.Store("mce-view", NewScript("mce-view", "/wp-includes/js/mce-view"+suffix+".js", []string{"shortcode", "jquery", "media-views", "media-audiovideo"}, "", 1))
m.Store("wp-api", NewScript("wp-api", "/wp-includes/js/wp-api"+suffix+".js", []string{"jquery", "backbone", "underscore", "wp-api-request"}, "", 1))
m.Store("react", NewScript("react", "/wp-includes/js/dist/vendor/react"+suffix+".js", []string{"wp-polyfill"}, "18.2.0", 1))
m.Store("react-dom", NewScript("react-dom", "/wp-includes/js/dist/vendor/react-dom"+suffix+".js", []string{"react"}, "18.2.0", 1))
m.Store("regenerator-runtime", NewScript("regenerator-runtime", "/wp-includes/js/dist/vendor/regenerator-runtime"+suffix+".js", nil, "0.13.11", 1))
m.Store("moment", NewScript("moment", "/wp-includes/js/dist/vendor/moment"+suffix+".js", nil, "2.29.4", 1))
m.Store("lodash", NewScript("lodash", "/wp-includes/js/dist/vendor/lodash"+suffix+".js", nil, "4.17.19", 1))
m.Store("wp-polyfill-fetch", NewScript("wp-polyfill-fetch", "/wp-includes/js/dist/vendor/wp-polyfill-fetch"+suffix+".js", nil, "3.6.2", 1))
m.Store("wp-polyfill-formdata", NewScript("wp-polyfill-formdata", "/wp-includes/js/dist/vendor/wp-polyfill-formdata"+suffix+".js", nil, "4.0.10", 1))
m.Store("wp-polyfill-node-contains", NewScript("wp-polyfill-node-contains", "/wp-includes/js/dist/vendor/wp-polyfill-node-contains"+suffix+".js", nil, "4.6.0", 1))
m.Store("wp-polyfill-url", NewScript("wp-polyfill-url", "/wp-includes/js/dist/vendor/wp-polyfill-url"+suffix+".js", nil, "3.6.4", 1))
m.Store("wp-polyfill-dom-rect", NewScript("wp-polyfill-dom-rect", "/wp-includes/js/dist/vendor/wp-polyfill-dom-rect"+suffix+".js", nil, "4.6.0", 1))
m.Store("wp-polyfill-element-closest", NewScript("wp-polyfill-element-closest", "/wp-includes/js/dist/vendor/wp-polyfill-element-closest"+suffix+".js", nil, "3.0.2", 1))
m.Store("wp-polyfill-object-fit", NewScript("wp-polyfill-object-fit", "/wp-includes/js/dist/vendor/wp-polyfill-object-fit"+suffix+".js", nil, "2.3.5", 1))
m.Store("wp-polyfill-inert", NewScript("wp-polyfill-inert", "/wp-includes/js/dist/vendor/wp-polyfill-inert"+suffix+".js", nil, "3.1.2", 1))
m.Store("wp-polyfill", NewScript("wp-polyfill", "/wp-includes/js/dist/vendor/wp-polyfill"+suffix+".js", []string{"wp-polyfill-inert", "regenerator-runtime"}, "3.15.0", 1))
m.Store("wp-tinymce-root", NewScript("wp-tinymce-root", "http://wp.test/wp-includes/js/tinymce/tinymce"+suffix+".js", nil, "49110-20201110", nil))
m.Store("wp-tinymce", NewScript("wp-tinymce", "http://wp.test/wp-includes/js/tinymce/plugins/compat3x/plugin"+suffix+".js", []string{"wp-tinymce-root"}, "49110-20201110", nil))
m.Store("wp-tinymce-lists", NewScript("wp-tinymce-lists", "http://wp.test/wp-includes/js/tinymce/plugins/lists/plugin"+suffix+".js", []string{"wp-tinymce"}, "49110-20201110", nil))
m.Store("wp-a11y", NewScript("wp-a11y", "/wp-includes/js/dist/a11y"+suffix+".js", []string{"wp-dom-ready", "wp-i18n", "wp-polyfill"}, "ecce20f002eda4c19664", 1))
m.Store("wp-annotations", NewScript("wp-annotations", "/wp-includes/js/dist/annotations"+suffix+".js", []string{"wp-data", "wp-hooks", "wp-i18n", "wp-polyfill", "wp-rich-text"}, "1720fc5d5c76f53a1740", 1))
m.Store("wp-api-fetch", NewScript("wp-api-fetch", "/wp-includes/js/dist/api-fetch"+suffix+".js", []string{"wp-i18n", "wp-polyfill", "wp-url"}, "bc0029ca2c943aec5311", 1))
m.Store("wp-autop", NewScript("wp-autop", "/wp-includes/js/dist/autop"+suffix+".js", []string{"wp-polyfill"}, "43197d709df445ccf849", 1))
m.Store("wp-blob", NewScript("wp-blob", "/wp-includes/js/dist/blob"+suffix+".js", []string{"wp-polyfill"}, "e7b4ea96175a89b263e2", 1))
m.Store("wp-block-directory", NewScript("wp-block-directory", "/wp-includes/js/dist/block-directory"+suffix+".js", []string{"wp-a11y", "wp-api-fetch", "wp-block-editor", "wp-blocks", "wp-components", "wp-compose", "wp-core-data", "wp-data", "wp-editor", "wp-element", "wp-hooks", "wp-html-entities", "wp-i18n", "wp-notices", "wp-plugins", "wp-polyfill", "wp-primitives", "wp-url"}, "9c45b8d28fc867ceed45", 1))
m.Store("wp-block-editor", NewScript("wp-block-editor", "/wp-includes/js/dist/block-editor"+suffix+".js", []string{"lodash", "react", "react-dom", "wp-a11y", "wp-api-fetch", "wp-blob", "wp-blocks", "wp-components", "wp-compose", "wp-data", "wp-date", "wp-deprecated", "wp-dom", "wp-element", "wp-escape-html", "wp-hooks", "wp-html-entities", "wp-i18n", "wp-is-shallow-equal", "wp-keyboard-shortcuts", "wp-keycodes", "wp-notices", "wp-polyfill", "wp-preferences", "wp-primitives", "wp-private-apis", "wp-rich-text", "wp-shortcode", "wp-style-engine", "wp-token-list", "wp-url", "wp-warning", "wp-wordcount"}, "43e40e04f77d598ede94", 1))
m.Store("wp-block-library", NewScript("wp-block-library", "/wp-includes/js/dist/block-library"+suffix+".js", []string{"lodash", "wp-a11y", "wp-api-fetch", "wp-autop", "wp-blob", "wp-block-editor", "wp-blocks", "wp-components", "wp-compose", "wp-core-data", "wp-data", "wp-date", "wp-deprecated", "wp-dom", "wp-element", "wp-escape-html", "wp-hooks", "wp-html-entities", "wp-i18n", "wp-keycodes", "wp-notices", "wp-polyfill", "wp-primitives", "wp-private-apis", "wp-reusable-blocks", "wp-rich-text", "wp-server-side-render", "wp-url", "wp-viewport", "editor"}, "3115f0b5551a55bb6d3b", 1))
m.Store("wp-block-serialization-default-parser", NewScript("wp-block-serialization-default-parser", "/wp-includes/js/dist/block-serialization-default-parser"+suffix+".js", []string{"wp-polyfill"}, "30ffd7e7e199f10b2a6d", 1))
m.Store("wp-blocks", NewScript("wp-blocks", "/wp-includes/js/dist/blocks"+suffix+".js", []string{"lodash", "wp-autop", "wp-blob", "wp-block-serialization-default-parser", "wp-compose", "wp-data", "wp-deprecated", "wp-dom", "wp-element", "wp-hooks", "wp-html-entities", "wp-i18n", "wp-is-shallow-equal", "wp-polyfill", "wp-shortcode"}, "639e14271099dc3d85bf", 1))
m.Store("wp-components", NewScript("wp-components", "/wp-includes/js/dist/components"+suffix+".js", []string{"lodash", "react", "react-dom", "wp-a11y", "wp-compose", "wp-date", "wp-deprecated", "wp-dom", "wp-element", "wp-escape-html", "wp-hooks", "wp-html-entities", "wp-i18n", "wp-is-shallow-equal", "wp-keycodes", "wp-polyfill", "wp-primitives", "wp-private-apis", "wp-rich-text", "wp-warning"}, "bf6e0ec3089253604b52", 1))
m.Store("wp-compose", NewScript("wp-compose", "/wp-includes/js/dist/compose"+suffix+".js", []string{"react", "wp-deprecated", "wp-dom", "wp-element", "wp-is-shallow-equal", "wp-keycodes", "wp-polyfill", "wp-priority-queue"}, "7d5916e3b2ef0ea01400", 1))
m.Store("wp-core-data", NewScript("wp-core-data", "/wp-includes/js/dist/core-data"+suffix+".js", []string{"lodash", "wp-api-fetch", "wp-blocks", "wp-compose", "wp-data", "wp-deprecated", "wp-element", "wp-html-entities", "wp-i18n", "wp-is-shallow-equal", "wp-polyfill", "wp-url"}, "fc0de6bb17aa25caf698", 1))
m.Store("wp-customize-widgets", NewScript("wp-customize-widgets", "/wp-includes/js/dist/customize-widgets"+suffix+".js", []string{"wp-block-editor", "wp-block-library", "wp-blocks", "wp-components", "wp-compose", "wp-core-data", "wp-data", "wp-deprecated", "wp-dom", "wp-element", "wp-hooks", "wp-i18n", "wp-is-shallow-equal", "wp-keyboard-shortcuts", "wp-keycodes", "wp-media-utils", "wp-polyfill", "wp-preferences", "wp-primitives", "wp-private-apis", "wp-widgets"}, "7ae69cc350436c0cf301", 1))
m.Store("wp-data", NewScript("wp-data", "/wp-includes/js/dist/data"+suffix+".js", []string{"lodash", "wp-compose", "wp-deprecated", "wp-element", "wp-is-shallow-equal", "wp-polyfill", "wp-priority-queue", "wp-private-apis", "wp-redux-routine"}, "90cebfec01d1a3f0368e", 1))
m.Store("wp-data-controls", NewScript("wp-data-controls", "/wp-includes/js/dist/data-controls"+suffix+".js", []string{"wp-api-fetch", "wp-data", "wp-deprecated", "wp-polyfill"}, "e10d473d392daa8501e8", 1))
m.Store("wp-date", NewScript("wp-date", "/wp-includes/js/dist/date"+suffix+".js", []string{"moment", "wp-deprecated", "wp-polyfill"}, "f8550b1212d715fbf745", 1))
m.Store("wp-deprecated", NewScript("wp-deprecated", "/wp-includes/js/dist/deprecated"+suffix+".js", []string{"wp-hooks", "wp-polyfill"}, "6c963cb9494ba26b77eb", 1))
m.Store("wp-dom", NewScript("wp-dom", "/wp-includes/js/dist/dom"+suffix+".js", []string{"wp-deprecated", "wp-polyfill"}, "e03c89e1dd68aee1cb3a", 1))
m.Store("wp-dom-ready", NewScript("wp-dom-ready", "/wp-includes/js/dist/dom-ready"+suffix+".js", []string{"wp-polyfill"}, "392bdd43726760d1f3ca", 1))
m.Store("wp-edit-post", NewScript("wp-edit-post", "/wp-includes/js/dist/edit-post"+suffix+".js", []string{"lodash", "wp-a11y", "wp-api-fetch", "wp-block-editor", "wp-block-library", "wp-blocks", "wp-components", "wp-compose", "wp-core-data", "wp-data", "wp-deprecated", "wp-editor", "wp-element", "wp-hooks", "wp-i18n", "wp-keyboard-shortcuts", "wp-keycodes", "wp-media-utils", "wp-notices", "wp-plugins", "wp-polyfill", "wp-preferences", "wp-primitives", "wp-private-apis", "wp-url", "wp-viewport", "wp-warning", "wp-widgets", "media-models", "media-views", "postbox", "wp-dom-ready"}, "d098b8ee5bdffa238c03", 1))
m.Store("wp-edit-site", NewScript("wp-edit-site", "/wp-includes/js/dist/edit-site"+suffix+".js", []string{"lodash", "react", "wp-a11y", "wp-api-fetch", "wp-block-editor", "wp-block-library", "wp-blocks", "wp-components", "wp-compose", "wp-core-data", "wp-data", "wp-deprecated", "wp-editor", "wp-element", "wp-hooks", "wp-html-entities", "wp-i18n", "wp-keyboard-shortcuts", "wp-keycodes", "wp-media-utils", "wp-notices", "wp-plugins", "wp-polyfill", "wp-preferences", "wp-primitives", "wp-private-apis", "wp-reusable-blocks", "wp-url", "wp-viewport", "wp-widgets"}, "fcf81e803ab1af60d4f8", 1))
m.Store("wp-edit-widgets", NewScript("wp-edit-widgets", "/wp-includes/js/dist/edit-widgets"+suffix+".js", []string{"wp-api-fetch", "wp-block-editor", "wp-block-library", "wp-blocks", "wp-components", "wp-compose", "wp-core-data", "wp-data", "wp-deprecated", "wp-dom", "wp-element", "wp-hooks", "wp-i18n", "wp-keyboard-shortcuts", "wp-keycodes", "wp-media-utils", "wp-notices", "wp-plugins", "wp-polyfill", "wp-preferences", "wp-primitives", "wp-private-apis", "wp-reusable-blocks", "wp-url", "wp-viewport", "wp-widgets"}, "d683d5fc75e655fdf974", 1))
m.Store("wp-editor", NewScript("wp-editor", "/wp-includes/js/dist/editor"+suffix+".js", []string{"lodash", "react", "wp-a11y", "wp-api-fetch", "wp-blob", "wp-block-editor", "wp-blocks", "wp-components", "wp-compose", "wp-core-data", "wp-data", "wp-date", "wp-deprecated", "wp-dom", "wp-element", "wp-hooks", "wp-html-entities", "wp-i18n", "wp-keyboard-shortcuts", "wp-keycodes", "wp-media-utils", "wp-notices", "wp-polyfill", "wp-preferences", "wp-primitives", "wp-private-apis", "wp-reusable-blocks", "wp-rich-text", "wp-server-side-render", "wp-url", "wp-wordcount"}, "1fb5fcf129627da4939e", 1))
m.Store("wp-element", NewScript("wp-element", "/wp-includes/js/dist/element"+suffix+".js", []string{"react", "react-dom", "wp-escape-html", "wp-polyfill"}, "b3bda690cfc516378771", 1))
m.Store("wp-escape-html", NewScript("wp-escape-html", "/wp-includes/js/dist/escape-html"+suffix+".js", []string{"wp-polyfill"}, "03e27a7b6ae14f7afaa6", 1))
m.Store("wp-format-library", NewScript("wp-format-library", "/wp-includes/js/dist/format-library"+suffix+".js", []string{"wp-a11y", "wp-block-editor", "wp-components", "wp-data", "wp-element", "wp-html-entities", "wp-i18n", "wp-polyfill", "wp-primitives", "wp-rich-text", "wp-url"}, "cd4a10ec005e2f001978", 1))
m.Store("wp-hooks", NewScript("wp-hooks", "/wp-includes/js/dist/hooks"+suffix+".js", []string{"wp-polyfill"}, "4169d3cf8e8d95a3d6d5", 1))
m.Store("wp-html-entities", NewScript("wp-html-entities", "/wp-includes/js/dist/html-entities"+suffix+".js", []string{"wp-polyfill"}, "36a4a255da7dd2e1bf8e", 1))
m.Store("wp-i18n", NewScript("wp-i18n", "/wp-includes/js/dist/i18n"+suffix+".js", []string{"wp-hooks", "wp-polyfill"}, "9e794f35a71bb98672ae", 1))
m.Store("wp-is-shallow-equal", NewScript("wp-is-shallow-equal", "/wp-includes/js/dist/is-shallow-equal"+suffix+".js", []string{"wp-polyfill"}, "20c2b06ecf04afb14fee", 1))
m.Store("wp-keyboard-shortcuts", NewScript("wp-keyboard-shortcuts", "/wp-includes/js/dist/keyboard-shortcuts"+suffix+".js", []string{"wp-data", "wp-element", "wp-keycodes", "wp-polyfill"}, "b696c16720133edfc065", 1))
m.Store("wp-keycodes", NewScript("wp-keycodes", "/wp-includes/js/dist/keycodes"+suffix+".js", []string{"wp-i18n", "wp-polyfill"}, "184b321fa2d3bc7fd173", 1))
m.Store("wp-list-reusable-blocks", NewScript("wp-list-reusable-blocks", "/wp-includes/js/dist/list-reusable-blocks"+suffix+".js", []string{"wp-api-fetch", "wp-components", "wp-compose", "wp-element", "wp-i18n", "wp-polyfill"}, "6ba78be26d660b6af113", 1))
m.Store("wp-media-utils", NewScript("wp-media-utils", "/wp-includes/js/dist/media-utils"+suffix+".js", []string{"wp-api-fetch", "wp-blob", "wp-element", "wp-i18n", "wp-polyfill"}, "f837b6298c83612cd6f6", 1))
m.Store("wp-notices", NewScript("wp-notices", "/wp-includes/js/dist/notices"+suffix+".js", []string{"wp-data", "wp-polyfill"}, "9c1575b7a31659f45a45", 1))
m.Store("wp-nux", NewScript("wp-nux", "/wp-includes/js/dist/nux"+suffix+".js", []string{"wp-components", "wp-compose", "wp-data", "wp-deprecated", "wp-element", "wp-i18n", "wp-polyfill", "wp-primitives"}, "038c48e26a91639ae8ab", 1))
m.Store("wp-plugins", NewScript("wp-plugins", "/wp-includes/js/dist/plugins"+suffix+".js", []string{"wp-compose", "wp-element", "wp-hooks", "wp-polyfill", "wp-primitives"}, "0d1b90278bae7df6ecf9", 1))
m.Store("wp-preferences", NewScript("wp-preferences", "/wp-includes/js/dist/preferences"+suffix+".js", []string{"wp-a11y", "wp-components", "wp-data", "wp-element", "wp-i18n", "wp-polyfill", "wp-primitives", "wp-preferences-persistence"}, "c66e137a7e588dab54c3", 1))
m.Store("wp-preferences-persistence", NewScript("wp-preferences-persistence", "/wp-includes/js/dist/preferences-persistence"+suffix+".js", []string{"wp-api-fetch", "wp-polyfill"}, "c5543628aa7ff5bd5be4", 1))
m.Store("wp-primitives", NewScript("wp-primitives", "/wp-includes/js/dist/primitives"+suffix+".js", []string{"wp-element", "wp-polyfill"}, "dfac1545e52734396640", 1))
m.Store("wp-priority-queue", NewScript("wp-priority-queue", "/wp-includes/js/dist/priority-queue"+suffix+".js", []string{"wp-polyfill"}, "422e19e9d48b269c5219", 1))
m.Store("wp-private-apis", NewScript("wp-private-apis", "/wp-includes/js/dist/private-apis"+suffix+".js", []string{"wp-polyfill"}, "6f247ed2bc3571743bba", 1))
m.Store("wp-redux-routine", NewScript("wp-redux-routine", "/wp-includes/js/dist/redux-routine"+suffix+".js", []string{"wp-polyfill"}, "d86e7e9f062d7582f76b", 1))
m.Store("wp-reusable-blocks", NewScript("wp-reusable-blocks", "/wp-includes/js/dist/reusable-blocks"+suffix+".js", []string{"wp-block-editor", "wp-blocks", "wp-components", "wp-core-data", "wp-data", "wp-element", "wp-i18n", "wp-notices", "wp-polyfill", "wp-primitives", "wp-url"}, "a7367a6154c724b51b31", 1))
m.Store("wp-rich-text", NewScript("wp-rich-text", "/wp-includes/js/dist/rich-text"+suffix+".js", []string{"wp-a11y", "wp-compose", "wp-data", "wp-deprecated", "wp-element", "wp-escape-html", "wp-i18n", "wp-keycodes", "wp-polyfill"}, "9307ec04c67d79b6e813", 1))
m.Store("wp-server-side-render", NewScript("wp-server-side-render", "/wp-includes/js/dist/server-side-render"+suffix+".js", []string{"wp-api-fetch", "wp-blocks", "wp-components", "wp-compose", "wp-data", "wp-element", "wp-i18n", "wp-polyfill", "wp-url"}, "d1bc93277666143a3f5e", 1))
m.Store("wp-shortcode", NewScript("wp-shortcode", "/wp-includes/js/dist/shortcode"+suffix+".js", []string{"wp-polyfill"}, "7539044b04e6bca57f2e", 1))
m.Store("wp-style-engine", NewScript("wp-style-engine", "/wp-includes/js/dist/style-engine"+suffix+".js", []string{"lodash", "wp-polyfill"}, "528e6cf281ffc9b7bd3c", 1))
m.Store("wp-token-list", NewScript("wp-token-list", "/wp-includes/js/dist/token-list"+suffix+".js", []string{"wp-polyfill"}, "f2cf0bb3ae80de227e43", 1))
m.Store("wp-url", NewScript("wp-url", "/wp-includes/js/dist/url"+suffix+".js", []string{"wp-polyfill"}, "16185fce2fb043a0cfed", 1))
m.Store("wp-viewport", NewScript("wp-viewport", "/wp-includes/js/dist/viewport"+suffix+".js", []string{"wp-compose", "wp-data", "wp-element", "wp-polyfill"}, "4f6bd168b2b8b45c8a6b", 1))
m.Store("wp-warning", NewScript("wp-warning", "/wp-includes/js/dist/warning"+suffix+".js", []string{"wp-polyfill"}, "4acee5fc2fd9a24cefc2", 1))
m.Store("wp-widgets", NewScript("wp-widgets", "/wp-includes/js/dist/widgets"+suffix+".js", []string{"wp-api-fetch", "wp-block-editor", "wp-blocks", "wp-components", "wp-compose", "wp-core-data", "wp-data", "wp-element", "wp-i18n", "wp-notices", "wp-polyfill", "wp-primitives"}, "040ac8be5e0cfc4b52df", 1))
m.Store("wp-wordcount", NewScript("wp-wordcount", "/wp-includes/js/dist/wordcount"+suffix+".js", []string{"wp-polyfill"}, "feb9569307aec24292f2", 1))
}
func defaultLocalize(h *Handle) {
AddDynamicLocalize(h, "utils", "userSettings", map[string]any{
"url": h.C.Request.RequestURI,
"uid": "0",
"time": number.IntToString(time.Now().Unix()),
"secure": h.IsHttps(),
})
AddStaticLocalize("wp-ajax-response", "wpAjax", map[string]any{
"noPerm": `抱歉,您不能这么做。`,
"broken": `出现了问题。`,
})
AddStaticLocalize("wp-api-request", "wpApiSettings", map[string]any{
"root": `/wp-json/`,
"nonce": `9a3ce0a5d7`,
"versionString": `wp/v2/`,
})
AddStaticLocalize("jquery-ui-autocomplete", "uiAutocompleteL10n", map[string]any{
"noResults": `未找到结果。`,
"oneResult": `找到1个结果。使用上下方向键来导航。`,
"manyResults": `找到%d个结果。使用上下方向键来导航。`,
"itemSelected": `已选择项目。`,
})
AddStaticLocalize("thickbox", "thickboxL10n", map[string]any{
"next": `下一页 &gt;`,
"prev": `&lt; 上一页`,
"image": `图片`,
"of": `/`,
"close": `关闭`,
"noiframes": `这个功能需要iframe的支持。您可能禁止了iframe的显示或您的浏览器不支持此功能。`,
"loadingAnimation": `/wp-includes/js/thickbox/loadingAnimation.gif`,
})
AddStaticLocalize("mediaelement", "_wpmejsSettings", map[string]any{
"pluginPath": `/wp-includes/js/mediaelement/`,
"classPrefix": `mejs-`,
"stretching": `responsive`,
"audioShortcodeLibrary": `mediaelement`,
"videoShortcodeLibrary": `mediaelement`,
})
AddStaticLocalize("zxcvbn-async", "_zxcvbnSettings", map[string]any{
"src": `/wp-includes/js/zxcvbn.min.js`,
})
AddStaticLocalize("mce-view", "mceViewL10n", map[string]any{
"shortcodes": []string{"wp_caption", "caption", "gallery", "playlist", "audio", "video", "embed"},
})
AddStaticLocalize("word-count", "wordCountL10n", map[string]any{
"type": `characters_excluding_spaces`,
"shortcodes": []string{"wp_caption", "caption", "gallery", "playlist", "audio", "video", "embed"},
})
}
func defaultTranslate() {
SetTranslation("common", "default", "")
SetTranslation("wp-pointer", "default", "")
SetTranslation("wp-auth-check", "default", "")
SetTranslation("wp-theme-plugin-editor", "default", "")
SetTranslation("password-strength-meter", "default", "")
SetTranslation("application-passwords", "default", "")
SetTranslation("auth-app", "default", "")
SetTranslation("user-profile", "default", "")
SetTranslation("media-views", "default", "")
SetTranslation("media-editor", "default", "")
SetTranslation("wp-a11y", "default", "")
SetTranslation("wp-annotations", "default", "")
SetTranslation("wp-api-fetch", "default", "")
SetTranslation("wp-block-directory", "default", "")
SetTranslation("wp-block-editor", "default", "")
SetTranslation("wp-block-library", "default", "")
SetTranslation("wp-blocks", "default", "")
SetTranslation("wp-components", "default", "")
SetTranslation("wp-core-data", "default", "")
SetTranslation("wp-customize-widgets", "default", "")
SetTranslation("wp-edit-post", "default", "")
SetTranslation("wp-edit-site", "default", "")
SetTranslation("wp-edit-widgets", "default", "")
SetTranslation("wp-editor", "default", "")
SetTranslation("wp-format-library", "default", "")
SetTranslation("wp-keycodes", "default", "")
SetTranslation("wp-list-reusable-blocks", "default", "")
SetTranslation("wp-media-utils", "default", "")
SetTranslation("wp-nux", "default", "")
SetTranslation("wp-preferences", "default", "")
SetTranslation("wp-reusable-blocks", "default", "")
SetTranslation("wp-rich-text", "default", "")
SetTranslation("wp-server-side-render", "default", "")
SetTranslation("wp-widgets", "default", "")
SetTranslation("common", "default", "")
SetTranslation("wp-pointer", "default", "")
SetTranslation("wp-auth-check", "default", "")
SetTranslation("wp-theme-plugin-editor", "default", "")
SetTranslation("password-strength-meter", "default", "")
SetTranslation("application-passwords", "default", "")
SetTranslation("auth-app", "default", "")
SetTranslation("user-profile", "default", "")
SetTranslation("media-views", "default", "")
SetTranslation("media-editor", "default", "")
SetTranslation("wp-a11y", "default", "")
SetTranslation("wp-annotations", "default", "")
SetTranslation("wp-api-fetch", "default", "")
SetTranslation("wp-block-directory", "default", "")
SetTranslation("wp-block-editor", "default", "")
SetTranslation("wp-block-library", "default", "")
SetTranslation("wp-blocks", "default", "")
SetTranslation("wp-components", "default", "")
SetTranslation("wp-core-data", "default", "")
SetTranslation("wp-customize-widgets", "default", "")
SetTranslation("wp-edit-post", "default", "")
SetTranslation("wp-edit-site", "default", "")
SetTranslation("wp-edit-widgets", "default", "")
SetTranslation("wp-editor", "default", "")
SetTranslation("wp-format-library", "default", "")
SetTranslation("wp-keycodes", "default", "")
SetTranslation("wp-list-reusable-blocks", "default", "")
SetTranslation("wp-media-utils", "default", "")
SetTranslation("wp-nux", "default", "")
SetTranslation("wp-preferences", "default", "")
SetTranslation("wp-reusable-blocks", "default", "")
SetTranslation("wp-rich-text", "default", "")
SetTranslation("wp-server-side-render", "default", "")
SetTranslation("wp-widgets", "default", "")
}
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`)
}
func defaultAddInLineScript() {
AddInlineScript("mediaelement-core", `var mejsL10n = {"language":"zh","strings":{"mejs.download-file":"\u4e0b\u8f7d\u6587\u4ef6","mejs.install-flash":"\u60a8\u6b63\u5728\u4f7f\u7528\u7684\u6d4f\u89c8\u5668\u672a\u5b89\u88c5\u6216\u542f\u7528Flash\u64ad\u653e\u5668\uff0c\u8bf7\u542f\u7528\u60a8\u7684Flash\u64ad\u653e\u5668\u63d2\u4ef6\uff0c\u6216\u4ece https:\/\/get.adobe.com\/flashplayer\/ \u4e0b\u8f7d\u6700\u65b0\u7248\u3002","mejs.fullscreen":"\u5168\u5c4f","mejs.play":"\u64ad\u653e","mejs.pause":"\u6682\u505c","mejs.time-slider":"\u65f6\u95f4\u8f74","mejs.time-help-text":"\u4f7f\u7528\u5de6\/\u53f3\u7bad\u5934\u952e\u6765\u524d\u8fdb\u4e00\u79d2\uff0c\u4e0a\/\u4e0b\u7bad\u5934\u952e\u6765\u524d\u8fdb\u5341\u79d2\u3002","mejs.live-broadcast":"\u73b0\u573a\u76f4\u64ad","mejs.volume-help-text":"\u4f7f\u7528\u4e0a\/\u4e0b\u7bad\u5934\u952e\u6765\u589e\u9ad8\u6216\u964d\u4f4e\u97f3\u91cf\u3002","mejs.unmute":"\u53d6\u6d88\u9759\u97f3","mejs.mute":"\u9759\u97f3","mejs.volume-slider":"\u97f3\u91cf","mejs.video-player":"\u89c6\u9891\u64ad\u653e\u5668","mejs.audio-player":"\u97f3\u9891\u64ad\u653e\u5668","mejs.captions-subtitles":"\u8bf4\u660e\u6587\u5b57\u6216\u5b57\u5e55","mejs.captions-chapters":"\u7ae0\u8282","mejs.none":"\u65e0","mejs.afrikaans":"\u5357\u975e\u8377\u5170\u8bed","mejs.albanian":"\u963f\u5c14\u5df4\u5c3c\u4e9a\u8bed","mejs.arabic":"\u963f\u62c9\u4f2f\u8bed","mejs.belarusian":"\u767d\u4fc4\u7f57\u65af\u8bed","mejs.bulgarian":"\u4fdd\u52a0\u5229\u4e9a\u8bed","mejs.catalan":"\u52a0\u6cf0\u7f57\u5c3c\u4e9a\u8bed","mejs.chinese":"\u4e2d\u6587","mejs.chinese-simplified":"\u4e2d\u6587\uff08\u7b80\u4f53\uff09","mejs.chinese-traditional":"\u4e2d\u6587(\uff08\u7e41\u4f53\uff09","mejs.croatian":"\u514b\u7f57\u5730\u4e9a\u8bed","mejs.czech":"\u6377\u514b\u8bed","mejs.danish":"\u4e39\u9ea6\u8bed","mejs.dutch":"\u8377\u5170\u8bed","mejs.english":"\u82f1\u8bed","mejs.estonian":"\u7231\u6c99\u5c3c\u4e9a\u8bed","mejs.filipino":"\u83f2\u5f8b\u5bbe\u8bed","mejs.finnish":"\u82ac\u5170\u8bed","mejs.french":"\u6cd5\u8bed","mejs.galician":"\u52a0\u5229\u897f\u4e9a\u8bed","mejs.german":"\u5fb7\u8bed","mejs.greek":"\u5e0c\u814a\u8bed","mejs.haitian-creole":"\u6d77\u5730\u514b\u91cc\u5965\u5c14\u8bed","mejs.hebrew":"\u5e0c\u4f2f\u6765\u8bed","mejs.hindi":"\u5370\u5730\u8bed","mejs.hungarian":"\u5308\u7259\u5229\u8bed","mejs.icelandic":"\u51b0\u5c9b\u8bed","mejs.indonesian":"\u5370\u5ea6\u5c3c\u897f\u4e9a\u8bed","mejs.irish":"\u7231\u5c14\u5170\u8bed","mejs.italian":"\u610f\u5927\u5229\u8bed","mejs.japanese":"\u65e5\u8bed","mejs.korean":"\u97e9\u8bed","mejs.latvian":"\u62c9\u8131\u7ef4\u4e9a\u8bed","mejs.lithuanian":"\u7acb\u9676\u5b9b\u8bed","mejs.macedonian":"\u9a6c\u5176\u987f\u8bed","mejs.malay":"\u9a6c\u6765\u8bed","mejs.maltese":"\u9a6c\u8033\u4ed6\u8bed","mejs.norwegian":"\u632a\u5a01\u8bed","mejs.persian":"\u6ce2\u65af\u8bed","mejs.polish":"\u6ce2\u5170\u8bed","mejs.portuguese":"\u8461\u8404\u7259\u8bed","mejs.romanian":"\u7f57\u9a6c\u5c3c\u4e9a\u8bed","mejs.russian":"\u4fc4\u8bed","mejs.serbian":"\u585e\u5c14\u7ef4\u4e9a\u8bed","mejs.slovak":"\u65af\u6d1b\u4f10\u514b\u8bed","mejs.slovenian":"\u65af\u6d1b\u6587\u5c3c\u4e9a\u8bed","mejs.spanish":"\u897f\u73ed\u7259\u8bed","mejs.swahili":"\u65af\u74e6\u5e0c\u91cc\u8bed","mejs.swedish":"\u745e\u5178\u8bed","mejs.tagalog":"\u4ed6\u52a0\u7984\u8bed","mejs.thai":"\u6cf0\u8bed","mejs.turkish":"\u571f\u8033\u5176\u8bed","mejs.ukrainian":"\u4e4c\u514b\u5170\u8bed","mejs.vietnamese":"\u8d8a\u5357\u8bed","mejs.welsh":"\u5a01\u5c14\u58eb\u8bed","mejs.yiddish":"\u610f\u7b2c\u7eea\u8bed"}};`, "before")
AddInlineScript("lodash", `window.lodash = _.noConflict();`, "after")
AddInlineScript("moment", `moment.updateLocale( 'zh_CN', {"months":["1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708"],"monthsShort":["1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708"],"weekdays":["\u661f\u671f\u65e5","\u661f\u671f\u4e00","\u661f\u671f\u4e8c","\u661f\u671f\u4e09","\u661f\u671f\u56db","\u661f\u671f\u4e94","\u661f\u671f\u516d"],"weekdaysShort":["\u5468\u65e5","\u5468\u4e00","\u5468\u4e8c","\u5468\u4e09","\u5468\u56db","\u5468\u4e94","\u5468\u516d"],"week":{"dow":1},"longDateFormat":{"LT":"ag:i","LTS":null,"L":null,"LL":"Y\u5e74n\u6708j\u65e5","LLL":"Y\u5e74n\u6708j\u65e5a g:i","LLLL":null}} );`, "after")
AddInlineScript("wp-i18n", `wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ 'ltr' ] } );`, "after")
AddInlineScript("text-widgets", `wp.textWidgets.idBases.push( "text" );`, "after")
AddInlineScript("custom-html-widgets", `wp.customHtmlWidgets.idBases.push( "custom_html" );`, "after")
}
func defaultAddInLineStyle() {
AddInlineStyle("global-styles", ``)
AddInlineStyle("global-styles", `.wp-block-navigation a:where(:not(.wp-element-button)){color: inherit;}`)
AddInlineStyle("global-styles", `:where(.wp-block-columns.is-layout-flex){gap: 2em;}`)
AddInlineStyle("global-styles", `.wp-block-pullquote{font-size: 1.5em;line-height: 1.6;}`)
}
var re = regexp.MustCompile(`(?is:\([A-Za-z0-9'.:\-/, ]+\))`)
var rea = regexp.MustCompile(`array\(array\(.*?\)\)`)
func themeJson() {
blocksData := __blocksData()
//path := config.GetConfig().WpDir
path := "/var/www/html/wordpress"
f, err := os.ReadFile(filepath.Join(path, "wp-includes/theme.json"))
if err != nil {
logs.Error(err, "can't open theme json", path)
return
}
var j map[string]any
err = json.Unmarshal(f, &j)
if err != nil {
logs.Error(err, "can't parse theme json")
return
}
t := ThemeJson{blocksData, j}
setThemeJson(j)
setSpacingSizes(t)
GetStyletSheet(t, nil, nil, nil)
}
func setThemeJson(m map[string]any) {
blocks, ok := maps.GetStrAnyVal[map[string]any](m, "settings.blocks")
if !ok {
return
}
var paths = [][]string{{"settings"}}
for name := range blocks {
paths = append(paths, []string{"settings", "blocks", name})
}
for _, path := range paths {
for _, metadatum := range presetsMetadata {
pathx := append(path, metadatum.path...)
key := strings.Join(pathx, ".")
preset, ok := maps.GetStrAnyVal[[]any](m, key)
if !ok || len(preset) < 1 {
continue
}
var presets []map[string]string
for _, a := range preset {
v, ok := a.(map[string]any)
if !ok {
continue
}
mm := map[string]string{}
for kk, vv := range v {
val, ok := vv.(string)
if !ok {
continue
}
mm[kk] = val
}
presets = append(presets, mm)
}
maps.SetStrAnyVal(m, key, map[string]any{
"default": presets,
})
}
}
}
var __propertyMappings = map[string]string{
"apiVersion": "api_version",
"title": "title",
"category": "category",
"parent": "parent",
"ancestor": "ancestor",
"icon": "icon",
"description": "description",
"keywords": "keywords",
"attributes": "attributes",
"providesContext": "provides_context",
"usesContext": "uses_context",
"supports": "supports",
"styles": "styles",
"variations": "variations",
"example": "example",
}
func __propertyMap(m map[string]any) {
for k, mappedKey := range __propertyMappings {
vv, ok := m[k]
if ok {
m[mappedKey] = vv
}
}
}
func __blocksData() map[string]any {
path := "/var/www/html/wordpress"
b, err := os.ReadFile(filepath.Join(path, "wp-includes/blocks/blocks-json.php"))
if err != nil {
logs.Error(err, "can't open block json", path)
return nil
}
bb := re.ReplaceAllStringFunc(string(b), func(s string) string {
return str.Replace(s, map[string]string{
"(": "[",
")": "]",
})
})
bb = strings.ReplaceAll(bb, "\"", `\"`)
bb = rea.ReplaceAllStringFunc(bb, func(s string) string {
s = strings.ReplaceAll(s, "array(array", "[")
ss := []rune(s)
ss[len(ss)-1] = ']'
s = string(ss)
return s
})
bb = str.Replace(bb, map[string]string{
"<?php": "",
"return": "",
"array": "",
"()": "[]",
"(": "{",
")": "}",
"=>": ":",
";": "",
"'": `"`,
})
var blocks map[string]any
err = json.Unmarshal([]byte(bb), &blocks)
if err != nil {
logs.Error(err, "can't parse block json")
return nil
}
c := map[string]any{
"version": int64(2),
}
for k, v := range blocks {
m, ok := v.(map[string]any)
if !ok {
continue
}
_, ok = m["style"]
if !ok {
m["style"] = str.Join("wp-block-", k)
}
_, ok = m["editorStyle"]
if !ok {
m["editorStyle"] = str.Join("wp-block-", k, "-editor")
}
__propertyMap(m)
name := maps.GetStrAnyValWithDefaults(m, "name", str.Join("core/", k))
blocks[name] = v
if name != k {
delete(blocks, k)
}
__blockSelectors(m)
s, ok := maps.GetStrAnyVal[map[string]any](m, "supports.__experimentalStyle")
if ok {
__removeComment(s)
maps.SetStrAnyVal(c, str.Join("styles.blocks.", name), s)
}
_, ok = maps.GetStrAnyVal[string](m, "supports.spacing.blockGap.__experimentalDefault")
if ok {
key := str.Join("styles.blocks.", name, ".spacing.blockGap")
_, ok := maps.GetStrAnyVal[string](c, key)
if !ok {
maps.SetStrAnyVal[map[string]any](c, key, nil)
}
}
}
return map[string]any{
"blocks_metadata": blocks,
"theme_json": c,
}
}
func __blockSelectors(m map[string]any) {
selector, ok := maps.GetStrAnyVal[string](m, "supports.__experimentalSelector")
if !ok {
vv, _ := maps.GetStrAnyVal[string](m, "name")
selector = str.Join(".wp-block-", str.Replaces(vv, [][]string{
{"core/", ""},
{"/", "-"},
}))
}
var features = map[string]string{}
maps.SetStrAnyVal(m, "supports.selector", selector)
color, ok := maps.GetStrAnyVal[string](m, "supports.color.__experimentalDuotone")
if ok {
maps.SetStrAnyVal(m, "duotone", color)
}
for k, v := range blockSupportFeatureLevelSelectors {
key := str.Join("supports.", k, ".__experimentalSelector")
vv, ok := maps.GetStrAnyVal[string](m, key)
if ok && vv != "" {
features[v] = scopeSelector(selector, vv)
}
}
if len(features) > 0 {
m["features"] = features
}
blockSelector := strings.Split(selector, ",")
for name, selor := range __elements {
var els []string
for _, s := range blockSelector {
if s == selor {
els = append(els, selor)
break
}
els = append(els, appendToSelector(selor, str.Join(s, " "), "left"))
}
maps.SetStrAnyVal(m, str.Join("elements.", name), strings.Join(els, ","))
}
styles, ok := maps.GetStrAnyVal[[]any](m, "styles")
if ok {
var styleSelectors = map[string]string{}
for _, ss := range styles {
s, ok := ss.(map[string]any)
if !ok {
continue
}
name, ok := maps.GetStrAnyVal[string](s, "name")
if !ok {
continue
}
styleSelectors[name] = appendToSelector(str.Join(".is-style-", name, ".is-style-", name), selector, "")
}
m["styleVariations"] = styleSelectors
}
}

View File

@ -0,0 +1,20 @@
package wp
import (
"testing"
)
func Test_themeJson(t *testing.T) {
tests := []struct {
name string
}{
{
name: "t1",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
themeJson()
})
}
}

View File

@ -0,0 +1,727 @@
package wp
import (
"encoding/json"
"fmt"
"github.com/fthvgb1/wp-go/app/cmd/reload"
"github.com/fthvgb1/wp-go/app/wpconfig"
"github.com/fthvgb1/wp-go/helper"
"github.com/fthvgb1/wp-go/helper/maps"
"github.com/fthvgb1/wp-go/helper/number"
"github.com/fthvgb1/wp-go/helper/slice"
str "github.com/fthvgb1/wp-go/helper/strings"
"github.com/fthvgb1/wp-go/safety"
"math"
"strconv"
"strings"
)
var scripts = reload.MapBy[string, *Script](func(m *safety.Map[string, *Script]) {
suffix := ".min"
defaultScripts(m, suffix)
})
func addScript(handle string, src string, deps []string, ver string, args any) {
script := NewScript(handle, src, deps, ver, args)
scripts.Store(handle, script)
}
func localize(handle, objectname string, l10n map[string]any) string {
if "jquery" == handle {
handle = "jquery-core"
}
after, ok := maps.GetStrAnyVal[string](l10n, "l10n_print_after")
if ok {
delete(l10n, "l10n_print_after")
}
v, _ := json.Marshal(l10n)
script := fmt.Sprintf("var %s = %s;", objectname, string(v))
if after != "" {
script = str.Join(script, "\n", after, ";")
}
return script
}
func AddStaticLocalize(handle, objectname string, l10n map[string]any) {
addData(handle, "data", localize(handle, objectname, l10n))
}
func AddDynamicLocalize(h *Handle, handle, objectname string, l10n map[string]any) {
AddDynamicData(h, handle, "data", localize(handle, objectname, l10n))
}
func getData(handle, key string) string {
h, ok := scripts.Load(handle)
if !ok {
return ""
}
return strings.Join(h.Extra[key], "\n")
}
func GetData(h *Handle, handle, key string) string {
hh, ok := scripts.Load(handle)
if !ok {
return ""
}
d := hh.Extra[key]
d = append(d, GetDynamicData(h, handle, key))
return strings.Join(d, "\n")
}
func addData(handle, key, data string) {
s, ok := scripts.Load(handle)
if !ok {
s = NewScript(handle, "", nil, "", nil)
}
if s.Extra == nil {
s.Extra = make(map[string][]string)
}
s.Extra[key] = append(s.Extra[key], data)
}
func AddInlineScript(handle, data, position string) {
if handle == "" || data == "" {
return
}
if position != "after" {
position = "before"
}
addData(handle, position, data)
}
func AddInlineStyle(handle, data string) {
if handle == "" || data == "" {
return
}
addData(handle, "after", data)
}
func InlineScripts(handle, position string, display bool) string {
ss := getData(handle, position)
if ss == "" {
return ""
}
scp := strings.Trim(ss, "\n")
if display {
return fmt.Sprintf("<script id='%s-js-%s'>\n%s\n</script>\n", handle, position, scp)
}
return scp
}
func AddScript(handle string, src string, deps []string, ver string, args any) {
script := NewScript(handle, src, deps, ver, args)
scripts.Store(handle, script)
}
type Script struct {
Handle string `json:"handle,omitempty"`
Src string `json:"src,omitempty"`
Deps []string `json:"deps,omitempty"`
Ver string `json:"ver,omitempty"`
Args any `json:"args,omitempty"`
Extra map[string][]string `json:"extra,omitempty"`
Textdomain string `json:"textdomain,omitempty"`
TranslationsPath string `json:"translations_path,omitempty"`
}
func NewScript(handle string, src string, deps []string, ver string, args any) *Script {
return &Script{Handle: handle, Src: src, Deps: deps, Ver: ver, Args: args}
}
func AddDynamicData(h *Handle, handle, key, data string) {
da := helper.GetContextVal(h.C, "__scriptDynamicData__", map[string]map[string][]string{})
m, ok := da[handle]
if !ok {
m = map[string][]string{}
}
m[key] = append(m[key], data)
da[handle] = m
}
func GetDynamicData(h *Handle, handle, key string) string {
da := helper.GetContextVal(h.C, "__scriptDynamicData__", map[string]map[string][]string{})
if len(da) < 1 {
return ""
}
m, ok := da[handle]
if !ok {
return ""
}
mm, ok := m[key]
if !ok {
return ""
}
return strings.Join(mm, "\n")
}
func SetTranslation(handle, domain, path string) {
hh, ok := scripts.Load(handle)
if !ok {
return
}
if !slice.IsContained(hh.Deps, handle) {
hh.Deps = append(hh.Deps, "wp-i18n")
}
if domain == "" {
domain = "default"
}
hh.Textdomain = domain
hh.TranslationsPath = path
}
var __elements = map[string]string{
"link": "a:where(:not(.wp-element-button))", // The `where` is needed to lower the specificity.
"heading": "h1, h2, h3, h4, h5, h6",
"h1": "h1",
"h2": "h2",
"h3": "h3",
"h4": "h4",
"h5": "h5",
"h6": "h6",
// We have the .wp-block-button__link class so that this will target older buttons that have been serialized.
"button": ".wp-element-button, .wp-block-button__link",
// The block classes are necessary to target older content that won't use the new class names.
"caption": ".wp-element-caption, .wp-block-audio figcaption, .wp-block-embed figcaption, .wp-block-gallery figcaption, .wp-block-image figcaption, .wp-block-table figcaption, .wp-block-video figcaption",
"cite": "cite",
}
const RootBlockSelector = "body"
type node struct {
Path []string
Selector string
}
var __validElementPseudoSelectors = map[string][]string{
"link": {":link", ":any-link", ":visited", ":hover", ":focus", ":active"},
"button": {":link", ":any-link", ":visited", ":hover", ":focus", ":active"},
}
var blockSupportFeatureLevelSelectors = map[string]string{
"__experimentalBorder": "border",
"color": "color",
"spacing": "spacing",
"typography": "typography",
}
func appendToSelector(selector, toAppend, position string) string {
s := strings.Split(selector, ",")
if position == "" {
position = "right"
}
return strings.Join(slice.Map(s, func(t string) string {
var l, r string
if position == "right" {
l = t
r = toAppend
} else {
l = toAppend
r = t
}
return str.Join(l, r)
}), ",")
}
func __removeComment(m map[string]any) {
delete(m, "//")
for _, v := range m {
mm, ok := v.(map[string]any)
if ok {
__removeComment(mm)
}
}
}
func scopeSelector(scope, selector string) string {
scopes := strings.Split(scope, ",")
selectors := strings.Split(selector, ",")
var a []string
for _, outer := range scopes {
outer = strings.Trim(outer, " \t\n\r\x00\x0B")
for _, inner := range selectors {
inner = strings.Trim(inner, " \t\n\r\x00\x0B")
if outer != "" && inner != "" {
a = append(a, str.Join(outer, " ", inner))
} else if outer == "" {
a = append(a, inner)
} else if inner == "" {
a = append(a, outer)
}
}
}
return strings.Join(a, ", ")
}
func getBlockNodes(m map[string]any) []map[string]any {
selectors, _ := maps.GetStrAnyVal[map[string]any](m, "blocks_metadata")
mm, _ := maps.GetStrAnyVal[map[string]any](m, "theme_json.styles.blocks")
var nodes []map[string]any
for k, v := range mm {
vv, ok := v.(map[string]any)
if !ok {
continue
}
s, _ := maps.GetStrAnyVal[string](selectors, str.Join(k, ".supports.selector"))
d, _ := maps.GetStrAnyVal[string](selectors, str.Join(k, ".duotone"))
f, _ := maps.GetStrAnyVal[string](selectors, str.Join(k, ".features"))
n, ok := maps.GetStrAnyVal[map[string]any](vv, "variations")
var variationSelectors []node
if ok {
for variation := range n {
ss, _ := maps.GetStrAnyVal[string](selectors, str.Join(k, ".styleVariations.", variation))
variationSelectors = append(variationSelectors, node{
Path: []string{"styles", "blocks", k, "variations", variation},
Selector: ss,
})
}
}
nodes = append(nodes, map[string]any{
"name": k,
"path": []string{"styles", "blocks", k},
"selector": s,
"duotone": d,
"features": f,
"variations": variationSelectors,
})
e, ok := maps.GetStrAnyVal[map[string]any](vv, "elements")
if !ok {
continue
}
for element, vvv := range e {
_, ok = vvv.(map[string]any)
if !ok {
continue
}
key := str.Join(k, ".elements.", element)
selector, _ := maps.GetStrAnyVal[string](selectors, key)
nodes = append(nodes, map[string]any{
"path": []string{"styles", "blocks", k, "elements", element},
"selector": selector,
})
if val, ok := __validElementPseudoSelectors[element]; ok {
for _, ss := range val {
_, ok = maps.GetStrAnyVal[string](vv, str.Join("elements.", ss))
if !ok {
continue
}
nodes = append(nodes, map[string]any{
"path": []string{"styles", "blocks", k, "elements", element},
"selector": appendToSelector(selector, ss, ""),
})
}
}
}
}
return nodes
}
func getSettingNodes(m, setting map[string]any) []node {
var nodes []node
nodes = append(nodes, node{
Path: []string{"settings"},
Selector: RootBlockSelector,
})
selectors, _ := maps.GetStrAnyVal[map[string]any](m, "blocks_metadata")
s, ok := maps.GetStrAnyVal[map[string]any](setting, "settings.blocks")
if !ok {
return nil
}
for name := range s {
selector, ok := maps.GetStrAnyVal[string](selectors, str.Join(name, ".supports.selector"))
if ok {
nodes = append(nodes, node{
Path: []string{"settings", "blocks", name},
Selector: selector,
})
}
}
return nodes
}
type ThemeJson struct {
blocksMetaData map[string]any
themeJson map[string]any
}
var presetsMetadata = []presetMeta{
{
path: []string{"color", "palette"},
preventOverride: []string{"color", "defaultPalette"},
useDefaultNames: false,
valueKey: "color",
valueFunc: nil,
cssVars: "--wp--preset--color--$slug",
classes: map[string]string{
".has-$slug-color": "color",
".has-$slug-background-color": "background-color",
".has-$slug-border-color": "border-color",
},
properties: []string{"color", "background-color", "border-color"},
}, {
path: []string{"color", "gradients"},
preventOverride: []string{"color", "defaultGradients"},
useDefaultNames: false,
valueKey: "gradient",
valueFunc: nil,
cssVars: "--wp--preset--gradient--$slug",
classes: map[string]string{
".has-$slug-gradient-background": "background",
},
properties: []string{"background"},
}, {
path: []string{"color", "duotone"},
preventOverride: []string{"color", "defaultDuotone"},
useDefaultNames: false,
valueKey: "",
valueFunc: wpGetDuotoneFilterProperty,
cssVars: "--wp--preset--duotone--$slug",
classes: map[string]string{},
properties: []string{"filter"},
}, {
path: []string{"typography", "fontSizes"},
preventOverride: []string{},
useDefaultNames: true,
valueKey: "",
valueFunc: wpGetTypographyFontSizeValue,
cssVars: "--wp--preset--font-size--$slug",
classes: map[string]string{
".has-$slug-font-size": "font-size",
},
properties: []string{"font-size"},
}, {
path: []string{"typography", "fontFamilies"},
preventOverride: []string{},
useDefaultNames: false,
valueKey: "fontFamily",
valueFunc: nil,
cssVars: "--wp--preset--font-family--$slug",
classes: map[string]string{
".has-$slug-font-family": "font-family",
},
properties: []string{"font-family"},
}, {
path: []string{"spacing", "spacingSizes"},
preventOverride: []string{},
useDefaultNames: true,
valueKey: "size",
valueFunc: nil,
cssVars: "--wp--preset--spacing--$slug",
classes: map[string]string{},
properties: []string{"padding", "margin"},
}, {
path: []string{"shadow", "presets"},
preventOverride: []string{"shadow", "defaultPresets"},
useDefaultNames: false,
valueKey: "shadow",
valueFunc: nil,
cssVars: "--wp--preset--shadow--$slug",
classes: map[string]string{},
properties: []string{"box-shadow"},
},
}
type presetMeta struct {
path []string
preventOverride []string
useDefaultNames bool
valueFunc func(map[string]string, map[string]any) string
valueKey string
cssVars string
classes map[string]string
properties []string
}
type declaration struct {
name string
value string
}
func wpGetDuotoneFilterProperty(preset map[string]string, _ map[string]any) string {
v, ok := preset["colors"]
if ok && "unset" == v {
return "none"
}
id, ok := preset["slug"]
if ok {
id = str.Join("wp-duotone-", id)
}
return str.Join(`url('#`, id, "')")
}
func wpGetTypographyFontSizeValue(preset map[string]string, m map[string]any) string {
size, ok := preset["size"]
if !ok {
return ""
}
if size == "" || size == "0" {
return size
}
origin := "custom"
if !wpconfig.HasThemeJson() {
origin = "theme"
}
typographySettings, ok := maps.GetStrAnyVal[map[string]any](m, "typography")
if !ok {
return size
}
fluidSettings, ok := maps.GetStrAnyVal[map[string]any](typographySettings, "fluid")
//todo so complex dying 👻
_ = fluidSettings
_ = origin
return size
}
var __themeJson *safety.Var[ThemeJson]
func GetThemeJson() ThemeJson {
return __themeJson.Load()
}
func wpGetTypographyValueAndUnit(value string, options map[string]any) {
/*options := maps.Merge(options, map[string]any{
"coerce_to": "",
"root_size_value": 16,
"acceptable_units": []string{"rem", "px", "em"},
})
u, _ := maps.GetStrAnyVal[[]string](options, "acceptable_units")
acceptableUnitsGroup := strings.Join(u, "|")*/
}
func computeThemeVars(m map[string]any) []declaration {
//todo ......
return nil
}
func computePresetVars(m map[string]any, origins []string) []declaration {
var declarations []declaration
for _, metadatum := range presetsMetadata {
slug := getSettingsValuesBySlug(m, metadatum, origins)
for k, v := range slug {
declarations = append(declarations, declaration{
name: strings.Replace(metadatum.cssVars, "$slug", k, -1),
value: v,
})
}
}
return declarations
}
func getSettingsValuesBySlug(m map[string]any, meta presetMeta, origins []string) map[string]string {
perOrigin := maps.GetStrAnyValWithDefaults[map[string]any](m, strings.Join(meta.path, "."), nil)
r := map[string]string{}
for _, origin := range origins {
if vv, ok := maps.GetStrAnyVal[[]map[string]string](perOrigin, origin); ok {
for _, preset := range vv {
slug := preset["slug"]
value := ""
if vv, ok := preset[meta.valueKey]; ok && vv != "" {
value = vv
} else if meta.valueFunc != nil {
value = meta.valueFunc(preset, m)
}
r[slug] = value
}
}
}
return r
}
func setSpacingSizes(t ThemeJson) {
m, _ := maps.GetStrAnyVal[map[string]any](t.themeJson, "settings.spacing.spacingScale")
unit, _ := maps.GetStrAnyVal[string](m, "unit")
currentStep, _ := maps.GetStrAnyVal[float64](m, "mediumStep")
mediumStep := currentStep
steps, _ := maps.GetStrAnyVal[float64](m, "steps")
operator, _ := maps.GetStrAnyVal[string](m, "operator")
increment, _ := maps.GetStrAnyVal[float64](m, "increment")
stepsMidPoint := math.Round(steps / 2)
reminder := float64(0)
xSmallCount := ""
var sizes []map[string]string
slug := 40
for i := stepsMidPoint - 1; i > 0 && slug > 0 && steps > 1; i-- {
if "+" == operator {
currentStep -= increment
} else if increment > 1 {
currentStep /= increment
} else {
currentStep *= increment
}
if currentStep <= 0 {
reminder = i
break
}
name := "small"
if i != stepsMidPoint-1 {
name = str.Join(xSmallCount, "X-Small")
}
sizes = append(sizes, map[string]string{
"name": name,
"slug": number.IntToString(slug),
"size": fmt.Sprintf("%v%s", number.Round(currentStep, 2), unit),
})
if i == stepsMidPoint-2 {
xSmallCount = strconv.Itoa(2)
}
if i < stepsMidPoint-2 {
n := str.ToInt[int](xSmallCount)
n++
xSmallCount = strconv.Itoa(n)
}
slug -= 10
}
slice.ReverseSelf(sizes)
sizes = append(sizes, map[string]string{
"name": "Medium",
"slug": "50",
"size": str.Join(number.ToString(mediumStep), unit),
})
currentStep = mediumStep
slug = 60
xLargeCount := ""
stepsAbove := steps - stepsMidPoint + reminder
for aboveMidpointCount := float64(0); aboveMidpointCount < stepsAbove; aboveMidpointCount++ {
if "+" == operator {
currentStep += increment
} else if increment >= 1 {
currentStep *= increment
} else {
currentStep /= increment
}
name := "Large"
if 0 != aboveMidpointCount {
name = str.Join(xLargeCount, "X-Large")
}
sizes = append(sizes, map[string]string{
"name": name,
"slug": strconv.Itoa(slug),
"size": fmt.Sprintf("%v%s", number.Round(currentStep, 2), unit),
})
if aboveMidpointCount == 1 {
xLargeCount = strconv.Itoa(2)
}
if aboveMidpointCount > 1 {
x := str.ToInt[int](xLargeCount)
x++
xLargeCount = strconv.Itoa(x)
}
slug += 10
}
if steps <= 7 {
for i := 0; i < len(sizes); i++ {
sizes[i]["name"] = strconv.Itoa(i + 1)
}
}
maps.SetStrAnyVal(t.themeJson, "settings.spacing.spacingSizes.default", sizes)
}
func (j ThemeJson) getCssVariables(settingNodes []node, origins []string) string {
var s strings.Builder
for _, settingNode := range settingNodes {
if "" == settingNode.Selector {
continue
}
n := maps.GetStrAnyValWithDefaults[map[string]any](j.themeJson, strings.Join(settingNode.Path, "."), nil)
declarations := computePresetVars(n, origins)
declarations = append(declarations, computeThemeVars(j.themeJson)...)
s.WriteString(toRuleset(settingNode.Selector, declarations))
}
return s.String()
}
func toRuleset(selector string, declarations []declaration) string {
if len(declarations) < 1 {
return ""
}
s := slice.Reduce(declarations, func(t declaration, r string) string {
return str.Join(r, t.name, ":", t.value, ";")
}, "")
return str.Join(selector, "{", s, "}")
}
func getStyleNodes(t ThemeJson) []node {
var styleNodes = []node{
{[]string{"styles"}, "body"},
}
m := maps.GetStrAnyValWithDefaults[map[string]any](t.themeJson, "styles.elements", nil)
if len(m) < 1 {
return nil
}
for e, s := range __elements {
_, ok := m[e]
if !ok {
continue
}
styleNodes = append(styleNodes, node{[]string{"styles", "elements", e}, s})
ss, ok := __validElementPseudoSelectors[e]
if ok {
for _, sel := range ss {
if maps.IsExists(__elements, sel) {
styleNodes = append(styleNodes, node{
Path: []string{"styles", "elements", e},
Selector: appendToSelector(s, sel, ""),
})
}
}
}
}
blocks, _ := maps.GetStrAnyVal[map[string]any](t.blocksMetaData, "theme_json.styles.blocks")
maps.SetStrAnyVal(t.themeJson, "styles.blocks", blocks)
blockNodes := getBlockNodes(t.blocksMetaData)
for _, blockNode := range blockNodes {
p, ok := maps.GetStrAnyVal[[]string](blockNode, "path")
s, oo := maps.GetStrAnyVal[string](blockNode, "selector")
if ok && oo {
styleNodes = append(styleNodes, node{Path: p, Selector: s})
}
}
return styleNodes
}
var validOrigins = []string{"default", "theme", "custom"}
func GetStyletSheet(t ThemeJson, types, origins []string, options map[string]string) string {
styleNodes := getStyleNodes(t)
settingsNodes := getSettingNodes(t.blocksMetaData, t.themeJson)
if types == nil && !wpconfig.HasThemeJson() {
types = []string{"variables", "presets", "base-layout-styles"}
} else if types == nil {
types = []string{"variables", "styles", "presets"}
}
if origins == nil {
origins = validOrigins
}
rootStyleKey, _ := slice.SearchFirst(styleNodes, func(n node) bool {
return n.Selector == RootBlockSelector
})
rootSettingsKey, _ := slice.SearchFirst(settingsNodes, func(n node) bool {
return n.Selector == RootBlockSelector
})
if os, ok := options["scope"]; ok {
for i := range settingsNodes {
settingsNodes[i].Selector = scopeSelector(os, settingsNodes[i].Selector)
}
for i := range styleNodes {
styleNodes[i].Selector = scopeSelector(os, styleNodes[i].Selector)
}
}
if or, ok := options["root_selector"]; ok && or != "" {
if rootSettingsKey > -1 {
settingsNodes[rootSettingsKey].Selector = or
}
if rootStyleKey > -1 && rootStyleKey < len(settingsNodes) {
settingsNodes[rootStyleKey].Selector = or
}
}
var s string
if slice.IsContained(types, "variables") {
s = t.getCssVariables(settingsNodes, origins)
slice.Delete(&types, slice.IndexOf(types, "variables"))
}
if slice.IsContained(types, "styles") {
s = t.getCssVariables(settingsNodes, origins)
}
return s
}

1605
app/theme/wp/scripts.json Normal file

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@ import (
"strings"
)
var sizes = []string{"site_icon-270", "site_icon-32", "site_icon-192", "site_icon-180"}
var iconSizes = []string{"site_icon-270", "site_icon-32", "site_icon-192", "site_icon-180"}
func CalSiteIcon(h *Handle) (r string) {
id := str.ToInteger[uint64](wpconfig.GetOption("site_icon"), 0)
@ -21,7 +21,7 @@ func CalSiteIcon(h *Handle) (r string) {
return
}
m := strings.Join(strings.Split(icon.AttachmentMetadata.File, "/")[:2], "/")
size := slice.FilterAndMap(sizes, func(t string) (string, bool) {
size := slice.FilterAndMap(iconSizes, func(t string) (string, bool) {
s, ok := icon.AttachmentMetadata.Sizes[t]
if !ok {
return "", false

View File

@ -14,6 +14,7 @@ import (
"html/template"
"net/http"
"os"
"strings"
)
type Handle struct {
@ -281,3 +282,10 @@ func NewHandleFn(fn HandleFn[*Handle], order float64, name string) HandleCall {
func NothingToDo(h *Handle) {
h.Abort()
}
func (h *Handle) IsHttps() bool {
if h.C.Request.TLS != nil {
return true
}
return "https" == strings.ToLower(h.C.Request.Header.Get("X-Forwarded-Proto"))
}

View File

@ -2,11 +2,15 @@ package wpconfig
import (
"context"
"github.com/fthvgb1/wp-go/app/cmd/reload"
"github.com/fthvgb1/wp-go/app/phphelper"
"github.com/fthvgb1/wp-go/app/pkg/config"
"github.com/fthvgb1/wp-go/app/pkg/models"
"github.com/fthvgb1/wp-go/helper/maps"
"github.com/fthvgb1/wp-go/model"
"github.com/fthvgb1/wp-go/safety"
"os"
"path/filepath"
"strings"
)
@ -31,15 +35,43 @@ func InitOptions() error {
for _, option := range ops {
options.Store(option["k"], option["v"])
}
themeJson = reload.VarsBy(hasThemeJson)
return nil
}
var themeJson *safety.Var[bool]
func HasThemeJson() bool {
if themeJson == nil {
return false
}
return themeJson.Load()
}
func hasThemeJson() bool {
styleSheet := GetOption("stylesheet")
rootDir := config.GetConfig().WpDir
dir := filepath.Join(rootDir, "wp-content/themes", styleSheet, "theme.json")
_, err := os.Stat(dir)
if err == nil {
return true
}
template := GetOption("template")
dir = filepath.Join(rootDir, "wp-content/themes", template, "theme.json")
_, err = os.Stat(dir)
return err == nil
}
func GetOption(k string) string {
v, ok := options.Load(k)
if ok {
return v
}
vv, err := model.GetField[models.Options](ctx, "option_value", model.Conditions(model.Where(model.SqlBuilder{{"option_name", k}})))
vv, err := model.GetField[models.Options](ctx, "option_value", model.Conditions(
model.Where(
model.SqlBuilder{{"option_name", k}}),
),
)
options.Store(k, vv)
if err != nil {
return ""

View File

@ -1,6 +1,10 @@
package maps
import "strings"
import (
"github.com/fthvgb1/wp-go/helper/slice"
"golang.org/x/exp/constraints"
"strings"
)
func GetStrAnyVal[T any](m map[string]any, key string, delimiter ...string) (r T, o bool) {
separator := "."
@ -111,7 +115,7 @@ func GetAnyAnyValWithDefaults[T any](m map[any]any, defaults T, key ...any) (r T
return
}
func RecursiveSetStrVal[T any](m map[string]any, k string, v T, delimiter ...string) {
func SetStrAnyVal[T any](m map[string]any, k string, v T, delimiter ...string) {
del := "."
if len(delimiter) > 0 && delimiter[0] != "" {
del = delimiter[0]
@ -148,7 +152,7 @@ func RecursiveSetStrVal[T any](m map[string]any, k string, v T, delimiter ...str
mx[kk[len(kk)-1]] = v
}
func RecursiveSetAnyVal[T any](m map[any]any, v T, k ...any) {
func SetAnyAnyVal[T any](m map[any]any, v T, k ...any) {
if len(k) < 1 {
return
} else if len(k) == 1 {
@ -162,10 +166,10 @@ func RecursiveSetAnyVal[T any](m map[any]any, v T, k ...any) {
mm = map[any]any{}
preKey := k[0:i]
if len(preKey) == 0 {
RecursiveSetAnyVal(m, mm, key...)
SetAnyAnyVal(m, mm, key...)
} else {
m, _ := GetAnyAnyMapVal[map[any]any](m, preKey...)
RecursiveSetAnyVal(m, mm, k[i])
SetAnyAnyVal(m, mm, k[i])
}
}
}
@ -173,3 +177,26 @@ func RecursiveSetAnyVal[T any](m map[any]any, v T, k ...any) {
mm, _ := GetAnyAnyMapVal[map[any]any](m, key...)
mm[k[len(k)-1]] = v
}
func AscEahByKey[K constraints.Ordered, V any](m map[K]V, fn func(K, V)) {
orderedEahByKey(m, slice.ASC, fn)
}
func DescEahByKey[K constraints.Ordered, V any](m map[K]V, fn func(K, V)) {
orderedEahByKey(m, slice.ASC, fn)
}
func orderedEahByKey[K constraints.Ordered, V any](m map[K]V, ordered int, fn func(K, V)) {
keys := Keys(m)
slice.Sorts(keys, ordered)
for _, key := range keys {
fn(key, m[key])
}
}
func Flip[K, V comparable](m map[K]V) map[V]K {
mm := make(map[V]K, len(m))
for k, v := range m {
mm[v] = k
}
return mm
}

View File

@ -240,7 +240,7 @@ func TestRecursiveSetAnyVal(t *testing.T) {
target := map[any]any{"m": map[any]any{3: map[any]any{"key": 3.4}}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
RecursiveSetAnyVal(tt.args.m, tt.args.v, tt.args.k...)
SetAnyAnyVal(tt.args.m, tt.args.v, tt.args.k...)
if !reflect.DeepEqual(tt.args.m, target) {
t.Fatalf("not equal target")
}
@ -287,7 +287,7 @@ func TestRecursiveSetStrVal(t *testing.T) {
target := map[string]any{"aa": map[string]any{"bb": map[string]any{"cc": 1}}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
RecursiveSetStrVal(tt.args.m, tt.args.k, tt.args.v)
SetStrAnyVal(tt.args.m, tt.args.k, tt.args.v)
if !reflect.DeepEqual(target, tt.args.m) {
t.Fatal()
}

View File

@ -106,3 +106,8 @@ func Counters[T constraints.Integer]() func() T {
return count
}
}
func Round(f float64, precision int) float64 {
p := math.Pow10(precision)
return math.Floor(f*p+0.5) / p
}

View File

@ -93,6 +93,10 @@ func Replace(s string, replace map[string]string) string {
}
return s
}
// Replaces replace string by slice as order
//
// [][]string sub []string like {old1,old2,old3,....,newString} all old[x] will be replaced by lasted newString
func Replaces(s string, replace [][]string) string {
for _, v := range replace {
if len(v) < 1 {
@ -100,7 +104,9 @@ func Replaces(s string, replace [][]string) string {
} else if len(v) == 1 {
s = strings.ReplaceAll(s, v[0], "")
} else {
s = strings.ReplaceAll(s, v[0], v[1])
for _, s2 := range v[0 : len(v)-1] {
s = strings.ReplaceAll(s, s2, v[len(v)-1])
}
}
}
return s