在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"><!--WPCC_NC_START--> <span id="wpcc_original_link" class="wpcc_current_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_lang" ><a class="wpcc_link" href="https://wpjian.com/zh-tw/wordpress-seo/2021012740776.html" title="繁体中文" data-wpel-link="internal">繁体中文</a></span> <!--WPCC_NC_END--></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/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/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/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/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/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/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/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/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/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-48864 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/wordpress-seo/2021120648864.html" data-wpel-link="internal">如何为 SEO 制作出色的页面标题</a></h2> <div class="cs-entry__excerpt"> 编写出色的页面标题是任何做 SEO 的人的基本技能。为什么?因为标题标签可能是用户在… </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">2021年12月6日</div></div> </div> </div> <div class="cs-entry__read-more"> <a href="https://wpjian.com/wordpress-seo/2021120648864.html" data-wpel-link="internal"> 阅读更多 </a> </div> </div> </div> </div> </article> <article class="cs-entry-default post-25592 post type-post status-publish format-standard 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/wordpress-seo/2019112725592.html" data-wpel-link="internal">2019假日营销指南|是行销</a></h2> <div class="cs-entry__excerpt"> 就假期支出而言,2018年是不可预测且消费者行为异常的一年。 假日销售较上年增长2.… </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年11月27日</div></div> </div> </div> <div class="cs-entry__read-more"> <a href="https://wpjian.com/wordpress-seo/2019112725592.html" data-wpel-link="internal"> 阅读更多 </a> </div> </div> </div> </div> </article> <article class="cs-entry-default post-51379 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/wordpress-seo/2021112651379.html" data-wpel-link="internal">企业和自由职业者的 5 种最佳工作替代方案</a></h2> <div class="cs-entry__excerpt"> [ad_1] 虽然您可能以运营网站或业务的各个方面而自豪,但这样做并不健康或不理智。… </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">2021年11月26日</div></div> </div> </div> <div class="cs-entry__read-more"> <a href="https://wpjian.com/wordpress-seo/2021112651379.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/" data-wpel-link="internal"> WP建站 </a> </div> <div class="cs-footer__desc"> <p class="copyright">© 2019 - 2022 by <a href="https://wpjian.com" 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> <!-- This website is like a Rocket, isn't it? Performance optimized by WP Rocket. Learn more: https://wp-rocket.me -->