[ad_1]
I’m trying to add a single tick-box option to General settings using the following code. However, it doesn’t save the result (which should be in the option named world_domination_toggle.
/**
* Add to settings
*
* Add a field to the general settings screen for switching the image on/off
*/
function world_domination_settings_init() {
add_settings_field( 'world_domination_toggle', __( 'Disable World Domination image', 'world-domination' ), 'world_domination_image_option', 'general', 'default', array( 'label_for' => 'world_domination_toggle' ) );
register_setting( 'general', 'world_domination_toggle' );
}
add_action( 'admin_init', 'world_domination_settings_init' );
/**
* Show image option switch
*
* Output the settings field for toggling the image on the dashboard
*/
function world_domination_image_option() {
echo '<label><input name="world_domination_toggle" id="world_domination_toggle" type="checkbox" value="1" ' . checked( 1, get_option( 'world_domination_toggle', 1 ), false ) . '/></label>';
}For a while it worked and then as soon as I changed some code it stopped – I reverted the code but it’s refused to work since and it’s driving me mad!
Does anybody have a clue as to what’s going wrong here?
