-
-
Save lmm214/5db1a1702a880baecba5 to your computer and use it in GitHub Desktop.
WordPress 使用 iframe 嵌入Github Gist代码,使用方法单独起一行写入: https://gist.github.com/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/(.*?)/([\w]+)#i', 'wp_iframe_handler_gist' ); | |
//七牛云缓存:新建空间,镜像源设置成“https://gist.github.com/”,然后把上面代码中的这句链接改成“https://你的空间项目.qiniudn.com/” |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/(.*?)/([\d]+)#i 改成 #https://gist.github.com/(.*?)/([\w]+)#i
因为原链接是: https://gist.github.com/ccbikai/11216526
现在是:https://gist.github.com/lmm214/5db1a1702a880baecba5