piotrpress/dynamic-block

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

Installs: 108

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:wordpress-plugin

pkg:composer/piotrpress/dynamic-block

v0.3.0 2025-10-06 15:59 UTC

This package is auto-updated.

Last update: 2025-10-06 15:59:37 UTC


README

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