defined('ABSPATH') || exit; if (!class_exists('Zib_CFSwidget')) return; // ===================== 工具函数 ===================== if (!function_exists('ccie_widget_def_icon')) { function ccie_widget_def_icon($type = 'image') { $icons = [ 'image' => 'fa fa-picture-o', 'tool' => 'fa fa-wrench', 'sort' => 'fa fa-sort-amount-desc', ]; return isset($icons[$type]) ? $icons[$type] : 'fa fa-picture-o'; } } if (!function_exists('ccie_get_img_url')) { function ccie_get_img_url($val) { if (is_array($val) && !empty($val['id'])) { return wp_get_attachment_url((int)$val['id']); } return is_string($val) ? esc_url_raw(trim($val)) : ''; } } // ===================== 注册CFS模块 ===================== Zib_CFSwidget::create('ccie_6box_compound_widget', [ 'title' => 'CCIE六合一侧边复合模块', 'zib_title' => false, 'zib_affix' => true, 'zib_show' => true, 'description' => '6合一:入场动画、左侧轮播、工具入口、排行切换、网站统计、文章列表', 'fields' => [ // 1.入场动画 ['type' => 'heading', 'content' => '1.模块入场动画'], [ 'id' => 'animate', 'type' => 'fieldset', 'title' => '动画设置', 'fields' => [ [ 'id' => 'anim_type', 'type' => 'button_set', 'title' => '动画类型', 'default' => 'top-in', 'options' => [ 'none' => '无动画', 'fade' => '淡入', 'bottom-in' => '从下往上滑出', 'top-in' => '从上往下滑出', 'left-in' => '从左往右滑出', 'right-in' => '从右往左滑出', 'scale-in' => '由小变大', 'scale-out' => '由大变小', ] ], ['id' => 'show_ids', 'type' => 'text', 'title' => '仅显示页面ID(逗号分隔)'], ['id' => 'hide_ids', 'type' => 'text', 'title' => '隐藏页面ID(逗号分隔)'], ] ], // 2.左侧轮播图 ['type' => 'heading', 'content' => '2.左侧轮播图'], [ 'id' => 'slider_base', 'type' => 'fieldset', 'title' => '轮播基础', 'fields' => [ ['id' => 'height', 'type' => 'number', 'title' => '轮播高度px', 'default' => 190, 'suffix' => 'px'], ['id' => 'auto', 'type' => 'switch', 'title' => '自动轮播', 'default' => true], ['id' => 'delay', 'type' => 'number', 'title' => '轮播间隔ms', 'default' => 5000, 'suffix' => 'ms'], ] ], [ 'id' => 'slider_list', 'type' => 'group', 'title' => '轮播图片列表', 'button_title' => '添加图片', 'max' => 12, 'fields' => [ ['id' => 'img', 'type' => 'upload', 'title' => '图片', 'library' => 'image', 'preview' => true], ['id' => 'link', 'type' => 'text', 'title' => '跳转链接', 'default' => '#'], ] ], // 3.左侧工具入口 ['type' => 'heading', 'content' => '3.左侧工具入口'], [ 'id' => 'tool_base', 'type' => 'fieldset', 'title' => '工具基础', 'fields' => [ ['id' => 'radius', 'type' => 'number', 'title' => '图标圆角px', 'default' => 5, 'suffix' => 'px'], ] ], [ 'id' => 'tool_list', 'type' => 'group', 'title' => '工具列表', 'button_title' => '新增工具', 'max' => 20, 'fields' => [ ['id' => 'icon', 'type' => 'icon', 'title' => '图标', 'default' => ccie_widget_def_icon('tool')], ['id' => 'title', 'type' => 'text', 'title' => '工具标题', 'default' => '看小姐姐'], ['id' => 'link', 'type' => 'text', 'title' => '跳转链接', 'default' => '#'], ] ], // 4.排行切换 ['type' => 'heading', 'content' => '4.左侧排行切换'], [ 'id' => 'rank_tabs', 'type' => 'group', 'title' => '排行标签', 'button_title' => '新增标签', 'max' => 8, 'fields' => [ ['id' => 'tab_name', 'type' => 'text', 'title' => '标签名称', 'default' => '未分类'], ['id' => 'cat_slug', 'type' => 'text', 'title' => '分类别名(留空全部分类)'], [ 'id' => 'order_type', 'type' => 'button_set', 'title' => '排序方式', 'default' => 'date', 'options' => [ 'date' => '发布时间', 'view' => '浏览量', 'comment' => '评论数', 'collect' => '收藏', 'like' => '点赞', 'rand' => '随机', ] ], ['id' => 'limit_num', 'type' => 'number', 'title' => '显示条数', 'default' => 10], ] ], // 5.右侧统计栏 ['type' => 'heading', 'content' => '5.右侧网站统计'], [ 'id' => 'stat_set', 'type' => 'fieldset', 'title' => '统计设置', 'fields' => [ ['id' => 'show_stat', 'type' => 'switch', 'title' => '显示统计模块', 'default' => true], ['id' => 'num_anim', 'type' => 'switch', 'title' => '数字滚动动画', 'default' => true], ['id' => 'anim_pct', 'type' => 'number', 'title' => '动画起始百分比', 'default' => 68, 'suffix' => '%'], ['id' => 'anim_ms', 'type' => 'number', 'title' => '动画时长ms', 'default' => 2600, 'suffix' => 'ms'], ['id' => 'fix_article', 'type' => 'number', 'title' => '文章修正值', 'default' => 0], ['id' => 'fix_user', 'type' => 'number', 'title' => '用户修正值', 'default' => 0], ['id' => 'fix_comment', 'type' => 'number', 'title' => '评论修正值', 'default' => 0], ['id' => 'fix_today', 'type' => 'number', 'title' => '今日更新修正值', 'default' => 0], ] ], // 6.右侧文章列表 ['type' => 'heading', 'content' => '6.右侧文章列表'], [ 'id' => 'article_set', 'type' => 'fieldset', 'title' => '列表全局参数', 'fields' => [ ['id' => 'list_cat', 'type' => 'text', 'title' => '分类别名(留空全部)'], [ 'id' => 'list_order', 'type' => 'button_set', 'title' => '排序方式', 'default' => 'date', 'options' => [ 'date' => '发布时间', 'view' => '浏览量', 'comment' => '评论数', 'collect' => '收藏', 'like' => '点赞', 'rand' => '随机', ] ], ['id' => 'pc_num', 'type' => 'number', 'title' => 'PC每页数量', 'default' => 20], ['id' => 'mobile_num', 'type' => 'number', 'title' => '手机每页数量', 'default' => 5], ['id' => 'show_avatar', 'type' => 'switch', 'title' => '显示作者头像', 'default' => true], ['id' => 'show_cat_color', 'type' => 'switch', 'title' => '彩色分类标签', 'default' => true], ['id' => 'show_date', 'type' => 'switch', 'title' => '显示发布日期', 'default' => true], ['id' => 'date_bg', 'type' => 'switch', 'title' => '日期背景色块', 'default' => true], ['id' => 'show_new', 'type' => 'switch', 'title' => '7天新标', 'default' => true], ] ], ] ]); // ===================== 前端渲染函数 ===================== if (!function_exists('ccie_6box_compound_widget')) { function ccie_6box_compound_widget($args, $instance) { $anim_cfg = isset($instance['animate']) && is_array($instance['animate']) ? $instance['animate'] : []; $curr_id = get_the_ID(); if (!empty($anim_cfg['show_ids'])) { $show_ids = array_filter(array_map('intval', explode(',', trim($anim_cfg['show_ids'])))); if (!in_array($curr_id, $show_ids)) return ''; } if (!empty($anim_cfg['hide_ids'])) { $hide_ids = array_filter(array_map('intval', explode(',', trim($anim_cfg['hide_ids'])))); if (in_array($curr_id, $hide_ids)) return ''; } $slider_base = isset($instance['slider_base']) && is_array($instance['slider_base']) ? $instance['slider_base'] : []; $slider_list = isset($instance['slider_list']) && is_array($instance['slider_list']) ? $instance['slider_list'] : []; $tool_base = isset($instance['tool_base']) && is_array($instance['tool_base']) ? $instance['tool_base'] : []; $tool_list = isset($instance['tool_list']) && is_array($instance['tool_list']) ? $instance['tool_list'] : []; $rank_tabs = isset($instance['rank_tabs']) && is_array($instance['rank_tabs']) ? $instance['rank_tabs'] : []; $stat_set = isset($instance['stat_set']) && is_array($instance['stat_set']) ? $instance['stat_set'] : []; $article_set = isset($instance['article_set']) && is_array($instance['article_set']) ? $instance['article_set'] : []; $anim_map = [ 'none' => 'anim-none', 'fade' => 'anim-fade', 'bottom-in' => 'anim-bottom', 'top-in' => 'anim-top', 'left-in' => 'anim-left', 'right-in' => 'anim-right', 'scale-in' => 'anim-scale-in', 'scale-out' => 'anim-scale-out', ]; $wrap_class = isset($anim_map[$anim_cfg['anim_type']]) ? $anim_map[$anim_cfg['anim_type']] : 'anim-top'; $article_total = intval(wp_count_posts('post')->publish) + intval($stat_set['fix_article'] ?? 0); $user_total = count_users()['total_users'] + intval($stat_set['fix_user'] ?? 0); $comment_total = intval(wp_count_comments()->approved) + intval($stat_set['fix_comment'] ?? 0); $today_query = new WP_Query([ 'post_type' => 'post', 'post_status' => 'publish', 'date_query' => [['after' => date('Y-m-d')]], 'no_found_rows' => true, 'posts_per_page' => -1 ]); $today_total = $today_query->post_count + intval($stat_set['fix_today'] ?? 0); wp_reset_postdata(); Zib_CFSwidget::echo_before($instance, "ccie-6box-wrap mb20 {$wrap_class}", $args); ?>
右侧文章列表
W12345-项目网
W12345的头像-项目网
已加入本站1天 总消费:19.90
通知图标

欢迎访问项目网