
/* =========================
 *  前台輸出（TITLE 已修正）
 * ========================= */

add_filter('the_content', function ($content) {
    if (!is_single()) return $content;

    global $wpdb;
    $table = $wpdb->prefix . 'lscf_channels';

    $post_id = get_the_ID();
    $post_title = get_the_title($post_id);

    $channels = $wpdb->get_results("SELECT * FROM $table ORDER BY sort_order ASC,id ASC");
    if (!$channels) return $content;

    $html = '<div class="lscf-wrap" style="margin-top:20px;"><div style="display:flex;gap:8px;">';

    foreach ($channels as $c) {

        $final_url = $c->url;

        // ✅ [TITLE] 正確帶入文章標題
        if ($c->is_search) {
            $final_url = str_replace(
                '[TITLE]',
                rawurlencode(wp_specialchars_decode($post_title)),
                $final_url
            );
        }

        $is_selected = true;

        $html .= '<a href="' . esc_url($final_url) . '" target="_blank">'
            . esc_html($c->name) .
            '</a> ';
    }

    $html .= '</div></div>';

    return $content . $html;
});<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://www.8news.net/wp-content/plugins/xml-sitemap-feed/assets/sitemap.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://www.8news.net/wp-sitemap-posts-post-1.xml</loc><lastmod>2026-04-15T00:19:24+08:00</lastmod></sitemap><sitemap><loc>https://www.8news.net/wp-sitemap-taxonomies-category-1.xml</loc><lastmod>2026-04-14T22:18:43+08:00</lastmod></sitemap><sitemap><loc>https://www.8news.net/wp-sitemap-taxonomies-post_tag-1.xml</loc><lastmod>2026-04-14T22:18:43+08:00</lastmod></sitemap><sitemap><loc>https://www.8news.net/wp-sitemap-taxonomies-gallery-1.xml</loc><lastmod>2025-10-06T08:24:02+08:00</lastmod></sitemap><sitemap><loc>https://www.8news.net/wp-sitemap-taxonomies-videos-1.xml</loc><lastmod>2025-09-08T19:14:07+08:00</lastmod></sitemap><sitemap><loc>https://www.8news.net/wp-sitemap-taxonomies-favorites-1.xml</loc><lastmod>2025-12-08T03:22:12+08:00</lastmod></sitemap><sitemap><loc>https://www.8news.net/wp-sitemap-taxonomies-special-1.xml</loc><lastmod>2026-04-14T22:18:43+08:00</lastmod></sitemap><sitemap><loc>https://www.8news.net/wp-sitemap-users-1.xml</loc><lastmod>2026-04-14T22:18:43+08:00</lastmod></sitemap><sitemap><loc>https://www.8news.net/sitemap-news.xml</loc><lastmod>2026-04-14T22:18:43+08:00</lastmod></sitemap></sitemapindex>
