[WordPress] 外掛分享: Patterns block

首頁外掛目錄 › Patterns block
⚠ 此外掛已下架 — 不再更新維護,建議勿安裝。
全新外掛
安裝啟用
尚無評分
1920 天前
最後更新
問題解決
WordPress 5.6+ PHP 7.3+ v1.0.0 上架:2020-12-15

內容簡介

這是一個外掛,可為已在您的 WordPress 安裝中註冊的區塊樣式添加變化區塊。這樣,您就可以直接從區塊插入器中添加變化區塊,或使用 / 命令添加。

當插入樣式區塊時,您可以從所有樣式的列表中選擇您想要的樣式。

此外掛的開發在 GitHub 上進行

過濾器

此外掛有兩個過濾器:

/**
* 允許設置預設變化的過濾器。
* 從而,樣式區塊就不能從插入器中選擇,
* 只能選擇變化區塊。
*
* @param string 要用作預設值的變化名稱。
*/
$default_variation_name = (string) apply_filters(
'krautpress_patterns_block_default_variation_name',
''
);

/**
* 過濾器,用於在區塊中顯示/使用變化。
*
* @param array $variation_data {
* 變化資料物件陣列,物件如下:
* (object) [
* 'name' => $pattern['name'],
* 'title' => $pattern['title'],
* 'attributes' => (object) [
* 'pattern' => $pattern['name'],
* ],
* ];
*
* $pattern['name'] 必須與樣式的 'name' 屬性相符。
* $pattern['title'] 會顯示給使用者。
* }
*/
$variation_data = (array) apply_filters(
'krautpress_patterns_block_variations_data',
$variation_data
);

0.1.0

最初版的發佈

開發者團隊

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

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

原文外掛簡介

Plugin that adds a block with variations for the registered block patterns in your installation. With that, you can add block patterns directly from the block inserter or with the / command.
When inserting the Patterns block, you can select the pattern you want from a list of all patterns.
Plugin development happens on GitHub
Filters
The plugin has two filters:
/**
* Filter that allows to set a default variation.
* With that, the patterns block cannot be selected from the inserter,
* but only the variations.
*
* @param string Name of the variation to use as default.
*/
$default_variation_name = (string) apply_filters(
'krautpress_patterns_block_default_variation_name',
''
);

/**
* Filter the variations to show/use in the block.
*
* @param array $variation_data {
* Array of variation data objects. Object looks like that:
* (object) [
* 'name' => $pattern['name'],
* 'title' => $pattern['title'],
* 'attributes' => (object) [
* 'pattern' => $pattern['name'],
* ],
* ];
*
* $pattern['name'] must match the 'name' of a pattern.
* $pattern['title'] is displayed to the user.
* }
*/
$variation_data = (array) apply_filters(
'krautpress_patterns_block_variations_data',
$variation_data
);

0.1.0
Initial release

延伸相關外掛

文章
Filter
Apply Filters
Mastodon