Skip to content

Instantly share code, notes, and snippets.

@jeffaspenburg
Forked from evanfraser/edd-product-version.php
Created September 17, 2021 12:54
Show Gist options
  • Save jeffaspenburg/30cd12a28abb9f54f34422ec50ee5280 to your computer and use it in GitHub Desktop.
Save jeffaspenburg/30cd12a28abb9f54f34422ec50ee5280 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