order数值调整

This commit is contained in:
xing 2023-06-15 18:00:57 +08:00
parent b1ebedd24c
commit 228e19ee85
8 changed files with 40 additions and 38 deletions

View File

@ -26,19 +26,19 @@ func configs(h *wp.Handle) {
wp.NewHandleFn(widget.IsCategory, 100, "widget.IsCategory"))
h.Index.SetPageEle(plugins.TwentyFifteenPagination())
h.PushCacheGroupHeadScript(constraints.AllScene, "CalCustomBackGround", 10, CalCustomBackGround)
h.PushCacheGroupHeadScript(constraints.AllScene, "colorSchemeCss", 10, colorSchemeCss)
h.PushCacheGroupHeadScript(constraints.AllScene, "CalCustomBackGround", 10.005, CalCustomBackGround)
h.PushCacheGroupHeadScript(constraints.AllScene, "colorSchemeCss", 10.0056, colorSchemeCss)
h.CommonComponents()
components.WidgetArea(h)
wp.ReplyCommentJs(h)
h.SetData("customHeader", customHeader(h))
wp.PushIndexHandler(constraints.PipeRender, h, wp.NewHandleFn(wp.IndexRender, 50, "wp.IndexRender"))
h.PushRender(constraints.Detail, wp.NewHandleFn(wp.DetailRender, 50, "wp.DetailRender"))
h.PushRender(constraints.Detail, wp.NewHandleFn(postThumb, 60, "postThumb"))
h.PushDataHandler(constraints.Detail, wp.NewHandleFn(wp.Detail, 100, "wp.Detail"))
wp.PushIndexHandler(constraints.PipeData, h, wp.NewHandleFn(wp.Index, 100, "wp.Index"))
h.PushDataHandler(constraints.AllScene, wp.NewHandleFn(wp.PreCodeAndStats, 80, "wp.PreCodeAndStats"))
h.PushRender(constraints.AllScene, wp.NewHandleFn(wp.PreTemplate, 70, "wp.PreTemplate"))
wp.PushIndexHandler(constraints.PipeRender, h, wp.NewHandleFn(wp.IndexRender, 50.005, "wp.IndexRender"))
h.PushRender(constraints.Detail, wp.NewHandleFn(wp.DetailRender, 50.005, "wp.DetailRender"))
h.PushRender(constraints.Detail, wp.NewHandleFn(postThumb, 60.005, "postThumb"))
h.PushDataHandler(constraints.Detail, wp.NewHandleFn(wp.Detail, 100.005, "wp.Detail"))
wp.PushIndexHandler(constraints.PipeData, h, wp.NewHandleFn(wp.Index, 100.005, "wp.Index"))
h.PushDataHandler(constraints.AllScene, wp.NewHandleFn(wp.PreCodeAndStats, 80.005, "wp.PreCodeAndStats"))
h.PushRender(constraints.AllScene, wp.NewHandleFn(wp.PreTemplate, 70.005, "wp.PreTemplate"))
}
func postThumb(h *wp.Handle) {

View File

@ -15,7 +15,7 @@ func pushScripts(h *wp.Handle) {
}
return head
})
h.PushGroupFooterScript(constraints.AllScene, "{theme}.footer", 20, footerScript)
h.PushGroupFooterScript(constraints.AllScene, "{theme}.footer", 20.005, footerScript)
}

View File

@ -37,19 +37,19 @@ func Hook(h *wp.Handle) {
func configs(h *wp.Handle) {
wp.InitPipe(h)
h.PushHandler(constraints.PipeMiddleware, constraints.Home,
wp.NewHandleFn(widget.IsCategory, 100, "widget.IsCategory"))
wp.NewHandleFn(widget.IsCategory, 100.006, "widget.IsCategory"))
h.PushComponentFilterFn("bodyClass", calClass)
h.PushCacheGroupHeadScript(constraints.AllScene, "colorScheme-customHeader", 10, colorScheme, customHeader)
components.WidgetArea(h)
pushScripts(h)
h.PushRender(constraints.AllStats, wp.NewHandleFn(calCustomHeader, 10, "calCustomHeader"))
h.PushRender(constraints.AllStats, wp.NewHandleFn(calCustomHeader, 10.005, "calCustomHeader"))
h.SetComponentsArgs(widgets.Widget, map[string]string{
"{$before_widget}": `<section id="%s" class="%s">`,
"{$after_widget}": `</section>`,
})
h.PushRender(constraints.AllStats,
wp.NewHandleFn(wp.PreTemplate, 70, "wp.PreTemplate"),
wp.NewHandleFn(errorsHandle, 80, "errorsHandle"),
wp.NewHandleFn(wp.PreTemplate, 70.005, "wp.PreTemplate"),
wp.NewHandleFn(errorsHandle, 80.005, "errorsHandle"),
)
videoHeader(h)
h.Detail.CommentRender = commentFormat
@ -58,11 +58,11 @@ func configs(h *wp.Handle) {
wp.ReplyCommentJs(h)
h.PushPostPlugin(postThumbnail)
wp.SetComponentsArgsForMap(h, widgets.Search, "{$form}", searchForm)
wp.PushIndexHandler(constraints.PipeRender, h, wp.NewHandleFn(wp.IndexRender, 10, "wp.IndexRender"))
h.PushRender(constraints.Detail, wp.NewHandleFn(wp.DetailRender, 10, "wp.DetailRender"))
h.PushDataHandler(constraints.Detail, wp.NewHandleFn(wp.Detail, 100, "wp.Detail"), wp.NewHandleFn(postThumb, 90, "{theme}.postThumb"))
wp.PushIndexHandler(constraints.PipeData, h, wp.NewHandleFn(wp.Index, 100, "wp.Index"))
h.PushDataHandler(constraints.AllScene, wp.NewHandleFn(wp.PreCodeAndStats, 90, "wp.PreCodeAndStats"))
wp.PushIndexHandler(constraints.PipeRender, h, wp.NewHandleFn(wp.IndexRender, 10.005, "wp.IndexRender"))
h.PushRender(constraints.Detail, wp.NewHandleFn(wp.DetailRender, 10.005, "wp.DetailRender"))
h.PushDataHandler(constraints.Detail, wp.NewHandleFn(wp.Detail, 100.005, "wp.Detail"), wp.NewHandleFn(postThumb, 90.005, "{theme}.postThumb"))
wp.PushIndexHandler(constraints.PipeData, h, wp.NewHandleFn(wp.Index, 100.005, "wp.Index"))
h.PushDataHandler(constraints.AllScene, wp.NewHandleFn(wp.PreCodeAndStats, 90.005, "wp.PreCodeAndStats"))
}
var searchForm = `<form role="search" method="get" class="search-form" action="/">

View File

@ -86,7 +86,7 @@ func (h *Handle) PushComponents(scene, componentType string, components ...Compo
c[componentType] = append(c[componentType], components...)
}
func (h *Handle) PushGroupComponentStr(scene, componentType, name string, order int, strs ...string) {
func (h *Handle) PushGroupComponentStr(scene, componentType, name string, order float64, strs ...string) {
var component = Components[string]{
Val: strings.Join(slice.FilterAndMap(strs, func(t string) (string, bool) {
t = strings.Trim(t, " \n\r\t\v\x00")
@ -101,7 +101,7 @@ func (h *Handle) PushGroupComponentStr(scene, componentType, name string, order
h.PushComponents(scene, componentType, component)
}
func (h *Handle) PushCacheGroupHeadScript(scene, name string, order int, fns ...func(*Handle) string) {
func (h *Handle) PushCacheGroupHeadScript(scene, name string, order float64, fns ...func(*Handle) string) {
h.PushGroupCacheComponentFn(scene, constraints.HeadScript, name, order, fns...)
}
@ -109,14 +109,14 @@ func (h *Handle) PushFooterScript(scene string, components ...Components[string]
h.PushComponents(scene, constraints.FooterScript, components...)
}
func (h *Handle) PushGroupFooterScript(scene, name string, order int, strs ...string) {
func (h *Handle) PushGroupFooterScript(scene, name string, order float64, strs ...string) {
h.PushGroupComponentStr(scene, constraints.FooterScript, name, order, strs...)
}
func (h *Handle) PushCacheGroupFooterScript(scene, name string, order int, fns ...func(*Handle) string) {
func (h *Handle) PushCacheGroupFooterScript(scene, name string, order float64, fns ...func(*Handle) string) {
h.PushGroupCacheComponentFn(scene, constraints.FooterScript, name, order, fns...)
}
func (h *Handle) PushGroupCacheComponentFn(scene, componentType, name string, order int, fns ...func(*Handle) string) {
func (h *Handle) PushGroupCacheComponentFn(scene, componentType, name string, order float64, fns ...func(*Handle) string) {
h.PushComponents(scene, componentType, NewComponent(name, "", true, order, func(h *Handle) string {
return strings.Join(slice.Map(fns, func(t func(*Handle) string) string {
return t(h)
@ -124,18 +124,18 @@ func (h *Handle) PushGroupCacheComponentFn(scene, componentType, name string, or
}))
}
func NewComponent(name, val string, cached bool, order int, fn func(handle *Handle) string) Components[string] {
func NewComponent(name, val string, cached bool, order float64, fn func(handle *Handle) string) Components[string] {
return Components[string]{Fn: fn, Name: name, Cached: cached, Order: order, Val: val}
}
func (h *Handle) AddCacheComponent(scene, componentType, name string, order int, fn func(*Handle) string) {
func (h *Handle) AddCacheComponent(scene, componentType, name string, order float64, fn func(*Handle) string) {
h.PushComponents(scene, componentType, NewComponent(name, "", true, order, fn))
}
func (h *Handle) PushHeadScript(scene string, components ...Components[string]) {
h.PushComponents(scene, constraints.HeadScript, components...)
}
func (h *Handle) PushGroupHeadScript(scene, name string, order int, str ...string) {
func (h *Handle) PushGroupHeadScript(scene, name string, order float64, str ...string) {
h.PushGroupComponentStr(scene, constraints.HeadScript, name, order, str...)
}

View File

@ -31,6 +31,7 @@ func WidgetArea(h *wp.Handle) {
func sidebars() []wp.Components[string] {
v := wpconfig.GetPHPArrayVal("sidebars_widgets", []any{}, "sidebar-1")
var i = 10.5
return slice.FilterAndMap(v, func(t any) (wp.Components[string], bool) {
vv := t.(string)
ss := strings.Split(vv, "-")
@ -53,7 +54,8 @@ func sidebars() []wp.Components[string] {
component.Name = widgetComponents.name
component.Cached = widgetComponents.cached
}
component.Order = 10
i -= 0.001
component.Order = i
return component, true
})
}

View File

@ -157,12 +157,12 @@ wp.i18n.setLocaleData( { 'text direction\u0004ltr': [ 'ltr' ] } );
<script src='/wp-includes/js/dist/a11y.min.js?ver=ecce20f002eda4c19664' id='wp-a11y-js'></script>
`
c := []Components[string]{
NewComponent("wp-a11y-js-translations", tr, true, 10, nil),
NewComponent("VideoSetting", hs, true, 10, nil),
NewComponent("header-script", scripts[len(scripts)-1], true, 10, nil),
NewComponent("wp-a11y-js-translations", tr, true, 10.0065, nil),
NewComponent("VideoSetting", hs, true, 10.0064, nil),
NewComponent("header-script", scripts[len(scripts)-1], true, 10.0063, nil),
}
for _, s := range scene {
h.PushGroupFooterScript(s, "wp-custom-header", 10, scripts[0:len(scripts)-2]...)
h.PushGroupFooterScript(s, "wp-custom-header", 10.0066, scripts[0:len(scripts)-2]...)
h.PushFooterScript(s, c...)
}
ok = true

View File

@ -12,11 +12,11 @@ type HandlePipeFn[T any] func(HandleFn[T], T)
type Pipe struct {
Name string
Order int
Order float64
Fn HandlePipeFn[*Handle]
}
func NewPipe(name string, order int, fn HandlePipeFn[*Handle]) Pipe {
func NewPipe(name string, order float64, fn HandlePipeFn[*Handle]) Pipe {
return Pipe{Name: name, Order: order, Fn: fn}
}

View File

@ -80,7 +80,7 @@ type Components[T any] struct {
Name string
Val T
Fn func(*Handle) T
Order int
Order float64
Cached bool
}
@ -88,7 +88,7 @@ type HandleFn[T any] func(T)
type HandleCall struct {
Fn HandleFn[*Handle]
Order int
Order float64
Name string
}
@ -239,7 +239,7 @@ func (h *Handle) PushHandlers(pipeScene string, call HandleCall, statsOrScene ..
func (h *Handle) CommonComponents() {
h.PushCacheGroupHeadScript(constraints.AllScene, "siteIconAndCustomCss", 0, CalSiteIcon, CalCustomCss)
h.PushRender(constraints.AllStats, NewHandleFn(CalComponents, 10, "wp.CalComponents"))
h.PushRender(constraints.AllStats, NewHandleFn(CalComponents, 10.001, "wp.CalComponents"))
h.PushRender(constraints.AllStats, NewHandleFn(PreRenderTemplate, 0, "wp.PreRenderTemplate"))
AdditionScript(h)
}
@ -274,7 +274,7 @@ func PreRenderTemplate(h *Handle) {
h.Abort()
}
func NewHandleFn(fn HandleFn[*Handle], order int, name string) HandleCall {
func NewHandleFn(fn HandleFn[*Handle], order float64, name string) HandleCall {
return HandleCall{Fn: fn, Order: order, Name: name}
}