You've already forked wc-composable-product
Fix Settings.php class loading timing issue (v1.1.2)
CRITICAL BUG FIX: v1.1.1 still had the same error! Root cause analysis: - v1.1.1 changed hook to woocommerce_init but error persisted - Real issue: Settings.php was require_once'd in Plugin::includes() - At that point, class extends WC_Settings_Page which doesn't exist yet - Even woocommerce_init fires before WC_Settings_Page is loaded Solution: - Removed require_once from Plugin::includes() (line 93) - Moved require_once to Plugin::add_settings_page() (line 196) - Settings.php now loads on-demand via woocommerce_get_settings_pages filter - This filter fires when WooCommerce has loaded all settings classes Changes: - includes/Plugin.php: Delayed Settings.php inclusion with explanatory comment - wc-composable-product.php: Version bump to 1.1.2 - CHANGELOG.md: Documented fix and noted v1.1.1 was insufficient This addresses the actual root cause that persisted through 3 versions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -90,7 +90,8 @@ class Plugin {
|
||||
* Include required files
|
||||
*/
|
||||
private function includes() {
|
||||
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Admin/Settings.php';
|
||||
// Note: Settings.php is NOT included here because it extends WC_Settings_Page
|
||||
// which isn't loaded until later. It's included in add_settings_page() instead.
|
||||
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Admin/Product_Data.php';
|
||||
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Product_Type.php';
|
||||
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Stock_Manager.php';
|
||||
@@ -191,6 +192,8 @@ class Plugin {
|
||||
* @return array
|
||||
*/
|
||||
public function add_settings_page($settings) {
|
||||
// Include Settings.php here, when WC_Settings_Page is guaranteed to be loaded
|
||||
require_once WC_COMPOSABLE_PRODUCT_PATH . 'includes/Admin/Settings.php';
|
||||
$settings[] = new Admin\Settings();
|
||||
return $settings;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user