Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 在wordpress插件中使用颜色框_Html_Jquery Ui_Jquery Plugins_Wordpress - Fatal编程技术网

Html 在wordpress插件中使用颜色框

Html 在wordpress插件中使用颜色框,html,jquery-ui,jquery-plugins,wordpress,Html,Jquery Ui,Jquery Plugins,Wordpress,我正在开发一个wordpress插件,我需要在其中实现colorbox。我有以下代码。插件工作正常,但颜色框不工作。我已经将相同的颜色框代码复制到了一个html文件及其工作状态。唯一的问题是wordpress插件。要么我没有完全导入js和css,要么其他任何东西都出了问题。我急需帮助 <?php /* Plugin Name: my plugin Plugin URI: http://www.xxx.com/ Description: xxx Author: xxx Version: 1

我正在开发一个wordpress插件,我需要在其中实现colorbox。我有以下代码。插件工作正常,但颜色框不工作。我已经将相同的颜色框代码复制到了一个html文件及其工作状态。唯一的问题是wordpress插件。要么我没有完全导入js和css,要么其他任何东西都出了问题。我急需帮助

<?php

/*
Plugin Name: my plugin
Plugin URI: http://www.xxx.com/
Description: xxx
Author: xxx
Version: 1.0
Author URI: http://www.xxx.com
*/


wp_enqueue_style('colorbox.css', '\wordpress\wp-  
content\plugins\calc_plugin\colorbox.css');
wp_enqueue_script('jquery.js', '\wordpress\wp-content\plugins\calc_plugin\jquery.js',  
array('jquery1'));
wp_enqueue_script('colorbox.js', '\wordpress\wp- 
content\plugins\calc_plugin\colorbox.js', array('jquery2'));

function calc_form_markup() {
$markup = <<<EOT




<script>
$(document).ready(function(){
$(".inline").colorbox({inline:true, width:"600", height:"450"});
});
</script>


<div style='display:none' >

<div id='inline_content1' style='padding:10px; background:#fff;'>
<p><strong>This is inline content 1</strong></p>
<image src = "http://wallpaper.goodfon.com/image/240138-1360x768.jpg" width = "175"     
height = " 150">
</div>

</div>

<p><a class='inline' href="#inline_content1">Inline HTML</a></p>

EOT;

return $markup;

}

add_shortcode('calc_form', 'calc_form_markup');


?>

您没有加载Colorbox运行所需的
jQuery
脚本。只需将其排队,然后再排队
Colorbox.js

wp_enqueue_script("jquery");

您的
wp\u enqueue\u脚本
错误

以下是参数:

wp_enqueue_script( 
     $handle
    ,$src
    ,$deps
    ,$ver
    ,$in_footer 
);
$deps
(依赖项)是jQuery,它已经包含在WordPress中,并使用
jQuery
而不是
'jquery1'
调用

您的JavaScript错误,请在WordPress中使用无冲突包装,即
jQuery
,而不是
$


$(document).ready(function()
应该是
jQuery(document).ready(function()

我根据您的建议更改了文件,还包括了jQuery.请查看上面的代码,现在它包括jQuery,但colorbox仍然不起作用