Skip to content

Instantly share code, notes, and snippets.

@rinatkhaziev
Created July 23, 2013 15:43
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 rinatkhaziev/6063442 to your computer and use it in GitHub Desktop.
Save rinatkhaziev/6063442 to your computer and use it in GitHub Desktop.
Sample code of DFP Async setTargeting support for ACM
<?php
class Doubleclick_For_Publishers_Async_ACM_Provider extends ACM_Provider {
public $crawler_user_agent = 'Mediapartners-Google';
function filter_output_html( $output_html, $tag_id ) {
// .. omitted
$targeting_params_array = apply_filters( 'acm_targeting_params', array( 'kw' => 'testkeyword' ), $tag_id );
$targeting_string = $this->format_targeting_string( $targeting_params_array );
// .. omitted
}
/**
* Format setTargeting string
* @param array $params_array [description]
* @return string [description]
*/
function format_targeting_string( $params_array = array() ) {
$ret = '';
// Iterate over array of key value pairs and format a string
foreach( (array) $params_array as $key => $value ) {
// .. sanitize, validate, and append
}
return $ret;
}
}
@harvitronix
Copy link

What, you didn't like my idea to just allow anything at all to be appended to the end of the slot definition? Haha.

This is a much better idea you've got here.

Is it necessary to send a sample array or tag id to the filter, do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment