当前位置:网站首页 > WordPress教程 > 正文
WordPress 使用 iframe 嵌入Github Gist代码
作者:xlnxin发布时间:2021-04-15分类:WordPress教程浏览:382
导读:在网上看到在Gists地址后边加上pibb就可以生成...
在网上看到在Gists地址后边加上pibb就可以生成调用的Html,刚好In笔记需要调用一些Gist的代码,就写了下边的代码。
在主题functions.php加入代码:
123456789 | /** * WordPress 使用 iframe 嵌入Github Gist代码 * https://www.wpdaxue.com/wp-iframe-handler-gist.html */function wp_iframe_handler_gist( $matches, $attr, $url, $rawattr ) {$iframe = '<iframe width="100%" height="300" src="https://gist.github.com/'. esc_attr($matches[1]) .'/'. esc_attr($matches[2]) . '.pibb" frameborder=0 ></iframe>';return apply_filters( 'iframe_gist', $iframe, $matches, $attr, $url, $rawattr );}wp_embed_register_handler( 'gist_iframe', '#https://gist.github.com/(.*?)/([\d]+)#i', 'wp_iframe_handler_gist' ); |
使用的时候,只需要单独起一行,然后直接插入对应的地址即可,比如:
https://gist.github.com/ccbikai/11216526
相关推荐
- 小程序和H5中canvas卡顿的性能优化方向和实践
- 微信小程序反编译报SyntaxError: Unexpected token ‘}‘ 不完美的解决方法
- 解决小程序反编译出现 app-service.js
- PHP把textarea中的回车换行替换为br
- zblogphp使用GetArticleList、GetList函数调用热门文章列表
- 淘宝给大家发6.5元新年购物红包啦,不要嫌少还有很多优惠,快来领取吧!
- 抓包软件Fiddler命令行和HTTP断点调试
- 正则匹配任意字符(常用正则表达式的书写)
- PHP开启openssl的方法-解决ZBlog主题插件无法启用的问题
- WordPress自动截取限定数字的摘要
- WordPress教程排行
- 最近发表