Example #1
0
function blackbird_auto_insert_adsense_fourth($post_content)
{
    if (!is_single()) {
        return $post_content;
    }
    $afterParagraph = 4;
    // display after the "n"th paragraph
    $adsense = blackbird_return_adsense('468x60');
    preg_match_all('/<\\/p>/', $post_content, $matches, PREG_OFFSET_CAPTURE);
    $insert_at = $matches[0][$afterParagraph - 1][1];
    return substr($post_content, 0, $insert_at) . $adsense . substr($post_content, $insert_at, strlen($post_content));
}
 public function widget($args, $instance)
 {
     echo blackbird_return_adsense($instance['ad_type']);
 }
function display_adsense_300($atts)
{
    extract(shortcode_atts(array('ad_type' => '300x250'), $atts));
    return blackbird_return_adsense($ad_type);
}