前言介紹
- 這款 WordPress 外掛「Linkify Text」是 2011-12-04 上架。 目前已經下架不再更新,不建議安裝使用。
- 目前有 1000 個安裝啟用數。
- 上一次更新是 2018-07-20,距離現在已有 2479 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
- 外掛最低要求 WordPress 4.7 以上版本才可以安裝。
- 有 14 人給過評分。
- 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。
外掛協作開發者
外掛標籤
link | text | replace | autolink | hyperlink |
內容簡介
這個外掛允許您定義單詞或詞組,只要它們出現在您的文章或頁面中,就會自動連結到您指定的 URL。例如,無論您在哪提到「WordPress」這個詞,都可以自動連結為「WordPress」。
通過設置和過濾器可以控制插件的其他功能:
可以啟用評論的文本鏈接(預設為不啟用)
可以設置文本鏈接區分大小寫(預設為不區分大小寫)
可以限制文章中每個詞組僅鏈接一次(默認情況下,所有詞組的所有出現都會鏈接)
鏈接可以設置為在新窗口中打開(預設為不在新窗口中打開)
您還可以將多個詞組鏈接到同一個鏈接,並且只需在設置中定義該鏈接的特殊語法。
許多過濾器可以通過編程自定義外掛的行為,所有這些過濾器都有記錄。
鏈接:插件主頁 | 插件目錄頁面 | GitHub | 作者主頁
鉤子
該外掛公開了多個用於鉤取的過濾器。通常,使用過濾器的代碼最好放入 mu-plugin 或特定於網站的外掛中(這超出了本自述文件的範圍)。請記住,大多數由這些過濾器控制的功能可以通過外掛的設置頁面進行配置。這些過濾器可能只對能編寫代碼的高級用戶感興趣。
c2c_linkify_text_filters(過濾器)
“c2c_linkify_text_filters”鉤子允許您自定義哪些鉤子應對其應用文本鏈接。
參數:
$hooks(數組):要對其應用文本鏈接的數組鉤子。
例子:
/**
*啟用自訂字段的文本鏈接功能。
*
* @param array $filters 由Linkify Text插件處理的過濾器。
*/
function more_text_replacements( $filters ) {
$filters[] = 'the_meta'; // 在此處,您可以輸入任何您想要的過濾器的名稱。
return $filters;
}
add_filter( 'c2c_linkify_text_filters', 'more_text_replacements' );
c2c_linkify_text_comments(過濾器)
“c2c_linkify_text_comments”鉤子允許您自定義或覆蓋指示是否應在評論中啟用文本鏈接的設置。
參數:
$state(布爾值):表示是否為評論啟用文本鏈接的true或false。默認值將是通過外掛的設置頁面設置的值。
例子:
// 永遠不要在評論中啟用文本鏈接。
add_filter( 'c2c_linkify_text_comments', '__return_false' );
c2c_linkify_text(過濾器)
“c2c_linkify_text”鉤子允許您自定義或覆蓋定義所有文本短語及其關聯鏈接的設置。
參數:
$linkify_text_array(數組):文本及其關聯鏈接的數組。默認值將是通過外掛的設置頁面設置的值。
例子:
/**
*編程方式添加更多要鏈接的文本。
*
* @param array $text_to_links 文字及其相關URL的數組。
*/
原文外掛簡介
This plugin allows you to define words or phrases that, whenever they appear in your posts or pages, get automatically linked to the URLs of your choosing. For instance, wherever you may mention the word “WordPress”, that can get automatically linked as “WordPress“.
Additional features of the plugin controlled via settings and filters:
Text linkification can be enabled for comments (it isn’t by default)
Text linkification can be made case sensitive (it isn’t by default)
Text linkification can be limited to doing only one linkification per term, per post (by default, all occurrences of a term are linkified)
Text linkification links can be set to open in a new window (it isn’t by default)
You can also link multiple terms to the same link and only define that link once in the settings via use of a special link syntax.
A number of filters exist to programmatically customize the behavior of the plugin, all of which are documented.
Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage
Hooks
The plugin exposes a number of filters for hooking. Typically, code making use of filters should ideally be put into a mu-plugin or site-specific plugin (which is beyond the scope of this readme to explain). Bear in mind that most of the features controlled by these filters are configurable via the plugin’s settings page. These filters are likely only of interest to advanced users able to code.
c2c_linkify_text_filters (filter)
The ‘c2c_linkify_text_filters’ hook allows you to customize what hooks get text linkification applied to them.
Arguments:
$hooks (array): Array of hooks that will be text linkified.
Example:
/**
* Enables text linkification for custom fields.
*
* @param array $filters The filters handled by the Linkify Text plugin.
*/
function more_text_replacements( $filters ) {
$filters[] = 'the_meta'; // Here you could put in the name of any filter you want
return $filters;
}
add_filter( 'c2c_linkify_text_filters', 'more_text_replacements' );
c2c_linkify_text_comments (filter)
The ‘c2c_linkify_text_comments’ hook allows you to customize or override the setting indicating if text linkification should be enabled in comments.
Arguments:
$state (bool): Either true or false indicating if text linkification is enabled for comments. The default value will be the value set via the plugin’s settings page.
Example:
// Prevent text linkification from ever being enabled in comments.
add_filter( 'c2c_linkify_text_comments', '__return_false' );
c2c_linkify_text (filter)
The ‘c2c_linkify_text’ hook allows you to customize or override the setting defining all of the text phrases and their associated links.
Arguments:
$linkify_text_array (array): Array of text and their associated links. The default value will be the value set via the plugin’s settings page.
Example:
/**
* Programmatically adds more text to be linked.
*
* @param array $text_to_links Array of text and their associated URLs.
*/
function my_text_linkifications( $text_to_links ) {
// Add text link
$text_to_links['Matt Mullenweg'] => 'https://ma.tt';
// Unset a text link that we never want defined
if ( isset( $text_to_links['WordPress'] ) ) {
unset( $text_to_links['WordPress'] );
}
// Important! Return the changes.
return $text_to_links;
}
add_filter( 'c2c_linkify_text', 'my_text_linkifications' );
c2c_linkify_text_case_sensitive (filter)
The ‘c2c_linkify_text_case_sensitive’ hook allows you to customize or override the setting indicating if text matching for potential text linkification should be case sensitive or not.
Arguments:
$state (bool): Either true or false indicating if text matching is case sensitive. The default value will be the value set via the plugin’s settings page.
Example:
// Prevent text matching from ever being case sensitive.
add_filter( 'c2c_linkify_text_case_sensitive', '__return_false' );
c2c_linkify_text_replace_once (filter)
The ‘c2c_linkify_text_replace_once’ hook allows you to customize or override the setting indicating if text linkification should be limited to once per term per piece of text being processed regardless of how many times the term appears.
Arguments:
$state (bool): Either true or false indicating if text linkification is to only occur once per term. The default value will be the value set via the plugin’s settings page.
Example:
// Only linkify a term once per post.
add_filter( 'c2c_linkify_text_replace_once', '__return_true' );
c2c_linkify_text_open_new_window (filter)
The ‘c2c_linkify_text_open_new_window’ hook allows you to customize or override the setting indicating if links should open in a new window.
Arguments:
$state (bool): Either true or false indicating if links should open in a new window. The default value will be the value set via the plugin’s settings page, which itself is defaulted to false.
Example:
// Make links open in a new window.
add_filter( 'c2c_linkify_text_open_new_window', '__return_true' );
c2c_linkify_text_linked_text (filter)
The ‘c2c_linkify_text_linked_text’ hook allows you to customize or override the replacement link markup for a given string. Return the value of $old_text to effectively prevent the given text linkification.
Arguments:
$new_text (string): The link markup that will replace $old_text.
$old_text (string): The text being replaced/linkified.
$link (string): The URL that $old_text is to be linked to.
$text_to_link (array): The full array of text and the URLs they should link to.
Example:
/**
* Disable linkification of links for posts that have the 'disable_linkify_text'
* custom field defined.
*
* @param array $display_link The associative array of attributes to be used for the link.
* @param string $old_text The text being replaced/linkified.
* @param string $link_for_text The URL that $old_text is to be linked to.
* @param string $text_to_link The full array of text and the URLs they should link to.
* @return string
*/
function selectively_disable_text_linkification( $display_link, $old_text, $link_for_text, $text_to_link ) {
if ( get_metadata( 'post', get_the_ID(), 'disable_linkify_text', true ) ) {
$display_link = $old_text;
}
return $display_link;
}
add_filter( 'c2c_linkify_text_linked_text', 'selectively_disable_text_linkification', 10, 4 );
c2c_linkify_text_link_attrs (filter)
The ‘c2c_linkify_text_link_attrs’ hook allows you to add or customize attributes for the link.
Arguments:
$attrs (array): The associative array of attributes to be used for the link. By default includes ‘href’.
$old_text (string): The text being replaced/linkified.
$link (string): The URL that $old_text is to be linked to.
Example:
/**
* Force links created by Linkify Text plugin to open in a new tab.
*
* @param array $attrs The associative array of attributes to be used for the link.
* @param string $old_text The text being replaced/linkified.
* @param string $link The URL that $old_text is to be linked to.
* @return array
*/
function my_linkify_text_attrs( $attrs, $old_text, $link ) {
$attrs['target'] = '_blank';
return $attrs;
}
add_filter( 'c2c_linkify_text_link_attrs', 'my_linkify_text_attrs', 10, 3 );
各版本下載點
- 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
- 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Linkify Text」來進行安裝。
(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。
1.0 | 1.5 | 1.6 | 1.7 | 1.8 | 1.9 | 1.9.1 | trunk |
延伸相關外掛(你可能也想知道)
Autolink Generator 》總結:這款外掛可根據設定的關鍵字在 WordPress 文章內容中生成並插入額外的連結和 AI 生成的內容。, , 1. 這款 WordPress 外掛的作用是什麼?, - 根據設定的...。
WP KeyLink 》此外掛能夠自動連結文章內指定的關鍵詞至指定的網址。此連結會永久地出現在文章內容中。除此之外,您可以定義關鍵詞連結的限制,以避免被 Google 識別為連結...。
Twitterify 》這款外掛可自動將 hashtag(例如 #wordpress)轉換為標籤連結,@連結轉換為作者連結(例如 @metinsaylan),以及自動將 URI(例如 http://wpassist.me)轉換...。
Tags Autolink 》Tags Autolink 是一個 SEO 外掛,可以自動將文章和頁面中出現的標籤名稱轉換成對應的標籤網址連結。該外掛會保留原本的文字大小寫。它尤其適用於 SEO,因為它...。
Pages Autolink 》Pages Autolink 是一款 SEO 外掛程式,可以自動將頁面名稱轉為相對應的頁面網址連結,並保留原始文字大小寫。這對於使用頁面建立詞彙表的部落客來說特別有用...。
Categories Autolink 》Categories Autolink 是一個 SEO 外掛,可以自動將在文章和頁面中使用的類別名稱轉換為對應的類別 URL 連結。保持文字中原本的單字大小寫。對於使用類別建立...。
AutoLink 》這個外掛程式會使用 GoogleAPI 將定界符號替換為連結。例如:[movie]She’s The Man[/movie],會被替換為:She’s the man。, 其他內容。