getActive(true), $driver . '.instance'); if (empty($instance)) { return new \WP_Error( 'fluent_cart_storage_driver_invalid', /* translators: %1$s: the storage driver slug that was submitted */ sprintf(__('The storage driver "%1$s" is not enabled.', 'fluent-cart'), $driver) ); } // Third-party drivers only have to implement BaseStorageInterface, which // declares neither method; treat those as bucketless rather than fataling. if (!method_exists($instance, 'hasBucket') || !$instance->hasBucket()) { return ''; } $bucket = method_exists($instance, 'getEffectiveBucket') ? (string)$instance->getEffectiveBucket() : ''; if ($bucket === '') { return new \WP_Error( 'fluent_cart_storage_bucket_missing', /* translators: %1$s: the storage driver slug that was submitted */ sprintf(__('No bucket is configured for the "%1$s" storage driver.', 'fluent-cart'), $driver) ); } return $bucket; } /** * Read-path variant: never fails, so a misconfigured driver degrades to the * driver's own default bucket instead of breaking an existing download. * Returns null when nothing can be resolved, which every driver reads as * "use my configured bucket". * * @param string $driver * @return string|null */ public static function resolveOrNull($driver) { $bucket = static::resolve($driver); if (is_wp_error($bucket) || $bucket === '') { return null; } return $bucket; } }