未获取API设置已保存选项页面上更新后的确认消息

时间:2018-02-07 12:31:41

标签: wordpress wordpress-theming

我可以将选项页面添加到仪表板菜单,到目前为止它工作正常(至少对我而言)但是我没有在更新页面后获得 API设置已保存的消息

enter image description here

add_action( 'admin_menu', 'add_acme_options_page' );
function add_acme_options_page() {

    add_menu_page(
        'Acme Options',
        'Acme Options',
        'manage_options',
        'acme-options-page',
        'display_acme_options_page'
    );

}

function display_acme_options_page() {

    echo '<h2>Acme Options</h2>';

    echo '<form method="post" action="options.php">';

    do_settings_sections( 'acme-options-page' );
    settings_fields( 'acme-settings' );

    submit_button();

    echo '</form>';

}

add_action( 'admin_init', 'acme_admin_init_one' );
function acme_admin_init_one() {

    add_settings_section(
        'acme-settings-section-one',      
        'Acme Settings Part One',         
        'display_acme_settings_message',  
        'acme-options-page'               
    );

    add_settings_field(
        'acme-input-field',        
        'Acme Input Field',        
        'render_acme_input_field',  
        'acme-options-page',        
        'acme-settings-section-one' 
    );

    register_setting(
        'acme-settings',    
        'acme-input-field'    
    );

}

function display_acme_settings_message() {
    echo "This displays the settings message.";
}

function render_acme_input_field() {

    $input = get_option( 'acme-input-field' );
    echo '<input type="text" id="acme-input-field" name="acme-input-field" value="' . $input . '" />';

}

add_action( 'admin_init', 'acme_admin_init_two' );
function acme_admin_init_two() {

    add_settings_section(
        'acme-settings-section-two',
        'Acme Settings Part Two',
        'display_another_acme_settings_message',
        'acme-options-page'
    );

    add_settings_field(
        'acme-input-field-two',
        'Acme Input Field Two',
        'render_acme_input_field_two',
        'acme-options-page',
        'acme-settings-section-two'
    );

    register_setting(
        'acme-settings',
        'acme-input-field-two'
    );

}

function display_another_acme_settings_message() {
    echo "This displays the second settings message.";
}

function render_acme_input_field_two() {

    $input = get_option( 'acme-input-field-two' );
    echo '<input type="text" id="acme-input-field-two" name="acme-input-field-two" value="' . $input . '" />';

}

如果我错过了某个部分或者......你能告诉我吗?

0 个答案:

没有答案