Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ADD THIS TO YOUR functions.php FILE ----------------------------------------------------------------------------- */
- function ten80_google_adsense( $attr, $content ) {
- // Variables for use in script -----------------------------------------------------------------------------------
- $pub_account = 'pub-[your-account-number-here]';
- $size = ( !isset( $attr['size'] ) ? $size = '300x250' : $size = $attr['size'] );
- $sizeA = explode('x', $size);
- $sizeW = $sizeA[0];
- $sizeH = $sizeA[1];
- // Output the Google Ads block -----------------------------------------------------------------------------------
- echo '
- <script type="text/javascript">
- google_ad_client = "'.$pub_account.'";
- google_ad_width = '.$sizeW.';
- google_ad_height = '.$sizeH.';
- google_ad_format = "'.$size.'_as";
- google_ad_type = "text_image";
- google_color_border = "FFFFFF";
- google_color_bg = "0000FF";
- google_color_link = "FFFFFF";
- google_color_text = "000000";
- google_color_url = "008000";
- </script>
- <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- ';
- }
- add_shortcode('googleads', 'ten80_google_adsense');
- /* CALL THE SHORTCODE LIKE THIS ------------------------------------------------------------------------------------ */
- /*
- Specify a banner size: [googleads size="460x60"]
- Defaults to 300x250: [googleads]
- */
Add Comment
Please, Sign In to add comment