\s*/i', '', $svg); $svg = preg_replace('/^]*>\s*/i', '', $svg); // 移除 上的固定宽高,让 CSS 控制尺寸 $svg = preg_replace('/\swidth="[^"]*"/', '', $svg); $svg = preg_replace('/\sheight="[^"]*"/', '', $svg); // 移除 iconfont 冗余属性 $svg = preg_replace('/\sclass="[^"]*"/', '', $svg); $svg = preg_replace('/\st="[^"]*"/', '', $svg); $svg = preg_replace('/\sp-id="[^"]*"/', '', $svg); $svg = preg_replace('/\sxmlns:xlink="[^"]*"/', '', $svg); // 移除路径上的 opacity 属性 $svg = preg_replace('/(<(?:path|circle|rect|polygon|line|polyline|ellipse)[^>]*)\sopacity="[^"]*"/', '$1', $svg); $cache[$name] = $svg; return $svg; } return ''; } endif; // ============================================================ // 图标 key → 显示名称 // ============================================================ if (!function_exists('aksrt_icon_key_to_name')) : function aksrt_icon_key_to_name($key) { $map = array( 'github' => 'GitHub', 'google' => 'Google', 'x' => 'X', 'email' => '邮箱', 'wechat' => '微信', 'qq' => 'QQ', 'weibo' => '微博', 'telegram' => 'Telegram', 'discord' => 'Discord', 'bilibili' => 'Bilibili', 'linkedin' => 'LinkedIn', 'facebook' => 'Facebook', 'youtube' => 'YouTube', 'instagram' => 'Instagram', 'web' => '网站', ); return isset($map[$key]) ? $map[$key] : ucwords(str_replace('-', ' ', $key)); } endif; // ============================================================ // 联系方式图标选项(仅保留选定的 15 个) // ============================================================ if (!function_exists('aksrt_contact_icon_options')) : function aksrt_contact_icon_options($selected = '') { $icons = array( 'github' => 'GitHub', 'google' => 'Google', 'x' => 'X', 'email' => '邮箱', 'wechat' => '微信', 'qq' => 'QQ', 'weibo' => '微博', 'telegram' => 'Telegram', 'discord' => 'Discord', 'bilibili' => 'Bilibili', 'linkedin' => 'LinkedIn', 'facebook' => 'Facebook', 'youtube' => 'YouTube', 'instagram' => 'Instagram', 'web' => '网站', ); $html = ''; foreach ($icons as $key => $label) { $sel = $key === $selected ? ' selected' : ''; $html .= ''; } return $html; } endif;