Created
May 23, 2012 01:06
-
-
Save lgedeon/2772643 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class AllHipHop_Complex_Ads { | |
public function __construct() { | |
add_action( 'wp_head', array( $this, 'wp_head' ) ); | |
add_action( 'body_open', array( $this, 'body_open' ) ); | |
add_action( 'wp_foot', array( $this, 'wp_foot' ) ); | |
add_filter( 'acm_default_url', array( $this, 'acm_default_url' ) ); | |
add_filter( 'acm_output_html', array( $this, 'acm_output_html' ), 10, 2 ); | |
add_filter( 'acm_output_tokens', array( $this, 'acm_output_tokens' ), 10, 3 ); | |
add_filter( 'acm_ad_tag_ids', array( $this, 'acm_ad_tag_ids' ) ); | |
add_filter( 'acm_provider_slug', function() { return 'complex_media_network'; } ); | |
} | |
function acm_default_url( $url ) { | |
if ( 0 === strlen( $url ) ) { | |
return "http://cdn.complexmedianetwork.com/js/cmnUNT.js"; | |
} | |
} | |
function acm_output_html( $html, $tag_id ) { | |
switch ( $tag_id ) { | |
case 'head_script': | |
$output_html = '<!-- cmnUNT | Begin head script --> | |
<script type="text/javascript"> | |
cmnunt_site = \'%cmnunt_site%\'; | |
cmnunt_silo = \'%cmnunt_silo%\'; | |
cmnunt_subsilo = \'%cmnunt_subsilo%\'; | |
cmnunt_tier = \'%cmnunt_tier%\'; | |
cmnunt_zone = \'%cmnunt_zone%\'; | |
cmnunt_kw = \'%cmnunt_kw%\'; | |
cmnunt_exclude = \'%cmnunt_exclude%\'; | |
</script> | |
<script type="text/javascript" src="%url%"></script> | |
<!-- cmnUNT | End head script -->'; | |
break; | |
case 'wallpaper_takeover': | |
$output_html = '<script type="text/javascript">cmnTB();cmnUNT(\'tover\', tile_num++);</script>'; | |
break; | |
default: // for header_ads, fixed_height_side and variable_height_side | |
$output_html = '<!-- cmnUNT | Begin ad tag --><script type="text/javascript">cmnUNT(\'%size_type%\', tile_num++);</script><!-- cmnUNT | End ad tag -->'; | |
break; | |
} | |
return $output_html; | |
} | |
function acm_output_tokens( $output_tokens, $tag_id, $code_to_display ) { | |
/* set any conditionals here that do not need to be user editable. Warning: this runs after the values from the UI so don't use this for defaults */ | |
$output_tokens['%cmnunt_site%'] = 'cmn_allhiphop'; // hardcoded for AHH. | |
$output_tokens['%cmnunt_silo%'] = 's_mus'; // hardcoded for AHH. | |
$output_tokens['%cmnunt_subsilo%'] = ''; // we are not using this for AHH, but this is where to set it. | |
$output_tokens['%cmnunt_exclude%'] = is_single() ? 'ugc' : ''; | |
if ( is_home() ) { | |
$output_tokens['%cmnunt_tier%'] = 'to,home'; | |
$output_tokens['%cmnunt_kw%'] = ''; | |
} else { | |
$output_tokens['%cmnunt_tier%'] = is_single() ? 'to,t2,internal' : 'to,t2,subhome' ; | |
$output_tokens['%cmnunt_kw%'] = is_single() ? implode(',', wp_list_pluck( get_the_tags() ) ) : ''; | |
} | |
return $output_tokens; | |
} | |
function acm_ad_tag_ids( $tag_ids ) { | |
$tag_ids[] = array( 'tag' => 'head_script', 'url_vars' => array() ); | |
$tag_ids[] = array( 'tag' => 'ad_tag', 'url_vars' => array() ); | |
$tag_ids[] = array( 'tag' => 'wallpaper_takeover', 'url_vars' => array() ); | |
return $tag_ids; | |
} | |
function wp_head() { | |
do_action( 'acm_tag', 'head_script' ); | |
} | |
/* wp_head fires before (outside) the body, so we added an action just after body opens. | |
* to add to the confusion, wp_foot fires inside the body which is right where we need it | |
*/ | |
function body_open() { | |
?> | |
<div id="cmn_wrap"> | |
<?php | |
do_action( 'acm_tag', 'header_ads' ); | |
} | |
function wp_foot() { | |
?> | |
<?php // Place the this code right before Wallpaper Takeover Code. ?> | |
<!-- Quantcast Tag --> | |
<script type="text/javascript"> | |
var _qevents = _qevents || []; | |
(function() { | |
var elem = document.createElement('script'); | |
elem.src = (document.location.protocol == "https:" ? "https://secure" : "http://edge") + ".quantserve.com/quant.js"; | |
elem.async = true; | |
elem.type = "text/javascript"; | |
var scpt = document.getElementsByTagName('script')[0]; | |
scpt.parentNode.insertBefore(elem, scpt); | |
})(); | |
</script> | |
<script type="text/javascript"> | |
_qevents.push( { qacct:"p-a0gOdUACucKCE"} ); | |
</script> | |
<noscript> | |
<div style="display: none;"><img src="//pixel.quantserve.com/pixel/p-a0gOdUACucKCE.gif" height="1" width="1" alt="Quantcast"/></div> | |
</noscript> | |
<!-- End Quantcast tag --> | |
<?php // Place the this code right before Wallpaper Takeover Code. ?> | |
<!-- Begin comScore Tag --> | |
<script>document.write(unescape("%3Cscript src=\'" + (document.location.protocol == "https:" ? "https://sb" : "http://b") + ".scorecardresearch.com/beacon.js\' %3E%3C/script%3E"));</script> | |
<script> | |
COMSCORE.beacon({ | |
c1:2, | |
c2:6685975, | |
c3:"", | |
c4:"<?php echo $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; ?>", | |
c5:"", | |
c6:"", | |
c15:"" | |
}); | |
</script> | |
<noscript><img src="http://b.scorecardresearch.com/p?c1=2&c2=6685975&c3=&c4=&c5=&c6=&c15=&cj=1" /></noscript> | |
<!-- End comScore Tag --> | |
</div><!-- cmn_wrap --> | |
<?php | |
do_action( 'acm_tag', 'wallpaper_takeover' ); | |
} | |
} | |
$ahh_complex_ads = new AllHipHop_Complex_Ads; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment