Last active
March 17, 2016 04:08
-
-
Save renventura/18255f04769fcdfd1e58 to your computer and use it in GitHub Desktop.
Store the content of an Easy Digital Downloads licensed download in a shortcode to use anywhere on your WordPress website.
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 //* Mind this opening PHP tag | |
/** | |
* This snippet creates a shortcode that renders the content of a | |
* licensed download/product's change log in Easy Digital Downloads. | |
* | |
* Example: [edd_changelog download_id="0000"] (replace 0000 with the ID of a download post) | |
* | |
* @author Ren Ventura <EngageWP.com> | |
* @link https://www.engagewp.com/include-easy-digital-downloads-software-licensing-change-logs-posts/ | |
*/ | |
// Change Log Content | |
add_shortcode( 'edd_changelog', 'edd_changelog_callback' ); | |
function edd_changelog_callback( $atts ) { | |
// Available attributes | |
$shortcode_atts = array( | |
'download_id' => 0, | |
); | |
$shortcode_atts = shortcode_atts( $shortcode_atts, $atts ); | |
// Extract each att to a variable | |
extract( $shortcode_atts ); | |
// Return the changelog data | |
return get_post_meta( $download_id, '_edd_sl_changelog', true ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment