1));
$options = get_option('tanish');
# defaults
if( ! isset($options['showauthors' ]) ) $options['showauthors' ] = 0;
if( ! isset($options['expandfirst' ]) ) $options['expandfirst '] = 0;
if( ! isset($options['showcredits' ]) ) $options['showcredits '] = 1;
if( ! isset($options['hidecomments']) ) $options['hidecomments'] = 0;
if( ! isset($options['mainbgimage' ]) ) $options['mainbgimage '] = 'None';
if( ! isset($options['mainbgtile' ]) ) $options['mainbgtile ' ] = 'None';
if( ! isset($options['iewarn' ]) ) $options['iewarn' ] = 0;
# end defaults
update_option('tanish', $options);
# setup admin menu
add_action('admin_menu', 'tanish_admin_menu');
if ( function_exists('register_sidebar') )
add_sidebars();
//-------------------------------------------------------------------------------
function tanish_admin_menu()
{
add_theme_page('Tanish Options', 'Tanish Options', 'edit_themes', "Audacity of Tanish", 'tanish_options');
}
//-------------------------------------------------------------------------------
function tanish_options()
{
global $options;
if( $_POST['action'] == 'save' )
save_options();
print
"
Keep up with Audacity of Tanish
Follow on Twitter, or join the Facebook Page. Subscribe to the blog.
Create bug/feature requests, download the latest code, and more!
";
}
//------------------------------------------------------------------------------
function images_dir_html($dir, $count, $fldname)
{
global $options;
$html =
"
";
$ctr = $count - 2;
foreach( array_merge(array("None", "Random"), scandir(TEMPLATEPATH . "/images/" . $dir)) as $image )
{
if( $image == '.' || $image == '..' )
continue;
if( $ctr > 0 && ($ctr % $count) == 0 )
$html .= "
\n";
$ctr++;
$checked = "";
if( $options[$fldname] == $image )
$checked = "checked";
$html .= "
";
if( $image == "None" || $image == "Random" )
$html .= $image;
else
$html .= "

";
$html .= " ";
}
$html .=
"
";
return($html);
}
//------------------------------------------------------------------------------
function comments_hide_html()
{
global $options;
if( $options['hidecomments'] != 1 )
return;
// Could check for is_single() or some such here but do we really
// save much by doing so? The logic is safe even without the check
// since the jQuery will fire only for #single.
print
"
";
}
//------------------------------------------------------------------------------
function bg_images_css($selector, $optname, $imgdir, $pos_repeat)
{
global $options;
$image = $options[$optname];
if( $image == 'None' )
return;
if( $image == "Random" )
{
$images = preg_grep("/^\./", scandir(TEMPLATEPATH . "/images/" . $imgdir), PREG_GREP_INVERT);
$randidx = rand(2, sizeof($images)-1);
$image = $images[$randidx];
}
// the v=$randidx below is because Firefox refuses to reload a background image
// unless the URL has changed.
return
("
$selector
{
background: url(" . get_bloginfo('template_url') .
"/images/$imgdir/$image?v=$randidx) $pos_repeat;
}
");
}
//------------------------------------------------------------------------------
function save_options()
{
global $_POST, $options;
$options['showauthors' ] = ( isset($_POST['showauthors' ]) ) ? 1 : 0;
$options['expandfirst' ] = ( isset($_POST['expandfirst' ]) ) ? 1 : 0;
$options['showcredits' ] = ( isset($_POST['showcredits' ]) ) ? 1 : 0;
$options['hidecomments'] = ( isset($_POST['hidecomments']) ) ? 1 : 0;
$options['iewarn' ] = ( isset($_POST['iewarn' ]) ) ? 1 : 0;
$options['mainbgimage' ] = ( isset($_POST['mainbgimage' ]) ) ? $_POST['mainbgimage'] : "None";
$options['mainbgtile' ] = ( isset($_POST['mainbgtile' ]) ) ? $_POST['mainbgtile' ] : "None";
update_option('tanish', $options);
print
"
";
}
//------------------------------------------------------------------------------
function add_sidebars()
{
register_sidebar(array(
'name' => 'bottombarleft',
'before_widget' => "",
));
register_sidebar(array(
'name' => 'bottombarcenter',
'before_widget' => "",
));
register_sidebar(array(
'name' => 'bottombarright',
'before_widget' => "",
));
}
?>