Created
May 18, 2012 15:03
-
-
Save lgedeon/2725746 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_filter( 'acm_default_url', 'acm_default_url' ); | |
add_filter( 'acm_output_html', 'acm_output_html' ); | |
add_filter( 'acm_output_tokens', 'acm_output_tokens', 10, 3 ); | |
add_filter( 'acm_ad_tag_ids', 'acm_ad_tag_ids' ); | |
add_filter( 'acm_provider_slug', function() { return 'complex-ad-network'; } ); | |
} | |
function my_acm_default_url( $url ) { | |
if ( 0 === strlen( $url ) ) { | |
return "http://cdn.complexmedianetwork.com/js/cmnUNT.js"; | |
} | |
} | |
function acm_output_html( $html ) { | |
switch ( $tag_id ) { | |
case 'head_script': | |
$output_html = '<!-- cmnUNT | Begin head script --> | |
<script type="text/javascript"> | |
cmnunt_site = \'cmn_allhiphop\'; | |
cmnunt_silo = \'s_mus\'; | |
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 'ad_tag': | |
$output_html = '<!-- cmnUNT | Begin ad tag --><script type="text/javascript">cmnUNT(\'%size_type%\', tile_num++);</script><!-- cmnUNT | End ad tag -->'; | |
break; | |
case 'wallpaper_takeover': | |
$output_html = '<script type="text/javascript">cmnTB();cmnUNT(\'tover\', tile_num++);</script>'; | |
break; | |
default: | |
break; | |
} | |
return $output_html; | |
} | |
function acm_output_tokens( $output_tokens, $tag_id, $code_to_display ) { | |
$output_tokens['%cmnunt_subsilo%'] = true; | |
$output_tokens['%cmnunt_tier%'] = true; | |
$output_tokens['%cmnunt_zone%'] = true; | |
$output_tokens['%cmnunt_kw%'] = true; | |
$output_tokens['%cmnunt_exclude%'] = true; | |
$output_tokens['%size_type%'] = true; | |
return $output_tokens; | |
} | |
function my_acm_ad_tag_ids( $tag_ids ) { | |
$tag_ids[] = array( 'tag' => 'head_script' ); | |
$tag_ids[] = array( 'tag' => 'ad_tag' ); | |
$tag_ids[] = array( 'tag' => 'wallpaper_takeover' ); | |
return $tag_ids; | |
} | |
function wp_head() { | |
?> | |
<?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 --> | |
<?php | |
} | |
} | |
$ahh_complex_ads = new AHH_Complex_Ads; | |
/** | |
* This part belongs in a file called complex-ad-network.php, but we will keep | |
* it here until we are closer to launch. We still have a lot of changes to make | |
* and it will have to be sent to VIP seperately. | |
*/ | |
/** | |
* Complex Ad Network Ad Provider for Ad Code manager | |
* | |
* @since | |
*/ | |
class Complex_Ad_Network_ACM_Provider extends ACM_Provider { | |
function __construct() { | |
// Default output HTML | |
$this->output_html = '<!-- cmnUNT | Begin ad tag --><script type="text/javascript">cmnUNT(\'%size_type%\', tile_num++);</script><!-- cmnUNT | End ad tag -->'; | |
// Default Ad Tag Ids (you will pass this in your shortcode or template tag) | |
$this->ad_tag_ids = array( | |
array( | |
'tag' => '3x3', | |
'url_vars' => array( | |
'size_type' => '3x3', | |
) | |
), | |
array( | |
'tag' => 'fixed', | |
'url_vars' => array( | |
'size_type' => '300x250', | |
) | |
), | |
array( | |
'tag' => 'variable', | |
'url_vars' => array( | |
'size_type' => '300x250,300x600', | |
) | |
), | |
); | |
// Only allow ad tags called from following URLS | |
$this->whitelisted_script_urls = array( 'cdn.complexmedianetwork.com' ); | |
$this->columns = apply_filters( 'acm_provider_columns', array( 'cmnunt_subsilo' => 'Sub Silo', 'cmnunt_tier' => 'Tier', 'cmnunt_zone' => 'Zone', 'cmnunt_kw' => 'Keywords' ) ); | |
parent::__construct(); | |
} | |
/** | |
* Filter the columns that can appear in the list table of ad codes | |
*/ | |
function filter_list_table_columns( $columns ) { | |
return $columns; | |
} | |
} | |
class Doubleclick_For_Publishers_ACM_WP_List_Table extends ACM_WP_List_Table { | |
function __construct() { | |
parent::__construct( array( | |
'singular'=> 'doubleclick_for_publishers_acm_wp_list_table', //Singular label | |
'plural' => 'doubleclick_for_publishers_acm_wp_list_table', //plural label, also this well be one of the table css class | |
'ajax' => true | |
) ); | |
} | |
/** | |
* This is nuts and bolts of table representation | |
*/ | |
function get_columns() { | |
$columns = array( | |
'id' => __( 'ID', 'ad-code-manager' ), | |
'site_name' => __( 'Site Name', 'ad-code-manager' ), | |
'zone1' => __( 'Zone1', 'ad-code-manager' ), | |
'priority' => __( 'Priority', 'ad-code-manager' ), | |
'conditionals' => __( 'Conditionals', 'ad-code-manager' ), | |
); | |
return apply_filters( 'acm_list_table_columns', $columns ); | |
} | |
/** | |
* Representation of the site name | |
*/ | |
function column_site_name( $item ) { | |
$output = esc_html( $item['url_vars']['site_name'] ); | |
$output .= $this->row_actions_output( $item ); | |
return $output; | |
} | |
/** | |
* Representation of zone1 | |
*/ | |
function column_zone1( $item ) { | |
return esc_html( $item['url_vars']['zone1'] ); | |
} | |
} | |
/* | |
* cmnunt_subsilo = \'%cmnunt_subsilo%\'; | |
cmnunt_tier = \'%cmnunt_tier%\'; | |
cmnunt_zone = \'%cmnunt_zone%\'; | |
cmnunt_kw = \'%cmnunt_kw%\'; | |
cmnunt_exclude = \'%cmnunt_exclude%\'; | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment