Block Pattern Plugin presentation
written by: Jeff McNearBlock Pattern Plugin presentation
On Thursday September 29 2022 we resumed in person meetings!
Here are the slides for that presentation
Click below to download the sample plugin:
Here is the plugin code in its’ entirety
<?php
/**
* Plugin Name: Bill Murray Pattern
* Description: Bill Murray pattern demo
* Version: 1.05
* Author: Jeff McNear
*/
/**
* Register Custom Block Pattern Styles
*/
//https://wpblockz.com/tutorial/remove-default-block-patterns-from-wordpress/
add_action('init', function() {
remove_theme_support('core-block-patterns');
});
// adding a new pattern category
register_block_pattern_category(
'bill',
array( 'label' => __( 'Bill Murray', 'bmp' ) )
);
//https://awhitepixel.com/blog/gutenberg-block-patterns-a-developers-look/
add_action('init', function() {
if (!function_exists('register_block_pattern')) {
return;
}
// starts the pattern
register_block_pattern('bmp/bill-murray-bio', [
'title' => __('Bill Murray Bio', 'bmp'),
'keywords' => ['Bill Murray, bio'],
'categories' => ['featured' , 'bill'],
'viewportWidth' => 1000,
'content' => "
<!-- wp:columns --><div class=\"wp-block-columns\"><!-- wp:column {\"width\":\"66.66%\"} --><div class=\"wp-block-column\" style=\"flex-basis:66.66%\"><!-- wp:heading --><h2>A new Pattern</h2><!-- /wp:heading --><!-- wp:paragraph --><p>some descriptive text</p><!-- /wp:paragraph --><!-- wp:social-links --><ul class=\"wp-block-social-links\"><!-- wp:social-link {\"service\":\"facebook\"} /--><!-- wp:social-link {\"service\":\"youtube\"} /--><!-- wp:social-link {\"service\":\"twitter\"} /--><!-- wp:social-link {\"service\":\"linkedin\"} /--></ul><!-- /wp:social-links --></div><!-- /wp:column --><!-- wp:column {\"width\":\"33.33%\"} --><div class=\"wp-block-column\" style=\"flex-basis:33.33%\"><!-- wp:image {\"sizeSlug\":\"large\"} --><figure class=\"wp-block-image size-large\"><img src=\"https://www.fillmurray.com/g/400/400\" alt=\"\"/></figure><!-- /wp:image --></div><!-- /wp:column --></div><!-- /wp:columns -->\n
",
]);
// ends the pattern
}); // ends the function