horttcore/wp-content-templates

Set default block templates for post types

Installs: 95

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

pkg:composer/horttcore/wp-content-templates

1.0.2 2019-05-10 08:52 UTC

This package is auto-updated.

Last update: 2025-09-10 23:46:18 UTC


README

Gutenberg is capabable for defining default blocks for a new created post type.

Installation

$ composer require horttcore/wp-content-templates

Documentation

<?php
/**
 * @param string $postType Post type
 * @param array $template Template
 * @param string $templateLock Lock template empty string, all or insert
 *      all — prevents all operations. It is not possible to insert new blocks, move existing blocks, or delete blocks.
 *      insert — prevents inserting or removing blocks, but allows moving existing blocks.
 */
ContentTemplate( string $postType, array $blocks [, string $templateLock <'insert'|'all'>] );

Example

<?php
use Horttcore\ContentTemplates\ContentTemplate;

new ContentTemplate('post', [
    [
        [ 'core/image', {} ],
        [ 'core/paragraph', { placeholder: 'Image Details' } ],
    ]
])->register();

Changelog

v1.0.2 - 2019/05/10

  • Small fix

v1.0.1 - 2019/05/10

  • Changed: Parameter $blocks is required in the constructor
  • Improved documentation

v1.0 - 2019/05/09

  • Initial release