Sometimes creating WordPress options just sucks. I seem to go digging through the codex for this every time I create a checkbox. This is the easy way and is compatible with php 8.2. This is my reminder.
case 'your-option-name':
printf('<input %s class="wppd-ui-toggle" id="%s" name="%s" type="checkbox" value="random_page.php">',
$value === 'random_page.php' ? 'checked' : 'false',
$field['id'],
$field['id']
);
break;
// Example 1 - Get an option, or do nothing
if(get_option('your-option-name')){ // echos out "random_page.php"
get_option( 'your-option-name' );
}
else {
// echos out "false or empty value"
}
// Example 2 - Combining an INCLUDE statement with a OPTION, or do nothing
if(get_option('your-option-name')){
include ( get_option( 'your-option-name' ));
}
else {
}