This is not
the block
you are looking for
Arūnas Liuiza
WordPress Core Contributor, WordPress Kaunas Meetup co-organizer, WordCamp (Lithuania, Riga, Stockholm, Jyväskylä, Oslo, Norrköping) speaker and one of the editors of the Lithuanian WordPress translation team and co-host of Kodo Poetai podcast.
Free & premium WordPress plugin developer
Software Engineer at
For Developers
deployer.seravo.com - a service that syncs WordPress plugins from GitHub to WordPress.org automatically.
TryoutWP.com - a service to spin up live temporary demo sites for WordPress plugins and themes.
Learn Javascript,
DEEPLY?
Damn,
that's HARD...
How to survive in Gutenberg world
as a PHP developer
Use ACF, Luke
No, really.
/whois GutenFactory
- An early attempt on PHP-based Gutenberg management
- Built by yours truly
- Discontinued
Sample
add_filter( 'gutenfactory_blocks', 'my_awesome_block' );
function my_awesome_block( $blocks ) {
$blocks['arunas/my_awesome_block'] = [
'name' => 'My Awesome Block',
'category' => 'common',
'style' => plugins_url( 'my-awesome-block.css', __FILE__ ),
'editor_style' => plugins_url( 'my-awesome-block-editor.css', __FILE__ ),
'callback' => 'my_awesome_block_render',
'fields' => [
// define the fields here.
]
];
}
/whois ACF
Sample
add_action('acf/init', 'my_register_blocks');
function my_register_blocks() {
// check function exists.
if( function_exists('acf_register_block_type') ) {
// Register a testimonial block.
acf_register_block_type(array(
'name' => 'testimonial',
'title' => __('Testimonial'),
'description' => __('A custom testimonial block.'),
'render_template' => 'template-parts/blocks/testimonial/testimonial.php',
'category' => 'formatting',
));
}
}
/whois ACF Builder
- A PHP Library to easily build ACF fields via code
- A more straightforward alternative to ACF JSON files
Sample
$banner = new StoutLogic\AcfBuilder\FieldsBuilder('banner');
$banner
->addText('title')
->addWysiwyg('content')
->addImage('background_image')
->setLocation('block', '==', 'acf/testimonial')
->or('block', '==', 'acf/anotherone');
add_action('acf/init', function() use ($banner) {
acf_add_local_field_group($banner->build());
});
/whois Lazy Blocks
- a Gutenberg blocks visual constructor
- The ACF of Gutenberg age
- UI based, but has an option to export a PHP snippet
Sample
if ( function_exists( 'lazyblocks' ) ) :
lazyblocks()->add_block( array(
'title' => 'Custom block',
'slug' => 'lazyblock/custom-block',
'supports' => array(
'html' => false,
'multiple' => true,
),
'controls' => array(
// define fields
),
'code' => array(
// editor/frontend templates or callbacks, assets
),
) );
endif;
Questions?
This is not the block you're looking for
By Arūnas Liuiza
This is not the block you're looking for
WordPress Meetup Kaunas #41
- 1,367