Is there a hook attached to general settings save?

You just need to register_setting() on your setting and it will be saved automatically. See the Settings API for more info. Here’s a complete example:

function spw_cb() {
    if( !($value = get_option('sprockets_per_widget')) ) {
        $value = 7;
    }

    ?>
    <input type="text" size="3" name="sprockets_per_widget" value="<?php echo $value; ?>" /> Numeric only!
    <?php
}

function spw_init() {
    add_settings_field('sprockets_per_widget', 'Sprockets per Widget', 'spw_cb', 'general');
    register_setting('general', 'sprockets_per_widget', 'intval');
}
add_action('admin_init', 'spw_init');

Leave a Comment