Skip to content

Instantly share code, notes, and snippets.

View annezazu's full-sized avatar

annezazu

View GitHub Profile
@annezazu
annezazu / template-specific-pattern
Created February 9, 2023 20:18
Register patterns for specific template types
register_block_pattern(
'wp-my-theme/404-template-pattern',
array(
'title' => __( '404 Only template pattern', 'wp-my-theme' ),
'templateTypes' => array( '404' ),
'content' => '<!-- wp:paragraph {"align":"center","fontSize":"x-large"} --><p class="has-text-align-center has-x-large-font-size">404 pattern</p><!-- /wp:paragraph -->',
)
);
@annezazu
annezazu / content lock pattern
Last active April 18, 2024 16:45
An example of a pattern with content locking implemented.
function register_block_patterns() {
if ( class_exists( 'WP_Block_Patterns_Registry' ) ) {
$content = '<!-- wp:group {"templateLock":"contentOnly","align":"wide","layout":{"type":"constrained"}} -->
<div class="wp-block-group alignwide"><!-- wp:image {"align":"wide","id":501,"sizeSlug":"full","linkDestination":"none","style":{"color":{"duotone":["#1a4548","#ffffff"]}}} -->
<figure class="wp-block-image alignwide size-full"><img src="https://s.w.org/patterns/files/2021/06/Group-17-scaled.jpg" alt="Image of a woman being carried through the air by swans." class="wp-image-501"/></figure>
<!-- /wp:image -->
<!-- wp:columns {"verticalAlignment":"center","align":"wide"} -->
@annezazu
annezazu / event-recap.php
Created July 11, 2022 18:08
FSE Outreach Call For Testing Event Recap Starter Pattern
<?php
/**
* Title: Event Recap
* Slug: twentytwentytwo/event-recap
* Block Types: core/post-content
* Post Types: post
* Categories: featured, text
*/
?>
@annezazu
annezazu / new-event-announcement.php
Last active July 11, 2022 18:07
FSE Outreach Call For Testing New Event Starter Pattern
<?php
/**
* Title: New Event Announcement
* Slug: twentytwentytwo/new-event-announcement
* Block Types: core/post-content
* Post Types: post
* Categories: featured, text
*/
?>
@annezazu
annezazu / Theme.json example for simple presets
Last active February 17, 2022 10:10
Theme.json example showing how you can set up different simple presets for various blocks.
{
"schema": "https://schemas.wp.org/trunk/theme.json",
"version": 2,
"settings": {
"layout": {
"contentSize": "800px",
"wideSize": "1000px"
},
"color": {
"custom": true,
@annezazu
annezazu / locked pattern example
Last active April 18, 2024 00:38
A pattern that demonstrates how block locking can work.
function register_block_patterns() {
if ( class_exists( 'WP_Block_Patterns_Registry' ) ) {
$content = '<!-- wp:cover {"dimRatio":70,"customGradient":"linear-gradient(135deg,rgb(255,255,255) 20%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(253,253,253) 80%)","isDark":false,"align":"full","lock":{"remove":false,"move":true}} -->
<div class="wp-block-cover alignfull is-light"><span aria-hidden="true" class="has-background-dim-70 wp-block-cover__gradient-background has-background-dim has-background-gradient" style="background:linear-gradient(135deg,rgb(255,255,255) 20%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(253,253,253) 80%)"></span><div class="wp-block-cover__inner-container"><!-- wp:heading {"textAlign":"center","style":{"typography":{"lineHeight":"1.2"}},"textColor":"grey","lock":{"remove":true,"move":true}} -->
<h2 class="has-text-align-center has-grey-color has-text-color" id="book-your-next-adventure" st