is_usable() && null === $override && '' !== $document_root ) { update_option( self::OPTION_LOCATION, array( 'path' => $location->path(), 'mode' => $location->mode(), ), true ); } return $location; } /** * The file store, or null when no folder is usable. */ public static function store(): ?FileStore { $location = self::location(); return $location->is_usable() ? new FileStore( $location->path() ) : null; } /** * Signer for file links. The key is derived from the site's auth salt, so it differs per site * and changes when the salts are rotated (which invalidates all outstanding links). */ public static function signer(): UrlSigner { return new UrlSigner( hash_hmac( 'sha256', 'fitzaro-file-links', wp_salt( 'auth' ) ) ); } /** * Whether a path is an existing, writable directory. * * @param string $path Absolute path. */ public static function is_writable_dir( string $path ): bool { return is_dir( $path ) && wp_is_writable( $path ); } /** * Random lowercase suffix for the uploads fallback folder, created once per site. */ private static function suffix(): string { $suffix = (string) get_option( self::OPTION_SUFFIX, '' ); if ( 1 !== preg_match( '/^[a-z0-9]{6,32}$/', $suffix ) ) { $suffix = strtolower( wp_generate_password( 16, false, false ) ); update_option( self::OPTION_SUFFIX, $suffix, false ); } return $suffix; } }