From 56a16859d6730b7c166aa9369341af613155308d Mon Sep 17 00:00:00 2001 From: Seaton Jiang Date: Fri, 20 Aug 2021 15:48:40 +0800 Subject: [PATCH] feat: add more ad position (#394) --- assets/img/ad.png | Bin 603 -> 0 bytes inc/theme-options.php | 94 ++++++++++++++++++++++-------------------- single.php | 24 +++++------ 3 files changed, 60 insertions(+), 58 deletions(-) delete mode 100644 assets/img/ad.png diff --git a/assets/img/ad.png b/assets/img/ad.png deleted file mode 100644 index 0a967edc18863372009b791eae1261d71ed09ef2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 603 zcmV-h0;K(kP))kthVfE)@lBtTPbTxv!dLYW7#Oh z-7n~F)ZKkRccbR+M?&{sb*?HL#chp~J8&j+w?=kvTDAMWIUio>s)R4PXhL^uuWQ$bs@>(TXgm9u z*_+bcYMKfs)w}Oz2AFw`jxLDlZaptsm$yoEm!Uf0K$e*5qO&pGjgGD0(LLy@)svje zLz2D2bWeu_N8-_4Zqx`Py00b8+4t(+P~$}CUUo>})%`kI-sxU)NH7-G_gV$+soJOe zNE0#LOAQI`eY!XG$1&YY4GChO?o&-o=w4z-a4sI*TWZ1%?XHOKWrhSRKl(5JKEa;7 z;?@0}E$N=s=KBQ6kl@0j`%SX%YPr1=-3z2^^Pqb7pzBU2uhpY_vB14qt9KuzbI7K< pg6;qS0000000000006)r@&zjUwuMW&%z6L-002ovPDHLkV1f)`G0p%0 diff --git a/inc/theme-options.php b/inc/theme-options.php index d9de9d0..f4e2db6 100644 --- a/inc/theme-options.php +++ b/inc/theme-options.php @@ -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', ), ), ), diff --git a/single.php b/single.php index 1c13b92..92cf335 100644 --- a/single.php +++ b/single.php @@ -74,13 +74,11 @@ $select_col = $col_array[kratos_option('g_article_widgets', 'two_side')];
'; - } - echo ''; - if (kratos_option('s_singletop_url')) { - echo ''; + if (!empty(kratos_option('single_ad_top_group'))) { + foreach (kratos_option('single_ad_top_group') as $group_item) { + if ($group_item['ad_switcher']) { + echo '
'; + } } } the_content(); @@ -111,13 +109,11 @@ $select_col = $col_array[kratos_option('g_article_widgets', 'two_side')]; 'nextpagelink' => __('下一页', 'kratos') ) ); - if (kratos_option('s_singledown', false)) { - if (kratos_option('s_singledown_url')) { - echo ''; - } - echo ''; - if (kratos_option('s_singledown_url')) { - echo ''; + if (!empty(kratos_option('single_ad_bottom_group'))) { + foreach (kratos_option('single_ad_bottom_group') as $group_item) { + if ($group_item['ad_switcher']) { + echo '
'; + } } } ?>