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 t …

Author:Florian Brinkmann (profile at wordpress.org)
WordPress version required:5.6
WordPress version tested:5.6.4
Plugin version:1.0.0
Added to WordPress repository:16-12-2020
Last updated:16-12-2020
Rating, %:0
Rated by:0
Plugin URI:
Total downloads:210
plugin download
Click to start download

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