Last active
February 18, 2022 14:54
-
-
Save markhowellsmead/f8a771c2f6198e127219697c316b9d71 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:group {"backgroundColor":"secondary","textColor":"primary","layout":{"inherit":true}} --> | |
<div class="wp-block-group has-primary-color has-secondary-background-color has-text-color has-background"> | |
<!-- wp:media-text --> | |
<div class="wp-block-media-text alignwide is-stacked-on-mobile"> | |
<figure class="wp-block-media-text__media"></figure> | |
<div class="wp-block-media-text__content"> | |
<!-- wp:paragraph --> | |
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Officia magni, aut esse aliquam omnis voluptate placeat nemo dolorem totam beatae, ipsa atque veritatis impedit tempora quaerat, perferendis accusamus! Ab, ipsam.</p> | |
<!-- /wp:paragraph --> | |
</div> | |
</div> | |
<!-- /wp:media-text --> | |
</div> | |
<!-- /wp:group --> |
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 GroupWithMediaText | |
{ | |
public function run() | |
{ | |
add_filter('init', [$this, 'register']); | |
} | |
public function register() | |
{ | |
ob_start(); | |
get_template_part('partials/patterns/group-with-media-text'); | |
$content = ob_get_contents(); | |
ob_end_clean(); | |
register_block_pattern( | |
'sht/group-with-media-text', | |
[ | |
'title' => __('Group with media and text', 'sha'), | |
'categories' => ['text'], | |
'content' => $content, | |
] | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment