Comments (4)
Thinking about this some more I think the API for this should be even simpler. The goal we should be aiming for is that patterns work the same way as page templates in core. They are completely self-contained to one file.
<?php
/**
* Pattern Name: Example Pattern
* Pattern Description: description
* Pattern Categories: common
*
* @package tenuptheme
*/
?>
<!-- wp:columns -->
<div class="wp-block-columns">
<!-- wp:column -->
<div class="wp-block-column">
<!-- wp:paragraph -->
<p>Example</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:column -->
<!-- wp:column -->
<div class="wp-block-column">
<!-- wp:paragraph -->
<p>Example</p>
<!-- /wp:paragraph -->
</div>
<!-- /wp:column -->
</div>
<!-- /wp:columns -->
This pattern file should be located in a folder named patterns
in the root of the theme. The theme then includes this file and converts it to this internally:
register_block_pattern(
"$textdomain/$pattern_filename",
array(
'title' => Example Pattern, // taken from the file header of the pattern
'description' => description, // taken from the file header of the pattern
'categories' => commom, // taken from the file header of the pattern
'content' => // the actual content of the pattern file;
)
);
from wp-scaffold.
This also aligns with what Core has planned for patterns so in the future we can remove this shim in favor of the core API:
WordPress/gutenberg#36751
The approach in this PR is exactly what I had in mind.
from wp-scaffold.
Sounds like the right approach to me.
from wp-scaffold.
We decided to abandon this approach in favor of waiting for core to implement it here: WordPress/gutenberg#36751
from wp-scaffold.
Related Issues (20)
- WordPress 6.1 Compatibility Tracking
- Fix support for CSS logical properties
- Add PHP Scaffold for CPTs and Taxonomies HOT 1
- Build an "Import on Visibility" and "Interaction" Helper HOT 1
- Ensure BFCache Eligibility
- Third-party Script Management
- Should WP Scaffold use GPLv2 instead of the MIT License? HOT 1
- Update css reset and some base styles
- WordPress 6.3 Compatibility Tracking
- Error: Cannot find module '@10up/babel-preset-default' on clean install HOT 4
- Headless scaffold
- PHPCS does not scan mu-plugins folder
- Add prettier / remove prettier from eslint config HOT 2
- Bump Node versions HOT 1
- Add opinionated code quality tools HOT 2
- Automate the process of renaming the theme and plugin to match the project name HOT 3
- Simplify scaffold HOT 3
- Headless theme
- Float based alignments are causing layout issues for adjacent blocks
- Enhance CSS reset with a custom reset.css file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wp-scaffold.