好的,这是我第一次将jQuery包含到wordpress中,我花了整整两天的时间才弄明白这一点。无论我读了多少篇文章,我都找不到一个完美的例子。
这是我的插件文件。。。非常简单。
<?php
/*
Plugin Name: jQuery Include Test
Plugin URI: http://jquery.com
description: A test to include jQuery.
Author: blah blah
Author URI:
*/
// jQuery alert to pop up when the page loads.
function pop_jquery_test() {
$src = plugins_url(\'includes/jquerytest.js\', __FILE__);
wp_register_script( \'jquerytest\', $src );
wp_enqueue_script( \'jquerytest\' );
wp_enqueue_script( \'jquery\' );
}
add_action(\'init\',\'pop_jquery_test\');
这是jquerytest。js文件$j=jQuery.noConflict();
$jQuery(document).ready(function(){
alert(\'hi there\');
});
现在的问题是,我如何让它工作?从某种意义上说,当我激活插件时,它会像上面的jquery代码那样弹出。