PHP code example of gebruederheitz / wp-block-video-overlay

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

    

gebruederheitz / wp-block-video-overlay example snippets


\Gebruederheitz\GutenbergBlocks\BlockRegistrar::getInstance();

new \Gebruederheitz\GutenbergBlocks\VideoOverlay\VideoOverlayBlock();

use Gebruederheitz\GutenbergBlocks\VideoOverlay\VideoOverlayBlock;

add_filter(VideoOverlayBlock::HOOK_EMBED_TYPES, function ($embedTypes) use $services {
    $embedTypes[''] = ['displayName' => 'internal'];

        foreach ($services as $serviceId => $service) {
            $embedTypes[$serviceId] = [
                'displayName' => $service['prettyName'] ?? $serviceId,
            ];
        }

        return $embedTypes;
});

use Gebruederheitz\GutenbergBlocks\VideoOverlay\VideoOverlayBlock;

new VideoOverlayBlock();   // Default: 'youtube' service (data-ghct-src and data-ghct-type="youtube")
new VideoOverlayBlock(''); // Default: no consent management (src and no data-ghct-src)
new VideoOverlayBlock('vimeo') // Default: 'vimeo' service (data-ghct-src and data-ghct-type="vimeo")

add_filter(VideoOverlayBlock::HOOK_CC_LANG_PREFS, function ($enabled) {
    /* ... */
    return true;
});

use Gebruederheitz\GutenbergBlocks\VideoOverlay\VideoOverlayBlock;

add_filter(VideoOverlayBlock::HOOK_ATTRIBUTES, function ($attributes) {
    $attributes['myCustomAttribute'] = [
        'type' => 'string',
        'default' => 'attribute default value',
    ];
    
    return $attributes;
})

add_filter(VideoOverlayBlock::HOOK_TEMPLATE_PARTIAL, function (string $partial, string $type, array $attributes) {
    if ($type === 'overlay') {
        return get_theme_file_path('templates/block/video/video-type-overlay.php');
    }
    
    return $partial;
}, 3);