/**
* 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);
}
AI走進校園!開南大學開辦研習營 桃園教師共探智慧教育新契機
AI走進校園!開南大學開辦研習營 桃園教師共探智慧教育新契機
- 因應新課綱推動與AI科技快速發展,開南大學資訊管理學系昨(24)日辦理「114年度智慧科技素養與程式設計創新應用競賽-桃園市AI科技競賽研習。
- 開南大學資訊管理學系昨日辦理「114年度智慧科技素養與程式設計創新應用競賽-桃園市AI科技競賽研習營」。
- 開南大學資訊管理學系主任劉鎮豪表示,AI與科技素養已是全球教育的重要核心,此次研習以競賽實作為導向,協助教師強化邏輯思維與問題解決能力,將A。
- Q:這篇在講什麼?
- A:因應新課綱推動與AI科技快速發展,開南大學資訊管理學系昨(24)日辦理「114年度智慧科技素養與程式設計創新應用競賽-桃園市AI科技競賽研習。
- Q:重點是什麼?
- A:開南大學資訊管理學系昨日辦理「114年度智慧科技素養與程式設計創新應用競賽-桃園市AI科技競賽研習營」。
因應新課綱推動與AI科技快速發展,開南大學資訊管理學系昨(24)日辦理「114年度智慧科技素養與程式設計創新應用競賽-桃園市AI科技競賽研習營」,吸引桃園市中小學教師們齊聚一堂,共同探索AI教育新契機。
開南大學資訊管理學系昨日辦理「114年度智慧科技素養與程式設計創新應用競賽-桃園市AI科技競賽研習營」。圖:開南大學提供
開南大學資訊管理學系主任劉鎮豪表示,AI與科技素養已是全球教育的重要核心,此次研習以競賽實作為導向,協助教師強化邏輯思維與問題解決能力,將AI觀念有效融入課程,是教學創新與教育升級的關鍵一步。
此次研習以競賽實作為導向,協助教師強化邏輯思維與問題解決能力。圖:開南大學提供
活動安排三場專題講座,分別聚焦在「AI時代下的教育轉型挑戰與機會、機器人底盤結構與萬向輪應用以及AI影像辨識與雲台俯仰軸程式設計」,協助教師掌握AI基礎知識與應用趨勢。實作課程則以「AI機器人夾取物資與避障任務、擊打數字牌任務」兩項競賽活動為主軸,教師親自操作RoboMaster S1機器人,進行影像識別與路徑規劃等任務,現場互動熱烈,討論精進方式。
桃園市教師會理事長陳俊裕說,此次活動不僅強化教師AI應用實務能力,也促進跨校教師專業交流,對桃園市整體AI教育能量的深化,具有重要意義。
台灣校園人工智慧教育協會主任伍貽麟亦強調,協會未來將持續與學校合作辦理更多AI教育活動,透過大學端,大手拉小手,協助第一線教師掌握數位轉型脈動,推動智慧學習環境的建構與深化。
透過此次研習,教師們不僅提升AI科技素養,更為未來智慧教學與創新課程設計注入嶄新動能,開南大學也再次展現其在AI教育領域的積極角色與研究能量。
此次研習營由教育部國民及學前教育署、桃園市教育局指導,國立台灣師範大學科技應用與人力資源發展學系主辦,台灣校園人工智慧教育協會承辦,並由開南大學資訊管理學系與桃園市教師會協辦,展現中央與地方、學界與業界共同推動智慧教育的堅定決心。