脚本宝典收集整理的这篇文章主要介绍了php – 在WordPress中包含一个github jquery插件,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
1)将这些行添加到< head>我的header.PHP文件:
<script tyPE="text/javascript" src="https://ajax.GOOGLEapis.COM/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript" src="/path/to/jquery.countdown.js"></script>
2)在< / head>之间使用我想要的配置初始化插件和< body>在我的header.PHP文件中,在这种情况下:
<script> $(function() { VAR endDate = "November 30,2015 10:00:00"; $('.countdown.styled').countdown({ date: endDate,render: function(data) { $(this.el).htML("<div>" + this.leadingZeros(data.days,2) + " <span>days</span></div><div>" + this.leadingZeros(data.hours,2) + " <span>hours</span></div><div>" + this.leadingZeros(data.min,2) + " <span>minutes</span></div><div>" + this.leadingZeros(data.sec,2) + " <span>seconds</span></div>"); } }); }); </script>
<?PHP if(is_front_page() ) { ?> <div id="cdtoevent" class="countcont"> <div class="countdown styled"></div> </div> <?PHP } ?>
它完美无缺!
(如果我理解的话,wordpress默认使用jQuery,通过使用默认方法我让用户下载jquery两次,这也增加了我的加载时间,对吗?)
这意味着在我的functions.PHP文件中将jquery和我的脚本排入队列,如下所示:
wp_enqueue_script('jquery'); function add_cdtoevent() { wp_enqueue_script('countdown',get_template_directory_uri() . 'countdown.js',array('jquery'),true ); } add_action( 'wp_enqueue_scripts','add_cdtoevent' );
然后重复步骤2)和3)的默认方法,它根本不起作用!我尝试在步骤2)中包装我的jquery代码,就像这样:
jQuery(document).ready(function( $) { // $Works! You can test IT with next line if you like // console.LOG($); });
但它仍然无效.
如果有人可以提供帮助,我们将非常感激!
我目前在header.PHP中有什么:
<?PHP if(is_front_page() ) { ?> <div id="cdtoevent" class="countcont"> <div class="countdown styled"></div> </div> <?PHP } ?>
我目前在footer.PHP中有什么:
<script type="text/javascript"> $(function() { var endDate = "November 14,render: function(data) { $(this.el).html("<div>" + this.leadingZeros(data.days,2) + " <span>seconds</span></div>"); } }); }); </script>
我目前在我的functions.PHP中有什么:
// Loads JavaScript file with functionality specific to LCQC. wp_enqueue_script('jquery'); function add_cdtoevent() { wp_enqueue_script('countdown','add_cdtoevent' );
The jquery plugin(.js)
以上是脚本宝典为你收集整理的php – 在WordPress中包含一个github jquery插件全部内容,希望文章能够帮你解决php – 在WordPress中包含一个github jquery插件所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。