get_module_dir(); $trait_dir = $module_dir . '/' . $this->get_module_name() . 'Trait/'; foreach ( $this->get_trait_files() as $file ) { $path = $trait_dir . $file; if ( file_exists( $path ) ) { require_once $path; } } } /** * Called by Divi 5's dependency manager (or our fallback). * Validates prerequisites, loads traits and the main class file, * then registers the module with Divi 5. */ public function load(): void { $module_dir = __DIR__ . '/' . $this->get_module_dir(); $json_folder = $module_dir . '/module-json'; $json_file = $json_folder . '/module.json'; if ( ! is_dir( $json_folder ) || ! file_exists( $json_file ) ) { return; } $id = $this->get_module_namespace() . '\\' . $this->get_module_name(); if ( isset( self::$registered_modules[ $id ] ) ) { return; } if ( ! class_exists( 'ET\Builder\Packages\ModuleLibrary\ModuleRegistration' ) ) { return; } $class = $this->get_module_namespace() . '\\' . $this->get_module_name(); // Load traits first, then the main class file (traits are inlined into the class) $this->load_traits(); $class_file = $module_dir . '/' . $this->get_module_name() . '.php'; if ( file_exists( $class_file ) ) { require_once $class_file; } if ( ! method_exists( $class, 'render_callback' ) ) { return; } try { ModuleRegistration::register_module( $json_folder, [ 'render_callback' => [ $class, 'render_callback' ] ] ); self::$registered_modules[ $id ] = true; } catch ( \Exception $e ) { if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log error_log( 'WPFunnels Divi5: Module registration failed for ' . $id . ': ' . $e->getMessage() ); } } } }