Created
July 23, 2013 15:43
-
-
Save rinatkhaziev/6063442 to your computer and use it in GitHub Desktop.
Sample code of DFP Async setTargeting support for ACM
This file contains 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 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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?