wordpress PHP合并js,如何在WordPress中添加外部JavaScript

我想在WordPress中插入放置在该文件夹中的外部JavaScript.

如果我使用脚本标记包含它显示“

下面是我的代码

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个移动文件

hBRjf.png

解决方法:

在WordPress中包含脚本的正确方法是使用wp_enqueue_script().

如果您以前注册过脚本,则只需引用它:

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.

请注意,如果在dependencies参数中包含jQuery等默认脚本,则无需单独注册和/或将它们排入队列.

标签:jquery,wordpress,php,javascript,charts

来源: https://codeday.me/bug/20190627/1308258.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值