我正在开发一个自定义插件。 " Vrial_Throb_WC_Integration"是我用来与Woocommerce集成的插件类,但这显示错误:
致命错误:未捕获错误:在E:\ xamp \ htdocs \ wwp \ wp-content \ plugins \ woocommerce \ includes \ admin \ settings \ class-wc-settings-integration中调用未定义的方法Vrial_Throb_WC_Integration :: admin_options() .php:80堆栈跟踪:#0 E:\ xamp \ htdocs \ wwp \ wp-includes \ class-wp-hook.php(298):WC_Settings_Integrations->输出('')#1 E:\ xamp \ htdocs \ wwp \ wp-includes \ class-wp-hook.php(323):WP_Hook-> apply_filters('',Array)#2 E:\ xamp \ htdocs \ wwp \ wp-includes \ plugin.php(453):WP_Hook-> do_action(数组)#3 E:\ xamp \ htdocs \ wwp \ wp-content \ plugins \ woocommerce \ includes \ admin \ views \ html-admin- settings.php(26):do_action(' woocommerce_set ...')#4 E:\ xamp \ htdocs \ wwp \ wp-content \ plugins \ woocommerce \ includes \ admin \ class-wc-admin -settings.php(169):include(' E:\ xamp \ htdocs \ ...')#5 E:\ xamp \ htdocs \ wwp \ wp-content \ plugins \ woocommerce \ includes \ admin \ class-wc-admin-menus.php(204):WC_Admin_Settings :: output()#6 E:\ xamp \ htdocs \ wwp \ wp-includes \ class-wp-hook.php(298):WC_Admin_Menus - > settings_page('')#7 E:\ xamp \ htdocs \ wwp \ wp-includes \ class-wp-hook.php(323):在E:\ xamp \ htdocs \ wwp \第80行的wp-content \ plugins \ woocommerce \ includes \ admin \ settings \ class-wc-settings-integrations.php
这是我的自定义类集成的代码:
class Vrial_Throb_WC_Integration {
/**
* Construct the plugin.
*/
public function __construct() {
add_action( 'plugins_loaded', array( $this, 'init' ) );
}
/**
* Initialize the plugin.
*/
public function init() {
// Checks if WooCommerce is installed.
if ( class_exists( 'WC_Integration' ) ) {
// Include our integration class.
include_once 'viral_throb_wc_integration.php';
// Register the integration.
add_filter( 'woocommerce_integrations', array( $this, 'add_integration' ) );
} else {
// throw an admin error if you like
}
}
/**
* Add a new integration to WooCommerce.
*/
public function add_integration( $integrations ) {
$integrations[] = 'Vrial_Throb_WC_Integration';
return $integrations;
}
}
$viral_throb_integration = new Vrial_Throb_WC_Integration( __FILE__ );