[...], ...]. */ public static function catalog(): array { return require __DIR__ . '/free-templates-data.php'; } /** * Flatten whatever shape the wpwand_data option is carrying into one name => template list. * * Two shapes exist in the wild: the one this plugin ships, and the {free, pro} payload a Pro * licence sync writes straight from the licence server. Both must read. * * @param mixed $data * @return array> */ public static function flatten($data): array { if (!is_array($data)) { return []; } if (isset($data['free']) || isset($data['pro'])) { $free = is_array($data['free'] ?? null) ? $data['free'] : []; $pro = is_array($data['pro'] ?? null) ? $data['pro'] : []; return array_merge($free, $pro); } return $data; } /** * Seed the wpwand_data option from the built-in catalog. Mirrors wpwand_get_data($sync): * writes only when the option is empty, or when $force (the "Sync" action) is set. */ public static function seed(bool $force = false): bool { if (!get_option('wpwand_data') || $force) { return (bool) update_option('wpwand_data', self::catalog()); } return false; } }