2022-09-01 02:31:11 +00:00
|
|
|
package models
|
|
|
|
|
|
|
|
var Options = make(map[string]string)
|
2022-09-13 03:23:28 +00:00
|
|
|
var TermsIds []uint64
|
2022-09-01 02:31:11 +00:00
|
|
|
|
|
|
|
func InitOptions() error {
|
|
|
|
ops, err := SimpleFind[WpOptions](SqlBuilder{{"autoload", "yes"}}, "option_name, option_value")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if len(ops) == 0 {
|
|
|
|
ops, err = SimpleFind[WpOptions](nil, "option_name, option_value")
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, options := range ops {
|
|
|
|
Options[options.OptionName] = options.OptionValue
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-09-05 01:49:14 +00:00
|
|
|
func InitTerms() (err error) {
|
|
|
|
var themes []interface{}
|
|
|
|
themes = append(themes, "wp_theme")
|
|
|
|
var name []interface{}
|
|
|
|
name = append(name, "twentyfifteen")
|
|
|
|
terms, err := Find[WpTerms](SqlBuilder{{
|
|
|
|
"tt.taxonomy", "in", "",
|
|
|
|
}, {"t.name", "in", ""}}, "t.term_id", nil, SqlBuilder{{
|
|
|
|
"t", "inner join", "wp_term_taxonomy tt", "t.term_id = tt.term_id",
|
|
|
|
}}, 1, themes, name)
|
2022-09-13 03:23:28 +00:00
|
|
|
for _, wpTerms := range terms {
|
|
|
|
TermsIds = append(TermsIds, wpTerms.TermId)
|
|
|
|
}
|
2022-09-05 01:49:14 +00:00
|
|
|
return
|
2022-09-01 02:31:11 +00:00
|
|
|
}
|