Created
October 8, 2019 14:19
-
-
Save mklasen/85b4e5f4934db6d6a47f05da4244b630 to your computer and use it in GitHub Desktop.
EDD: Enable software updates for free downloads
This file contains hidden or 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 | |
class Enable_Software_Updates_For_Free_Downloads { | |
public function __construct() { | |
$this->hooks(); | |
} | |
public function hooks() { | |
add_filter( 'edd_sl_generate_license_key', array( $this, 'generate_free_license_key' ), 10, 5 ); | |
add_filter( 'edd_sl_check_license_status', array( $this, 'skip_free_download_license_check' ), 10, 2 ); | |
} | |
/** | |
* When generating a free license, set the key. | |
*/ | |
public function generate_free_license_key( $key, $license_id, $download_id, $payment_id, $cart_index ) { | |
if ( edd_is_free_download( $download_id ) ) { | |
$key = 'free-download'; | |
} | |
return $key; | |
} | |
/** | |
* Mark license as valid when it's a free download. (since it's never activated) | |
*/ | |
public function skip_free_download_license_check( $status, $license ) { | |
if ( $license->__get( 'key' ) === 'free-download' ) { | |
$status = 'valid'; | |
} | |
return $status; | |
} | |
} |
This file contains hidden or 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 | |
$edd_updater = new EDD_SL_Plugin_Updater( $this->_store_url, __FILE__, array( | |
'version' => $this->_version, | |
'license' => 'free-download', | |
'item_id' => $this->_item_id, | |
'author' => 'Sympose', | |
'url' => home_url(), | |
'beta' => false | |
) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you