在WordPress中創建自定義RSS Feed:新手指南

[ad_1]

RSS提要非常好 博客工具 可以幫助您增加受眾群體。 默認情況下,WordPress帶有標準的RSS feed功能,對於大多數用戶來說已經足夠了。 但是,如果您想提供特定的內容或在Feed中添加帖子縮略圖,則需要在WordPress中創建自定義RSS Feed。

幸運的是,您可以通過添加幾行代碼來相對輕鬆地自定義RSS feed。 請注意,此方法可能不適用於初學者,因為您需要訪問子主題的functions.php文件。 但是,大多數中級用戶應該能夠按照以下說明進行操作。

在本文中,我們將向您展示如何在WordPress中創建自定義RSS feed。 我們還將討論為什麼它有用,以及如何使用簡單的插件在網站上展示來自外部資源的內容。 我們走吧!

了解RSS提要以及它們如何使您的網站受益

RSS代表Really Simple Syndication。 它是一種方便的功能,使博客作者可以在其他站點上和通過供稿閱讀器共享其內容。 這使訂戶可以跟蹤新帖子,而無需手動檢查他們喜歡的每個網站。 還有其他在WordPress中使用RSS提要的方法,我們已經在中討論了 上一篇文章

訂閱RSS feed的訪問者可以使用其選擇的feed閱讀器來瀏覽內容,發表評論並在社交媒體上分享帖子。 您應該可以通過yourdomain.com/feed訪問站點的feed。 注意,這樣做只會顯示代碼。 你需要一個專門的 新聞聚合器 諸如 飼料 看到它的全部榮耀。

如果要區分內容,可以創建自定義RSS提要並以特定讀者為目標。 如果您的網站迎合了多個細分市場,這將非常有用。

您也可以使用我們的外部來源推薦帖子 Feedzy 插入。 例如,您可以 匯總內容 來自其他博客,播客甚至YouTube頻道的內容,並將其顯示在您的網站上以增加參與度。

如何在#WordPress中創建自定義#RSS提要:新手指南?

點擊鳴叫

如何在WordPress中創建自定義RSS源

不幸的是,定製RSS feed需要一些高級知識,因此,除非您至少對代碼有所了解,否則我們不建議您採用這種方法。

在繼續之前,明智的做法是 備份您的網站 因此,如果出現問題,您可以將其恢復。 當您準備好繼續時,請按照以下說明進行操作。

本教程將幫助您創建具有以下屬性的自定義RSS feed:

  • 帖子標題
  • 鏈接
  • 發布日期
  • 作者
  • 摘抄

您可以在以下兩個位置之一添加這些代碼段:

  1. 您可以使用 免費的代碼片段插件,它提供了方便的界面來管理這些類型的代碼段。 對於大多數人來說,這是最簡單的選擇。
  2. 您可以編輯子主題的functions.php文件-確保 使用兒童主題 這樣您在更新主題時就不會覆蓋所做的更改。

首先,添加 以下代碼段

add_action(’init’,’customRSS’); 函數customRSS(){add_feed(’feedname’,’customRSSFunc’); }

這將在您的站點上啟動customRSS功能。 您需要根據要調用新Feed的名稱來相應地更改「 feedname」。

接下來,您需要創建一個回調函數,可以通過添加以下代碼來完成:

函數customRSSFunc(){get_template_part(’rss’,’feedname’); }

這會將您的供稿鏈接到其自己的模板文件,我們將在稍後創建該文件。 請注意,「 get_template_part」函數具有兩個參數:URL段和提要名稱。 我們建議將子彈設置為「 rss」,以便於導航。

接下來,您需要創建供稿模板。 使用上一個代碼片段(例如rss-feedname.php)中的參數,在子主題文件夾中創建一個新文件,並將其另存為slug-name.php。

模板文件的代碼如下:

<?php / ** *模板名稱:自定義RSS模板-Feedname * / $ postCount = 5; //供稿中顯示的帖子數$ posts = query_posts('showposts =「。$ postCount); header(」 Content-Type:'.feed_content_type('rss-http')。'; charset =「。get_option (「 blog_charset'),為true); 回聲'<?xml version =「 1.0」 encoding =「'。get_option('blog_charset')。'」?'。'>‘; ?> > <?php bloginfo_rss('name'); ?>-Feed </ title> <atom:link href =「 https://themeisle.com/blog/custom-rss-feed-wordpress/<?php self_link();?>」 rel =「 self」 type = 「 application / rss + xml」 /> <link> <?php bloginfo_rss('url')?> </ link> <description> <?php bloginfo_rss('description')?> </ description> <lastBuildDate> <? php echo mysql2date('D,d MYH:i:s +0000',get_lastpostmodified('GMT'),false); ?> </ lastBuildDate> <language> <?php echo get_option('rss_language'); ?> </ language> <sy:updatePeriod> <?php echo apply_filters('rss_update_period','hourly'); ?> </ sy:updatePeriod> <sy:updateFrequency> <?php echo apply_filters('rss_update_frequency','1'); ?> </ sy:updateFrequency> <?php do_action('rss2_head'); ?> <?php while(have_posts()):the_post(); ?> <item> <title> <?php the_title_rss(); ?> </ title> <link> <?php the_permalink_rss(); ?> </ link> <pubDate> <?php echo mysql2date('D,d MYH:i:s +0000',get_post_time('Ymd H:i:s',true),false); ?> </ pubDate> <dc:creator> <?php the_author(); ?> </ dc:creator> <guid isPermaLink =「 false」> <?php the_guid(); ?> </ guid> <說明> <![CDATA[<?php the_excerpt_rss() ?>]]> </ description> <content:encoded> <![CDATA[<?php the_excerpt_rss() ?>]]> </ content:encoded> <?php rss_enclosure(); ?> <?php do_action('rss2_item'); ?> </ item> <?php結束; ?> </ channel> </ rss></p> <p>請注意,您可以通過更改postCount變數來控制供稿中顯示的帖子數。 如果您希望供稿顯示圖像,注釋等,也可以修改此模板。</p> <p>對Feed模板滿意後,將其保存並轉到信息中心中的Settings(設置)→Permalinks(永久鏈接)。 單擊保存更改。 這將刷新重寫規則,以便您的Feed可以正確顯示。</p> <p>現在,您應該可以通過yourdomain.com/feed/feedname訪問您的自定義供稿(用自定義值替換值)。</p> <p>如何在WordPress網站上顯示其他RSS源</p> <p>或者,另一個 <a href="https://themeisle.com/blog/rss-feeds-in-wordpress/" data-wpel-link="external" target="_self" rel="nofollow external noopener noreferrer">使用RSS提要的方式</a> 用於展示您網站上其他博客或平台的供稿。 在這種情況下,您可以使用 <a href="https://themeisle.com/plugins/feedzy-rss-feeds/" data-wpel-link="external" target="_self" rel="nofollow external noopener noreferrer">我們的Feedzy插件</a> 並從外部RSS提要中導入內容。</p> <p>安裝並激活Feedzy後,請轉到頁面或發布要添加一個或多個Feed的位置。 如果您使用的是「塊編輯器」,則可以添加Feedzy塊並粘貼所需的源URL: </p> <p><img fetchpriority="high" decoding="async" src="https://wpjian.com/wp-content/uploads/2021/01/Adding-feeds-with-Feedzy.png" width="1628" height="655" alt="使用Feedzy和「塊編輯器」添加外部RSS feed。" class="wp-image-38447"></p> <p>在右側邊欄的設置區域中,您可以調整要顯示的源的數量,緩存時間和排序順序。</p> <p>如果您喜歡使用經典編輯器,則可以使用Feedzy短代碼 [feedzy-rss feeds=” source_URL”] 並將其嵌入到您希望供稿顯示在您網站上的任何位置。 </p> <p>或者,您可以使用小部件,可以通過儀錶板中的外觀→小部件來激活它:</p> <p><img decoding="async" src="https://wpjian.com/wp-content/uploads/2021/01/Activating-Feedzy-widget.png" width="1616" height="738" alt="在WordPress中激活Feedzy小部件。" class="wp-image-38448"></p> <p>您還可以將RSS供稿作為帖子導入WordPress,我們將在以下文章中詳細討論 <a href="https://themeisle.com/blog/import-rss-feeds-into-wordpress-as-posts/" data-wpel-link="external" target="_self" rel="nofollow external noopener noreferrer">另一個教程</a>。</p> <p>立即在WordPress中創建自定義RSS提要</p> <p>在WordPress中創建自定義RSS feed可能很棘手。 但是,如果您對代碼感到滿意,則可以輕鬆添加不同的提要,並開始向讀者提供獨特的內容。</p> <p> <a href="https://twitter.com/share?text=How+to+set+up+custom+%23RSS+feeds+on+your+%23WordPress+site+%F0%9F%93%87&via=themeisle&related=themeisle&url=https://themeisle.com/blog/custom-rss-feed-wordpress/" target="_blank" rel="noopener nofollow external noreferrer" data-wpel-link="external">如何在#WordPress網站上設置自定義#RSS提要?</a></p> <p> <a href="https://twitter.com/share?text=How+to+set+up+custom+%23RSS+feeds+on+your+%23WordPress+site+%F0%9F%93%87&via=themeisle&related=themeisle&url=https://themeisle.com/blog/custom-rss-feed-wordpress/" target="_blank" rel="noopener nofollow external noreferrer" data-wpel-link="external">點擊鳴叫 </p> <p> </a></p> <p>在本文中,我們向您展示了如何在WordPress中創建自定義RSS feed。 您需要添加一些自定義代碼段並創建一個模板來自定義Feed的外觀,因此只有在具備必要技能的情況下,才嘗試使用此方法。 另外,要在您的網站上展示外部供稿,您可以使用 <a href="https://themeisle.com/plugins/feedzy-rss-feeds/" data-wpel-link="external" target="_self" rel="nofollow external noopener noreferrer">Feedzy</a> 沒有任何編碼知識。</p> <p>有關如何在WordPress中使用RSS提要的其他一些想法,請查看以下文章:</p> <ul> <li><a href="https://themeisle.com/blog/rss-feeds-in-wordpress/" data-wpel-link="external" target="_self" rel="nofollow external noopener noreferrer">在WordPress中使用RSS提要的七種方法</a></li> <li><a href="https://themeisle.com/blog/import-rss-feeds-into-wordpress-as-posts/" data-wpel-link="external" target="_self" rel="nofollow external noopener noreferrer">如何將RSS feed作為帖子導入WordPress</a></li> <li><a href="https://themeisle.com/blog/wordpress-news-aggregator-website/" data-wpel-link="external" target="_self" rel="nofollow external noopener noreferrer">如何創建WordPress新聞聚合網站</a></li> </ul> <p>您對自定義RSS提要有疑問嗎? 讓我們在下面的評論部分中知道!</p> <p> <script type="rocketlazyloadscript" async data-rocket-src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></p> </div> </div> </div> </div> </div> <aside id="secondary" class="cs-widget-area cs-sidebar__area"> <div class="cs-sidebar__inner"> <div class="widget_text widget custom_html-2 widget_custom_html"><div class="textwidget custom-html-widget"><a href="https://www.vultr.com/?ref=8945630-8H" data-wpel-link="external" target="_self" rel="nofollow external noopener noreferrer"><img src="https://wpjian.com/wp-content/uploads/2020/09/VULTR.jpg" width="100%" height="auto"></a></div></div><div class="widget widget_wpcc-2 widget_wpcc"> <div id="wpcc_widget_inner"> <span id="wpcc_original_link" class="wpcc_lang" ><a class="wpcc_link" href="https://wpjian.com/wordpress-seo/2021012740776.html" title="簡體中文" data-wpel-link="internal">簡體中文</a></span> <span id="wpcc_zh-tw_link" class="wpcc_current_lang" ><a class="wpcc_link" href="https://wpjian.com/zh-tw/wordpress-seo/2021012740776.html" title="繁体中文" data-wpel-link="internal">繁体中文</a></span> </div> </div><div class="widget powerkit_widget_posts-2 powerkit_widget_posts"> <div class="widget-body pk-widget-posts pk-widget-posts-template-default pk-widget-posts-template-list posts-per-page-6"> <ul> <li class="pk-post-item"> <article class="post-61438 post type-post status-publish format-standard has-post-thumbnail category-tips cs-entry cs-video-wrap" style=""> <div class="cs-entry__outer"> <div class="cs-entry__inner cs-entry__thumbnail cs-overlay-ratio cs-ratio-original"> <div class="cs-overlay-background cs-overlay-transparent"> <img width="150" height="97" src="https://wpjian.com/wp-content/uploads/2024/01/wordpress-theme-file-editor.webp.jpg" class="attachment-thumbnail size-thumbnail wp-post-image" alt="" decoding="async" loading="lazy" /> </div> <a class="cs-overlay-link" href="https://wpjian.com/zh-tw/tips/2024010561438.html" data-wpel-link="internal"></a> </div> <div class="cs-entry__inner cs-entry__content"> <h3 class="cs-entry__title"> <a href="https://wpjian.com/zh-tw/tips/2024010561438.html" data-wpel-link="internal">如何在沒有插件的情況下在 WordPress 中導入 CSV 文件</a> </h3> </div> </div> </article> </li> <li class="pk-post-item"> <article class="post-61410 post type-post status-publish format-standard has-post-thumbnail category-tips cs-entry cs-video-wrap" style=""> <div class="cs-entry__outer"> <div class="cs-entry__inner cs-entry__thumbnail cs-overlay-ratio cs-ratio-original"> <div class="cs-overlay-background cs-overlay-transparent"> <img width="150" height="67" src="https://wpjian.com/wp-content/uploads/2024/01/how-to-enable-maintenance-mode-in-wordpress.png" class="attachment-thumbnail size-thumbnail wp-post-image" alt="" decoding="async" loading="lazy" /> </div> <a class="cs-overlay-link" href="https://wpjian.com/zh-tw/tips/2024010561410.html" data-wpel-link="internal"></a> </div> <div class="cs-entry__inner cs-entry__content"> <h3 class="cs-entry__title"> <a href="https://wpjian.com/zh-tw/tips/2024010561410.html" data-wpel-link="internal">如何將 WordPress 置於維護模式(安全且簡單的方法)</a> </h3> </div> </div> </article> </li> <li class="pk-post-item"> <article class="post-61400 post type-post status-publish format-standard has-post-thumbnail category-tips cs-entry cs-video-wrap" style=""> <div class="cs-entry__outer"> <div class="cs-entry__inner cs-entry__thumbnail cs-overlay-ratio cs-ratio-original"> <div class="cs-overlay-background cs-overlay-transparent"> <img width="150" height="46" src="https://wpjian.com/wp-content/uploads/2024/01/how-to-add-images-708x218-1.jpg" class="attachment-thumbnail size-thumbnail wp-post-image" alt="" decoding="async" loading="lazy" /> </div> <a class="cs-overlay-link" href="https://wpjian.com/zh-tw/tips/2024010561400.html" data-wpel-link="internal"></a> </div> <div class="cs-entry__inner cs-entry__content"> <h3 class="cs-entry__title"> <a href="https://wpjian.com/zh-tw/tips/2024010561400.html" data-wpel-link="internal">如何向 WordPress 帖子添加多媒體</a> </h3> </div> </div> </article> </li> <li class="pk-post-item"> <article class="post-61390 post type-post status-publish format-standard category-tips cs-entry cs-video-wrap" style=""> <div class="cs-entry__outer"> <div class="cs-entry__inner cs-entry__content"> <h3 class="cs-entry__title"> <a href="https://wpjian.com/zh-tw/tips/2023092061390.html" data-wpel-link="internal">谷歌域名與WordPress集成:建立您的專業網站</a> </h3> </div> </div> </article> </li> <li class="pk-post-item"> <article class="post-61386 post type-post status-publish format-standard category-tips cs-entry cs-video-wrap" style=""> <div class="cs-entry__outer"> <div class="cs-entry__inner cs-entry__content"> <h3 class="cs-entry__title"> <a href="https://wpjian.com/zh-tw/tips/2023092061386.html" data-wpel-link="internal">了解WordPress社區:專訪揭示內部運作</a> </h3> </div> </div> </article> </li> <li class="pk-post-item"> <article class="post-61382 post type-post status-publish format-standard category-tips cs-entry cs-video-wrap" style=""> <div class="cs-entry__outer"> <div class="cs-entry__inner cs-entry__content"> <h3 class="cs-entry__title"> <a href="https://wpjian.com/zh-tw/tips/2023092061382.html" data-wpel-link="internal">Azure 提供的 WordPress 免費遊樂場</a> </h3> </div> </div> </article> </li> </ul> </div> </div><div class="widget_text widget custom_html-4 widget_custom_html"><div class="textwidget custom-html-widget"><script type="rocketlazyloadscript" async data-rocket-src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8713839794068339" crossorigin="anonymous"></script> <!-- block --> <ins class="adsbygoogle" style="display:inline-block;width:300px;height:250px" data-ad-client="ca-pub-8713839794068339" data-ad-slot="7982876503"></ins> <script type="rocketlazyloadscript"> (adsbygoogle = window.adsbygoogle || []).push({}); </script></div></div> </div> </aside> </div> <div class="cs-entry__post-related"> <h5 class="cs-section-heading cs-section-heading-common is-style-cnvs-block-section-heading-default halignleft "><span class="cs-section-subheadings">相關文章</span></h5> <div class="cs-entry__post-wrap"> <article class="cs-entry-default post-2600 post type-post status-publish format-standard has-post-thumbnail category-wordpress-seo cs-entry cs-video-wrap"> <div class="cs-entry__outer"> <div class="cs-entry__inner cs-entry__content"> <h2 class="cs-entry__title"><a href="https://wpjian.com/zh-tw/wordpress-seo/201905302600.html" data-wpel-link="internal">Google廣告將於6月刪除兩種出價策略</a></h2> <div class="cs-entry__excerpt"> [ad_1] 谷歌正計劃 去掉 6月下旬的「目標搜索頁面位置」和「目標排名分享」出價… </div> <div class="cs-entry__details "> <div class="cs-entry__details-data"> <div class="cs-entry__details-meta"> <div class="cs-entry__post-meta" ><div class="cs-meta-date">2019年5月30日</div></div> </div> </div> <div class="cs-entry__read-more"> <a href="https://wpjian.com/zh-tw/wordpress-seo/201905302600.html" data-wpel-link="internal"> 閱讀更多 </a> </div> </div> </div> </div> </article> <article class="cs-entry-default post-3563 post type-post status-publish format-standard has-post-thumbnail category-wordpress-seo cs-entry cs-video-wrap"> <div class="cs-entry__outer"> <div class="cs-entry__inner cs-entry__content"> <h2 class="cs-entry__title"><a href="https://wpjian.com/zh-tw/wordpress-seo/201906173563.html" data-wpel-link="internal">谷歌被指控從歌詞網站「天才」中搜集內容</a></h2> <div class="cs-entry__excerpt"> [ad_1] 領先的歌詞網站Genius.com指責谷歌竊取其內容並將其發布在搜索結… </div> <div class="cs-entry__details "> <div class="cs-entry__details-data"> <div class="cs-entry__details-meta"> <div class="cs-entry__post-meta" ><div class="cs-meta-date">2019年6月17日</div></div> </div> </div> <div class="cs-entry__read-more"> <a href="https://wpjian.com/zh-tw/wordpress-seo/201906173563.html" data-wpel-link="internal"> 閱讀更多 </a> </div> </div> </div> </div> </article> <article class="cs-entry-default post-8860 post type-post status-publish format-standard has-post-thumbnail category-wordpress-seo cs-entry cs-video-wrap"> <div class="cs-entry__outer"> <div class="cs-entry__inner cs-entry__content"> <h2 class="cs-entry__title"><a href="https://wpjian.com/zh-tw/wordpress-seo/201909178860.html" data-wpel-link="internal">如何使用Google&nbspSheets為多個網址自動化Pagespeed數據分析</a></h2> <div class="cs-entry__excerpt"> [ad_1] 計算單個頁面速度性能指標可以幫助您了解網站整體運行的效率。由於Goog… </div> <div class="cs-entry__details "> <div class="cs-entry__details-data"> <div class="cs-entry__details-meta"> <div class="cs-entry__post-meta" ><div class="cs-meta-date">2019年9月17日</div></div> </div> </div> <div class="cs-entry__read-more"> <a href="https://wpjian.com/zh-tw/wordpress-seo/201909178860.html" data-wpel-link="internal"> 閱讀更多 </a> </div> </div> </div> </div> </article> </div> </div> </div> </div> </main> <footer class="cs-footer cs-footer-one" data-scheme="default"> <div class="cs-container"> <div class="cs-footer__item"> <div class="cs-footer__col cs-col-left"> <div class="cs-footer__inner"> <div class="cs-logo"> <a class="cs-footer__logo cs-logo-once" href="https://wpjian.com/zh-tw/" data-wpel-link="internal"> WP建站 </a> </div> <div class="cs-footer__desc"> <p class="copyright">© 2019 - 2022 by <a href="https://wpjian.com/zh-tw/" data-wpel-link="internal">WPJIAN</a>. </p> </div> </div> </div> <div class="cs-footer__col cs-col-center"> </div> <div class="cs-footer__col cs-col-right"> <div class="cs-footer-social-links"> </div> </div> </div> </div> </footer> </div> </div> <script type="rocketlazyloadscript" id="rocket-browser-checker-js-after"> "use strict";var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var RocketBrowserCompatibilityChecker=function(){function RocketBrowserCompatibilityChecker(options){_classCallCheck(this,RocketBrowserCompatibilityChecker),this.passiveSupported=!1,this._checkPassiveOption(this),this.options=!!this.passiveSupported&&options}return _createClass(RocketBrowserCompatibilityChecker,[{key:"_checkPassiveOption",value:function(self){try{var options={get passive(){return!(self.passiveSupported=!0)}};window.addEventListener("test",null,options),window.removeEventListener("test",null,options)}catch(err){self.passiveSupported=!1}}},{key:"initRequestIdleCallback",value:function(){!1 in window&&(window.requestIdleCallback=function(cb){var start=Date.now();return setTimeout(function(){cb({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-start))}})},1)}),!1 in window&&(window.cancelIdleCallback=function(id){return clearTimeout(id)})}},{key:"isDataSaverModeOn",value:function(){return"connection"in navigator&&!0===navigator.connection.saveData}},{key:"supportsLinkPrefetch",value:function(){var elem=document.createElement("link");return elem.relList&&elem.relList.supports&&elem.relList.supports("prefetch")&&window.IntersectionObserver&&"isIntersecting"in IntersectionObserverEntry.prototype}},{key:"isSlowConnection",value:function(){return"connection"in navigator&&"effectiveType"in navigator.connection&&("2g"===navigator.connection.effectiveType||"slow-2g"===navigator.connection.effectiveType)}}]),RocketBrowserCompatibilityChecker}(); </script> <script id="rocket-preload-links-js-extra"> var RocketPreloadLinksConfig = {"excludeUris":"\/page\/|\/(?:.+\/)?feed(?:\/(?:.+\/?)?)?$|\/(?:.+\/)?embed\/|\/(index\\.php\/)?(.*)wp\\-json(\/.*|$)|\/refer\/|\/go\/|\/recommend\/|\/recommends\/","usesTrailingSlash":"","imageExt":"jpg|jpeg|gif|png|tiff|bmp|webp|avif|pdf|doc|docx|xls|xlsx|php","fileExt":"jpg|jpeg|gif|png|tiff|bmp|webp|avif|pdf|doc|docx|xls|xlsx|php|html|htm","siteUrl":"https:\/\/wpjian.com","onHoverDelay":"100","rateThrottle":"3"}; </script> <script type="rocketlazyloadscript" id="rocket-preload-links-js-after"> (function() { "use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e=function(){function i(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(e,t,n){return t&&i(e.prototype,t),n&&i(e,n),e}}();function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var t=function(){function n(e,t){i(this,n),this.browser=e,this.config=t,this.options=this.browser.options,this.prefetched=new Set,this.eventTime=null,this.threshold=1111,this.numOnHover=0}return e(n,[{key:"init",value:function(){!this.browser.supportsLinkPrefetch()||this.browser.isDataSaverModeOn()||this.browser.isSlowConnection()||(this.regex={excludeUris:RegExp(this.config.excludeUris,"i"),images:RegExp(".("+this.config.imageExt+")$","i"),fileExt:RegExp(".("+this.config.fileExt+")$","i")},this._initListeners(this))}},{key:"_initListeners",value:function(e){-1<this.config.onHoverDelay&&document.addEventListener("mouseover",e.listener.bind(e),e.listenerOptions),document.addEventListener("mousedown",e.listener.bind(e),e.listenerOptions),document.addEventListener("touchstart",e.listener.bind(e),e.listenerOptions)}},{key:"listener",value:function(e){var t=e.target.closest("a"),n=this._prepareUrl(t);if(null!==n)switch(e.type){case"mousedown":case"touchstart":this._addPrefetchLink(n);break;case"mouseover":this._earlyPrefetch(t,n,"mouseout")}}},{key:"_earlyPrefetch",value:function(t,e,n){var i=this,r=setTimeout(function(){if(r=null,0===i.numOnHover)setTimeout(function(){return i.numOnHover=0},1e3);else if(i.numOnHover>i.config.rateThrottle)return;i.numOnHover++,i._addPrefetchLink(e)},this.config.onHoverDelay);t.addEventListener(n,function e(){t.removeEventListener(n,e,{passive:!0}),null!==r&&(clearTimeout(r),r=null)},{passive:!0})}},{key:"_addPrefetchLink",value:function(i){return this.prefetched.add(i.href),new Promise(function(e,t){var n=document.createElement("link");n.rel="prefetch",n.href=i.href,n.onload=e,n.onerror=t,document.head.appendChild(n)}).catch(function(){})}},{key:"_prepareUrl",value:function(e){if(null===e||"object"!==(void 0===e?"undefined":r(e))||!1 in e||-1===["http:","https:"].indexOf(e.protocol))return null;var t=e.href.substring(0,this.config.siteUrl.length),n=this._getPathname(e.href,t),i={original:e.href,protocol:e.protocol,origin:t,pathname:n,href:t+n};return this._isLinkOk(i)?i:null}},{key:"_getPathname",value:function(e,t){var n=t?e.substring(this.config.siteUrl.length):e;return n.startsWith("/")||(n="/"+n),this._shouldAddTrailingSlash(n)?n+"/":n}},{key:"_shouldAddTrailingSlash",value:function(e){return this.config.usesTrailingSlash&&!e.endsWith("/")&&!this.regex.fileExt.test(e)}},{key:"_isLinkOk",value:function(e){return null!==e&&"object"===(void 0===e?"undefined":r(e))&&(!this.prefetched.has(e.href)&&e.origin===this.config.siteUrl&&-1===e.href.indexOf("?")&&-1===e.href.indexOf("#")&&!this.regex.excludeUris.test(e.href)&&!this.regex.images.test(e.href))}}],[{key:"run",value:function(){"undefined"!=typeof RocketPreloadLinksConfig&&new n(new RocketBrowserCompatibilityChecker({capture:!0,passive:!0}),RocketPreloadLinksConfig).init()}}]),n}();t.run(); }()); </script> <script type="rocketlazyloadscript" data-rocket-src="https://wpjian.com/wp-includes/js/imagesloaded.min.js?ver=5.0.0" id="imagesloaded-js" defer></script> <script type="rocketlazyloadscript" data-rocket-src="https://wpjian.com/wp-content/themes/networker/assets/vendor/flickity.pkgd.min.js?ver=1.1.4" id="flickity-js" defer></script> <script id="csco-scripts-js-extra"> var csLocalize = {"siteSchemeMode":"light","siteSchemeToogle":"1"}; var csco_mega_menu = {"rest_url":"https:\/\/wpjian.com\/wp-json\/csco\/v1\/menu-posts"}; </script> <script type="rocketlazyloadscript" data-rocket-src="https://wpjian.com/wp-content/themes/networker/assets/js/scripts.js?ver=1.1.4" id="csco-scripts-js" defer></script> </body> </html> <!-- WP Chinese Conversion Full Page Converted. Target Lang: zh-tw --> <!-- This website is like a Rocket, isn't it? Performance optimized by WP Rocket. Learn more: https://wp-rocket.me -->