WordPress theme options checkbox default checked state

With the code that you’ve added to your question, you’re adding the HTML ‘checked’ attribute twice, which is probably why things are getting confused. You have it hard-coded as checked="checked", but then checked( 1, get_option( 'theme_custom_option' ), false ) will write another checked attribute corresponding to the actual value of the option.

You should be able to verify this would have been able to debug it by looking at the generated HTML with view-source or developer tools.

Taken from the docs page for the checked function in WordPress https://developer.wordpress.org/reference/functions/checked/ your code should probably look something like this:

echo '<input type="checkbox" class="theme-custom-checkbox" name="theme_custom_option"  value="1" ' ;
echo checked( 1, get_option( 'theme_custom_option' ), false );
echo ' />';

Note code tidied a bit for readability