1
我在wordpress中开发一个插件,这个插件有一个自定义文章,我想将日期选择脚本添加到metabox。我试图排队我的脚本这种方式,但似乎不起作用导致这些脚本不低于工作code.Use都不变的插件,如果有可能的主文件中定义的方法加载脚本在wordpress中排队不工作
require_once(plugin_dir_path(__FILE__) . 'functions.php');
function chahadat_scripts()
{
wp_register_script('imagelightbox.js', plugins_url('js/imagelightbox.js', __FILE__));
wp_enqueue_script( 'imagelightbox.js');
wp_register_script('imagelightbox.min.js', plugins_url('js/imagelightbox.min.js', __FILE__));
wp_enqueue_script( 'imagelightbox.min.js');
wp_register_script('jquery', 'https://code.jquery.com/jquery-1.12.4.js', array(jquery), 3.3, true);
wp_register_script('jqueryui', 'https://code.jquery.com/ui/1.12.1/jquery-ui.js', array(jquery), 3.3, true);
wp_register_style('jqueryuistyle', 'https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css', 3.3, true);
wp_register_script('dates', plugins_url('js/date.js', __FILE__));
wp_enqueue_script( 'dates');
}
add_action('wp_enqueue_scripts', 'chahadat_scripts');
谢谢,但这不起作用,我不得不提到我尝试使用WordPress的仪表板 –
内日期选择器脚本,然后用“admin_enqueue_scripts”阿尔科检查网页的源文件替换“wp_enqueue_scripts”,并检查被加载JS或不, –
我做了,但现在我得到这个错误'TypeError:jQuery(...)。datepicker不是一个函数'和我的date.js只包含这个'jQuery(document).ready(function(){ jQuery “#datepicker”).datepicker(); });' –