mirror of https://github.com/vtrois/kratos
feat: add more ad position (#394)
parent
fd21cb73c4
commit
56a16859d6
Binary file not shown.
Before Width: | Height: | Size: 603 B |
|
@ -1006,75 +1006,81 @@ CSF::createSection($prefix, array(
|
|||
'icon' => 'fas fa-arrow-right',
|
||||
'fields' => array(
|
||||
array(
|
||||
'id' => 's_singletop_fieldset',
|
||||
'type' => 'fieldset',
|
||||
'id' => 'single_ad_top_group',
|
||||
'type' => 'group',
|
||||
'title' => '文章顶部广告',
|
||||
'subtitle' => '点击添加广告,最多添加 3 个顶部广告',
|
||||
'min' => 1,
|
||||
'max' => 3,
|
||||
'fields' => array(
|
||||
array(
|
||||
'type' => 'subheading',
|
||||
'content' => __('文章顶部广告', 'kratos'),
|
||||
'id' => 'ad_id',
|
||||
'type' => 'text',
|
||||
'title' => __('唯一标识', 'kratos'),
|
||||
'subtitle' => __('仅用于识别广告内容,可以作为备注使用', 'kratos'),
|
||||
),
|
||||
array(
|
||||
'id' => 's_singletop',
|
||||
'type' => 'switcher',
|
||||
'title' => __('功能开关', 'kratos'),
|
||||
'subtitle' => __('开启/关闭文章顶部广告', 'kratos'),
|
||||
'text_on' => __('开启', 'kratos'),
|
||||
'text_off' => __('关闭', 'kratos'),
|
||||
),
|
||||
array(
|
||||
'id' => 's_singletop_img',
|
||||
'id' => 'ad_img',
|
||||
'type' => 'upload',
|
||||
'title' => __('广告图片', 'kratos'),
|
||||
'title' => __('轮播图片', 'kratos'),
|
||||
'subtitle' => __('可以直接填写图片链接,也可以上传图片', 'kratos'),
|
||||
'library' => 'image',
|
||||
'preview' => true,
|
||||
'subtitle' => __('仅当开启此功能时生效', 'kratos'),
|
||||
),
|
||||
array(
|
||||
'id' => 's_singletop_url',
|
||||
'id' => 'ad_url',
|
||||
'type' => 'text',
|
||||
'title' => __('广告链接', 'kratos'),
|
||||
'subtitle' => __('如果不填写,将只显示图片', 'kratos'),
|
||||
'title' => __('网址链接', 'kratos'),
|
||||
'subtitle' => __('需要填写完整的链接地址,包含协议头', 'kratos'),
|
||||
),
|
||||
array(
|
||||
'id' => 'ad_switcher',
|
||||
'type' => 'switcher',
|
||||
'title' => __('功能开关', 'kratos'),
|
||||
'subtitle' => __('开启/关闭此条广告', 'kratos'),
|
||||
'text_on' => __('开启', 'kratos'),
|
||||
'text_off' => __('关闭', 'kratos'),
|
||||
'default' => true
|
||||
),
|
||||
),
|
||||
'default' => array(
|
||||
's_singletop' => false,
|
||||
's_singletop_img' => get_template_directory_uri() . '/assets/img/ad.png',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'id' => 's_singledown_fieldset',
|
||||
'type' => 'fieldset',
|
||||
'id' => 'single_ad_bottom_group',
|
||||
'type' => 'group',
|
||||
'title' => '文章底部广告',
|
||||
'subtitle' => '点击添加广告,最多添加 3 个顶部广告',
|
||||
'min' => 1,
|
||||
'max' => 3,
|
||||
'fields' => array(
|
||||
array(
|
||||
'type' => 'subheading',
|
||||
'content' => __('文章底部广告', 'kratos'),
|
||||
'id' => 'ad_id',
|
||||
'type' => 'text',
|
||||
'title' => __('唯一标识', 'kratos'),
|
||||
'subtitle' => __('仅用于识别广告内容,可以作为备注使用', 'kratos'),
|
||||
),
|
||||
array(
|
||||
'id' => 's_singledown',
|
||||
'type' => 'switcher',
|
||||
'title' => __('功能开关', 'kratos'),
|
||||
'subtitle' => __('开启/关闭文章底部广告', 'kratos'),
|
||||
'text_on' => __('开启', 'kratos'),
|
||||
'text_off' => __('关闭', 'kratos'),
|
||||
),
|
||||
array(
|
||||
'id' => 's_singledown_img',
|
||||
'id' => 'ad_img',
|
||||
'type' => 'upload',
|
||||
'title' => __('广告图片', 'kratos'),
|
||||
'title' => __('轮播图片', 'kratos'),
|
||||
'subtitle' => __('可以直接填写图片链接,也可以上传图片', 'kratos'),
|
||||
'library' => 'image',
|
||||
'preview' => true,
|
||||
'subtitle' => __('仅当开启此功能时生效', 'kratos'),
|
||||
),
|
||||
array(
|
||||
'id' => 's_singledown_url',
|
||||
'id' => 'ad_url',
|
||||
'type' => 'text',
|
||||
'title' => __('广告链接', 'kratos'),
|
||||
'subtitle' => __('如果不填写,将只显示图片', 'kratos'),
|
||||
'title' => __('网址链接', 'kratos'),
|
||||
'subtitle' => __('需要填写完整的链接地址,包含协议头', 'kratos'),
|
||||
),
|
||||
array(
|
||||
'id' => 'ad_switcher',
|
||||
'type' => 'switcher',
|
||||
'title' => __('功能开关', 'kratos'),
|
||||
'subtitle' => __('开启/关闭此条广告', 'kratos'),
|
||||
'text_on' => __('开启', 'kratos'),
|
||||
'text_off' => __('关闭', 'kratos'),
|
||||
'default' => true
|
||||
),
|
||||
),
|
||||
'default' => array(
|
||||
's_singledown' => false,
|
||||
's_singledown_img' => get_template_directory_uri() . '/assets/img/ad.png',
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
24
single.php
24
single.php
|
@ -74,13 +74,11 @@ $select_col = $col_array[kratos_option('g_article_widgets', 'two_side')];
|
|||
</div>
|
||||
<div class="content" id="lightgallery">
|
||||
<?php
|
||||
if (kratos_option('s_singletop', false)) {
|
||||
if (kratos_option('s_singletop_url')) {
|
||||
echo '<a href="' . kratos_option('s_singletop_url') . '" target="_blank" rel="noreferrer">';
|
||||
}
|
||||
echo '<img src="' . kratos_option('s_singletop_img') . '">';
|
||||
if (kratos_option('s_singletop_url')) {
|
||||
echo '</a>';
|
||||
if (!empty(kratos_option('single_ad_top_group'))) {
|
||||
foreach (kratos_option('single_ad_top_group') as $group_item) {
|
||||
if ($group_item['ad_switcher']) {
|
||||
echo '<div style="margin-bottom:5px"><a href="' . $group_item['ad_url'] . '" target="_blank" rel="noreferrer"><img src="' . $group_item['ad_img'] . '"></a></div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
the_content();
|
||||
|
@ -111,13 +109,11 @@ $select_col = $col_array[kratos_option('g_article_widgets', 'two_side')];
|
|||
'nextpagelink' => __('<span>下一页</span>', 'kratos')
|
||||
)
|
||||
);
|
||||
if (kratos_option('s_singledown', false)) {
|
||||
if (kratos_option('s_singledown_url')) {
|
||||
echo '<a href="' . kratos_option('s_singledown_url') . '" target="_blank" rel="noreferrer">';
|
||||
}
|
||||
echo '<img src="' . kratos_option('s_singledown_img') . '">';
|
||||
if (kratos_option('s_singledown_url')) {
|
||||
echo '</a>';
|
||||
if (!empty(kratos_option('single_ad_bottom_group'))) {
|
||||
foreach (kratos_option('single_ad_bottom_group') as $group_item) {
|
||||
if ($group_item['ad_switcher']) {
|
||||
echo '<div style="margin-bottom:5px"><a href="' . $group_item['ad_url'] . '" target="_blank" rel="noreferrer"><img src="' . $group_item['ad_img'] . '"></a></div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue