我可以在wordpress插件中使用第三方jquery插件吗?什么都找不到。结构会是什么样子?我会将脚本排队,就像我在主题中工作一样吗?我对wordpress很新。
我的插件也需要doctype和head标签以及所有这些吗?我猜不是吗?
我正在尝试使用非wordpress脚本并将其转换为插件。这是我的代码,我正在使用这个第三方插件 - http://filamentgroup.com/lab/update_to_jquery_visualize_accessible_charts_with_html5_from_designing_with/
<?php
/ *
插件名称:Crashboard
描述:碰撞测试
版本:0.3
作者:模糊逻辑
许可证:GPL2
* /
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>CrashBoard</title>
<link href="css/basic.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://filamentgroup.github.com/EnhanceJS/enhance.js"></script>
<script type="text/javascript" src='js/visualize.jQuery.js'></script>
<link href='css/visualize.css' type="text/css" rel="stylesheet" />
<link href='css/visualize-light.css' type="text/css" rel="stylesheet" />
<style>
#chart{
display: none;
}
#chart7{
display: none;
}
#gross{
display: none;
}
#gross7{
display: none;
}
#table_2 {
margin-left: 550px;
margin-top: -668px;
margin-bottom: 474px;
}
#sevenchart {
margin-left: 520px;
margin-top: -450px;
}
#sevengross{
margin-left: 260px;
margin-top: -30px;
}
#thirtychart {
margin-top: -38px;
margin-left: 22px;
}
#thirtygross {
margin-top: -38px;
margin-left: 22px;
margin-bottom: 15px;
}
#chart thead, td{
min-width: 60px;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$('#table').visualize({type: 'area', width: 950, height: 270}).appendTo('#thirtychart');
});
</script>
</head>
<body>
<br/>
<table id="table">
<caption>30 Day Sales Overview</caption>
<thead>
<tr>
<td></td>
<th scope="col">Units Sold</th>
<th scope="col">Total Value Sold</th>
<th scope="col">Total Clicks from Referrals</th>
<th scope="col">Total Referrals to Sales</th>
<th scope="col">Total commission Paid Out</th>
</tr>
</thead>
<tbody>
<tr>
<?php
global $wpdb;
$y='';
for($i=30; $i>=0; $i--){
$the_time = time() - ($i * 24 * 60 * 60);
$the_date = date('m-d', $the_time);
echo "<th scope=\"row\">" . $the_date . "</th>";
$day_quant = '';
$day_gross = '';
$day_clicks = '';
$day_completes = '';
$day_payments = '';
$iminus1 = '';
$iminus1 = $i-1;
$ipn_list = $wpdb->get_results("Select * FROM paypal_ipn WHERE paypal_date >= DATE_SUB(NOW(), INTERVAL $i day) AND paypal_date <= DATE_SUB(NOW(), INTERVAL $iminus1 day)");
if($ipn_list!=null){
foreach( $ipn_list as $ipn_data ){
$order_quant = $ipn_data->quantity;
$day_quant += $order_quant;
$order_gross = $ipn_data->payment_gross;
$day_gross += $order_gross;
}
echo "<td>" . $day_quant . "</td>";
echo "<td>" . $day_gross . "</td>";
}else{
echo "<td>0</td>";
echo "<td>0</td>";
}
$affiliate_list = $wpdb->get_results("Select * FROM wp_affiliatedata WHERE paypal_date >= DATE_SUB(NOW(), INTERVAL $i day) AND paypal_date <= DATE_SUB(NOW(), INTERVAL $iminus1 day)");
if($affiliate_list!=null){
foreach( $affiliate_list as $affiliate_data ){
$refer_clicks = $affiliate_data->uniques;
$day_clicks += $refer_clicks;
$refer_completes = $affiliate_data->completes;
$day_completes += $refer_completes;
$refer_payments = $affiliate_data->payments;
$day_payments += $refer_payments;
}
echo "<td>" . $day_clicks . "</td>";
echo "<td>" . $day_completes . "</td>";
echo "<td>" . $day_payments . "</td>";
}else{
echo "<td>0</td>";
echo "<td>0</td>";
echo "<td>0</td>";
echo "</tr>";
}
}
?>
</tbody>
</table>
我想把它变成一个仪表板小部件,所以从我看到的,我需要将主脚本放入1个函数并注册函数..但是第三方jquery和css如何适应它,如果在所有?非常感谢您的帮助!
答案 0 :(得分:0)
很棒的文章,找到了我要找的所有内容 - http://www.jdmweb.com/resources/jquery_to_wordpress_plugin
这里是Fancybox需要的代码作为示例第三方jquery插件:
//Group the code inside a function
function fancybox_wp_setup(){
wp_enqueue_style(
"jquery.fancybox", WP_PLUGIN_URL."/jQuery2Wp_fancybox/jquery.fancybox-1.3.1.css",
false, "1.3.1");
wp_enqueue_script("jquery");
wp_enqueue_script(
"jquery.fancybox", WP_PLUGIN_URL."/jQuery2Wp_fancybox/jquery.fancybox.js",
array("jquery"), "1.3.1",1);
wp_enqueue_script(
"jquery.fancyboxsetup", WP_PLUGIN_URL."/jQuery2Wp_fancybox/fancybox-setup.js",
array("jquery","jquery.fancybox"), "",1);
}