[WordPress] 外掛分享: Text Replace

WordPress 外掛 Text Replace 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「Text Replace」是 2004-12-20 上架。
  • 目前有 4000 個安裝啟用數。
  • 上一次更新是 2021-07-12,距離現在已有 1392 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 4.9 以上版本才可以安裝。
  • 有 18 人給過評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

coffee2code |

外掛標籤

text | replace | shortcut | coffee2code | substitution |

內容簡介

這個外掛讓你輕鬆地定義出應用於文章中的文字或 HTML,以替代實際出現在文章中的字詞或片語。這是一個方便的技巧,可用於創建常見、冗長或經常更改的文本/HTML 的快捷方式,或是表情符號。

外掛的其他特點可以透過設置和過濾器來控制,包括:

- 可啟用評論的文字替換功能(默認情況下,未啟用)
- 文字替換可以設定大小寫不敏感(預設區分大小寫)
- 文字替換可以限制每篇文章每個術語只進行一次替換(預設情況下,所有術語的所有彩現都會被替換)
- 文字替換可以提早或延遲處理 WordPress 文本過濾過程(預設提早)
- 文字替換可以擴大至影響其他過濾器

以下是一些需要注意的事項:

- 以冒號為例,最好定義一些在文本中不會出現的快捷方式:
:wp: => WordPress
:aol: => 美國線上公司
否則,可能會出現正確但不需要的替換,如 “Hi => Hello“ 會導致“His majesty” 更改為“Hellos majesty”。

- 如果您想使用此外掛處理表情符號,您應該在寫作設置管理頁面上禁用 WordPress 的默認表情符號處理程序。

- 此外掛預設設置為篩選“the_content”、“the_excerpt”、“widget_text”,可選擇篩選“get_comment_text”和“get_comment_excerpt”的篩選器。它還可以預設處理來自其他流行插件(如 Advanced Custom Fields(ACF)和 Elementor)的篩選器。 “更多過濾器”設置可用於指定其他應由插件處理的過濾器。過濾器“c2c_text_replace_filters”也可用於添加或修改受影響的過濾器列表。

- HTML 標記內(如標記名稱和屬性)的文本將不會匹配。因此,例如,在`text`中,您無法指望`: mycss:`快捷方式能夠正常工作。

- 特別注意:請注意,您在文章中使用的快捷文本將以該方式存儲在數據庫中。雖然顯示文章的調用將看到篩選後的文本替換版本,但直接在數據庫上運行的任何操作都不會看到擴展的替換文本。因此,如果您只是將“美國線上公司”稱為“:aol:”(其中:aol: => 美國線上公司),由於文本替換,訪問您的網站的訪問者將看到連結的擴展文本,但數據庫搜索永遠找不到“美國線上公司”的匹配項。

- 然而,不將替換文本保存到數據庫並在加載數據時評估替換文本的好處是,如果修改了替換文本,所有使用快捷方式的頁面將從現在開始使用更新的替換文本。

連結:外掛主頁|外掛目錄頁|GitHub|作者網站

原文外掛簡介

This plugin allows you to easily define text or HTML that should be used in your posts in place of words or phrases that are actually present in the posts. This is a handy technique for creating shortcuts to common, lengthy, or frequently changing text/HTML, or for smilies.
Additional features of the plugin controlled both via settings and filters:

Text replacement can be enabled for comments (it isn’t by default)
Text replacement can be made case insensitive (it is case sensitive by default)
Text replacement can be limited to doing only one replacement per term, per post (by default, all occurrences of a term are replaced)
Text replacement can be handled early or late in WordPress’s text filtering process (it’s early by default)
Text replacement can be expanded to affect other filters

A few things to keep these things in mind:

Your best bet with defining shortcuts is to define something that would never otherwise appear in your text. For instance, bookend the shortcut with colons:
:wp: => WordPress
:aol: => America Online, Inc.

Otherwise, you risk proper but undesired replacements:
Hi => Hello

Would have the effect of changing “His majesty” to “Hellos majesty”.

If you intend to use this plugin to handle smilies, you should probably disable WordPress’s default smilie handler on the Writing Settings admin page.

This plugin is set to filter ‘the_content’, ‘the_excerpt’, ‘widget_text’, and optionally, ‘get_comment_text’ and ‘get_comment_excerpt’. Filters from popular plugins such as Advanced Custom Fields (ACF) and Elementor are also handled by default (see FAQ for specifics). The “More filters” setting can be used to specify additional filters that should be handled by the plugin. The filter ‘c2c_text_replace_filters’ can also be used to add or modify the list of filters affected.

Text inside of HTML tags (such as tag names and attributes) will not be matched. So, for example, you can’t expect the :mycss: shortcut to work in text

SPECIAL CONSIDERATION: Be aware that the shortcut text that you use in your posts will be stored that way in the database. While calls to display the posts will see the filtered, text-replaced version, anything that operates directly on the database will not see the expanded replacement text. So if you only ever referred to “America Online” as “:aol:” (where :aol: => America Online), visitors to your site will see the linked, expanded text due to the text replace, but a database search would never turn up a match for “America Online”.

However, a benefit of the replacement text not being saved to the database and instead evaluated when the data is being loaded into a web page is that if the replacement text is modified, all pages making use of the shortcut will henceforth use the updated replacement text.

Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage
Developer Documentation
Developer documentation can be found in DEVELOPER-DOCS.md. That documentation covers the numerous hooks provided by the plugin. Those hooks are listed below to provide an overview of what’s available.

c2c_text_replace_filters : Customize what hooks get text replacement applied to them.
c2c_text_replace_third_party_filters : Customize what third-party hooks get text replacement applied to them.
c2c_text_replace_filter_priority : Override the default priority for the ‘c2c_text_replace’ filter.
c2c_text_replace Customize or override the setting defining all of the text replacement shortcuts and their replacements.
c2c_text_replace_comments : Customize or override the setting indicating if text replacement should be enabled in comments.
c2c_text_replace_case_sensitive : Customize or override the setting indicating if text replacement should be case sensitive.
c2c_text_replace_once : Customize or override the setting indicating if text replacement should be limited to once per term per piece of text being processed regardless of how many times the term appears.

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「Text Replace」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


1.0 | 2.0 | 2.5 | 3.0 | 3.1 | 3.2 | 3.5 | 3.6 | 3.7 | 3.8 | 3.9 | 4.0 | 3.0.2 | 3.1.1 | 3.2.1 | 3.2.2 | 3.5.1 | 3.6.1 | 3.9.1 | trunk |

延伸相關外掛(你可能也想知道)

  • Encryption contest 》這個外掛包含一個完整的評估競賽系統。它允許您為未來的日期(例如第一週的任務1,周末的任務2等)創建任務佇列。, 任務更改基於日期。一旦您設定了參數,您...。

文章
Filter
Apply Filters
Mastodon