/**
* Plugin Name: WP Yahoo RSS (With SEO Delay & Security Hardening)
* Plugin URI: https://gen.caca01.com/
* Description: Wordpress Yahoo RSS feed tweaked for only tyenews.com (Includes SEO Time Delay, Path locking, and Performance fix)
* Version: 1.0.9
* Author: Carter Wu (Final Patch: Route locking + Query Scoping + UTC Time) + Safe Cache Patch
* Author URI: https://gen.caca01.com/
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: wp-yahoo-rss
*/
if (!defined('ABSPATH')) exit;
const YH_DELAY_MINUTES = 120;
const YH_QUERY_VAR = 'yh_feed_stats';
function yh_register_rewrite_rules() {
add_rewrite_rule('^yahoo-rss(?:/([^/]+))?/?$', 'index.php?' . YH_QUERY_VAR . '=true&type=$matches[1]', 'top');
}
add_filter('query_vars', 'yh_feed_query_vars');
function yh_feed_query_vars($query_vars) {
$query_vars[] = YH_QUERY_VAR;
$query_vars[] = 'type';
return $query_vars;
}
register_activation_hook(__FILE__, 'yh_feed_activate');
function yh_feed_activate() {
yh_register_rewrite_rules();
flush_rewrite_rules(false);
}
register_deactivation_hook(__FILE__, 'yh_feed_deactivate');
function yh_feed_deactivate() {
flush_rewrite_rules(false);
}
add_action('init', 'yh_feed_init');
function yh_feed_init() {
yh_register_rewrite_rules();
}
add_action('parse_request', 'yh_feed_parse_request');
function yh_feed_parse_request(&$wp) {
if (!array_key_exists(YH_QUERY_VAR, $wp->query_vars)) {
return;
}
$is_yahoo_path = false;
if (!empty($wp->request) && preg_match('#^yahoo-rss(?:/|$)#', $wp->request)) {
$is_yahoo_path = true;
}
if ($is_yahoo_path) {
if (!defined('IS_YAHOO_FEED')) {
define('IS_YAHOO_FEED', true);
}
$linkify_path = dirname(__FILE__) . '/data/linkify.php';
if (file_exists($linkify_path)) {
require_once $linkify_path;
}
}
}
add_action('template_redirect', 'yh_feed_render_output');
function yh_feed_render_output() {
if (!defined('IS_YAHOO_FEED') || IS_YAHOO_FEED !== true) {
return;
}
if (!defined('DONOTCACHEPAGE')) define('DONOTCACHEPAGE', true);
if (!defined('DONOTCACHEOBJECT')) define('DONOTCACHEOBJECT', true);
if (!defined('DONOTCACHEDB')) define('DONOTCACHEDB', true);
// ✅ 改這裡:用 query var 取 type(rewrite 進來就是 query var)
$type = get_query_var('type');
$type = is_string($type) ? sanitize_key($type) : '';
$cache_key = 'yh_yahoo_feed_xml_' . md5($type);
$force = (isset($_GET['nocache']) && $_GET['nocache'] !== '');
if (!$force) {
$cached = get_transient($cache_key);
if (is_string($cached) && $cached !== '') {
header('Content-Type: text/xml; charset=utf-8');
echo $cached;
exit();
}
}
$list_path = dirname(__FILE__) . '/data/list.php';
if (!file_exists($list_path)) {
status_header(404);
header('Content-Type: text/plain; charset=UTF-8');
echo 'Error: RSS template file not found.';
exit();
}
ob_start();
try {
include $list_path;
$xml = ob_get_clean();
} catch (Throwable $e) {
if (ob_get_level()) ob_end_clean();
status_header(500);
header('Content-Type: text/plain; charset=UTF-8');
echo 'Feed error: ' . $e->getMessage();
exit();
}
if (is_string($xml) && $xml !== '') {
set_transient($cache_key, $xml, 60);
}
header('Content-Type: text/xml; charset=utf-8');
echo $xml;
exit();
}
function yh_filter_cats($categories) {
if (empty($categories) || !is_array($categories)) return '';
foreach ($categories as $category) {
if (!is_object($category)) continue;
$name = isset($category->name) ? trim((string)$category->name) : '';
$slug = isset($category->slug) ? strtolower(trim((string)$category->slug)) : '';
if (
$name === 'YAHOO' ||
$name === '不送YAHOO' ||
$slug === 'nosend-yahoo' ||
$slug === '不上yahoo' ||
strpos($slug, 'yahoo') !== false
) {
return '';
}
}
return isset($categories[0]->name) ? esc_html($categories[0]->name) : '';
}
function yh_cat_yahoo($category) {
return $category;
}
add_action('pre_get_posts', 'yh_exclude_nosend_yahoo_from_yahoo_rss');
function yh_exclude_nosend_yahoo_from_yahoo_rss($query) {
if (is_admin() || !defined('IS_YAHOO_FEED') || IS_YAHOO_FEED !== true) {
return;
}
$pt = $query->get('post_type');
if (!empty($pt) && $pt !== 'post') {
return;
}
$query->set('post_type', 'post');
static $exclude_term_ids = null;
if ($exclude_term_ids === null) {
$exclude_term_ids = array();
$term_slugs = array('nosend-yahoo', '不上yahoo');
foreach ($term_slugs as $slug) {
$term = get_category_by_slug($slug);
if ($term && !is_wp_error($term)) {
$exclude_term_ids[] = (int) $term->term_id;
}
}
}
if (!empty($exclude_term_ids)) {
$tax_query = (array) $query->get('tax_query');
$tax_query[] = array(
'taxonomy' => 'category',
'field' => 'term_id',
'terms' => $exclude_term_ids,
'operator' => 'NOT IN',
);
$query->set('tax_query', $tax_query);
}
$delay_minutes = (int) YH_DELAY_MINUTES;
if ($delay_minutes > 0) {
$cutoff_ts = (int) current_time('timestamp', true) - ($delay_minutes * 60);
$cutoff_time = gmdate('Y-m-d H:i:s', $cutoff_ts);
$date_query = (array) $query->get('date_query');
$date_query[] = array(
'column' => 'post_date_gmt',
'before' => $cutoff_time,
);
$query->set('date_query', $date_query);
}
$query->set('ignore_sticky_posts', true);
$query->set('no_found_rows', true);
$query->set('cache_results', false);
$query->set('update_post_meta_cache', false);
$query->set('update_post_term_cache', true);
}
秋冬腰痠更容易痠痛?醫曝「天氣與疼痛」真正關係

【健康醫療網/記者黃奕寧報導】每到秋冬,診間常見腰痠背痛患者明顯增加。有人舊疾復發,也有人突然感到僵硬不適;甚至平時沒有腰痛的人,也因氣溫驟降開始喊痛。國泰綜合醫院復健科劉怡均醫師指出,低溫確實會讓肌肉與筋膜收縮、局部血流變少,引發僵硬與痠痛。不過,大型研究顯示,急性下背痛與氣溫、濕度、氣壓並無明確直接關聯。
慢性疼痛族群更敏感 氣象變化放大症狀
劉怡均醫師表示,新發作腰痛多與天氣無關,但慢性肌肉骨骼疼痛患者對氣候變化較敏感,氣壓或濕度波動容易放大原有症狀。天氣變化也會影響主觀痛感,尤其氣壓劇烈起伏時更為明顯。研究亦顯示,低溫可能改變神經傳導,使部分人對疼痛更敏銳。因此天氣不是疼痛的根本原因,但確實可能使既有問題惡化。
秋冬保養原則 保暖規律動最重要
秋冬為腰痠背痛高峰,劉怡均醫師建議,適度保暖能減少肌肉僵硬,必要時短時間熱敷有助放鬆。規律運動同樣關鍵,即使天冷也應維持活動量,如快走、有氧、核心訓練或伸展,可降低慢性腰痛與復發風險。日常姿勢需注意,避免久坐久躺、定時起身活動,搬重物時保持正確姿勢;寒風中工作者更應加強保暖。情緒與睡眠也會影響疼痛感受,維持心情穩定與良好睡眠品質都有助緩解不適。
何時該就醫?症狀惡化別再撐
多數秋冬腰痛屬輕度不適,按保暖與活動原則通常能改善。但若疼痛持續惡化超過兩週,或合併下肢麻木、無力、步態不穩、大小便控制異常,須立即就醫。中老年人若突然劇烈腰痛,也需排除骨折或神經壓迫。舊疾若頻繁復發、影響生活,應由復健科醫師進一步評估。必要時會安排X光、核磁共振或電生理檢查,並提供復健、藥物或超音波導引注射等治療。
從生活著手 秋冬也能自在不痠痛
秋冬腰痛不必然全由天氣造成,但低溫確實讓身體更容易不適。從保暖、運動、姿勢與睡眠等細節著手,可大幅減少疼痛。若症狀持續或惡化,切勿忍耐,及早接受專業協助,才能在寒冬維持良好活動力與生活品質。
【延伸閱讀】
腰痠背痛是警訊! 手術定位+神經監測順利為55歲女移除脊髓內腫瘤
腰痠背痛是警訊!三個影響脊椎狀況 別讓小痛變大病
資料來源:健康醫療網 https://www.healthnews.com.tw/readnews.php?id=66951
免責聲明:本文為外稿合作單位授權刊登,如對內容有任何疑問,請向原作單位確認。