两天前,a制作了一个插件,允许我在帖子中插入带有短代码的切换框[toggle Title="My title"]toggle test[/toggle]
我还在WordPress上发布了我的插件。org插件
http://wordpress.org/extend/plugins/toggle-box/.
The Problem
我在沙盒上制作了整个插件,我在本地机器上使用XAMPP制作了这个插件,过了一会儿,我在另一个WordPress博客上安装了这个插件,在那里安装好了CSS和JS正在加载到页面中,但切换不起作用!!!!(样式和JS出现在头部,标题也出现了,但当我点击它时,它没有切换。)然后我尝试在其他一些博客上使用这些插件,但遇到了同样的问题。然后我在我的机器上设置了另一个WordPress沙盒,并使用了那里的插件,但它在那里不起作用,所以我意识到我的代码有一些错误,我找不到。因此,请有人确定并提供问题的解决方案,谢谢
Code of my plugin
/切换框。php<?php
/**
* Plugin Name: Toggle box
* Plugin URI: http://wordpress.org/extend/plugins/toggle-box/
* Description: This is an awesome custom plugin which adds toggle box funtionality in to your theme themes.
* Author: phantom.omaga
* Author URI: http://profiles.wordpress.org/users/phantom.omaga/
* Version: 0.1.0
**/
//*************************** Toggle Boxes Short Code ***************************//
function togglebox($atts, $content = null) {
extract(shortcode_atts(array(
\'title\' => \'\',
), $atts));
$out .= \'<h3 class="toggle"><strong><a href="#">\' .$title. \'</a></strong></h3>\';
$out .= \'<div class="toggle-box" style="display: none;"><p>\';
$out .= do_shortcode($content);
$out .= \'</p></div>\';
return $out;
}
add_shortcode(\'toggle\', \'togglebox\');
//*************************** Get Plugin URL ***************************//
function get_pluginurl() {
// WP < 2.6
if ( !function_exists(\'plugins_url\') )
return get_option(\'siteurl\') . \'/wp-content/plugins/\' . plugin_basename(dirname(__FILE__));
return plugins_url(plugin_basename(dirname(__FILE__)));
}
//*************************** Calls Toggle Box css and js***************************//
function add_togglebox () {
?>
<link type="text/css" href="<?php echo plugins_url(\'toggle-box\'); ?>/toggle-box.css" rel="stylesheet" />
<script type="text/javascript" src="<?php echo plugins_url(\'toggle-box\'); ?>/toggle-box.js"></script>
<?php }
add_action(\'wp_head\', \'add_togglebox\');
?>
/切换框。css/*************************** Shortcodes: Toggle Box ***************************/
h3.toggle {
background-repeat: no-repeat;
background-position: -27px -23px;
font-size: 16px;
padding: 0 0 20px 23px;
cursor: pointer;
}
h3.toggle a {
text-decoration: none;
display: block;
}
h3.toggle-active {
background-position: -6px -50px;
}
.toggle-box {
clear:both;
margin: 0 0 10px 0;
overflow: hidden;
}
h3.toggle {
background-image: url(images/sprite.png);
}
/切换框。js公司/*************************** Toggle Content ***************************/
jQuery(document).ready(function(){
jQuery(".toggle-box").hide();
jQuery(".toggle").toggle(function(){
jQuery(this).addClass("toggle-active");
}, function () {
jQuery(this).removeClass("toggle-active");
});
jQuery(".toggle").click(function(){
jQuery(this).next(".toggle-box").slideToggle();
});
});
/图像/sprite.png使用firebug时,我发现问题出在jQuery上
未定义jQuery
[在此错误上中断]jQuery(文档)。就绪(函数(){
我已经给它下了定义,好吧,我想有人能告诉我应该怎么做才能把它做好。