Route download redirect through provider interface

This commit is contained in:
Keith Solomon
2026-08-09 23:26:02 -05:00
parent e25431a25d
commit 62a049b2c2
+3 -4
View File
@@ -99,8 +99,7 @@ function projects_portfolio_handle_download_redirect() {
$project_id = get_query_var( 'project_download_id' ); $project_id = get_query_var( 'project_download_id' );
if ( $project_id ) { if ( $project_id ) {
$github_url = get_post_meta( $project_id, '_projects_portfolio_github_url', true ); $download_url = projects_portfolio_get_release_url( (int) $project_id );
$download_url = projects_portfolio_get_github_release_url( $github_url );
if ( $download_url ) { if ( $download_url ) {
// Increment download count. // Increment download count.
@@ -108,12 +107,12 @@ function projects_portfolio_handle_download_redirect() {
++$download_count; ++$download_count;
update_post_meta( $project_id, '_projects_portfolio_download_count', $download_count ); update_post_meta( $project_id, '_projects_portfolio_download_count', $download_count );
// Redirect to the GitHub ZIP file. // Redirect to the release ZIP on the project's host.
wp_safe_redirect( esc_url_raw( $download_url ) ); wp_safe_redirect( esc_url_raw( $download_url ) );
exit; exit;
} else { } else {
wp_die( wp_die(
esc_html__( 'Invalid download URL. Please check the GitHub repository.', 'projects-wp' ), esc_html__( 'Invalid download URL. Please check the repository URL.', 'projects-wp' ),
esc_html__( 'Download Error', 'projects-wp' ), esc_html__( 'Download Error', 'projects-wp' ),
array( 'response' => 404 ) array( 'response' => 404 )
); );