' , '</div>"/>

sahifa设置banner AD

Published
2022-04-27
浏览次数 :  141

<?php tie_banner('banner_below_header' , '<div class="e3lan e3lan-below_header">' , '</div>' ); 

/** 函数定义 **/

function tie_banner( $banner , $before= false , $after = false){

	if(tie_get_option( $banner )):
		echo $before;
		$protocol = is_ssl() ? 'https' : 'http';
		if(tie_get_option( $banner.'_img' )):
			$target = $nofollow ="";
			if( tie_get_option( $banner.'_tab' )) $target='target="_blank"';
			if( tie_get_option( $banner.'_nofollow' )) $nofollow='rel="nofollow"';?>

			<a href="<?php echo tie_get_option( $banner.'_url' ) ?>" title="<?php echo tie_get_option( $banner.'_alt') ?>" <?php echo $target; echo $nofollow ?>>
				<img src="<?php echo tie_get_option( $banner.'_img' ) ?>" alt="<?php echo tie_get_option( $banner.'_alt') ?>" />
			</a>
		<?php

			elseif( tie_get_option( $banner.'_publisher' ) ):

				$mobile_width = 300;
				$mobile_height = 250;

				if( $banner == 'banner_top' || $banner == 'banner_below_header' ){
					$mobile_width = 320;
					$mobile_height = 100;
				}

		?>
		<script type="text/javascript">
			var adWidth = jQuery(document).width();
			google_ad_client = "<?php echo tie_get_option( $banner.'_publisher' ) ?>";
			<?php if( $banner != 'banner_above' && $banner != 'banner_below' ){ ?>if ( adWidth >= 768 ) {
			  google_ad_slot	= "<?php echo tie_get_option( $banner.'_728' ) ?>";
			  google_ad_width	= 728;
			  google_ad_height 	= 90;
			} else <?php } ?> if ( adWidth >= 468 ) {
			  google_ad_slot	= "<?php echo tie_get_option( $banner.'_468' ) ?>";
			  google_ad_width 	= 468;
			  google_ad_height 	= 60;
			}else {
			  google_ad_slot 	= "<?php echo tie_get_option( $banner.'_300' ) ?>";
			  google_ad_width 	= <?php echo $mobile_width ?>;
			  google_ad_height 	= <?php echo $mobile_height ?>;
			}
		</script>

		<script src="<?php echo $protocol ?>://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
		<?php elseif(tie_get_option( $banner.'_adsense' )): ?>
			<?php echo do_shortcode(htmlspecialchars_decode(tie_get_option( $banner.'_adsense' ))) ?>
		<?php
		endif;
		?>
		<?php
		echo $after;
	endif;
}

  • 标签1
  • 标签1
  • 标签1
Top