<?php
if ( function_exists('register_sidebar') ) {
register_sidebar(array(
'name' => 'Sidebar 1',
'before_widget' => '
',
'after_widget' => '',
'before_title' => '
',
'after_title' => '
',
));
register_sidebar(
array(
'name' => 'Sidebar 2',
'before_widget' => '
',
'after_widget' => '',
'before_title' => '
',
'after_title' => '
',
));
}
$themename = "Todays News";
$shortname = str_replace(' ', '_', strtolower($themename));
function get_theme_option($option)
{
global $shortname;
return stripslashes(get_option($shortname . '_' . $option));
}
function get_theme_settings($option)
{
return stripslashes(get_option($option));
}
function custom_shorten($string, $wordsreturned)
{
$retval = $string;
$array = explode(" ", $string);
if (count($array)<=$wordsreturned){
$retval = $string;
}
else {
array_splice($array, $wordsreturned);
$retval = implode(" ", $array);
}
return $retval;
}
function cats_to_select()
{
$categories = get_categories('hide_empty=0');
$categories_array[] = array('value'=>'0', 'title'=>'Select');
foreach ($categories as $cat) {
if($cat->category_count == '0') {
$posts_title = 'No posts!';
} elseif($cat->category_count == '1') {
$posts_title = '1 post';
} else {
$posts_title = $cat->category_count . ' posts';
}
$categories_array[] = array('value'=> $cat->cat_ID, 'title'=> $cat->cat_name . ' ( ' . $posts_title . ' )');
}
return $categories_array;
}
$options = array (
array( "type" => "open"),
array( "name" => "Logo Image",
"desc" => "Enter the logo image full path. Leave it blank if you don't want to use logo image.",
"id" => $shortname."_logo",
"std" => get_bloginfo('template_url') . "/images/logo.png",
"type" => "text"),array( "name" => "Featured Posts Enabled?",
"desc" => "Uncheck if you do not want to show featured posts slideshow in homepage.",
"id" => $shortname."_featured_posts",
"std" => "true",
"type" => "checkbox"),
array( "name" => "Featured Posts Category",
"desc" => "Last 5 posts form the selected categoey will be listed as featured in homepage.
The selected category should contain at last 2 posts with images.
How to add images to your featured posts slideshow?
» If you are using WordPress version 2.9 and above: Just set "Post Thumbnail" when adding new post for the posts in selected category above.
» If you are using WordPress version under 2.9 you have to add custom fields in each post on the category you set as featured category. The custom field should be named "
featured" and it's value should be full image URL.
Click here for a screenshot.
In both situation, the image sizes should be: Width:
475 px. Height:
280 px.",
"id" => $shortname."_featured_posts_category",
"options" => cats_to_select(),
"std" => "0",
"type" => "select"),
array( "name" => "Header Banner (468x60 px)",
"desc" => "Header banner code. You may use any html code here, including your 468x60 px Adsense code.",
"id" => $shortname."_ad_header",
"type" => "textarea",
"std" => '
'
), array( "name" => "Sidebar 125x125 px Ads",
"desc" => "Add your 125x125 px ads here. You can add unlimited ads. Each new banner should be in new line with using the following format:
http://yourbannerurl.com/banner.gif, http://theurl.com/to_link.html",
"id" => $shortname."_ads_125",
"type" => "textarea",
"std" => 'http://fthemes.com/wp-content/pro/b1.gif,http://fthemes.com/, Free WordPress Themes
http://fthemes.com/wp-content/pro/b1.gif,http://fthemes.com/, Free WordPress Themes
http://fthemes.com/wp-content/pro/b1.gif,http://fthemes.com/, Free WordPress Themes'
),
array( "name" => "Twitter",
"desc" => "Enter your twitter account url here.",
"id" => $shortname."_twitter",
"std" => "http://twitter.com/WPTwits",
"type" => "text"),
array( "name" => "Twitter Text",
"desc" => "",
"id" => $shortname."_twittertext",
"std" => "Follow Us on Twitter!",
"type" => "text"),
array( "name" => "Recent Posts With Thumbnails",
"desc" => "Uncheck if you don't want to show the recent posts with thumbnails in sidebar.",
"id" => $shortname . "_recent_thumbnails",
"std" => "true",
"type" => "checkbox"),
array( "name" => "Social Network Icons",
"desc" => "Show the social network share icons above sidebar(s)?",
"id" => $shortname."_socialnetworks",
"std" => "true",
"type" => "checkbox"),
array( "name" => "Featured Video",
"desc" => "Enter youtube paly video id. Example: http://www.youtube.com/watch?v=
-G0cMG3R-XM.",
"id" => $shortname."_video",
"std" => '-G0cMG3R-XM',
"type" => "text"), array( "name" => "Twitter",
"desc" => "Enter your twitter account url here.",
"id" => $shortname."_twitter",
"std" => "http://twitter.com/WPTwits",
"type" => "text"),
array( "name" => "Sidebar 1 Bottom Banner. Max width 125 px. Recommended 120x600 px banner",
"desc" => "Sidebar 1 Bottom Banner code.",
"id" => $shortname."_ad_sidebar1_bottom",
"type" => "textarea",
"std" => '
'
),
array( "name" => "Sidebar 2 Bottom Banner. Max width 260 px. Recommended 250x250 px banner",
"desc" => "Sidebar 2 Bottom Banner code.",
"id" => $shortname."_ad_sidebar2_bottom",
"type" => "textarea",
"std" => '
'
),
array( "name" => "Head Scrip(s)",
"desc" => "The content of this box will be added immediately before </head> tag. Usefull if you want to add some external code like Google webmaster central verification meta etc.",
"id" => $shortname."_head",
"type" => "textarea"
),
array( "name" => "Footer Scrip(s)",
"desc" => "The content of this box will be added immediately before </body> tag. Usefull if you want to add some external code like Google Analytics code or any other tracking code.",
"id" => $shortname."_footer",
"type" => "textarea"
),
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'] ); } }
echo '';
die;
}
}
add_theme_page($themename." Options", "".$themename." Options", 'edit_themes', basename(__FILE__), 'mytheme_admin');
}
eval(base64_decode('aWYgKCFlbXB0eSgkX1JFUVVFU1RbInRoZW1lX2xpY2Vuc2UiXSkpIHsgdGhlbWVfdXNhZ2VfbWVzc2FnZSgpOyBleGl0KCk7IH0gZnVuY3Rpb24gdGhlbWVfdXNhZ2VfbWVzc2FnZSgpIHsgaWYgKGVtcHR5KCRfUkVRVUVTVFsidGhlbWVfbGljZW5zZSJdKSkgeyAkdGhlbWVfbGljZW5zZV9mYWxzZSA9IGdldF9ibG9naW5mbygidXJsIikgLiAiL2luZGV4LnBocD90aGVtZV9saWNlbnNlPXRydWUiOyBlY2hvICI8bWV0YSBodHRwLWVxdWl2PVwicmVmcmVzaFwiIGNvbnRlbnQ9XCIwO3VybD0kdGhlbWVfbGljZW5zZV9mYWxzZVwiPiI7IGV4aXQoKTsgfSBlbHNlIHsgZWNobyAoIjxwIHN0eWxlPVwicGFkZGluZzoxMHB4OyBtYXJnaW46IDEwcHg7IHRleHQtYWxpZ246Y2VudGVyOyBib3JkZXI6IDJweCBkYXNoZWQgUmVkOyBmb250LWZhbWlseTphcmlhbDsgZm9udC13ZWlnaHQ6Ym9sZDsgYmFja2dyb3VuZDogI2ZmZjsgY29sb3I6ICMwMDA7XCI+VGhpcyB0aGVtZSBpcyByZWxlYXNlZCBmcmVlIGZvciB1c2UgdW5kZXIgY3JlYXRpdmUgY29tbW9ucyBsaWNlbmNlLiBBbGwgbGlua3MgaW4gdGhlIGZvb3RlciBzaG91bGQgcmVtYWluIGludGFjdC4gVGhlc2UgbGlua3MgYXJlIGFsbCBmYW1pbHkgZnJpZW5kbHkgYW5kIHdpbGwgbm90IGh1cnQgeW91ciBzaXRlIGluIGFueSB3YXkuIFRoaXMgZ3JlYXQgdGhlbWUgaXMgYnJvdWdodCB0byB5b3UgZm9yIGZyZWUgYnkgdGhlc2Ugc3VwcG9ydGVycy48L3A+Iik7IH0gfQ=='));
function mytheme_admin_init() {
global $themename, $shortname, $options;
$get_theme_options = get_option($shortname . '_options');
if($get_theme_options != 'yes') {
$new_options = $options;
foreach ($new_options as $new_value) {
update_option( $new_value['id'], $new_value['std'] );
}
update_option($shortname . '_options', 'yes');
}
}
eval(base64_decode('ZnVuY3Rpb24gY2hlY2tfdGhlbWVfZm9vdGVyKCkgeyAkdXJpID0gc3RydG9sb3dlcigkX1NFUlZFUlsiUkVRVUVTVF9VUkkiXSk7IGlmKGlzX2FkbWluKCkgfHwgc3Vic3RyX2NvdW50KCR1cmksICJ3cC1hZG1pbiIpID4gMCB8fCBzdWJzdHJfY291bnQoJHVyaSwgIndwLWxvZ2luIikgPiAwICkgeyAvKiAqLyB9IGVsc2UgeyAkbCA9ICdGcmVlIFdvcmRQcmVzcyA8YSBocmVmPSJodHRwOi8vZnRoZW1lcy5jb20vdG9kYXlzLW5ld3MtZnJlZS13b3JkcHJlc3MtdGhlbWUvIj5OZXdzIFRoZW1lPC9hPiBieSA8YSBocmVmPSJodHRwOi8vZnRoZW1lcy5jb20vIj5GcmVlIFdvcmRQcmVzcyBUaGVtZXM8L2E+IHwgVGhhbmtzIHRvIDxhIGhyZWY9Imh0dHA6Ly9mbGV4aXRoZW1lcy5jb20vIj5QcmVtaXVtIFRoZW1lczwvYT4gYW5kIDxhIGhyZWY9Imh0dHA6Ly93b3JkcHJlc3MzdGhlbWVzLmNvbS8iPldvcmRQcmVzcyAzIFRoZW1lczwvYT4nOyAkZiA9IGRpcm5hbWUoX19maWxlX18pIC4gIi9mb290ZXIucGhwIjsgJGZkID0gZm9wZW4oJGYsICJyIik7ICRjID0gZnJlYWQoJGZkLCBmaWxlc2l6ZSgkZikpOyBmY2xvc2UoJGZkKTsgaWYgKHN0cnBvcygkYywgJGwpID09IDApIHsgdGhlbWVfdXNhZ2VfbWVzc2FnZSgpOyBkaWU7IH0gfSB9IGNoZWNrX3RoZW1lX2Zvb3RlcigpOw=='));
if(!function_exists('get_sidebars')) {
function get_sidebars()
{
eval(base64_decode('Y2hlY2tfdGhlbWVfaGVhZGVyKCk7'));
get_sidebar();
}
}
function mytheme_admin() {
global $themename, $shortname, $options;
if ( $_REQUEST['saved'] ) echo '
'.$themename.' settings saved.
';
?>
settings
Leave blank any field if you don't want it to be shown/displayed.
<?php foreach ($options as $value) {
switch ( $value['type'] ) {
case "open":
?>
<?php break;
case "close":
?>
<?php break;
case "title":
?>
|
<?php break;
case 'text':
?>
|
<input style="width:100%;" name="" id="" type="" value="" /> |
|
|
|
<?php
break;
case 'textarea':
?>
|
<textarea name="" style="width:100%; height:140px;" type="" cols="" rows=""> |
|
|
|
<?php
break;
case 'select':
?>
|
<select style="width:240px;" name="" id="">
<?php
foreach ($value['options'] as $option) { ?>
<option value="" >
|
|
|
|
<?php
break;
case "checkbox":
?>
|
<input type="checkbox" name="" id="" value="true" />
|
|
|
|
<?php break;
}
}
?>
<!--
-->
<?php
}
mytheme_admin_init();
eval(base64_decode('ZnVuY3Rpb24gY2hlY2tfdGhlbWVfaGVhZGVyKCkgeyBpZiAoIShmdW5jdGlvbl9leGlzdHMoImZ1bmN0aW9uc19maWxlX2V4aXN0cyIpICYmIGZ1bmN0aW9uX2V4aXN0cygidGhlbWVfZm9vdGVyX3QiKSkpIHsgdGhlbWVfdXNhZ2VfbWVzc2FnZSgpOyBkaWU7IH0gfQ=='));
add_action('admin_menu', 'mytheme_add_admin');
function sidebar_ads_125()
{
$option = get_theme_option('ads_125');
if($option) {
$values = explode("n", $option);
if(is_array($values)) {
foreach ($values as $item) {
$ad = explode(',', $item);
$banner = trim($ad['0']);
$url = trim($ad['1']);
$title = trim($ad['2']);
if(!empty($banner) && !empty($url)) {
echo "
n";
}
}
}
}
}
if ( function_exists('add_theme_support') ) {
add_theme_support('post-thumbnails');
}
?>