(编辑)好的,我现在正在重写这篇文章,因为我知道你想要做什么,基于你的评论。
要让您的设置出现在定制器的主题设置部分,您需要编辑settings_schema.json。您还需要了解 JSON 的工作原理。
当您打开settings_schema.json 时,它将如下所示:
[
{
"name": "theme_info",
"theme_name": "Some Theme Name",
"theme_author": "Author Name",
"theme_version": "1.5"
},
{
"name": "Custom Feature",
"settings": [
{
"type": "checkbox",
"id": "enable_feature",
"label": "Enable Feature",
"default": false
}
]
},
{
"name": "Popup Message",
"settings": [
{
"type": "paragraph",
"content": "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Voluptatem, dicta quae fugiat beatae ullam sit iure at."
}
]
}
]
您需要将您的部分添加到文件中。将它添加到末尾可能是最容易的。所有部分都包含在方括号[ ] 中(这使它成为一个数组),您需要在最外面的方括号之间找到最后一个部分。在我上面的示例代码中,它将是弹出消息部分。该部分包含在大括号 { } 中(这使它成为一个对象)。转到右大括号并在其后放置一个逗号,然后按 Enter。在新行上,粘贴您的架构代码。
添加了您的部分后看起来像这样:
[
{
"name": "theme_info",
"theme_name": "Some Theme Name",
"theme_author": "Author Name",
"theme_version": "1.5"
},
{
"name": "Custom Feature",
"settings": [
{
"type": "checkbox",
"id": "enable_feature",
"label": "Enable Feature",
"default": false
}
]
},
{
"name": "Popup Message",
"settings": [
{
"type": "paragraph",
"content": "Lorem ipsum dolor sit, amet consectetur adipisicing elit. Voluptatem, dicta quae fugiat beatae ullam sit iure at."
}
]
},
{
"name": "icons",
"settings": [
{
"type": "text",
"label": "your headline for the section"
}
]
}
]
保存文件并刷新定制器。您应该会在主题设置的底部看到您的新部分。