defined('ABSPATH') || exit; if (!class_exists('Zib_CFSwidget')) { return; } // 默认图标工具函数 if (!function_exists('tengfei_ccie_default_icon')) { function tengfei_ccie_default_icon($type = 'image') { $icons = array( 'image' => 'fa fa-picture-o', 'tool' => 'fa fa-wrench', 'sort' => 'fa fa-sort-amount-desc', 'chart' => 'fa fa-bar-chart', 'list' => 'fa fa-list-alt', 'animate' => 'fa fa-film', ); return isset($icons[$type]) ? $icons[$type] : $icons['image']; } } // 默认6大模块配置数据 if (!function_exists('tengfei_ccie_default_data')) { function tengfei_ccie_default_data() { return array( // 1.左侧轮播图 'slider' => array( 'height' => 190, 'effect' => '3d-block', 'auto' => true, 'delay' => 5000, 'imgs' => array( array('img' => '', 'link' => '#') ) ), // 2.左侧工具入口 'tools' => array( 'radius' => 5, 'list' => array( array('icon' => '', 'title' => '看小姐姐', 'link' => '#') ) ), // 3.左侧排行切换 'rank' => array( 'tabs' => array( array('name' => '未分类', 'cat' => '', 'order' => 'date', 'num' => 10) ) ), // 4.右侧统计栏 'stats' => array( 'show_top' => true, 'start_day' => '2026-03-10', 'num_anim' => true, 'start_pct' => 68, 'anim_time' => 2600, 'fix_article' => 0, 'fix_comment' => 0, 'fix_user' => 0, 'fix_today' => 0 ), // 5.右侧文章列表 'article_list' => array( 'cat' => '', 'order' => 'date', 'total' => 40, 'page_size' => 20, 'mobile_size' => 5, 'avatar' => true, 'tag_color' => true, 'show_time' => true, 'time_bg' => true, 'time_color' => '#222', 'time_radius' => 0, 'new_mark' => true, 'show_btn' => true ), // 6.入场动画设置 'animate' => array( 'type' => 'top-in', 'id_show' => '', 'id_hide' => '' ) ); } } // 图片/链接提取函数 if (!function_exists('tengfei_ccie_pick_url')) { function tengfei_ccie_pick_url($value) { if (is_array($value)) { if (!empty($value['url'])) { $value = $value['url']; } elseif (!empty($value['id'])) { $value = wp_get_attachment_url((int) $value['id']); } else { $value = ''; } } return $value !== '' ? esc_url_raw((string) $value) : ''; } } // SVG图标清洗 if (!function_exists('tengfei_ccie_svg')) { function tengfei_ccie_svg($svg, $fallback = 'image') { $svg = is_string($svg) ? trim($svg) : ''; if ($svg === '') { return tengfei_ccie_default_icon($fallback); } $allowed = array( 'svg' => array('class','viewbox','viewBox','fill','stroke','stroke-width','stroke-linecap','stroke-linejoin','xmlns','aria-hidden','role','focusable'), 'path' => array('d','fill','stroke','stroke-width','stroke-linecap','stroke-linejoin'), 'polygon' => array('points','fill','stroke','stroke-width'), 'circle' => array('cx','cy','r','fill','stroke','stroke-width'), 'rect' => array('x','y','width','height','rx','ry','fill','stroke','stroke-width'), 'line' => array('x1','y1','x2','y2','stroke','stroke-width','stroke-linecap'), 'polyline' => array('points','fill','stroke','stroke-width','stroke-linecap','stroke-linejoin'), ); $clean = wp_kses($svg, $allowed); return $clean !== '' ? $clean : tengfei_ccie_default_icon($fallback); } } // 图标渲染 if (!function_exists('tengfei_ccie_icon_html')) { function tengfei_ccie_icon_html($icon, $fallback = 'image') { $icon = is_string($icon) ? trim($icon) : ''; if ($icon === '') { $icon = tengfei_ccie_default_icon($fallback); } if (stripos($icon, '