Route download redirect through provider interface
This commit is contained in:
@@ -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 )
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user