2022-11-17 08:29:39 +00:00
|
|
|
package wpconfig
|
2022-11-15 03:11:08 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2023-01-12 10:17:34 +00:00
|
|
|
wp2 "github/fthvgb1/wp-go/internal/wp"
|
2022-11-15 03:11:08 +00:00
|
|
|
"github/fthvgb1/wp-go/models"
|
|
|
|
"github/fthvgb1/wp-go/safety"
|
|
|
|
)
|
|
|
|
|
2023-01-12 10:17:34 +00:00
|
|
|
var Terms safety.Map[uint64, wp2.Terms]
|
|
|
|
var TermTaxonomies safety.Map[uint64, wp2.TermTaxonomy]
|
2022-11-15 03:11:08 +00:00
|
|
|
|
|
|
|
func InitTerms() (err error) {
|
|
|
|
ctx := context.Background()
|
2023-01-12 10:17:34 +00:00
|
|
|
terms, err := models.SimpleFind[wp2.Terms](ctx, nil, "*")
|
2022-11-15 03:11:08 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, wpTerms := range terms {
|
|
|
|
Terms.Store(wpTerms.TermId, wpTerms)
|
|
|
|
}
|
2023-01-12 10:17:34 +00:00
|
|
|
termTax, err := models.SimpleFind[wp2.TermTaxonomy](ctx, nil, "*")
|
2022-11-15 03:11:08 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
for _, taxonomy := range termTax {
|
|
|
|
TermTaxonomies.Store(taxonomy.TermTaxonomyId, taxonomy)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|