I'm working on a WordPress theme and I've created an options page that is already setup and functioning for inputs and textareas. Which can easily be carried to the template pages with:
<?php $options = get_option('kittytheme_options'); echo $options['kittens']; ?>
Now, how would one modify that to work as a checkbox conditional? The following is probably wrong in many ways, but should illustrate what I'm trying:
<?php $options = get_option('kittytheme_options'); if ( $options['kittycheckbox'] == '0' ) : ?>Theme By: <a href="http://someurl.com/">Company Name</a><?php endif; ?>
So basically the idea is that the link should show by default being equal to 0 or nothing. But, when the checkbox to hide this area is checked in the options it would equal 1 therefore hiding it.
From the options page/form here's the checkbox:
<input id="kittytheme_options[kittycheckbox]" name="kittytheme_options[kittycheckbox]" type="checkbox" value="1" <?php checked( '1', $options['kittycheckbox'] ); ?> />
<label class="description" for="kittytheme_options[kittycheckbox]"><?php _e( 'Hide Kitty Credit', 'kittytheme' ); ?></label>
And the final validation function is:
function theme_options_validate( $input ) {
global $select_options;
if ( ! isset( $input['kittycheckbox'] ) )
$input['kittycheckbox'] = null;
$input['kittycheckbox'] = ( $input['kittycheckbox'] == 1 ? 1 : 0 );
return $input;
}