horttcore/wp-content-templates

为帖子类型设置默认块模板

1.0.2 2019-05-10 08:52 UTC

This package is auto-updated.

Last update: 2024-09-10 21:26:12 UTC


README

Gutenberg 可以定义新创建的帖子类型的默认块。

安装

$ composer require horttcore/wp-content-templates

文档

<?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'>] );

示例

<?php
use Horttcore\ContentTemplates\ContentTemplate;

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

变更日志

v1.0.2 - 2019/05/10

  • 小修复

v1.0.1 - 2019/05/10

  • 变更:构造函数中需要参数 $blocks
  • 改进文档

v1.0 - 2019/05/09

  • 初始版本