Fixes #2897: Long query string displayed as part of download file name
This commit is contained in:
parent
fa91ef80d4
commit
f6892a676c
|
@ -41,12 +41,14 @@ foreach ($items as $item) :
|
||||||
foreach ( $download_file_urls as $file_url => $download_file_url ) {
|
foreach ( $download_file_urls as $file_url => $download_file_url ) {
|
||||||
echo '<br/><small>';
|
echo '<br/><small>';
|
||||||
|
|
||||||
|
$filename = woocommerce_get_filename_from_url( $file_url );
|
||||||
|
|
||||||
if ( count( $download_file_urls ) > 1 ) {
|
if ( count( $download_file_urls ) > 1 ) {
|
||||||
echo sprintf( __('Download %d:', 'woocommerce' ), $i + 1 );
|
echo sprintf( __('Download %d:', 'woocommerce' ), $i + 1 );
|
||||||
} elseif ( $i == 0 )
|
} elseif ( $i == 0 )
|
||||||
echo __( 'Download:', 'woocommerce' );
|
echo __( 'Download:', 'woocommerce' );
|
||||||
|
|
||||||
echo ' <a href="' . $download_file_url . '" target="_blank">' . current( explode( '?', basename( $file_url ) ) ) . '</a></small>';
|
echo ' <a href="' . $download_file_url . '" target="_blank">' . $filename . '</a></small>';
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,9 @@ $order = new WC_Order( $order_id );
|
||||||
|
|
||||||
foreach ( $download_file_urls as $file_url => $download_file_url ) {
|
foreach ( $download_file_urls as $file_url => $download_file_url ) {
|
||||||
|
|
||||||
$links[] = '<small><a href="' . $download_file_url . '">' . sprintf( __( 'Download file%s', 'woocommerce' ), ( count( $download_file_urls ) > 1 ? ' ' . ( $i + 1 ) . ': ' : ': ' ) ) . basename( $file_url ) . '</a></small>';
|
$filename = woocommerce_get_filename_from_url( $file_url );
|
||||||
|
|
||||||
|
$links[] = '<small><a href="' . $download_file_url . '">' . sprintf( __( 'Download file%s', 'woocommerce' ), ( count( $download_file_urls ) > 1 ? ' ' . ( $i + 1 ) . ': ' : ': ' ) ) . $filename . '</a></small>';
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1717,3 +1717,16 @@ function woocommerce_save_address() {
|
||||||
}
|
}
|
||||||
|
|
||||||
add_action( 'template_redirect', 'woocommerce_save_address' );
|
add_action( 'template_redirect', 'woocommerce_save_address' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the filename part of a download URL
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string $file_url
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
|
||||||
|
function woocommerce_get_filename_from_url( $file_url ) {
|
||||||
|
$parts = parse_url( $file_url );
|
||||||
|
return basename( $parts['path'] );
|
||||||
|
}
|
Loading…
Reference in New Issue