Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danieliser/fd8026f59ab370de1de028bd3f53f9fd to your computer and use it in GitHub Desktop.
Save danieliser/fd8026f59ab370de1de028bd3f53f9fd to your computer and use it in GitHub Desktop.
<?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