內容簡介
這是一個外掛,可為已在您的 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
最初版的發佈
開發者團隊
原文外掛簡介
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
