kmdigital / acf-block-builder
ACF Builder 的包装器,用于注册 ACF 块。
1.5.0
2019-06-16 01:01 UTC
Requires
- roots/acorn: dev-master
- roots/support: dev-master
- stoutlogic/acf-builder: ^1.8
Requires (Dev)
README
ACF Builder 的轻量级包装器,用于注册 ACF 块。默认用法是 Sage 10,但其他主题也支持。
安装
在你的主题或插件中
$ composer require kmdigital/acf-block-builder
使用方法
use KMDigital\AcfBlockBuilder\Block; $testimonial = new Block('testimonial'); $testimonial ->addWysiwyg('content') ->addText('person') ->addText('where') ->addText('when'); add_action('acf/init', function () use ($testimonial) { acf_add_local_field_group($testimonial->build()); });
你可以使用额外的方法来设置和覆盖块选项
$testimonial // Allows you to set a custom title for the block. // Default is the block name/slug titlized. ->setTitle('Review') // Allows you to set the block description. Default is none. ->setDescription('A review with meta.') // Allows you to set the block description. Default is a block. ->setIcon('star-half') // Allows you to set the block category. Default is none. ->setCategory('common') // Allows you to set the block keywords. Default is none. ->setKeywords('review', 'testimonial') // Allows you to use a different rendering function. Default is Sage 10 (Acorn). ->renderWith(['Me\\View\\', 'render']);
默认渲染函数
默认渲染函数适用于 Sage 10 或使用 Acorn 的项目。它会在 resources/views/blocks
(如果 resources/views
是你的默认视图路径)中搜索模板。