OK, that’s where I stand after a bit more research:
In single.php:
<?
if ($mytheme_facebook_enable == "false") { ?>
<? } else { ?>
<a href="https://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>" title="Share on Facebook.">
<img src="<?php bloginfo('template_directory'); ?>/images/facebook.png" alt="Share on Facebook" id="sharethis-last" />
</a>
<? } ?>
<?
if ($mytheme_twitter_enable == "false") { ?>
<? } else { ?>
<a href="https://twitter.com/home/?status=<?php the_title(); ?> : <?php the_permalink(); ?>" title="Tweet this!">
<img src="<?php bloginfo('template_directory'); ?>/images/twitter.png" alt="Tweet this!" />
</a>
<? } ?>
<?
if ($mytheme_delicious_enable == "false") { ?>
<? } else { ?>
<a href="https://del.icio.us/post?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" title="Bookmark on Delicious.">
<img src="<?php bloginfo('template_directory'); ?>/images/delicious.png" alt="Bookmark on Delicious" />
</a>
<? } ?>
<?
if ($mytheme_stumbleupon_enable == "false") { ?>
<? } else { ?>
<a href="https://www.stumbleupon.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" title="StumbleUpon.">
<img src="<?php bloginfo('template_directory'); ?>/images/stumbleupon.png" alt="StumbleUpon" />
</a>
<? } ?>
Then in functions.php I added these functions:
<?php
$themename = "My Theme";
$shortname = "mytheme";
$options = array (
array( "name" => "Theme settings",
"type" => "title"),
array( "type" => "open"),
array( "name" => "Enable Facebook",
"desc" => "Check Box to enable (Share section)",
"id" => $shortname."_facebook_enable",
"type" => "checkbox",
"std" => "false"),
array( "name" => "Enable Twitter",
"desc" => "Check Box to enable (Share section)",
"id" => $shortname."_twitter_enable",
"type" => "checkbox",
"std" => "false"),
array( "name" => "Enable Delicious",
"desc" => "Check Box to enable (Share section)",
"id" => $shortname."_delicious_enable",
"type" => "checkbox",
"std" => "false"),
array( "name" => "Enable Stumbleupon",
"desc" => "Check Box to enable (Share section)",
"id" => $shortname."_stumbleupon_enable",
"type" => "checkbox",
"std" => "false"),
array( "type" => "close")
);
function mytheme_add_admin() {
global $themename, $shortname, $options;
if ( $_GET['page'] == basename(__FILE__) ) {
if ( 'save' == $_REQUEST['action'] ) {
foreach ($options as $value) {
update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
foreach ($options as $value) {
if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } }
header("Location: themes.php?page=functions.php&saved=true");
die;
} else if( 'reset' == $_REQUEST['action'] ) {
foreach ($options as $value) {
delete_option( $value['id'] ); }
header("Location: themes.php?page=functions.php&reset=true");
die;
}
}
add_theme_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
}
function mytheme_admin() {
global $themename, $shortname, $options;
if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
?>
<div class="wrap">
<h2><?php echo $themename; ?> settings</h2>
<form method="post">
<?php foreach ($options as $value) {
switch ( $value['type'] ) {
case "open":
?>
<table width="100%" border="0" style="padding:10px;">
<?php break;
case "close":
?>
</table><br />
<?php break;
case "title":
?>
<table width="100%" border="0" style="padding:5px 10px;"><tr>
<td colspan="2"><h3><?php echo $value['name']; ?></h3></td>
</tr>
<?php
break;
case "checkbox":
?>
<tr>
<td width="20%" rowspan="2" valign="middle"><strong><?php echo $value['name']; ?></strong></td>
<td width="80%"><? if(get_settings($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = ""; } ?>
<input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
</td>
</tr>
<tr>
<td><small><?php echo $value['desc']; ?></small></td>
</tr><tr><td colspan="2" style="margin-bottom:5px;border-bottom:1px dotted #000000;"> </td></tr>
<?php break;
}
}
?>
<!--</table>-->
<p class="submit">
<input name="save" type="submit" value="Save changes" />
<input type="hidden" name="action" value="save" />
</p>
</form>
<form method="post">
<p class="submit">
<input name="reset" type="submit" value="Reset" />
<input type="hidden" name="action" value="reset" />
</p>
</form>
<?php } // End custom theme admin page
add_action('admin_menu', 'mytheme_add_admin'); ?>
Now all my bookmarks are displayed, even if only one checkbox is checked.
Any idea why?