A block library for WordPress theme.
composer require kunoichi/block-library
First, load autoloader in your theme's functions.php
.
require __DIR__ . '/vendor/autoload.php';
2nd, enable block library.
Kunoichi\BlockLibrary::enable();
If you want select blocks to be enabled, explicitly delcare the class names.
Kunoichi\BlockLibrary::enable( [
\Kunoichi\BlockLibrary\Blocks\PostList::class,
\Kunoichi\BlockLibrary\Blocks\BubbleBlock::class,
] );
Available block classes are located in src/Kunoichi/BlockLibrary/Blocks
.
Or else, you can exclude unwanted blocks with 2nd parameter.
// 1st param is inclusive, 2nd param is exclusive.
Kunoichi\BlockLibrary::enable( [], [
\Kunoichi\BlockLibrary\Blocks\PriceTable::class,
] );
All blocks are registered via PHP Class and JavaScripts corresponding, thus 1 block has at least 1 php file and 1 js file.
PHP files are located at src/Kunoichi/BlockLibrary/Blocks, JavaScript files are also located at assts/js/blocks;
18 blocks are available.
Styled alert blocks.
Speech bubble with avatar.
Card style link.
Parents: available only in kunoichi/cards
Display card style links. Helpful as category link list and so on.
Clipboard button for copying text.
Display UI parts to invoke user's action.
Dynamic Block: see CallToAction
Definition Term.
Parents: available only in kunoichi/definition-list
Definition Description.
Parents: available only in kunoichi/definition-list
Definition list.
Same as Oembed link block, but this link is referred as post ID.
Dynamic Block: see InternalLink
Display offer list of products with price, links, and spec.
Title, price, and specs of an offer.
Parents: available only in kunoichi/offer
Action link for offer block.
Parents: available only in kunoichi/offer
Product offer with price, link, and spec. Helpful for promoting external products.
Parents: available only in kunoichi/offer-list
Panel block for emphasized and separated contents.
Display post list in various format.
Dynamic Block: see PostList
Display price table. Insert 3 or 4 items.
Price item in price tables.
Parents: available only in kunoichi/price-table
Enhanced group block which supports background.
Step Block
Parents: available only in kunoichi/steps
Step by step how-tos. Ready for JSON-LD.
Display testimonials list.
Dynamic Block: see Testimonials
Tile item in tiled grid.
Parents: available only in kunoichi/tiled-grid
Grid style layout of panel items. Ready for text & background colors.
Display TOC extracted from Heading tags in post content.
You can enable widgets in the same way as blocks.
\Kunoichi\BlockLibrary::widgets();
This method also has $includes
and $excludes
params.
This library is not plugin, so it does no effect by itself. Please make a empty theme and load from it.
This library build assets with npm.
# Install npm.
npm install
# Build assets.
npm run package
# Watch changes.
npm run watch
This library is licensed under GPL 3.0 and later.
© 2019 Kunoichi INC.