providers / doubleclick-for-publishers.php code>中找到有关如何扩展ACM以适应您的需求的想法。 p>Once this configuration is in place, the Ad Code Manager admin interface will allow you to add new ad codes, modify the parameters for your script URL, and define conditionals to determine when the ad code appears.
完成此配置后,广告代码管理器管理界面将允许您添加新的广告代码,修改脚本URL的参数以及定义条件来确定广告代码何时显示。
Conditionals are core WordPress functions like is_page(), is_category(), or your own custom functions that evaluate certain expression and then return true or false.
条件语句是WordPress的核心功能,例如is_page(),is_category()或您自己的自定义函数,这些函数对某些表达式求值,然后返回true或false。 p>
Fork the plugin on Github and 在Github上分叉插件和
.wordpress.com/" rel="nofollow">follow our development blog.
.wordpress.com /“ rel =” nofollow“>关注我们的开发博客。 p>
Configuration Filters
配置过滤器 h3>
There are some filters which allow you to easily customize the output of the plugin.
有些过滤器可让您轻松自定义插件的输出。
You should place these filters in your theme’s functions.php file or in another appropriate place.
您应该将这些过滤器放置在主题的functions.php文件中或其他合适的位置。 p>
Check out this gist to see all of the filters in action.
查看要点,以查看所有正在使用的过滤器。 p>
acm_ad_tag_ids
acm_ad_tag_ids h4>
Ad tag ids are used as a parameter when adding tags to your theme (e.g. do_action( ‘acm_tag’, ‘my_top_leaderboard’ )).
在向主题添加标签时(例如do_action('acm_tag','my_top_leaderboard')),广告标签ID用作参数。
The url_vars
defined as part of each tag here will also be used to replace tokens in your default URL.
在此处定义为每个标记一部分的 url_vars code>也将用于替换默认URL中的标记。 p>Arguments:
参数:
* array $tag_ids array of default tag ids
*数组$ tag_ids个默认标签ID的数组 p>
Example usage: Add a new ad tag called ‘my_top_leaderboard’
用法示例:添加一个名为“ my_top_leaderboard”的新广告代码 p>
add_filter( 'acm_ad_tag_ids', 'my_acm_ad_tag_ids' ); add_filter('acm_ad_tag_ids','my_acm_ad_tag_ids'); function my_acm_ad_tag_ids( $tag_ids ) {
函数my_acm_ad_tag_ids($ tag_ids){
$tag_ids[] = array(
$ tag_ids [] = array(
'tag' => 'my_top_leaderboard', // tag_id
'tag'=>'my_top_leaderboard',// tag_id
'url_vars' => array(
'url_vars'=>数组(
'sz' => '728x90', // %sz% token
'sz'=>'728x90',//%sz%令牌
'fold' => 'atf', // %fold% token
'fold'=>'atf',//%fold%令牌
'my_custom_token' => 'something' // %my_custom_token% will be replaced with 'something'
'my_custom_token'=>'something'//%my_custom_token%将被替换为'something'
),
),
);
);
return $tag_ids;
返回$ tag_ids;
}
}
code> pre>
acm_default_url
acm_default_url h4>
Set the default tokenized URL used when displaying your ad tags.
设置显示广告代码时使用的默认标记化URL。
This filter is required.
此过滤器是必需的。 p>
Arguments:
参数:
* string $url The tokenized url of Ad Code
* string $ url广告代码的标记化网址 p>
Example usage: Set your default ad code URL
用法示例:设置默认广告代码网址 p>
add_filter( 'acm_default_url', 'my_acm_default_url' ); add_filter('acm_default_url','my_acm_default_url'); function my_acm_default_url( $url ) {
函数my_acm_default_url($ url){
if ( 0 === strlen( $url ) ) {
如果(0 === strlen($ url)){
return "http://ad.doubleclick.net/adj/%site_name%/%zone1%;s1=%zone1%;s2=;pid=%permalink%;fold=%fold%;kw=;test=%test
返回“ http://ad.doubleclick.net/adj/%site_name%/%zone1%;s1=%zone1%;s2=;pid=%永久链接%; fold =%fold%; kw =; test =%test
%;ltv=ad;pos=%pos%;dcopt=%dcopt%;tile=%tile%;sz=%sz%;";
%; ltv = ad; pos =%pos%; dcopt =%dcopt%; tile =%tile%; sz =%sz%;“;
}
}
}
}
code> pre>
acm_output_html
acm_output_html h4>
The HTML outputted by the do_action( 'acm_tag', 'ad_tag_id' );
call in your theme.
在主题中调用 do_action('acm_tag','ad_tag_id'); code>输出的HTML。Support multiple ad formats ( e.g. Javascript ad tags, or simple HTML tags ) by adjusting the HTML rendered for a given ad tag.
通过调整为给定广告代码呈现的HTML,支持多种广告格式(例如Javascript广告代码或简单的HTML代码)。 p>
The %url%
token used in this HTML will be filled in with the URL defined with acm_default_url
.
此HTML中使用的%url% code>令牌将使用 acm_default_url code>定义的URL进行填充。 p>Arguments:
参数:
* string $output_html The original output HTML
*字符串$ output_html原始输出HTML
* string $tag_id Ad tag currently being accessed
*字符串$ tag_id当前正在访问的广告代码 p>
Example usage:
用法示例: p>
add_filter( 'acm_output_html', 'my_acm_output_html', 10, 2 ); add_filter('acm_output_html','my_acm_output_html',10,2); function my_acm_output_html( $output_html, $tag_id ) {
函数my_acm_output_html($ output_html,$ tag_id){
switch ( $tag_id ) {
开关($ tag_id){
case 'my_leaderboard':
案例“ my_leaderboard”:
$output_html = '';
$ output_html =' ';
break;
打破;
case 'rich_media_leaderboard':
案例“ rich_media_leaderboard”:
$output_html = '';
$ output_html ='