PHP code example of kaiseki / wp-block-content-filter

1. Go to this page and download the library: Download kaiseki/wp-block-content-filter 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/ */

    

kaiseki / wp-block-content-filter example snippets


use Kaiseki\WordPress\BlockContentFilter\Filter\CoreHeadingClassFilter;
use Kaiseki\WordPress\BlockContentFilter\Filter\CoreParagraphClassFilter;

return [
    'block_content_filter' => [
        // Each key is an fnmatch pattern matched against the block's blockName.
        // Each value is a list of BlockContentFilterInterface class-strings (or
        // instances) run as a pipeline over the rendered block HTML.
        'core/paragraph' => [
            CoreParagraphClassFilter::class,
        ],
        'core/heading' => [
            CoreHeadingClassFilter::class,
        ],
    ],
];

use Kaiseki\WordPress\BlockContentFilter\DisableFullscreenMode;

return [
    'hook' => [
        'provider' => [
            DisableFullscreenMode::class,
        ],
    ],
];

use Kaiseki\WordPress\BlockContentFilter\BlockContentFilterInterface;

final class MyFilter implements BlockContentFilterInterface
{
    /**
     * @param array<mixed> $block
     */
    public function __invoke(string $content, array $block): string
    {
        return $content . '<!-- filtered -->';
    }
}