I have a problem I'm trying to solve, but with no avail because php is really not my field. I already searched the forums and found a few solutions to similar problems, but I couldn't get the to work.
I created a Theme Options Page where you can for ex. upload a Logo to be used on the Website. I created a check box and want to delete the logo if the check box is checked. Anyway, the logo is deleted when I click Save changes, but regardless if I checked the check box or not.
This is my code:
// LOGO
function logo_setting() {
$options = get_option('theme_options');
if (empty($options['logo'])) :
$options['logo'] = '';
else :
echo "<img src='{$options['logo']}' width='205px' /><br>";
//DELETE OPTION
if (!isset( $options['del_logo'] ) ) :
$options['del_logo'] = '';
echo "<br>Remove logo? ";
?> <input type="checkbox" id="del_logo" name="theme_options[del_logo]" value="1" <?php checked( true, $options['del_logo'] ); ?> /><?php
echo "<br>If logo is removed, Site Title will be used.";
else :
$options = get_option('theme_options');
$options['logo'] = '';
update_option('theme_options', $options);
echo "Logo removed";
endif;
$options['del_logo'] = ( $options['del_logo'] == 1 ? 1 : 0 );
return $options;
endif;
echo "<input type='file' name='logo' />";
}
I hope someone can explain to me what I'm doing wrong and how I should do it properly.