/**
* 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);
}
桃園紅利桃子新增7功能 慶市民卡7周年抽日本雙人機票
桃園紅利桃子新增7功能 慶市民卡7周年抽日本雙人機票
- 為擴大疫後振興、深化市民數位生活,桃園市資訊科技局今年7月15日推出的「市民卡紅利桃子」點數平台,自上路以來已破200萬人次使用。
- 今(26)日桃園市長鄭文燦宣布,紅利桃子為達到全面擴大使用、全民數位升級、全心傾聽民意,新增加「點數票券商城」、「串接智慧零售平台」、「多元。
- 資科局推出「市民卡7週年—紅利桃子放大祭」加碼振興活動。
- Q:這篇在講什麼?
- A:為擴大疫後振興、深化市民數位生活,桃園市資訊科技局今年7月15日推出的「市民卡紅利桃子」點數平台,自上路以來已破200萬人次使用。
- Q:重點是什麼?
- A:今(26)日桃園市長鄭文燦宣布,紅利桃子為達到全面擴大使用、全民數位升級、全心傾聽民意,新增加「點數票券商城」、「串接智慧零售平台」、「多元。
為擴大疫後振興、深化市民數位生活,桃園市資訊科技局今年7月15日推出的「市民卡紅利桃子」點數平台,自上路以來已破200萬人次使用。今(26)日桃園市長鄭文燦宣布,紅利桃子為達到全面擴大使用、全民數位升級、全心傾聽民意,新增加「點數票券商城」、「串接智慧零售平台」、「多元支付」、「發票載具」、「雲端發票捐贈」、「線上投票」及「民意調查」等7項智慧便民服務,並將自10月29日起至12月18日推出「市民卡7週年—紅利桃子放大祭」加碼振興活動。
資科局推出「市民卡7週年—紅利桃子放大祭」加碼振興活動。圖:資科局提供
資科局說明,「紅利桃子」是運用點數發放模式,1點等值1元,讓全台民眾透過多元管道參與桃園市府活動並取得點數,並可持點數到當地超過1300間特約商家折抵消費,達到市政活動推廣、民眾有感、商家振興之經濟循環目標。為使民眾花點更便利,新增「紅利桃子票券商城」服務,讓點數可以透過線上方式,輕鬆兌換為電子票券,減少地區與時間的限制,並與「快一點」智慧餐飲零售平台進行功能串接,讓點數也能成為民眾點餐後的支付方式之一,讓使用範圍整合線上線下全面擴大。
同時,資科局提及,為配合中央政府數位轉型政策,鼓勵全民數位升級及店家數位轉型,民眾透過紅利桃子拿到點數,還能在點數折抵完後,直接點選平台內建的行動支付選項完成數位付款及進行統一發票電子載具歸戶,一站式的設計讓付款流程更順暢便利、數位體驗更加完整,讓民眾、店家、市府共同打造桃園數位生活。
此外,資格局表示,在推動各項施政服務與活動時,市府最看重的就是市民的聲音與建議,為促進全民市政參與,此次紅利桃子新增線上投票及民意調查功能,要讓民眾可以針對市政議題發表意見或進行活動滿意度評分,用民意打造全民共識的開放政府,協助政府調整方案、進行決策。同時增加「公益捐贈發票」功能,民眾可透過紅利桃子捐贈電子發票給在地弱勢團體,不但能拿點還能做公益。
資科局長余宛如表示,紅利桃子數位平台是全台第一且唯一的「點+金+章+券」應用的市政推廣平台,為推廣紅利桃子全新7大功能上線,結合新功能與拿好康的紅利桃子777放大祭將從10月29日盛大展開,結合「政府幫助小頭家數位轉型」、「民眾拿點小確幸」、「點數消費助振興」活動目的,推出7大活動、7大好禮,讓民眾透過捐發票、市政問答、小遊戲等方式天天拿點數,全程參與的幸運兒最高能獲5000點,進行點數消費還能再抽Gogoro電動腳踏車、日本雙人來回機票等總價值高達百萬的豪華大獎,活動詳情可至紅利桃子官網查詢。