Last active
February 18, 2022 14:54
-
-
Save markhowellsmead/fd3aa3bc0482730225fc6ede24114985 to your computer and use it in GitHub Desktop.
Register a block pattern using PHP. Fits into the Theme structure of https://github.com/SayHelloGmbH/hello-roots/
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
<!-- wp:columns {"backgroundColor":"secondary"} --> | |
<div class="wp-block-columns has-secondary-background-color has-background"><!-- wp:column --> | |
<div class="wp-block-column"><!-- wp:paragraph --> | |
<p>One</p> | |
<!-- /wp:paragraph --></div> | |
<!-- /wp:column --> | |
<!-- wp:column --> | |
<div class="wp-block-column"><!-- wp:paragraph --> | |
<p>Two</p> | |
<!-- /wp:paragraph --></div> | |
<!-- /wp:column --> | |
<!-- wp:column --> | |
<div class="wp-block-column"><!-- wp:paragraph --> | |
<p>Three</p> | |
<!-- /wp:paragraph --></div> | |
<!-- /wp:column --></div> | |
<!-- /wp:columns --> |
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
<?php | |
namespace SayHello\Theme\Pattern; | |
/** | |
* Manage single block pattern | |
* | |
* @author Say Hello GmbH <hello@sayhello.ch> | |
*/ | |
class ThreeColumns | |
{ | |
public function run() | |
{ | |
add_filter('init', [$this, 'register']); | |
} | |
public function register() | |
{ | |
ob_start(); | |
get_template_part('partials/patterns/three-columns'); | |
$content = ob_get_contents(); | |
ob_end_clean(); | |
register_block_pattern( | |
'sht/three-columns', | |
[ | |
'title' => __('Simple three-column layout', 'sha'), | |
'categories' => ['text'], | |
'content' => $content, | |
] | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment