Nuffnang's Ad Units into your blog. Configure from Nuffnang Configuration page. To use, add <?php if (function_exists('nuffnang')) nuffnang('type', 'echo'); ?> in your template.
Version: 2.0
Author: Safirul Alredha
Author URI: http://zeo.unic.net.my
License: GPL
*/
$nuffnang_bid = get_option('nuffnang_bid');
function nuffnang_header() {
global $nuffnang_bid;
if ( empty($nuffnang_bid) )
return;
echo '';
}
add_action('wp_head','nuffnang_header');
function nuffnang($type='', $echo = 1) {
global $nuffnang_bid;
if ( empty($nuffnang_bid) )
return;
switch($type) {
case 'leaderboard':
$output .= "k.js";
$format .= 'leaderboard';
break;
case 'rectangle':
$output .= "j.js";
$format .= 'rectangle';
break;
case 'skyscraper':
default:
$output .= "lmn.js";
$format .= 'skyscraper';
break;
}
$ads = '
';
if ($echo)
echo $ads;
return $ads;
}
function nuffnang_add_to_content($content) {
global $post, $posts;
if ( is_single() || $post == $posts[0] && !is_page() && !is_feed() ) {
$content .= nuffnang('rectangle', 0);
}
return $content;
}
if ( get_option('nuffnang_addtocontent') == '1' )
add_filter('the_content', 'nuffnang_add_to_content');
function widget_nuffnang_init() {
global $nuffnang_bid;
if ( !function_exists('register_sidebar_widget') || !function_exists('register_widget_control') || empty($nuffnang_bid) )
return;
function widget_nuffnang($args) {
extract($args);
$options = get_option('widget_nuffnang');
$title = $options['title'];
echo $before_widget . $before_title . $title . $after_title;
nuffnang();
echo $after_widget;
}
function widget_nuffnang_control() {
$options = $newoptions = get_option('widget_nuffnang');
if ( $_POST['nuffnang-submit'] ) {
$newoptions['title'] = strip_tags(stripslashes($_POST['nuffnang-title']));
}
if ( $options != $newoptions ) {
$options = $newoptions;
update_option('widget_nuffnang', $options);
}
$title = htmlspecialchars($options['title'], ENT_QUOTES);
echo '
';
}
register_sidebar_widget('Nuffnang', 'widget_nuffnang');
register_widget_control('Nuffnang', 'widget_nuffnang_control', 300, 100);
}
function nuffnang_conf() {
if ( isset($_POST['submit']) ) {
if ( function_exists('current_user_can') && !current_user_can('manage_options') )
die(__('Cheatin’ uh?'));
$nuffnang_bid = strip_tags(stripslashes($_POST['nuffnang_bid']));
update_option('nuffnang_bid', $nuffnang_bid);
if ( isset($_POST['nuffnang_addtocontent']) )
update_option('nuffnang_addtocontent', '1');
else
update_option('nuffnang_addtocontent', '0');
echo "" . __('Options saved.') . "
";
}
?>