Skip to content

Instantly share code, notes, and snippets.

@evanfraser
Last active September 17, 2021 12:54
Show Gist options
  • Save evanfraser/54a1c47afa42410fe8c9c2b25ccf7d70 to your computer and use it in GitHub Desktop.
Save evanfraser/54a1c47afa42410fe8c9c2b25ccf7d70 to your computer and use it in GitHub Desktop.
<?php
/**
* Shortcode: EDD Product Version
*
* [edd_product_version]
* You can add id="post_id_here" to display the version number of a defined product.
*/
function shortcode_edd_product_version($atts) {
$atts = shortcode_atts(array(
'id' => get_the_ID(),
), $atts);
$args = array(
'download_id' => get_post_meta($atts['id'], '_edd_sl_version', true),
'download_name' => get_the_title($atts['id']),
);
$result = null;
if (class_exists('EDD_Software_Licensing')) {
$result = $args['download_id'];
}
return $result;
}
add_shortcode('edd_product_version', 'shortcode_edd_product_version');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment