我为 wordpress 插件创建了一个代码,以在 head 中包含文件。我没有很好的知识,但在谷歌搜索后我创建了它....但确保代码不正确
add_action ('init', 'ajp_header_init');
add_action('wp_head','ajp_instance_code');
//This function includes the required css and js files
function ajp_header_init()
{
if ($directories[count($directories)-1] == 'mu-plugins' )
define ('AJP_PLUGIN_URL', content_url().'/'.$plugin_dir);
else
define ('AJP_PLUGIN_URL', rtrim(content_url().'/plugins/'.plugin_basename(dirname(__FILE__)), '/'));
wp_register_script('Jquery Adaptive Plugin',AJP_PLUGIN_URL.'/lib/jquery.adaptivate.min.js',false);
wp_register_script('Jquery Adaptive Plugin',AJP_PLUGIN_URL.'/lib/jquery.adaptivate.js',false);
wp_register_style('Jquery Adaptive Style',AJP_PLUGIN_URL.'/css/adaptive.css',false);
wp_enqueue_script('jquery');
wp_enqueue_script('Jquery Adaptive Plugin');
wp_enqueue_style('Jquery Adaptive Style');
}
function ajp_instance_code()
{
echo"
<script type='text/javascript'>
$('html').adaptivate({
'widths': [240, 320, 480, 640, 768, 960, 1024, 1280, 1440, 1600, 1920, 2400],
'format': 'width_{operator}_{width}',
'orientationFormat': 'orientation_{orientation}'
});
</script>
";