Skip to content

Instantly share code, notes, and snippets.

@mjangda
Created June 13, 2013 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjangda/5771347 to your computer and use it in GitHub Desktop.
Save mjangda/5771347 to your computer and use it in GitHub Desktop.
Load ad-busters from the theme if the REQUEST_URI matches one of the whitelisted requests.
<?php
add_action( 'init', 'x_maybe_load_ad_busters' );
function x_maybe_load_ad_busters() {
$ad_busters = array(
'/adcentric/ifr_b.html',
'/atlas/atlas_rm.htm',
'/doubleclick/DARTIframe.html',
'/eyereturn/eyereturn.html',
'/flashtalking/ftlocal.html',
'/pointroll/PointRollAds.htm',
'/unicast/unicastIFD.html',
);
$request = $_SERVER['REQUEST_URI'];
$request_path = parse_url( $request, PHP_URL_PATH );
$index = array_search( $request_path, $ad_busters );
if ( false === $index )
return;
$output = '';
$file = locate_template( array( 'static/iframe-busters' . $ad_busters[ $index ] ) );
if ( $file )
$output = file_get_contents( $file );
echo $output;
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment