Last active
December 25, 2015 13:39
-
-
Save amdrew/6985653 to your computer and use it in GitHub Desktop.
Get an array containing of all the log IDs for a particular download using the EDD Logging Class in Easy Digital Downloads.
This file contains hidden or 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 | |
/** | |
* Get an array of all the log IDs using the EDD Logging Class | |
* | |
* @return array if logs, null otherwise | |
* @param $download_id Download's ID | |
*/ | |
function get_log_ids( $download_id = '' ) { | |
// Instantiate a new instance of the class | |
$edd_logging = new EDD_Logging; | |
// get logs for this download with type of 'sale' | |
$logs = $edd_logging->get_logs( $download_id, 'sale' ); | |
// if logs exist | |
if ( $logs ) { | |
// create array to store our log IDs into | |
$log_ids = array(); | |
// add each log ID to the array | |
foreach ( $logs as $log ) { | |
$log_ids[] = $log->ID; | |
} | |
// return our array | |
return $log_ids; | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment