I tested your code and the default values are being displayed correctly.
Doing a var_dump($_REQUEST);
shows what's the problem with the update message, we have to check simpy for $_REQUEST['settings-updated']
.
You can remove the is_admin()
checking, as admin_init
and admin_menu
only run on admin.
The validation function should be something like this, validating each input field and returning a clean array with sanitized values:
function xyz_validate_options( $input ) {
$new_input = array();
if( isset( $input['facebook'] ) )
$new_input['facebook'] = esc_url( $input['facebook'] );
if( isset( $input['footer_copyright'] ) )
$new_input['footer_copyright'] = esc_attr( $input['footer_copyright'] );
return $new_input;
}