Integrating the new BuySellAds code into Thematic

The old code snip­pet from BuySellAds.com didn’t require to change any­thing in the code of a site/blog; only to be copy­pas­ted into a text wid­get was the deal. The new code is much bet­ter as it is not block­ing the rest of the page while it’s load­ing, but you have to put a code snip­pet right after the open­ing <body> tag on all pages. In Them­atic, this can be eas­ily accom­plished without any plu­gins or theme file hacks, just paste this into the functions.php of your child theme:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
function bsa_before() { ?>

<!-- BuySellAds.com Ad Code -->
<script type="text/javascript">
(function(){
  var bsa = document.createElement('script');
     bsa.type = 'text/javascript';
     bsa.async = true;
     bsa.src = '//s3.buysellads.com/ac/bsa.js';
  (document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(bsa);
})();
</script>
<!-- END BuySellAds.com Ad Code -->
<?php }

add_action('thematic_before', 'bsa_before');
?>

Then you can put the actual ad slot code from the ‘Get ad code’ page into a text wid­get in your side­bar, or any other place as you wish.

1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 1.00 out of 5)
Loading ... Loading ...
This entry was posted in Webdesign and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

2 Comments

  1. Posted March 9, 2010 at 12:09 | Permalink

    Simple but very use­ful! Thanks Eugen.

    • Eugen R. 510
      Posted March 9, 2010 at 17:14 | Permalink

      You’re wel­come!

Post a Comment

Do not spam. Do not name yourself after website names. To have an avatar, register at gravatar. Note: your e-mail will never be published or used, it is needed only to ensure you're not a spambot.

Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting