【发布时间】:2017-05-19 21:44:49
【问题描述】:
我在 woocommerce xero 插件中有以下功能。
/**
* @return string
*/
public function get_name() {
return apply_filters( 'woocommerce_xero_contact_name', $this->name, $this );
}
我需要改变
'woocommerce_xero_contact_name', $this->name, $this );
到这里
'woocommerce_xero_contact_name', $this->billing_company, $this );
当我尝试为我的functions.php 编写函数时,我不断收到错误消息:“不在对象上下文中使用$this”,我不明白。
我的函数现在是这样的;
public function xero_contact_name_1( $this ) {
return $this->billing_company;
}
add_filter( 'woocommerce_xero_contact_name', 'xero_contact_name_1' );
任何想法我做错了什么?
谢谢
【问题讨论】:
标签: php wordpress function filter woocommerce