catalog === null) { $metadata = ModuleRegistration::get_all_core_modules_metadata(); $this->catalog = new ModuleCatalog( is_array($metadata) ? $metadata : [], static function (string $name): array { $defaults = ModuleRegistration::get_default_attrs($name, 'default'); return is_array($defaults) ? $defaults : []; } ); } return $this->catalog; } /** Divi version written into builderVersion of new blocks. */ public function builderVersion(): string { return defined('ET_BUILDER_PRODUCT_VERSION') ? (string) ET_BUILDER_PRODUCT_VERSION : '5.2.1'; } /** * Whether Divi's builder is switched on for $postType (Divi → Theme-Optionen → Builder); false without Divi. */ public static function builderEnabledFor(string $postType): bool { return function_exists('et_builder_enabled_for_post_type') && (bool) et_builder_enabled_for_post_type($postType); } /** * Whether Divi still has block type $name: registered with WordPress, or in Divi's core module metadata (Divi * renders global instances itself and does not always register the type with WordPress). */ public static function knowsBlock(string $name): bool { if (class_exists('WP_Block_Type_Registry') && \WP_Block_Type_Registry::get_instance()->is_registered($name)) { return true; } if (! method_exists(ModuleRegistration::class, 'get_all_core_modules_metadata')) { return false; } foreach ((array) ModuleRegistration::get_all_core_modules_metadata() as $module) { if (is_array($module) && ($module['name'] ?? null) === $name) { return true; } } return false; } }