I have been selling WordPress plugins with Easy Digital Downloads for a few years now. I’m very grateful for the Software Licensing extension for Easy Digital Downloads because it enables me to track sales through the use of the built-in licensing function. Every time one of my plugins licenses is activated on a customer’s site, Software Licensing gets notified of the site URL, which is awesome. This can potentially let me see how my customers are using the plugins I’ve created. Unfortunately, there isn’t a “master report” that shows me all of the sites my plugins have been activated on.
Instead, if I wanted to view all of the sites, I would have to click through to the details page for each license. If I have hundreds of licenses this could be a very time-consuming process.
Show Easy Digital Downloads Licensed URLs
I decided to create a little function that queries the database to show Easy Digital Downloads licensed URLs for all of the sites that have activated one of my plugins. This way I can have one master report that shows a list of the sites my customers have been using my plugins on.
function get_sites(){ $licenses = get_posts( array( 'posts_per_page' => -1, 'post_type' => 'edd_license', 'meta_query' => array( array( 'key' => '_edd_sl_sites', ) ) ) ); wp_reset_postdata(); $post_ids = array(); if ( $licenses ){ foreach( $licenses as $license ){ $post_ids[] = $license->ID; } } if ( $post_ids ){ echo '<ul>'; foreach ( $post_ids as $post_id ){ $sites = get_post_meta( $post_id, '_edd_sl_sites', true ); $download_id = get_post_meta( $post_id, '_edd_sl_download_id', true); $download = get_the_title( $download_id ); if ( $sites ){ foreach( $sites as $site ){ echo '<li><a href="http://' . $site . '">http://' . $site . '</a> - ' . $download . '</li>'; } } } echo '</ul>'; } } |
This function can be used anywhere to display all of the sites that your customers are using your plugins. If you want it for your own internal purposes, you can create a page on the admin side that displays this information. You can even display this on the front end of the site to show off a list of sites that are using your plugin. While the example isn’t formatted in a very pretty format, it could be modified in order to build a showcase section on your site.
There might be a better way of doing this, but this is functional. And for my purposes, it did what I needed it to do. If you have any thoughts on how to improve this or how you might be able to use this information, let me know in the comments.
Leave a Reply