我有网站,我将编写一个插件,在数据库中添加和更新记录。
我的问题是我在插件文件中使用 JavaScript,但它在主页上的显示和它的显示问题。
我如何不在主页中显示此 JavaScript 代码,而仅在管理文件的插件页面中显示。
这是插件代码:-
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/css/jquery-ui.css" />
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/js/jquery-ui.js"></script>
<script language="JavaScript">
$(document).ready(function(){
//start autocomplate
var availableTags = [
<?php
$query = mysql_query("SELECT DISTINCT type FROM web_categories");
while ($rows = mysql_fetch_array($query)){
echo '"'.$rows['type'].'",';
}
echo '""';
?>
];
$("#type_1").autocomplete({source: availableTags});
// end autocomplate
//start autocomplate
var availableTags = [
<?php
$query = mysql_query("SELECT DISTINCT type FROM web_categories");
while ($rows = mysql_fetch_array($query)){
echo '"'.$rows['type'].'",';
}
echo '""';
?>
];
$("#type_11").autocomplete({source: availableTags});
// end autocomplate
//start autocomplate
var availableTags = [
<?php
$query = mysql_query("SELECT DISTINCT type FROM web_categories");
while ($rows = mysql_fetch_array($query)){
echo '"'.$rows['type'].'",';
}
echo '""';
?>
];
$("#type_2").autocomplete({source: availableTags});
// end autocomplate
//start autocomplate
var availableTags = [
<?php
$query = mysql_query("SELECT DISTINCT type FROM web_categories");
while ($rows = mysql_fetch_array($query)){
echo '"'.$rows['type'].'",';
}
echo '""';
?>
];
$("#type_3").autocomplete({source: availableTags});
// end autocomplate
});
</script>