gebruederheitz/wp-block-video-overlay
Composer 安装命令:
composer require gebruederheitz/wp-block-video-overlay
包简介
The backend helper for the video overlay block.
README 文档
README
see @gebruederheitz/wp-block-video-overlay
Usage
Registering the block
Given you have already initialized the gebruederheitz/wp-gutenberg-blocks BlockRegistrar somewhere:
\Gebruederheitz\GutenbergBlocks\BlockRegistrar::getInstance();
You will then simply have to instantiate a VideoOverlayBlock:
new \Gebruederheitz\GutenbergBlocks\VideoOverlay\VideoOverlayBlock();
Using consent management functionality
Managing user consent of third-party platforms is quite simple with this block
and @gebruederheitz/consent-tools.
To provide the editor scripts in
@gebruderheitz/wp-block-video-overlay
with a list of possible embed types, use the filter hook:
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; });
Changing the default embed provider
You can simply pass the default service's identifier to the constructor:
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")
Enabling video captions
Use the filter hook HOOK_CC_LANG_PREFS to provide an array of available
languages on your site to allow editors to input a language preset for Youtube
captions:
add_filter(VideoOverlayBlock::HOOK_CC_LANG_PREFS, function ($enabled) { /* ... */ return true; });
Editors may input a string in the Block Editor representing a language or locale slug (like "en", "en-GB", "en-US", "fr", "de-DE" etc.). The input is sanitized to only allow alphanumeric characters, dashes and underscores.
Defining additional attributes
Yes, there's a filter hook for that:
use Gebruederheitz\GutenbergBlocks\VideoOverlay\VideoOverlayBlock; add_filter(VideoOverlayBlock::HOOK_ATTRIBUTES, function ($attributes) { $attributes['myCustomAttribute'] = [ 'type' => 'string', 'default' => 'attribute default value', ]; return $attributes; })
Changing the block markup
You can override the template used by the block by simply putting a file into
wp-content/themes/{your-theme}/template-parts/blocks/video-overlay.php. The
block's attributes are accessible using get_query_var('attributeName'). Take
look at the default template as an example.
Alternatively you can filter & override the template partial path and gain even more control:
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);
gebruederheitz/wp-block-video-overlay 适用场景与选型建议
gebruederheitz/wp-block-video-overlay 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.27k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 gebruederheitz/wp-block-video-overlay 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gebruederheitz/wp-block-video-overlay 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.27k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-only
- 更新时间: 2021-07-08