[WordPress] 外掛分享: Extra Sentence Space

首頁外掛目錄 › Extra Sentence Space
WordPress 外掛 Extra Sentence Space 的封面圖片
50+
安裝啟用
★★★☆☆
3/5 分(2 則評價)
2267 天前
最後更新
問題解決
WordPress 1.5+ v1.3.9 上架:2009-06-10

內容簡介

即使您在撰寫文章時在每個句子之後添加兩個空格(假設您遵循建議使用此間隔的寫作風格),當在瀏覽器中查看時,瀏覽器會將連續的空格合併為一個空格。此外掛會在句子結束標點符號後添加 (不換行空格),以保留您的兩個空格格式。

注意:此外掛只會在文章中有兩個或更多空格分隔句子的地方強制執行二個空格,它不會在只有一個空格的情況下插入第二個空格。

鏈接: 外掛主頁 | 外掛目錄頁 | GitHub | 作者主頁

鈎子(hooks)

此外掛可透過兩個過濾器進行更多自定義設置。通常,這些自定義會放在當前主題的 functions.php 檔案中,或由其他外掛使用。

c2c_extra_sentence_space

過濾器c2c_extra_sentence_space允許您以替代方式安全地調用c2c_extra_sentence_space() ,以保證當外掛停用或刪除時,調用該函數不會導致您的網站出錯。這僅適用於直接使用該功能的情況,對於大多數用戶,這並不是典型的使用方式。

範例:

原本寫法為:

<?php echo c2c_extra_sentence_space( $mytext ); ?>

應該改成:

<?php echo apply_filters( 'c2c_extra_sentence_space', $mytext ); ?>

c2c_extra_sentence_space_punctuation

過濾器c2c_extra_sentence_space_punctuation允許您自定義在哪些標點符號之後會保留雙倍間隔(如果存在)。預設為「.!?」。

引數:

$punctuation (字串):保留雙倍間隔的預設標點符號。預設為「.!?」。

範例:

/**
* 修改標點符號後兩個空格應該保留的清單,包括正斜槓和右括號。
*
* @param string $punctuation 標點符號。
* @return string
*/
function more_extra_space_punctuation( $punctuation ) {
// 在保留字符列表中添加「/」和「)」。
return $punctuation . '/)';
}
add_filter( 'c2c_extra_sentence_space_punctuation', 'more_extra_space_punctuation' );

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.3.9) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「Extra Sentence Space」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

Even though you may add two spaces after each sentence when writing a post (assuming you subscribe to a writing style that suggests such spacing) web browsers will collapse consecutive blank spaces into a single space when viewed. This plugin adds a   (non-breaking space) after sentence-ending punctuation to retain the appearance of your two-space intent.
NOTE: The plugin will only enforce the two-space gap in places where two or more spaces actually separate sentences in your posts. It will NOT insert a second space if only one space is present.
Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage
Hooks
The plugin is further customizable via two filters. Typically, these customizations would be put into your active theme’s functions.php file, or used by another plugin.
c2c_extra_sentence_space
The ‘c2c_extra_sentence_space’ filter allows you to use an alternative approach to safely invoke c2c_extra_sentence_space() in such a way that if the plugin were deactivated or deleted, then your calls to the function won’t cause errors in your site. This only applies if you use the function directly, which is not typical usage for most users.
Example:
Instead of:

Do:

c2c_extra_sentence_space_punctuation
The ‘c2c_extra_sentence_space_punctuation’ filter allows you to customize the punctuation, characters, and/or symbols after which double-spacing (when present) is preserved. By default these are ‘.!?’.
Arguments:

$punctuation (string): The default characters after which double-spacing should be preserved. Default is ‘.!?’.

Example:
/**
* Modifies the list of characters after which two spaces should be preserved
* to include a forward slash.
*
* @param string $punctuation The punctuation.
* @return string
*/
function more_extra_space_punctuation( $punctuation ) {
// Add the '/' and ')' characters to the list of characters
return $punctuation . '/)';
}
add_filter( 'c2c_extra_sentence_space_punctuation', 'more_extra_space_punctuation' );

延伸相關外掛

文章
Filter
Apply Filters
Mastodon