[wordpress插件] Auto-hyperlink URLs自动超链接网址

wordpress 插件 文章 2020-02-24 09:10 636 0 全屏看文

AI助手支持GPT4.0

评分
88
描述

Automatically turns plaintext URLs and email addresses into links.

自动将纯文本URL和电子邮件地址转换为链接。

This plugin seeks to replace and extend WordPress’s default auto-hyperlinking function.

此插件旨在替换和扩展WordPress的默认自动超链接功能。

This plugin uses different pattern matching expressions than the WordPress default in order to prevent inappropriate adjacent characters from becoming part of the link (as WordPress has improved over the years, nowadays this is just a few edge cases like text links that are braced or bracketed)

该插件使用了与WordPress默认样式不同的模式匹配表达式,以防止不适当的相邻字符成为链接的一部分(随着WordPress多年来的发展,如今,这只是一些边缘情况,例如用括号括住或括起来的文本链接)

and it prevents invalid URIs (ie http://blah) from becoming links.

并且可以防止无效的URI(即http:// blah)成为链接。

More significantly, this plugin adds configurability to the auto-hyperlinker such that you can configure:

更重要的是,此插件为自动超链接程序增加了可配置性,以便您可以配置:

    • If you want text URLs to only show the hostname
    • 如果您希望文本URL仅显示主机名

    • If you want text URLs truncated after N characters
    • 如果您希望文本网址在N个字符后被截断

    • If you want auto-hyperlinked URLs to open in new browser window or not
    • 如果您希望自动链接的URL在新的浏览器窗口中打开或不打开

    • If you want the URI scheme (i.e. “http://”) to be stripped for displayed links
    • 如果您要为显示的链接删除URI方案(即“ http://”)

    • The text to come before and after the link text for truncated links
    • 截断链接的链接文本前后的文本

    • If you want rel=”nofollow” to be supported
    • 如果您想支持rel =“ nofollow”

    • If you wish to support additional domain extensions not already configured into the plugin
    • 如果您希望支持尚未在插件中配置的其他域扩展

    • If you want certain domains to be omitted from auto-linking
    • 如果您希望某些域从自动链接中被忽略

    This plugin will recognize any explicit URI scheme (http|https|ftp|news)://, etc, as well as email addresses.

    此插件将识别任何显式URI方案(http | https | ftp | news)://等,以及电子邮件地址。

    It also adds the new ability to recognize Class B domain references (i.e. “somesite.net”, not just domains prepended with “www.”) as valid links (i.e. “wordpress.org” would get auto-hyperlinked)

    它还增加了将B类域引用(即“ somesite.net”,而不仅仅是带有“ www。”的域)识别为有效链接的新功能(即,“ wordpress.org”将自动超链接)

    The following domain extensions (aka TLDs, Top-Level Domains) are recognized by the plugin: com, org, net, gov, edu, mil, us, info, biz, ws, name, mobi, cc, tv.

    插件可以识别以下域扩展名(又名TLD,顶级域):com,org,net,gov,edu,mil,us,info,biz,ws,ws,name,mobi,cc,tv。

    These only comes into play when you have a plaintext URL that does not have an explicit URI scheme specified.

    仅当您具有未指定显式URI方案的纯文本URL时,这些属性才起作用。

    If you need support for additional TLDs, you can add more via the plugin’s admin options page or via filter.

    如果您需要其他TLD的支持,则可以通过插件的管理选项页或过滤器添加更多内容。

    This plugin also activates auto-hyperlinking of text links within post/page content.

    此插件还可以激活帖子/页面内容中文本链接的自动超链接。

    Links: Plugin Homepage |

    链接:插件主页 |

    Plugin Directory Page |

    插件目录页面 |

    GitHub |

    GitHub |

    Author Homepage

    作者主页

    Examples

    示例

    (when running with default configuration):

    (使用默认配置运行时):

      To better illustrate what results you might get using the various settings above, here are examples.

      为更好地说明您使用上述各种设置可能会获得什么结果,请参见以下示例。

      For the following, assume the following URL is appearing as plaintext in a post: www.somelonghost.com/with/some/long/URL/that/might/mess/up/your/theme/and/

      对于以下情况,假定以下URL在帖子中以纯文本形式出现: www.somelonghost.com/with/some/long/URL/that/might/mess/up/your/theme/and/

      is/unsightly.php

      是/unsightly.php

      And unless explicitly stated, the results are using default values (nofollow is false, hyperlink emails is true, Hyperlink Mode is 0)

      除非明确说明,否则结果将使用默认值(nofollow为false,超链接电子邮件为true,超链接模式为0)

        Filters

        过滤器

        The plugin exposes seven filters for hooking.

        该插件提供了七个过滤器以进行挂钩。

        Typically, customizations utilizing these hooks would be put into your active theme’s functions.php file, or used by another plugin.

        通常,利用这些钩子进行的自定义将被放入活动主题的functions.php文件中,或由另一个插件使用。

        c2c_autohyperlink_urls_filters (filter)

        c2c_autohyperlink_urls_filters(过滤器)

        This hook allows you to customize which filters get processed by the plugin.

        此挂钩可让您自定义插件要处理的过滤器。

        Arguments:

        参数:

          • $filters (array): The filters whose text should be auto-hyperlinked.

          • $ filters(数组):文本应自动超链接的过滤器。

            Default array( 'the_content', 'the_excerpt', 'widget_text' ).

          • 默认 array('the_content','the_excerpt','widget_text')

          Example:

          示例:

          /** 

            / ** 

          * Auto-hyperlink additional filters. 

          *自动超链接附加过滤器。 

          * @param array $filters 

          * @参数数组$ filters 

          * @return array 

          * @返回数组 

          */

          * /

          function my_c2c_autohyperlink_urls_filters( $filters ) {    

          函数my_c2c_autohyperlink_urls_filters($ filters){    

          // Add in another filter to process.    

          //添加另一个过滤器进行处理。    

          $filters[] = 'my_custom_filter';    

          $ filters [] ='my_custom_filter';    

          return $filters;

          返回$ filters;

          }

          }

          add_filter( 'c2c_autohyperlink_urls_filters', 'my_c2c_autohyperlink_urls_filters' );

          add_filter('c2c_autohyperlink_urls_filters','my_c2c_autohyperlink_urls_filters');

          autohyperlink_urls_class (filter)

          autohyperlink_urls_class(过滤器)

          This hook allows you to customize the class added to links created by the plugin.

          此挂钩可让您自定义添加到由插件创建的链接中的类。

          Arguments:

          参数:

            • $class (string): The class name.

            • $ class(字符串):类名。

              Default ‘autohyperlink’.

            • 默认为“自动超链接”。

            Example:

            示例:

            // Set default class for links added by Auto-hyperlink URLs.

              //为自动超链接URL添加的链接设置默认类。

            add_filter( 'autohyperlink_urls_class', function ( $class ) { return 'myclass'; } );

            add_filter('autohyperlink_urls_class',function($ class){return'myclass';});

            autohyperlink_urls_link_attributes (filter)

            autohyperlink_urls_link_attributes(过滤器)

            This hook allows you to add custom attributes to links created by the plugin.

            此挂钩可让您向插件创建的链接添加自定义属性。

            Arguments:

            参数:

              • $attributes (array): The link attributes already created by the plugin.
              • $ attributes(数组):插件已创建的链接属性。

              • $context (string): The context for the link.

              • $ context(字符串):链接的上下文。

                Either ‘url’ or ’email’.

                “ url”或“ email”。

                Default ‘url’.

              • 默认为“ url”。

              • $title (string): The text for the link’s title attribute.
              • $ title(字符串):链接的title属性的文本。

              Example:

              示例:

              /** 

                / ** 

              * Output 'title' attribute for link, as done by plugin prior to v5.0. 

              *输出链接的“标题”属性,由v5.0之前的插件完成。 

              * @param array $attributes The attributes for the link tag. 

              * @param array $ attributes链接标记的属性。 

              * @param string $context The context for the link.

              * @param string $ context链接的上下文。

              Either 'url' or 'email'.

              “ url”或“ email”。

              Default 'url'. 

              默认为“ url”。 

              * @param string $title The text for the link's title attribute. 

              * @param string $ title链接的title属性的文本。 

              * @return array 

              * @返回数组 

              */

              * /

              function add_title_attribute_for_autohyperlink_urls( $attributes, $context = 'url', $title = '' ) {    

              函数add_title_attribute_for_autohyperlink_urls($ attributes,$ context ='url',$ title =''){    

              if ( $title ) {        

              如果($ title){        

              $attributes['title'] = $title;    

              $ attributes ['title'] = $ title;    

              }    

              }    

              return $attributes;

              返回$ attributes;

              }

              }

              add_filter( 'autohyperlink_urls_link_attributes', 'add_title_attribute_for_autohyperlink_urls', 10, 3 );

              add_filter('autohyperlink_urls_link_attributes','add_title_attribute_for_autohyperlink_urls',10,3);

              autohyperlink_urls_tlds (filter)

              autohyperlink_urls_tlds(过滤器)

              This hook allows you to custom the list of supported TLDs for non-URI scheme link auto-hyperlinking.

              此挂钩允许您为非URI方案链接自动超链接自定义受支持的TLD列表。

              Note that the value sent to the hook includes the default TLDs plus those added via the ‘more_extensions’ setting.

              请注意,发送到挂钩的值包括默认TLD以及通过“ more_extensions”设置添加的值。

              Also note that the TLDs are defined as a ‘|’-separated string.

              另请注意,顶级域名(TLD)定义为用“ |”分隔的字符串。

              Arguments:

              参数:

                • $tlds (string): The supported TLDs.

                • $ tlds(字符串):受支持的TLD。

                  Default 'com|org|net|gov|edu|mil|us|info|biz|ws|name|mobi|cc|tv'.

                • 默认'com | org | net | gov | edu | mil | us | info | biz | ws | name | mobi | cc | tv'

                Example:

                示例:

                // Add support for more TLDs.

                  //添加对更多TLD的支持。

                add_filter( 'autohyperlink_urls_tlds', function ( $tlds ) { return $tlds . '|in|io|tt'; } );

                add_filter('autohyperlink_urls_tlds',function($ tlds){return $ tlds。'| in | io | tt';});

                autohyperlink_urls_truncate_link (filter)

                autohyperlink_urls_truncate_link(过滤器)

                This hook allows you to custom how truncated links are displayed.

                此挂钩可让您自定义截断链接的显示方式。

                Arguments:

                参数:

                  • $url (string): The potentially truncated URL.
                  • $ url(字符串):可能被截断的URL。

                  • $original_url (string): The full, original URL.
                  • $ original_url(字符串):完整的原始URL。

                  • $context (string): The context for the link.

                  • $ context(字符串):链接的上下文。

                    Either ‘url’ or ’email’.

                    “ url”或“ email”。

                    Default ‘url’.

                  • 默认为“ url”。

                  autohyperlink_urls_custom_exclusions (filter)

                  autohyperlink_urls_custom_exclusions(过滤器)

                  This hook allows you to define custom logic to determine if a link should be hyperlinked.

                  此挂钩可让您定义自定义逻辑,以确定是否应将链接超链接。

                  Arguments:

                  参数:

                    • $should (bool): Should the link be hyperlinked?

                    • $应该(布尔):链接应该超链接吗?

                      Default true.

                    • 默认为true。

                    • $url (string): The full URL.
                    • $ url(字符串):完整的URL。

                    • $domain (string): Just the domain/host part of the URL.
                    • $ domain(字符串):仅是URL的域/主机部分。

                    Example:

                    示例:

                    /** 

                      / ** 

                    * Don't hyperlink links on the front page. 

                    *不要在首页上超链接。 

                    * @param bool $should 

                    * @param bool $应该 

                    * @param string $url 

                    * @参数字符串$ url 

                    * @param string $domain 

                    * @参数字符串$ domain 

                    * @return bool 

                    * @返回布尔 

                    */

                    * /

                    function my_autohyperlink_urls_custom_exclusions( $should, $url, $domain ) {    

                    函数my_autohyperlink_urls_custom_exclusions($ should,$ url,$ domain){    

                    if ( is_front_page() ) {        

                    如果(is_front_page()){        

                    return false;    

                    返回false;    

                    } else {        

                    }其他{        

                    return $should;    

                    返回$应该;    

                    }

                    }

                    }

                    }

                    add_filter( 'autohyperlink_urls_custom_exclusions', 'my_autohyperlink_urls_custom_exclusions' );

                    add_filter('autohyperlink_urls_custom_exclusions','my_autohyperlink_urls_custom_exclusions');

                    autohyperlink_urls_exclude_domains (filter)

                    autohyperlink_urls_exclude_domains(过滤器)

                    This hook allows you to specify domains that should not get auto-hyperlinked.

                    此挂钩允许您指定不应自动超链接的域。

                    Note that the value sent to the hook includes the value of the ‘exclude_domains’ setting.

                    请注意,发送到挂钩的值包括“ exclude_domains”设置的值。

                    Note that only the domain (without URI scheme or trailing slash) should be specified.

                    请注意,仅应指定域(不带URI方案或斜杠)。

                    Arguments:

                    参数:

                      • $excluded_domains (array): The domains already being excluded.

                      • $ excluded_domains(数组):域已被排除。

                        Default empty array.

                      • 默认为空数组。

                      Example:

                      示例:

                      /** 

                        / ** 

                      * Exclude certain domains from being auto-hyperlinked. 

                      *排除某些域自动超链接。 

                      * @param array $excluded_domains 

                      * @参数数组$ excluded_domains 

                      * @return array 

                      * @返回数组 

                      */

                      * /

                      function my_autohyperlink_urls_exclude_domains( $excluded_domains ) {    

                      函数my_autohyperlink_urls_exclude_domains($ excluded_domains){    

                      $excluded_domains[] = 'youtube.com';    

                      $ excluded_domains [] ='youtube.com';    

                      $excluded_domains[] = 'example.com';    

                      $ excluded_domains [] ='example.com';    

                      return $excluded_domains;

                      返回$ excluded_domains;

                      }

                      }

                      add_filter( 'autohyperlink_urls_exclude_domains', 'my_autohyperlink_urls_exclude_domains' );

                      add_filter('autohyperlink_urls_exclude_domains','my_autohyperlink_urls_exclude_domains');

安装步骤

    1. Whether installing or updating, whether this plugin or any other, it is always advisable to back-up your data before starting
    2. 无论是安装还是更新(无论是此插件还是其他插件),始终建议在开始之前备份您的数据

    3. Unzip auto-hyperlink-urls.zip inside the /wp-content/plugins/ directory (or install via the built-in WordPress plugin installer)

      / wp-content / plugins / 目录内

    4. 解压缩 auto-hyperlink-urls.zip (或通过内置的WordPress插件安装程序安装)

      >

      >

    5. Activate the plugin through the ‘Plugins’ admin menu in WordPress
    6. 通过WordPress中的“插件”管理菜单激活插件

    7. (optional) Go to the Settings -> Autohyperlink admin settings page (which you can also get to via the Settings link next to the plugin on

    8. (可选)转到“设置”->“自动超链接”管理员设置页面(也可以通过插件上的“设置”链接进入该页面,

      the Manage Plugins page) and customize the settings.

    9. “管理插件”页面)并自定义设置。

下载地址
https://downloads.wordpress.org/plugin/auto-hyperlink-urls.5.2.zip
-EOF-

AI助手支持GPT4.0