1. Go to this page and download the library: Download ralfhortt/wp-block library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ralfhortt / wp-block example snippets
use RalfHortt\WPBlock\BlockManifest;
(new BlockManifest(__DIR__ . '/build/blocks/blocks-manifest.php'))->register();
use RalfHortt\WPBlock\BlockDefaults;
// Static defaults
BlockDefaults::for('core/image')
->set('sizeSlug', 'large')
->set('linkDestination', 'media')
->register();
// Dynamic defaults with callbacks
BlockDefaults::for('core/image')
->set('sizeSlug', fn($metadata) => wp_is_mobile() ? 'thumbnail' : 'large')
->register();
// Multiple blocks with shared and individual defaults
BlockDefaults::for(['core/image', 'core/paragraph'])
->set('className', 'custom-block') // Both blocks
->set('core/image', 'sizeSlug', 'large') // Only core/image
->register();