'; $bbadOptions['opt_0']='R'; bb_update_option('bbad_options',$bbadOptions); } function bbad_ad_block(){ global $bbAds,$bbadOptions,$bbad_counter,$bb_alt; $bbad_counter++; $bbadOptions=bb_get_option('bbad_options'); if($bbad_counter<2){ for($x=0;$x<10;$x++){ if('' != $bbadOptions['ad_'.$x] && '' != $bbadOptions['opt_'.$x]){ $temp=$bbadOptions['opt_'.$x]; if($temp=='r' || $temp=='R'){ // Random post, chose a post number that exists $GFP=get_forum_posts(); $PPP=bb_get_option('page_topics'); // PPP = Posts displayed Per Page $LastPage=ceil($GFP/$PPP); if($PPP > $GFP){ // Single page, random between 0 and Total Posts in Topic (GFP) $temp=rand(0,$GFP); }else{ if($_GET['page']==$LastPage){ // Random between 0 and ( Total Posts - Posts Per Page ) $temp=rand(0,($GFP-$PPP)); }else{ // Random between 0 and full page of posts $temp=rand(0,$PPP); } } } $bbAds[$temp]=$bbadOptions['ad_'.$x]; } } } if(array_key_exists($bbad_counter,$bbAds)){ echo '
'.($bbadOptions['author_avatar'] ? '' : '').'

'.$bbadOptions['author_name'].'

'.stripslashes($bbAds[$bbad_counter]).'
'.sprintf( 'Posted %s ago', bb_get_post_time() ).'
'; $BBADWAT=TRUE; $bb_alt['post']+=1; } } /* function bbad_ad_block($text){ // No longer used, this function would filter through posts. global $bbAds,$bbadOptions,$bbad_counter,$bb_alt; $bbad_counter++; $bbadOptions=bb_get_option('bbad_options'); if($bbad_counter<2){ for($x=0;$x<10;$x++){ if('' != $bbadOptions['ad_'.$x] && '' != $bbadOptions['opt_'.$x]){ $temp=$bbadOptions['opt_'.$x]; if($temp=='r' || $temp=='R'){ // Random post, chose a post number that exists $GFP=get_forum_posts(); $PPP=bb_get_option('page_topics'); // PPP = Posts displayed Per Page $LastPage=ceil($GFP/$PPP); if($PPP > $GFP){ // Single page, random between 0 and Total Posts in Topic (GFP) $temp=rand(0,$GFP); }else{ if($_GET['page']==$LastPage){ // Random between 0 and ( Total Posts - Posts Per Page ) $temp=rand(0,($GFP-$PPP)); }else{ // Random between 0 and full page of posts $temp=rand(0,$PPP); } } } $bbAds[$temp]=$bbadOptions['ad_'.$x]; } } } if(array_key_exists($bbad_counter,$bbAds)){ $text.=" \n\n
  • '."\n".'
    '.($bbadOptions['author_avatar'] ? '' : '').'

    '.$bbadOptions['author_name'].'

    '.stripslashes($bbAds[$bbad_counter]).'
    '.sprintf( 'Posted %s ago', bb_get_post_time() ); $bb_alt['post']++; } return $text; } */ function bbad_configuration_page_add() { bb_admin_add_submenu('AdSense for bbPress', 'use_keys', 'bbad_configuration_page'); } function bbad_configuration_page_process() { if(isset($_POST['submit'])) { $bbad_options['author_name']=$_POST['author_name']; $bbad_options['author_avatar']=$_POST['author_avatar']; for($x=0;$x<10;$x++){ if (isset($_POST['ad_'.$x])) {$bbad_options['ad_'.$x]=$_POST['ad_'.$x];} if (isset($_POST['opt_'.$x])) {$bbad_options['opt_'.$x]=$_POST['opt_'.$x];} } bb_update_option('bbad_options',$bbad_options); bb_admin_notice(__('Settings Saved')); } } function bbad_configuration_page() { if('' == bb_get_option('bbad_options')){ bbad_install(); } $bbad_options=bb_get_option('bbad_options'); ?>

    AdSense for bbPress Configuration

    Author Name:
    Author Avatar:Enter the URL or path to an image file or leave blank for no avatar.


    Enter 'R' in any Post Number box to have that Ad displayed at a randomly chosen post number.
    Note that depending on the theme odd numbers typically have a white background, even numbers usually have a grey background. If you chose random placement the background of your ad color may look slightly out of place.
    Leave the Post Number box blank to not display, but store the Ad code.

    Display Ad Set At Post: