Giter Club home page Giter Club logo

Comments (4)

fabiankaegy avatar fabiankaegy commented on August 15, 2024

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.

fabiankaegy avatar fabiankaegy commented on August 15, 2024

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.

tlovett1 avatar tlovett1 commented on August 15, 2024

Sounds like the right approach to me.

from wp-scaffold.

fabiankaegy avatar fabiankaegy commented on August 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.