diff --git a/assets/img/ad.png b/assets/img/ad.png deleted file mode 100644 index 0a967ed..0000000 Binary files a/assets/img/ad.png and /dev/null differ 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 '
'; + } } } ?>