Wordpress插件与第三方jquery插件集成



我可以在wordpress插件中使用第三方jquery插件吗?找不到这方面的任何信息。结构会是什么样子?我会像处理主题一样把剧本排队吗?我对文字出版社很陌生。

我的插件还需要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>

我想把它做成一个仪表板小部件,所以根据我所看到的,我需要把主脚本放入一个函数中并注册该函数。。但是,如果有的话,第三方jquery和css将如何融入其中呢?非常感谢您提前提供的帮助!

了不起的文章,找到了我想要的一切-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);
}

最新更新