如何在选项页面‘阅读’中保存自定义选项?

时间:2016-05-01 作者:Bert

我想在默认的“阅读”选项页面中添加一些选项。我的代码是:

    add_settings_section("section_share", __("Sharing & Publishing", "honeycomb-wp"), __NAMESPACE__."\\\\displaySection",
                        "reading");
   register_setting("group_share", "honeycomb-reading-share");
   register_setting("group_share", "honeycomb-reading-tweet");
   register_setting("group_share", "honeycomb-reading-delay");
   register_setting("group_share", "honeycomb-reading-footer");

   add_settings_field("honeycomb-reading-share", __("Share", "honeycomb-wp"), __NAMESPACE__."\\\\displayField_share",
                      "reading", "section_share");
   add_settings_field("honeycomb-reading-tweet", __("Tweet", "honeycomb-wp"), __NAMESPACE__."\\\\displayField_tweet",
                      "reading", "section_share");
   add_settings_field("honeycomb-reading-delay", __("Delay", "honeycomb-wp"), __NAMESPACE__."\\\\displayField_delay",
                      "reading", "section_share");
   add_settings_field("honeycomb-reading-footer", __("Footer in RSS", "honeycomb-wp"), __NAMESPACE__."\\\\displayField_footer",
                      "reading", "section_share");
(在admin\\u init挂钩中)。这会在页面上很好地显示选项,但不会保存它们。是否有一个钩子用于此,或者是否无法在此页面中添加额外的部分?

1 个回复
最合适的回答,由SO网友:Bert 整理而成

找到它;需要使用所谓的“白名单”组:

register_setting("reading", "honeycomb-reading-share");
现有的选项页似乎都有一个与其页名相对应的组名。

相关推荐