$definition) { $attributes[$attrName] = ['settings' => $definition['settings'] ?? []]; } $metadata[] = array_filter([ 'name' => $module['name'], 'title' => $module['title'] ?? '', 'category' => $module['category'] ?? '', 'childrenName' => $module['childrenName'] ?? null, 'childModuleName' => $module['childModuleName'] ?? null, 'attributes' => $attributes, ], static fn ($value): bool => $value !== null); $defaults[$module['name']] = ModuleRegistration::get_default_attrs($module['name'], 'default'); } $file = dirname(__DIR__) . '/Fixtures/divi/metadata-sample.json'; $json = wp_json_encode( ['divi' => ET_BUILDER_PRODUCT_VERSION, 'metadata' => $metadata, 'defaults' => $defaults], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); if (! is_string($json) || file_put_contents($file, $json . "\n") === false) { WP_CLI::error('Cannot write ' . $file); } WP_CLI::success(sprintf('metadata-sample.json: %d modules, %d bytes', count($metadata), strlen($json)));