The keys that are never shared. */ public static function notShareable(): array { return ['excludedIDs', 'alt_uploadedimage']; } /** * The fields a network administrator may set. * * @return array> The schema, minus the two. */ public static function fields(): array { return array_diff_key( SettingsSchema::fields(), array_flip(self::notShareable()) ); } /** * The stored defaults, cleaned. * * @return array Only keys a network default may carry. */ public static function get(): array { if (!is_multisite()) { return []; } $stored = get_site_option(self::OPTION, []); if (!is_array($stored)) { return []; } // Through the same sanitiser as everything else, then filtered again: // a key could have been written before it joined the excluded list, or // by something other than this screen. return array_diff_key( SettingsSchema::sanitize($stored), array_flip(self::notShareable()) ); } /** * Stores a new set of defaults. * * @param array $values The submitted values. * * @return array What was actually stored. */ public static function save(array $values): array { $clean = array_diff_key( SettingsSchema::sanitize($values), array_flip(self::notShareable()) ); update_site_option(self::OPTION, $clean); return $clean; } /** * The values a site should start with. * * @return array Plugin defaults with the network's on top. */ public static function forNewSite(): array { return array_merge( SettingsSchema::sanitize(SettingsSchema::defaults()), self::get() ); } }