Commit 7e5eaad8715 for woocommerce

commit 7e5eaad87157f8351cd70df34404cb4a81afe8c3
Author: SH Sajal Chowdhury <72102985+shsajalchowdhury@users.noreply.github.com>
Date:   Mon May 25 17:55:51 2026 +0600

    Fix: Replace hardcoded /wp-content path with WP_CONTENT_DIR constant (#64376)

diff --git a/plugins/woocommerce/changelog/pr-64376 b/plugins/woocommerce/changelog/pr-64376
new file mode 100644
index 00000000000..8809a66a97b
--- /dev/null
+++ b/plugins/woocommerce/changelog/pr-64376
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Replace hardcoded /wp-content path with WP_CONTENT_DIR constant.
diff --git a/plugins/woocommerce/includes/class-wc-download-handler.php b/plugins/woocommerce/includes/class-wc-download-handler.php
index 1b6cb3afce4..2344659a667 100644
--- a/plugins/woocommerce/includes/class-wc-download-handler.php
+++ b/plugins/woocommerce/includes/class-wc-download-handler.php
@@ -310,14 +310,18 @@ class WC_Download_Handler {
 			);
 		}

+		$wp_content_dirname = ( 0 === strpos( WP_CONTENT_DIR, ABSPATH ) )
+			? '/' . substr( WP_CONTENT_DIR, strlen( ABSPATH ) )
+			: '/wp-content';
+
 		// See if path needs an abspath prepended to work.
 		if ( file_exists( ABSPATH . $file_path ) ) {
 			$remote_file = false;
 			$file_path   = ABSPATH . $file_path;

-		} elseif ( '/wp-content' === substr( $file_path, 0, 11 ) ) {
+		} elseif ( 0 === strpos( $file_path, $wp_content_dirname ) ) {
 			$remote_file = false;
-			$file_path   = realpath( WP_CONTENT_DIR . substr( $file_path, 11 ) );
+			$file_path   = realpath( WP_CONTENT_DIR . substr( $file_path, strlen( $wp_content_dirname ) ) );

 			// Check if we have an absolute path.
 		} elseif ( ( ! isset( $parsed_file_path['scheme'] ) || ! in_array( $parsed_file_path['scheme'], array( 'http', 'https', 'ftp' ), true ) ) && isset( $parsed_file_path['path'] ) ) {