Site icon Catch Themes

Adding a custom function to function.php

Hello, I am using catch box (Public), and would like to know how I can add a custom function to functions.php? At the moment every time there is an update of the theme, I have to add the code back. The code is for google Adsense, which is call out inside a post. This is the my site, www.ogutierrezjr.com/blog/ This is the function called out from the post [adsense float='center'] This is the code that I am trying to add to the functions.php
// **** Start of Google Addsence Function ****;
// allowed parameter: 'left', 'center', 'right', 'none';
// other entries will be treated as 'none';
function add_adsense($atts) {
  extract(shortcode_atts(array(
  'float' => 'none',
  ), $atts));
if( $float == 'left' ) $float = ' style=" float:left; margin: 10px 10px 5px 0; "';
elseif( $float == 'center' ) $float = ' style=" display:block; margin: 10px auto; text-align:center; "';
elseif( $float == 'right' ) $float = ' style=" float:right; margin: 10px 0 5px 10px; "';
else $float = '';
$ads = '<span class="adsense "'.$float.'>
			<script type="text/javascript"><!--
				google_ad_client = "ca-pub-4709087591608098";
				/* main_post_add */
				google_ad_slot = "2143366565";
				google_ad_width = 468;
				google_ad_height = 60;
				//-->
			</script>
				<script type="text/javascript"
				src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
			</script>
</span>';
return $ads;
}
 
add_shortcode('adsense', 'add_adsense');

// **** End of Google Addsence Function ****;
Exit mobile version