Exemplo n.º 1
0
 public function get_adbusters_array()
 {
     if (function_exists('wpcom_vip_load_plugin')) {
         wpcom_vip_load_plugin('adbusters');
         if (function_exists('wpcom_vip_get_ad_busters_array')) {
             return wpcom_vip_get_ad_busters_array();
         }
     }
     return array('adcentric/ifr_b.html', 'adinterax/adx-iframe-v2.html', 'atlas/atlas_rm.htm', 'blogads/iframebuster-4.html', 'checkm8/CM8IframeBuster.html', 'comscore/cs-arIframe.htm', 'doubleclick/DARTIframe.html', 'doubleclick/fif.html', 'eyeblaster/addineyeV2.html', 'eyewonder/interim.html', 'flashtalking/ftlocal.html', 'flite/fif.html', 'gumgum/iframe_buster.html', 'interpolls/pub_interpolls.html', 'jivox/jivoxIBuster.html', 'jpd/jpxdm.html', 'mediamind/MMbuster.html', 'mixpo/framebust.html', 'oggifinogi/oggiPlayerLoader.htm', 'pictela/Pictela_iframeproxy.html', 'pointroll/PointRollAds.htm', 'rubicon/rp-smartfile.html', 'saymedia/iframebuster.html', 'smartadserver/iframeout.html', 'undertone/iframe-buster.html', 'undertone/UT_iframe_buster.html', 'xaxis/InfinityIframe.html', '_uac/adpage.html', 'adcom/aceFIF.html');
 }
/**
 * If an appropriate request comes in, load an iframe ad buster file.
 *
 * Note: the following networks/scripts are insecure and will not be added to the plugin:
 * > EyeReturn (/eyereturn/eyereturn.html)
 * > Unicast (/unicast/unicastIFD.html)
 *
 * @since Adbusters (1.0)
 */
function wpcom_vip_maybe_load_ad_busters()
{
    $ad_busters = wpcom_vip_get_ad_busters_array();
    // To only support a specific ad network, use this filter and return an array containing the values of $ad_busters to load
    $whitelist_ads = (array) apply_filters('wpcom_vip_ad_busters_whitelist', $ad_busters);
    $ad_busters = array_intersect($ad_busters, $whitelist_ads);
    // To ignore an ad network, use this filter and return an array containing the values of $ad_busters to not load
    $block_ads = apply_filters('wpcom_vip_maybe_load_ad_busters', array());
    $ad_busters = array_diff($ad_busters, $block_ads);
    $ad_paths = $ad_busters;
    // nothing to do if there are no paths after whitelisting and blocking
    if (empty($ad_paths)) {
        return;
    }
    // If your ads need to be served from example.com/some/subfolder/*, pass "some/subfolder" to this filter
    $path = explode('/', apply_filters('wpcom_vip_ad_busters_custom_path', ''));
    $path = array_filter(array_map('sanitize_title', $path));
    $path = implode('/', $path);
    // Make sure both the ends of the path have slashes
    $path = _wpcom_vip_leadingslashit($path);
    $path = trailingslashit($path);
    $ad_busters = array_map(function ($ad_file) use($path) {
        return "{$path}{$ad_file}";
    }, $ad_busters);
    // Do we have a request for a supported network?
    $request = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
    $index = array_search($request, $ad_busters);
    if (false === $index) {
        return;
    }
    // Spit out the template
    $file = plugin_dir_path(__FILE__) . 'templates/' . $ad_paths[$index];
    if (!file_exists($file)) {
        return;
    }
    header('Content-type: text/html');
    readfile($file);
    exit;
}