class的调用函数,不能调用class内的其他函数
Call function of the class, which can't call other functions within the class
我正在尝试调整 WP Woocommerce 预订插件并添加从 Google 日历 API 获取事件的功能。
有class
Class WC_Bookings_Google_Calendar_Integration extends WC_Integration
,提供token获取和授权。
我给 class 添加了新功能
public function get_googlecal_bookings( $bookable_product, $min_date =
0, $max_date = 0 )
假设检索特定产品的最短日期和最长日期之间的所有预订。
来自我的 functions.php 我用
调用它
$existing_bookings =
WC_Bookings_Google_Calendar_Integration::get_googlecal_bookings($bookable_product,
$from, $to);
这适用于虚拟数据。
虽然,当我尝试在 function get_googlecal_bookings
中使用其他 class 函数时,例如 $api_url = $this->calendars_uri . $this->calendar_id . '/events/';
或 $access_token = $this->get_access_token();
我什么也没得到。
我知道我叫错了,只需要指出正确的方向
您将其作为静态函数调用 WC_Bookings_Google_Calendar_Integration::get_googlecal_bookings
,但您引用的是 $this
,这将不起作用,因为没有实例。
我正在尝试调整 WP Woocommerce 预订插件并添加从 Google 日历 API 获取事件的功能。
有class
Class WC_Bookings_Google_Calendar_Integration extends WC_Integration
,提供token获取和授权。
我给 class 添加了新功能
public function get_googlecal_bookings( $bookable_product, $min_date = 0, $max_date = 0 )
假设检索特定产品的最短日期和最长日期之间的所有预订。
来自我的 functions.php 我用
调用它$existing_bookings = WC_Bookings_Google_Calendar_Integration::get_googlecal_bookings($bookable_product, $from, $to);
这适用于虚拟数据。
虽然,当我尝试在 function get_googlecal_bookings
中使用其他 class 函数时,例如 $api_url = $this->calendars_uri . $this->calendar_id . '/events/';
或 $access_token = $this->get_access_token();
我什么也没得到。
我知道我叫错了,只需要指出正确的方向
您将其作为静态函数调用 WC_Bookings_Google_Calendar_Integration::get_googlecal_bookings
,但您引用的是 $this
,这将不起作用,因为没有实例。