如何获取事件的wordpress's oEmbed对象加载在TinyMCE
How to get event of wordpress's oEmbed object is loaded in TinyMCE
我将链接粘贴到WordPress TinyMCE编辑器中,像这样:https://gist.github.com/kolesnikof/642ae1317cc23b87977f/
然后得到oEmbed对象:http://prntscr.com/7wlsrz通过在functions.php中添加这样的代码:
<?php
/**
* Usage:
* Paste a gist link into a blog post or page and it will be embedded eg:
* https://gist.github.com/2926827
*
* If a gist has multiple files you can select one using a url in the following format:
* https://gist.github.com/2926827?file=embed-gist.php
*/
wp_embed_register_handler( 'gist', '/https:'/'/gist'.github'.com'/('d+)('?file=.*)?/i', 'wp_embed_handler_gist' );
function wp_embed_handler_gist( $matches, $attr, $url, $rawattr ) {
$embed = sprintf(
'<script src="https://gist.github.com/%1$s.js%2$s"></script>',
esc_attr($matches[1]),
esc_attr($matches[2])
);
return apply_filters( 'embed_gist', $embed, $matches, $attr, $url, $rawattr );
}
?>
我的问题:我想突出oEmbed代码,但我不知道事件处理程序触发ajax完成加载oEmbed内容
我解决了问题,但决策并不优雅:
添加脚本到oEmbed对象
if ( is_admin() ) $embed .= '<script>window.top.Prism.highlightElement(document.getElementsByTagName(''pre'')[0]);</script>';
相关文章:
- 引用对象中的通用值
- jQuery匹配JSON对象的部分文本
- 节点导出返回一个空对象
- 如何在Javascript中将JSon对象转换为数组
- 我可以在json对象中添加一个函数吗
- 使用JS将数组转换为json对象
- 全局变量和全局对象的属性之间有什么区别吗
- 比较从函数和生成的日期对象
- Javascript,访问一个主要对象模块模式中的每个对象
- 如果使用 lodash 将属性存在于另一个对象中,则向对象添加属性
- 调整窗口大小时,可拖动的对象会出现在容器外部
- 如何使用javascript从主svg对象动态创建svg视图框
- 如何使用json将对象列表从java转换为javascript
- 序列化数据属性中对象的最可靠方法
- 如何访问声音管理器2创建的声音对象
- FabricJs-限制主对象内添加对象的移动区域
- Javascript(Angular)从一个对象数组到第二个数组查找值
- 值对象在某个变量发生更改后发生更改
- 如何为json对象中的段发送array[]
- 如何获取事件的wordpress's oEmbed对象加载在TinyMCE