The problem is, by the time your WooCommerce_Chilexpress_Tags_Settings
is defined, WC_Settings_Page
has indeed not yet loaded; hence you got the fatal error.
And if you want to do it the same way that WooCommerce does it, place the WooCommerce_Chilexpress_Tags_Settings
in a separate PHP file, e.g. includes/class-woocommerce-chilexpress-tags-tettings.php
, and initialize the class from that file — i.e. return
an instance of WooCommerce_Chilexpress_Tags_Settings
like so:
<?php
// class-woocommerce-chilexpress-tags-tettings.php
defined( 'ABSPATH' ) || exit;
class WooCommerce_Chilexpress_Tags_Settings extends WC_Settings_Page {
...
}
return new WooCommerce_Chilexpress_Tags_Settings();
and include
it from my_plugin_add_settings()
:
function my_plugin_add_settings( $settings ) {
$settings[] = include 'path/to/includes/class-woocommerce-chilexpress-tags-tettings.php';
return $settings;
}
add_filter( 'woocommerce_get_settings_pages', 'my_plugin_add_settings' );
And if you noticed, you need to return the $settings
from my_plugin_add_settings()
.