meom/meom-cookiebot-embed

MEOM cookiebot 视频消息

安装: 333

依赖项: 0

建议者: 0

安全性: 0

星标: 0

关注者: 3

分支: 0

开放问题: 0

类型:wordpress-muplugin

1.1.1 2024-05-21 07:49 UTC

This package is auto-updated.

Last update: 2024-09-09 11:53:30 UTC


README

使用Cookiebot时,例如,YouTube视频可能会被Cookiebot阻止

此插件添加占位文本和链接到Cookiebot设置,用户可以在其中接受营销cookie。

请接受营销cookie观看此视频。

接受营销cookie后,视频将显示出来。

安装

注意,Composer包将此插件作为必须使用的插件安装在 mu-plugins 文件夹中。

使用Composer安装软件包。

composer require meom/meom-cookiebot-embed

或者,如果您想走在前沿

composer require meom/meom-cookiebot-embed:dev-main

样式

此插件不输出任何样式。以下是您主题样式中示例样式

.wp-block-embed__cookiebot-message {
    aspect-ratio: 16 / 9;
    background-color: #f2f2f2;
    display: grid;
    padding: 1rem;
    place-items: center;
    text-align: center;
}

过滤器

默认情况下,此插件只为视频嵌入块添加Cookiebot占位文本。

此条件可以通过 meom_cookiebot_embed_condition 过滤器进行更改。

为YouTube和Vimeo视频添加占位文本的代码示例

/**
 * Change condition when to show Cookiebot message.
 *
 * @param string $condition     Condition.
 * @param string $block_content The block content about to be appended.
 * @param array  $block         The full block, including name and attributes.
 */
function my_prefix_cookiebot_embed_condition( $condition, $block_content, $block ) {
    $condition = 'core/embed' === $block['blockName'] && ( 'youtube' === $block['attrs']['providerNameSlug'] || 'vimeo' === $block['attrs']['providerNameSlug'] );

    return $condition;
}
add_filter( 'meom_cookiebot_embed_condition', 'my_prefix_cookiebot_embed_condition', 10, 3 );

默认占位文本是 Oops! This video will not be shown because you have disabled the marketing cookies. To see the video, <a href="%s">accept marketing cookies</a>.。更改该消息的代码示例

/**
 * Filters the placeholder text added to the embed block.
 *
 * @param string $text Placeholder text.
 */
function my_prefix_cookiebot_placeholder_text( $text ) {
    $text = __( 'Oops! This embed will not be shown because you have disabled the marketing cookies. To see the embed, <a href="%s">accept marketing cookies</a>.', 'kala' );
    return $text;
}
add_filter( 'meom_cookiebot_placeholder_text', 'my_prefix_cookiebot_placeholder_text' );
``