【发布时间】:2016-11-30 16:13:54
【问题描述】:
我正在尝试在我的 wordpress 插件中使用以下 github 项目:
PHP Object wrapper for the Google Chart API
我尝试了以下方法:
require_once(WPPLUGIN_PATH. "gchart/gChartInit.php");
$piChart = new gPieChart(); // <---- here I get the error
$piChart->addDataSet(array(112,315,66,40));
$piChart->setLabels(array("first", "second", "third","fourth"));
$piChart->setLegend(array("first", "second", "third","fourth"));
$piChart->setColors(array("ff3344", "11ff11", "22aacc", "3333aa"));
echo $piChart->getImgCode();
我的问题似乎是,当我使用上面的代码时,它会在$piChart = new gPieChart(); 行跳转到另一个 wordpress-plugins 自动加载器并且没有正确加载gPieChart.php。
错误信息是:
[26-Jul-2016 20:39:59 UTC] PHP Fatal error: Class 'gPieChart' not found in /home/ubuntu/workspace/wp-content/plugins/wp-analytics-mail/sendTestMail.php on line 267
[26-Jul-2016 20:39:59 UTC] PHP Stack trace:
[26-Jul-2016 20:39:59 UTC] PHP 1. {main}() /home/ubuntu/workspace/index.php:0
[26-Jul-2016 20:39:59 UTC] PHP 2. require() /home/ubuntu/workspace/index.php:17
[26-Jul-2016 20:39:59 UTC] PHP 3. require_once() /home/ubuntu/workspace/wp-blog-header.php:19
[26-Jul-2016 20:39:59 UTC] PHP 4. include() /home/ubuntu/workspace/wp-includes/template-loader.php:75
[26-Jul-2016 20:39:59 UTC] PHP 5. include() /home/ubuntu/workspace/wp-content/themes/twentysixteen/page-analytics-analytics-mail.php:138
对如何使上述代码正常工作有什么建议吗?
感谢您的回复!
【问题讨论】:
-
stackoverflow.com/questions/38598182/… -- 如果你不使用作曲家,你需要自己构建一个自动加载器,除非那里有一个
-
@montrealist 请查看我的更新。