我使用plugin 包含此代码,我想将js位置更改为位于我的模板目录中,而不是位于插件中,而无需编辑插件文件
class jqueryTimelinrLoad {
public function registerScripts()
{
if (!wp_script_is( \'jquery\', \'registered\' )) wp_register_script( \'jquery\' );
wp_deregister_script(\'jquery.timelinr\');
wp_register_script(\'jquery.timelinr\', JQTL_BASE_URL . \'/assets/js/jquery.timelinr-1.0.js\', array( \'jquery\' ));
}
public function loadScripts() {
if (!is_admin()) {
if (!wp_script_is( \'jquery\', \'queue\' )) wp_enqueue_script( \'jquery\' );
wp_enqueue_script(\'jquery.timelinr\', JQTL_BASE_URL . \'/assets/js/jquery.timelinr-1.0.js\', array( \'jquery\' ));
}
}
}
我尝试了这个,它添加了新链接,但旧链接仍然存在function drw_timeline_js () {
$result = $GLOBALS["jqueryTimelinrLoad"]->loadScripts();
wp_dequeue_script(\'jquery.timelinr\');
wp_deregister_script( \'jquery.timelinr\');
wp_enqueue_script(\'jquery.timelinr2\', get_template_directory_uri() . \'/js/jquery.timelinr-1.0.js\', array( \'jquery\' ));
return $result;
}
add_action(\'init\', \'drw_timeline_js\', 1);