WP Manifestindependent plugin directory
manifest / editor / wordpress-dynamic-block

Dynamic Block

This WordPress plugin adds a dynamic block which renders an output of a selected php callback function added via a filter hook.

★ 1stars
159composer installs

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/piotrpress/wordpress-dynamic-block/archive/refs/heads/master.zip

On Packagist as piotrpress/dynamic-block:

composer require piotrpress/dynamic-block
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

This WordPress plugin adds a dynamic block which renders an output of a selected php callback function added via a filter hook.

Dynamic block in WordPress block editor view

Usage

Add callback functions via piotrpress/dynamic_block/callbacks filter:

add_filter( 'piotrpress/dynamic_block/callbacks', function( array $callbacks ) : array {
    $callbacks[ 'Current date' ] = fn( array $attributes ) : string => date( 'Y-m-d H:i:s' );
    return $callbacks;
} );

or if you would like to translate the label:

add_filter( 'piotrpress/dynamic_block/callbacks', function( array $callbacks ) : array {
    $callbacks[ 'current_date' ] = [
        'label' => __( 'Current date', 'textdomain' ),
        'value' => fn( array $attributes ) : string => date( 'Y-m-d H:i:s' );
    ];
    return $callbacks;
} );

Requirements

PHP >= 7.4 version.

License

GPL v3 or later