內容簡介
這個外掛會自動篩選標題、內容和評論中的大寫字母,並進行修正。
你可以自訂每種內容 (標題、內容、評論) 出現多少連續的大寫字母才觸發正常化處理。
這個外掛旨在在不影響 WordPress 資料庫內容的情況下即時改變顯示的文字!如果你想永久變更網站的內容或標題,你必須修改該文章。
請在安裝之前確定沒有 CSS 樣式會強制顯示大寫字母,否則字體的大小寫會受到 CSS 引導,而此外掛將會無效。如果外掛似乎無法使用,可以參考疑難排解章節進行解決。
安裝設定
安裝後,外掛會自動顯示正常化的文字。因此,標題、文章內容、小工具標題和評論會預設被篩選和正常化。
你可以在 functions.php 中自訂/添加/刪除過濾器,並提供 hook 名稱與允許的連續大寫字母數量。
1) 創建自己的 hook+rule
add_action( 'init', function() {
add_filter( 'rcl_hook_filters', function () { return array(
array( 'hook' => 'the_title', 'allowed_chars' => 6 ), // 標題
array( 'hook' => 'comment_text', 'allowed_chars' => 5 ), // 評論
array( 'hook' => 'widget_title', 'allowed_chars' => 6 ), // 小工具
);
} );
} );
2) 編輯單一過濾器數值 (並不會創建新的過濾器,只修改已經存在的過濾器數值)。如果要停用過濾器,但繼續使用標準設置的其餘過濾器,你需要將數值設置為“-1” (請見下面範例)。
add_filter( 'rcl_the_title', function () { return 60; } );
add_filter( 'rcl_comment_text', function () { return 3; } );
add_filter( 'rcl_widget_title', function () { return -1; } ); // 停用
最後提示一句,因為主要的文章/頁面內容類型不同 (並非字串),所以你需要如下設置文章內容的過濾器。
add_filter( 'rcl_the_content', function () { return 10; } );
// 或停用文章內容過濾器
// add_filter( 'rcl_the_content', function () { return -1; } );
如果你需要改變預設設置,只在評論中啟用大寫字母修正功能,你需要在 functions.php 中添加以下過濾器:
// functions.php
add_filter( 'rcl_the_content', function () { return -1; } ); // 停用
add_action( 'init', function() {
add_filter( 'rcl_hook_filters', function () { return array(
array( 'hook' => 'comment_text', 'allowed_chars' => 5 ), // 如果有兩個或更多大寫字母,就觸發文字正常化
);
} );
} );
疑難排解
該外掛不會改變你網站的 CSS 樣式,因為你可以從自訂器中輕鬆地進行設計並且不需要使用外掛。
因此,在安裝此外掛之前,建議你嘗試重置標題、內容和小工具的樣式,使用屬性 text-transform: inherit !important;。
版權
Remove CapsLock,版權所有 2021,Codekraft Studio
Remove CapsLock 釋出 GNU GPL 授權。
這是一個自由軟體,你可以重新散佈或修改它
依照自由軟體基金會 GNU 通用公共授權條款的規定,
不論版本 3 或任何之後版本,你都可以自由取得和使用它。
此程式是基於希望它有用的眾多動機之下發行的,
但是,沒有任何保證,甚至就一般適用性的保證都沒有。
更多詳細的資料,請參閱 GNU 通用公共授權條款。
外掛標籤
開發者團隊
原文外掛簡介
This plugin automatically filters titles, content and comments, searching and normalizing uppercase text.
You can customize the minimum amount of consecutive characters for each type of content (title, content, comments) before trigger the normalization function on that string.
This plugin is intended to change on-the-fly what is displayed without affecting what is stored in the wordpress database! If you want to change permanently the website content/titles you need to modify posts.
Please before install, be sure there isn’t any CSS rule that force uppercase otherwise the font case will be css driven and this plugin consequently useless. Check the troubleshooting section for guidance on this if the plugin seems not to work.
Setup
After installation, the plugin automatically displays normalised texts. So the title, post content, widget titles and comments will be filtered and normalised by default.
You can customize/add/remove filters adding to functions.php the name of the hook and the number of allowed consecutive uppercase characters.
1) To create your own set of hook+rule
add_action( 'init', function() {
add_filter( 'rcl_hook_filters', function () { return array(
array( 'hook' => 'the_title', 'allowed_chars' => 6 ), // title
array( 'hook' => 'comment_text', 'allowed_chars' => 5 ), // comments
array( 'hook' => 'widget_title', 'allowed_chars' => 6 ), // widget
);
} );
} );
2) To edit a single filter value (it doesn’t create any new filter, only change an already created one). In order to disable a filter, while continue to use the rest of the standard set, you need to set “-1” as value (example below).
add_filter( 'rcl_the_title', function () { return 60; } );
add_filter( 'rcl_comment_text', function () { return 3; } );
add_filter( 'rcl_widget_title', function () { return -1; } ); // disabled
One last note, since the main post/page content has a different content type (isn’t a string) you need to set the filter for the post content as below.
add_filter( 'rcl_the_content', function () { return 10; } );
// OR to disable the content filter
// add_filter( 'rcl_the_content', function () { return -1; } );
If you need to change the default setup and enable uppercase text correction ONLY for comments, you need to add to functions.php the filter as below:
// functions.php
add_filter( 'rcl_the_content', function () { return -1; } ); // disabled
add_action( 'init', function() {
add_filter( 'rcl_hook_filters', function () { return array(
array( 'hook' => 'comment_text', 'allowed_chars' => 5 ), // 2 or more uppercase digits triggers the text normalization
);
} );
} );
Troubleshooting
This plugin is not intended to change the css style of your website, because you can do this easily with customizer and without any plugin.
So before installing this plugin I suggest you try to reset the style of the title/content/widget, using the property text-transform: inherit !important;
copyright
Remove CapsLock, Copyright 2021 Codekraft Studio
Remove CapsLock is distributed under the terms of the GNU GPL
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the LICENSE file for more details.
