section and everything up until
* * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials * * @package WordPress * @subpackage Twenty_Seventeen * @since 1.0 * @version 1.0 */ require_once HELPER_FUNC_FILE_DIR; /** * 顯示講題檔案連結 */ function _display_talkfile_link($talkfile_link, $anchor, $confday) { $isOpenSlides = [ 1 => IS_OPEN_SLIDES_DAY1, 2 => IS_OPEN_SLIDES_DAY2, 3 => IS_OPEN_SLIDES_DAY3, 4 => IS_OPEN_SLIDES_DAY4 ]; $canShowSlides = isset($isOpenSlides[$confday]) && $isOpenSlides[$confday]; if (!$canShowSlides) { return ''; } $canViewAgenda = isset($_SESSION['can_view_agenda']) && $_SESSION['can_view_agenda']; $hasValidLink = strpos($talkfile_link, 'http') === 0; if ($canViewAgenda && $hasValidLink) { $cleanLink = str_replace(["\n", "\r", "\t"], '', $talkfile_link); return '' . ' ' . SLIDE_FILE_TEXT . ''; } return ''; } /** * 頁面類型檢查函數 */ function is_support_page($page_id) { return in_array($page_id, [SUPPORT_COM_PAGE_ID, SUPPORT_ORG_PAGE_ID]); } function is_speaker_page($page_id) { return in_array($page_id, [ KEYNOTE_SPEAKER_PAGE_ID, TOPIC_SPEAKER_PAGE_ID, VIP_PAGE_ID, SPECIAL_SPEAKER_PAGE_ID, HOST_PAGE_ID, PANEL_DISCUSSION_PAGE_ID ]); } function is_join_page($page_id) { return in_array($page_id, [VUL_PAGE_ID, SPEAKER_PAGE_ID]); } function is_signup_page($page_id) { return in_array($page_id, [SIGNUP_PAGE_ID, TRANSFER_TICKET_PAGE_ID, TRAFFIC_PAGE_ID]); } function is_sponsor_page($page_id) { return in_array($page_id, [SPONSOR_PAGE_ID, MEDIA_PARTNER_PAGE_ID]); } /** * 取得子選單配置 */ function get_sub_nav($type_or_pageid) { if (is_string($type_or_pageid)) { $type = $type_or_pageid; } elseif (is_int($type_or_pageid)) { $type = get_page_type($type_or_pageid); } $subNavConfigs = [ 'SPEAKER' => [ ['VIP', 'vip'], ['Keynote Speakers', 'keynote-speakers'], ['Topic Speakers', 'speakers'], ['Panel Discussion', 'panel-discussion'], ['Moderators', 'moderator'], ['All Sessions', 'category/all-sessions'], ], 'ABOUT' => [ ['Taiwan AI Academy (eng.)', '//en.aiacademy.tw'], ['Taiwan AI Academy (cht.)', '//aiacademy.tw'] ], 'SPONSOR' => [ ['贊助', 'sponsor'], ['媒體夥伴', 'partner'] ], 'PAST' => [ ['2024 Conf', '//conf2024.aiacademy.tw'], ['2023 Conf', '//conf2023.aiacademy.tw'], ['2022 Conf', '//conf2022.aiacademy.tw'], ['2021 Conf', '//conf2021.aiacademy.tw'], ['2020 Conf', '//conf2020.aiacademy.tw'], ['2019 Conf', '//aiacademy.kktix.cc/events/aia-alumni-2019'], ['2018 Conf', '//aiacademy.kktix.cc/events/aia-alumni-event-20181117'], ] ]; return $subNavConfigs[$type] ?? []; } /** * 根據頁面ID判斷頁面類型 */ function get_page_type($page_id) { if (is_support_page($page_id)) return 'SUPPORT'; if (is_speaker_page($page_id)) return 'SPEAKER'; if (is_join_page($page_id)) return 'JOIN'; if (is_signup_page($page_id)) return 'SIGNUP'; if (is_sponsor_page($page_id)) return 'SPONSOR'; return ''; } /** * 取得頁面標題 */ function get_pagetitle($id) { $titles = [ 'SUPPORT' => '支持', 'SPEAKER' => 'VIP / Speakers', 'JOIN' => '參與', 'SIGNUP' => '報名', 'SPONSOR' => '贊助' ]; $type = get_page_type($id); return $titles[$type] ?? the_title(); } /** * 判斷是否為外部連結 */ function _is_external_link($href) { return strpos($href, 'http') === 0; } /** * 設定 OG Meta 資料 */ function setup_og_meta() { global $post; $og_title_desc = get_post_meta(ABOUT_PAGE_ID, 'fb_og_title_desc', true); $og_title = ''; $og_desc = ''; $og_image = ''; // 解析 OG 設定 foreach (explode("\n", $og_title_desc) as $line) { if (strpos($line, '`') === false) continue; $parts = explode('`', str_replace("\r", '', $line)); if (strpos($_SERVER['REQUEST_URI'], WEB_URL . $parts[0]) === 0) { $og_title = $parts[1]; $og_desc = $parts[2]; if (isset($parts[3])) { $og_image = $parts[3]; } break; } } // 設定預設值 if (!$og_title) { $og_title = get_post_meta(ABOUT_PAGE_ID, 'fb_og_default_title', true) ?: '2017 台灣資料科學年會'; } if (!$og_desc) { $og_desc = get_post_meta(ABOUT_PAGE_ID, 'fb_og_default_desc', true) ?: '2017 台灣資料科學年會 2017/11/09 (Thu) ~ 2017/11/12 (Sun)'; } // 處理單一講者頁面 if (is_single()) { $cats = get_the_category($post->ID); $is_single_speaker = false; foreach ($cats as $c) { if ($c->category_parent == SPEAKER_CAT_ID || $c->term_id == SPEAKER_CAT_ID) { $is_single_speaker = true; break; } } if ($is_single_speaker) { $og_title = str_replace(''', "'", trim($post->post_title)); $og_desc = str_replace(["\n", ''], '', $post->post_content); } } // 設定圖片 if (!$og_image) { if (strpos($_SERVER['REQUEST_URI'], WEB_URL . 'support') !== false) { $og_image = IMG_URL . '2023-Meta-b.png?'; } else { if (isset($is_single_speaker) && $is_single_speaker) { $og_image = str_replace('.', '.', get_speaker_photo_imgsrc(get_speaker_id_by_post_name($post))); } else { $og_image = IMG_URL . '2024-Meta-b.png?1'; } } } return [ 'title' => $og_title, 'description' => $og_desc, 'image' => $og_image ]; } // 取得 OG Meta 資料 $og_meta = setup_og_meta(); ?> class="pID?> no-js">
推薦您使用 Safari (Apple內建), Edge(Windows10內建), Chrome (全設備), Edge (全設備), Firefox (全設備) 瀏覽本站。