255 || strpbrk($name, "/\\\0") !== false) { throw new RelayError('backup.parts_invalid', esc_html__('Files in the site’s root are left out by name: a file or folder directly in it.', 'siterelay')); } $names[] = $name; } return array_values(array_unique($names)); } /** @return string[] the parts a backup job holds */ public static function contents(array $settings): array { return is_array($settings['contents'] ?? null) ? array_values($settings['contents']) : self::LEGACY; } /** @return array the chosen file parts => their folders (the root's only off a network) */ public static function roots(array $settings): array { $parts = self::contents($settings); $roots = array_intersect_key(Groups::roots(Scope::for_settings($settings)), array_flip($parts)); if (in_array('root', $parts, true) && !is_multisite()) { $roots['root'] = RootFiles::dir(); } return $roots; } /** * What each chosen part leaves out. Built from every group's folder, so "other" never takes in a folder that * belongs to a group that wasn't chosen. * * @return array */ public static function excludes(array $settings, array $roots): array { $scope = Scope::for_settings($settings); $all = Groups::roots($scope); $out = array_intersect_key(Groups::excludes($all, [], SubsiteFiles::unchosen($scope, $all)), $roots); if (isset($roots['root'])) { $out['root'] = RootFiles::excludes($all, (array) ($settings['skip_root'] ?? [])); } return $out; } }