Last active
April 18, 2024 00:38
-
-
Save annezazu/acee30f8b6e8995e1b1a52796e6ef805 to your computer and use it in GitHub Desktop.
A pattern that demonstrates how block locking can work.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" style="line-height:1.2">Book your next adventure</h2> | |
<!-- /wp:heading --> | |
<!-- wp:buttons {"layout":{"type":"flex","justifyContent":"center","orientation":"horizontal"},"lock":{"remove":true,"move":false}} --> | |
<div class="wp-block-buttons"><!-- wp:button {"textColor":"white","style":{"border":{"radius":"10px"}},"className":"is-style-outline"} --> | |
<div class="wp-block-button is-style-outline"><a class="wp-block-button__link has-white-color has-text-color" href="#0" style="border-radius:10px">Find yours</a></div> | |
<!-- /wp:button --></div> | |
<!-- /wp:buttons --></div></div> | |
<!-- wp:paragraph {"align":"center","style":{"typography":{"fontStyle":"italic","fontWeight":"200"}},"textColor":"grey","lock":{"remove":false,"move":true}} --> | |
<p class="has-text-align-center has-grey-color has-text-color" style="font-style:italic;font-weight:200">Create moments you will remember forever</p> | |
<!-- /wp:paragraph --> | |
<!-- /wp:cover -->'; | |
register_block_pattern( | |
'custompattern/call-to-action-adventure', | |
array( | |
'title' => __( 'Call to Adventure', 'textdomain' ), | |
'description' => _x( 'A call to adventure.', 'Block pattern description', 'textdomain' ), | |
'content' => trim($content), | |
'categories' => array( 'buttons' ), | |
'keywords' => array( 'cta' ), | |
'viewportWidth' => 1400, | |
'blockTypes' => array( 'core/buttons' ), | |
) | |
); | |
} | |
} | |
add_action( 'init', 'register_block_patterns' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment