未调用带有设置API的回调

时间:2015-08-22 12:30:34

标签: php wordpress-plugin

我正在尝试创建一个使用设置API为我的用户添加一些选项的插件。我目前创建一个新的菜单页面,然后创建一个设置部分。这一切都很好,但后来我的回调函数没有被调用。谁能明白为什么?

function register_my_custom_menu_page() {

    add_menu_page( 'custom menu title', 'custom menu', 'manage_options', 'menu-slug', 'sandbox_initialize_theme_options' );

}


add_action( 'admin_menu', 'register_my_custom_menu_page' );


function sandbox_initialize_theme_options() {

    // First, we register a section. This is necessary since all future options must belong to one.
    add_settings_section(
        'general_settings_section',         // ID used to identify this section and with which to register options
        'Sandbox Options',                  // Title to be displayed on the administration page
        'sandbox_general_options_callback', // Callback used to render the description of the section
        'menu-slug'                           // Page on which to add this section of options
    );
} // end sandbox_initialize_theme_options


function sandbox_general_options_callback() {
    echo '<p>Select which areas of content you wish to display.</p>';
} // end sandbox_general_options_callback

0 个答案:

没有答案
相关问题