wordpress PHP合并js,如何在WordPress中添加外部JavaScript
我想在WordPress中插入放置在該文件夾中的外部JavaScript.
如果我使用腳本標(biāo)記包含它顯示“
下面是我的代碼
global $wpdb;
include("/asset/php/chart4php/inc/chartphp_dist.php");
$p = new chartphp();
$p->data_sql = $wpdb->get_results("select t2.name, count(t1.id) as score from custom_status as t2 left join wpsp_ticket as t1 on t2.name = t1.status group by t2.name");
$p->chart_type = "bar";
// Common Options
$p->title = "Category Sales";
$p->xlabel = "Category";
$p->ylabel = "Sales";
$color = array("#1AAF5D","#F2C500","#F45B00","#8E0000","#0E948C");
$p->color = $color[rand(0,4)];
$out = $p->render('c1');
嘗試包括js文件
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'ajax_search' );
wp_register_script( 'chartphp', plugins_url('/asset/php/chart4php/chartphp.js', __FILE__), array('jquery'));
wp_enqueue_script(‘chartphp’);
另外我想要包含3個(gè)移動(dòng)文件
解決方法:
在WordPress中包含腳本的正確方法是使用wp_enqueue_script().
如果您以前注冊(cè)過(guò)腳本,則只需引用它:
You could either link a script with a handle previously registered using the 07001 function, or provide this function with all the parameters necessary to link a script.
請(qǐng)注意,如果在dependencies參數(shù)中包含jQuery等默認(rèn)腳本,則無(wú)需單獨(dú)注冊(cè)和/或?qū)⑺鼈兣湃腙?duì)列.
標(biāo)簽:jquery,wordpress,php,javascript,charts
來(lái)源: https://codeday.me/bug/20190627/1308258.html
總結(jié)
以上是生活随笔為你收集整理的wordpress PHP合并js,如何在WordPress中添加外部JavaScript的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 安徽农金贷款需要什么条件
- 下一篇: 基于PHP的CURL快速入门