shortlist-digital / agreable-advert-plugin
适用于Croissant兼容网站的A tres agreable Adverts插件
3.0.3
2017-01-16 13:54 UTC
Requires
- getherbert/framework: ~0.9
- symfony/yaml: ~2.5
- dev-master
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.7.1
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.1
- 2.3.0
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.0
- 0.16.1
- 0.16.0
- 0.15.0
- 0.14.0
- 0.13.0
- 0.12.0
- 0.11.0
- 0.10.0
- 0.9.0
- 0.8.0
- 0.7.0
- 0.6.0
- 0.5.0
- 0.4.1
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.1
- 0.2.0
- 0.1.1
- dev-develop
- dev-admin-only
- dev-dfp-premium-refactor
- dev-configurable-section-tags
- dev-adblocker-fix
- dev-view-individual-advert
- dev-basic-publishing-refactor
This package is not auto-updated.
Last update: 2024-09-14 18:26:15 UTC
README
使用Herbert插件框架构建的WordPress插件,用于Croissant堆栈。
在Twig中使用
获取广告HTML
<!-- Twig function -->
{{ get_advert_html(post, 'horizontal', [{'pos': 'top'}]) }}
<!-- Outputs -->
<div data-module='AdvertSlot' data-advert-id='a876sd7f65sd76f'>
<script type='application/json'>
{ ...advert object }
</script>
</div>
获取广告数据
<!-- Twig function -->
{{ get_advert_data(post, 'horizontal', [{'pos': 'top'}]) }}
<!-- Outputs -->
{
'type': 'horizontal',
'key-values': [{'pos': 'top'}],
'devices': {
'desktop': {
'creative-sizes': [[970, 250], [728, 90]]
},
'tablet': {
'creative-sizes': [[728, 90]]
},
'mobile': {
'creative-sizes': [[320, 50]]
}
}
}
在PHP中使用
$advert_data = AgreableAdvertPlugin\Services\AdvertSlotGenerator::get_advert_data($post, 'horizontal', ['pos' => 'top']);
var_dump($advert_data);
// Outputs
{
'type': 'horizontal',
'key-values': [{'pos': 'top'}],
'devices': {
'desktop': {
'creative-sizes': [[970, 250], [728, 90]]
},
'tablet': {
'creative-sizes': [[728, 90]]
},
'mobile': {
'creative-sizes': [[320, 50]]
}
}
}
API路由
获取单个广告,以HTML形式呈现,包括容器CSS和JS以加载(用于即时文章)
/advert/{post_id}/{post_type}/{key_values}
/advert/2074/horizontal/pos=top,another_key=value
广告类型
水平
- 横幅 970x250
- 横幅 728x90
- 移动横幅
{
'type': 'horizontal',
'key-values': [{'pos': 'top|2'}],
'devices': {
'desktop': {
'creative-sizes': [[970, 250], [728, 90]]
},
'tablet': {
'creative-sizes': [[728, 90]]
},
'mobile': {
'creative-sizes': [[320, 50]]
}
}
}
垂直
- HPU 300x600
- MPU 300x250
{
'type': 'horizontal',
'key-values': [{'pos': 'top|2'}],
'devices': {
'desktop': {
'creative-sizes': [[300, 600], [300, 250]]
},
'tablet': {
'creative-sizes': [[300, 600], [300, 250]]
},
'mobile': {
'creative-sizes': [[300, 250]]
}
}
}
文章内
{
'type': 'in-article (tbc)',
'key-values': [{'pos': 'top|2'}],
'devices': {
'desktop': {
'creative-sizes': [[300, 600], [300, 250]]
},
'tablet': {
'creative-sizes': [[300, 600], [300, 250]]
},
'mobile': {
'creative-sizes': [[300, 250]]
}
}
}
皮肤
{
'type': 'skin',
'key-values': [{'pos': 'skin', 'pos': 'l|r'}],
'devices': {
'desktop': {
'creative-sizes': [[300, 900]]
}
}
}