OK. I did it. But I still don’t fully understand the Settings API fully.
Here is my entire options.php
file.
<?php
function respite_options_setup() {
$notfound = '<h1 class="aligncenter">Not found</h1><p>The link you followed here doesn’??t match any content on this site.</p>';
$copyright = sprintf( '© %s %s. All rights reserved.', date("Y"), get_bloginfo( 'name', 'display' ) );
add_option( 'notfound', $notfound );
add_option( 'copyright', $copyright );
}
add_action( 'after_setup_theme', 'respite_options_setup' );
function respite_notfound() {
$notfound = get_option( 'notfound' );
if ( $notfound ) printf( '%s', $notfound );
}
function respite_copyright() {
$copyright = get_option( 'copyright' );
if ( $copyright ) printf( '<div id="copyright">%s</div>', $copyright );
}
function respite_register_settings() {
register_setting( 'respite-settings-group', 'notfound' );
register_setting( 'respite-settings-group', 'copyright' );
register_setting( 'respite-settings-group', 'update_notification', 'respite_settings_update_notification' );
}
add_action( 'admin_init', 'respite_register_settings' );
function respite_settings_update_notification( $input ) {
add_settings_error(
'respite-settings-updated',
esc_attr('settings_updated'),
__('Settings saved.'),
'updated'
);
return $input;
}
function respite_admin_notices() {
settings_errors( 'respite-settings-updated' );
}
add_action( 'admin_notices', 'respite_admin_notices' );
function respite_register_options_page() {
add_theme_page('Theme Options', 'Theme Options', 'manage_options', 'respite-options', 'respite_options_page');
}
add_action('admin_menu', 'respite_register_options_page');
function respite_options_page() { ?>
<div class="wrap">
<h2>Theme Options</h2>
<p><em>Note: Respite has two custom menu locations: main navigation and footer links.</em></p>
<form method="post" action="options.php">
<?php settings_fields( 'respite-settings-group' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="notfound">Not found notice</label></th>
<td><input style="width: 100%;" type="text" id="notfound" name="notfound" value='<?php echo get_option('notfound'); ?>' /><br />You may use HTML and CSS</td>
</tr>
<tr valign="top">
<th scope="row"><label for="copyright">Copyright notice</label></th>
<td><input style="width: 100%;" type="text" id="copyright" name="copyright" value='<?php echo get_option('copyright'); ?>' /><br />You may use HTML and CSS</td>
</tr>
</table>
<?php submit_button(); ?>
</form>
</div>
<?php }
?>