@Mamaduka:
Here is why your settings aren’t updating. Your validation function is wrong. To wit:
function ev_options_validate( $input ) {
$ev_options = get_option( 'theme_evolutionary_options' );
$valid_input = $ev_options;
$ev_options['color_scheme'] = array_key_exists( $ev_options['color_scheme'], ev_get_valid_color_schemes() ) ? $ev_options['color_scheme'] : 'blue';
$ev_options['copytright'] = wp_kses_data( $ev_options['copyright'] );
return $valid_input;
}
You’re updating $ev_options, but returning $valid_input. You need to be updating $valid_input, not $ev_options.
Try this instead:
function ev_options_validate( $input ) {
$ev_options = get_option( 'theme_evolutionary_options' );
$valid_input = $ev_options;
$valid_input['color_scheme'] = array_key_exists( $ev_options['color_scheme'], ev_get_valid_color_schemes() ) ? $ev_options['color_scheme'] : 'blue';
$valid_input['copytright'] = wp_kses_data( $ev_options['copyright'] );
return $valid_input;
}
See if that fixes your problem?
EDITED TO ADD:
Your next problem in the validation function is that you’re comparing $ev_options to/against itself, when you need to be evaluating $input against $valid_input.
Instead of this:
function ev_options_validate( $input ) {
$ev_options = get_option( 'theme_evolutionary_options' );
$valid_input = $ev_options;
$valid_input['color_scheme'] = array_key_exists( $ev_options['color_scheme'], ev_get_valid_color_schemes() ) ? $ev_options['color_scheme'] : 'blue';
$valid_input['copytright'] = wp_kses_data( $ev_options['copyright'] );
return $valid_input;
}
Try this:
function ev_options_validate( $input ) {
$ev_options = get_option( 'theme_evolutionary_options' );
$valid_input = $ev_options;
$valid_input['color_scheme'] = array_key_exists( $input['color_scheme'], ev_get_valid_color_schemes() ) ? $input['color_scheme'] : 'blue';
$valid_input['copytright'] = wp_kses_data( $input['copyright'] );
return $valid_input;
}
Specifically, change this:
$valid_input['color_scheme'] = array_key_exists( $ev_options['color_scheme'], ev_get_valid_color_schemes() ) ? $ev_options['color_scheme'] : 'blue';
$valid_input['copytright'] = wp_kses_data( $ev_options['copyright'] );
To this:
$valid_input['color_scheme'] = array_key_exists( $input['color_scheme'], ev_get_valid_color_schemes() ) ? $input['color_scheme'] : 'blue';
$valid_input['copytright'] = wp_kses_data( $input['copyright'] );
And then, I think, your options should work.
@TheDeadMedic:
The Settings API handles looking at any $POST data. That’s not the problem.
Regarding the default-settings updating on init, here’s my original, example code:
function oenology_options_init() {
// set options equal to defaults
global $oenology_options;
$oenology_options = get_option( 'theme_oenology_options' );
if ( false === $oenology_options ) {
$oenology_options = oenology_get_default_options();
}
update_option( 'theme_oenology_options', $oenology_options );
}
// Initialize Theme options
add_action('after_setup_theme','oenology_options_init', 9 );
And here’s Mamaduka’s code:
function ev_options_init() {
// Set options equal to defaults
global $ev_options;
$ev_options = ev_theme_settings_defaults();
if ( false === $ev_options ) {
$ev_options = ev_theme_settings_defaults();
}
update_option( 'theme_evolutionary_options', $ev_options );
}
add_action( 'after_setup_theme', 'ev_options_init', 9 );
Do you see the difference? There is a critical change from oenology_options_init() to ev_options_init(), to wit:
This:
global $oenology_options;
$oenology_options = get_option( 'theme_oenology_options' );
Versus this:
global $ev_options;
$ev_options = ev_theme_settings_defaults();
Thus, in ev_options_init(), the function never actually does anything, because of the change.