Created
June 12, 2020 16:49
-
-
Save danieliser/fd8026f59ab370de1de028bd3f53f9fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function custom_edd_all_access_check_current_download( $download_id = 0 ) { | |
static $cache = []; | |
if ( ! isset( $cache[ $download_id ] ) ) { | |
$cache[ $download_id ] = edd_all_access_check( [ | |
'download_id' => $download_id, | |
'price_id' => 0, | |
] ); | |
} | |
return $cache[ $download_id ]; | |
} | |
function bb_logic_custom_user_can_download_extension( $rule ) { | |
if ( ! function_exists( 'edd_all_access_check' ) ) { | |
return false; | |
} | |
$download_id = get_the_ID(); | |
static $has_access = []; | |
if ( ! isset( $has_access[ $download_id ] ) ) { | |
$has_edd_all_access = custom_edd_all_access_check_current_download( $download_id ); | |
if ( true === $has_edd_all_access['success'] ) { | |
$has_access[ $download_id ] = true; | |
} | |
else if ( edd_has_user_purchased( get_current_user_id(), $download_id, null ) && check_users_download_license_status( $download_id ) ) { | |
$has_access[ $download_id ] = true; | |
} else { | |
$has_access[ $download_id ] = false; | |
} | |
} | |
return ( $rule->operator == "1" && true === $has_access[ $download_id ] ) || ( $rule->operator == "0" && false === $has_access[ $download_id ] ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment