php - 如何将 ShortCode 转换为 Gutenberg Block?
问题描述
我在functions.php中有简码:
function video( $atts, $content = null ) {
return '<div class="videoWrapper"><iframe width="1280" height="720" src="https://www.youtube.com/embed/' .$content. '" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>';
}
add_shortcode( 'video', 'video' );
我用它作为:
[video]videoID[/video]
输出是:
<div class="videoWrapper">
<iframe width="1280" height="720" src="https://www.youtube.com/embed/videoID" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen>
</iframe>
</div>
我有奇怪的键盘,我不知道如何输入[]
,所以每当我需要它时,我需要谷歌它或打开现有帖子以复制它并发布短代码,所以如果我可以预定义古腾堡块会容易得多点击添加[video]videoID[/video]
或[video="videoID"]
解决方案
推荐阅读
- arrays - 在 Perl 中生成数据结构
- python - 以自然方式排序字符串列表
- ansible - 在 Playbook 中使用条件语句根据 IP 地址执行
- angular - 如何以角度正确删除 html 表格元素?
- javascript - 如何使用javascript计算表面积?
- c++11 - windows makefile 中的 cl 选项是否会接受 -std=c++11 标志?
- java - 来自无限 Java 流的通量端点
- configuration - 通过 appsettings.json 为 Application Insights 配置 Serilog
- java - 软件内的数据库集成
- java - 如何在异步任务的 android 应用程序中添加 Internet 连接问题对话框