Created
August 4, 2013 08:50
-
-
Save samikeijonen/6149753 to your computer and use it in GitHub Desktop.
Show expire date in [purchase_history] shortcode.
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 | |
/* Show expire date in [purchase_history] table. */ | |
add_action( 'edd_purchase_history_header_after', 'my_edd_stuff_downloads_expire_th', 12 ); | |
add_action( 'edd_purchase_history_row_end', 'my_edd_stuff_downloads_expire_td', 12, 2 ); | |
/** | |
* Show expire date in [purchase_history] shortcode. | |
* | |
* @since 0.1.2 | |
*/ | |
function my_edd_stuff_downloads_expire_th() { | |
echo '<th class="my-edd-stuff-site-count">' . __( 'Expire', 'my-edd-stuff' ) . '</th>'; | |
} | |
/** | |
* Show expire date in [purchase_history] shortcode. | |
* | |
* @since 0.1.2 | |
*/ | |
function my_edd_stuff_downloads_expire_td( $payment_id, $purchase_data ) { | |
/* Get license expire date. */ | |
$expire_date = my_edd_stuff_get_expire_date( $payment_id, $purchase_data ); | |
/* Echo license expire date to [purchase_history] shortcode. */ | |
echo '<td class="my-edd-stuff-expire">' . date( get_option( 'date_format' ), $expire_date ) . '</td>'; | |
} | |
/** | |
* Get site count. | |
* | |
* @since 0.1.2 | |
*/ | |
function my_edd_stuff_get_expire_date( $payment_id, $purchase_data) { | |
$licensing = edd_software_licensing(); | |
$downloads = edd_get_payment_meta_downloads( $payment_id ); | |
/* Get license. */ | |
foreach( $downloads as $download ) { | |
$license = $licensing->get_license_by_purchase( $payment_id, $download['id'] ); | |
if( $license ) { | |
return absint( get_post_meta( $license->ID, '_edd_sl_expiration', true ) ); | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment