所以我有两个文件,“header.php”和“pluginfile.php”
我要调用的函数位于“pluginfile.php”中,并且是:
public function getNonSubscriptionAmount() {
$total = 0;
foreach($this->_items as $item) {
if(!$item->isSubscription()) {
$total += $item->getProductPrice() * $item->getQuantity();
}
else {
// item is subscription
$basePrice = $item->getBaseProductPrice();
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Item is a subscription with base price $basePrice");
$total += $basePrice;
}
}
return $total;
}
所以在'header.php'中我有:
<?php
include_once($_SERVER['DOCUMENT_ROOT']."/wp-content/plugins/plugin-name/folder/PluginFile.php");
print getNonSubscriptionAmount();
?>
加载任何页面时都会出现以下错误:
致命错误:在第 72 行的 /home/username/domain.com/wp-content/themes/theme/header.php 中调用未定义函数 getnonsubscriptionamount()
我现在已经花了几个小时试图独自解决这个问题,但一无所获!非常感谢任何帮助!