Skip to content

Instantly share code, notes, and snippets.

@mindctrl
Forked from sudar/readme.php
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save mindctrl/5199f22781d983c45ded to your computer and use it in GitHub Desktop.

Select an option

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.
<?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