我正在将我的Jplayer代码嵌入到我的网站中,但是在wordpress安装中已经存在jquery,但是当我在代码中复制我的代码时被破坏,因为它没有显示带有x的音量图标。当我包含外部jquery脚本时,它会打破entrie网站,但播放器正常工作。有没有更好的方式将jPlayer加入我的WordPress站点?Jplayer和wordpress 3.6.x
0
A
回答
1
jPlayer script enqueueing 必须按照WordPress规则播放。最简单的(也许是唯一的)方法是使用Shortcode。有很多开发人员,主要是主题开发人员,他们忽略了这个we don't dequeue the bundled jQuery version并加载了某个CDN的任何版本(至少,我们不知道我们在做什么)。
下面是一个粗略的测试,短代码回调函数必须被抛光很多。
public function plugin_setup() // hooked into plugins_loaded
{
add_action('wp_enqueue_scripts', array($this, 'enqueue'));
add_shortcode('jplayer', array($this, 'shortcode'));
}
public function enqueue()
{
wp_register_script(
'sj-jplayer',
$this->plugin_url . 'js/jquery.jplayer.min.js',
array('jquery'), // <------- Dependencies
false,
true
);
wp_register_style('sj-skin', $this->plugin_url . 'skin/blue.monday/jplayer.blue.monday.css');
wp_enqueue_script('sj-jplayer');
wp_enqueue_style('sj-skin');
}
public function shortcode($atts, $content)
{
ob_start();
require_once('html-shortcode.php');
$var = ob_get_clean();
return $var;
}
文件html-shortcode
是基本适应像this demo代码:
<?php
/*
* Prints the shortcode
*/
?>
<script type="text/javascript">
jQuery(document).ready(function($) // <------ WP noConflict
{
$("#jquery_jplayer_1").jPlayer({});
});
</script>
<div id="jquery_jplayer_1" class="jp-jplayer"></div>
我测试了这个jPlayer简码内的另一个,做了jScrollPane,和它的工作在iPad上。
+0
我实际上所做的是将播放器放入iframe中。它不干净,但它的工作 –
相关问题
- 1. cocos2d-x 3.6 PhysicsJointFixed error
- 2. ComponentFeedbackPanel与Firefox 3.6.x
- 3. Wordpress 3.6中的错误php
- 4. Pip in OS X 12/Python 3.6
- 5. jPlayer和Shoutcast配置
- 6. 在Netty 3.6.x中读取XML数据
- 7. Eclipse的安装3.6.x的对m2eclipse的
- 8. wordpress 3.6使用什么存储引擎?
- 9. 在WordPress 3.6中嵌入链接
- 10. WordPress的3.6:页下的类别
- 11. 升级到wordpress 3.6后的错误
- 12. WordPress 3.6中Mediaelement.js的重定向选项
- 13. 错误与WPAchemy上升级到WordPress 3.6
- 14. 无法加载css在wordpress 3.6
- 15. 使用jpa2和hibernate生产实例的persistence.xml示例3.6.x
- 16. jplayer和几个接口
- 17. 亚马逊Cloudhosting和JPlayer
- 18. FF 3.6和jQuery 1.7和removeEventListener()
- 19. Wordpress CMB2 qTranslate-x
- 20. JPlayer + MVC3 + IE9
- 21. WordPress 3.x和超级管理员
- 22. 蟒蛇3.6安装和lib64
- 23. Python 3.6 Tkinter和多处理
- 24. wordpress 3.x +日历
- 25. 使用python 3.6和pyomo表达式生成中的错误3.6
- 26. 使用python 3.6和anaconda在Windows 10上安装opencv 3.6
- 27. IE 6和FireFox 3.6中的文本框大小不同3.6
- 28. ASP.Net更新Jplayer
- 29. jPlayer + Rails 3.1.3 swfPath?
- 30. jPlayer mp3 not loading
我不能遗憾的代码仍然被网站所有者隐藏。但它的基本代码和播放器一次不在wordpress中,包括外部jquery文件。 –
查看JavaScript错误控制台当您使用现有的jQuery时究竟发生了什么事情 –