-
-
Save mindctrl/5199f22781d983c45ded to your computer and use it in GitHub Desktop.
Automatically update a download's version number and change log using a readme.txt file with the Easy Digital Downloads Software Licensing extension.
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 | |
| /* | |
| Plugin Name: EDD Readme Parsing Enhancements | |
| Description: Updates a Download's current version and change log fields when using the readme.txt parsing feature in Easy Digital Downloads. | |
| */ | |
| /** | |
| * Filters the EDD readme.txt parser response and updates the | |
| * download's current version and change log fields. | |
| */ | |
| function array_edd_readme_enchancer( $response, $download, $readme ) { | |
| // Update the current version number for the theme | |
| $meta_version = get_post_meta( $download->ID, '_edd_sl_version', true ); | |
| if ( '' != $readme['stable_tag'] && $meta_version != $readme['stable_tag'] ) { | |
| update_post_meta( $download->ID, '_edd_sl_version', $readme['stable_tag'] ); | |
| } | |
| // Update the change log field so we can display it on the front end. | |
| $meta_changelog = get_post_meta( $download->ID, '_edd_sl_changelog', true ); | |
| if( '' != $readme['sections']['change_log'] && $meta_changelog != $readme['sections']['change_log'] ) { | |
| update_post_meta( $download->ID, '_edd_sl_changelog', $readme['sections']['change_log'] ); | |
| } | |
| return $response; | |
| } | |
| add_filter( 'edd_sl_license_readme_response', 'array_edd_readme_enchancer', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment