コード例 #1
0
			</tr>
		</thead>
		<?php 
    foreach ($purchases as $post) {
        setup_postdata($post);
        $downloads = edd_get_payment_meta_downloads($post->ID);
        $purchase_data = edd_get_payment_meta($post->ID);
        if ($downloads) {
            foreach ($downloads as $download) {
                echo '<tr class="edd_download_history_row">';
                $id = isset($purchase_data['cart_details']) ? $download['id'] : $download;
                $price_id = isset($download['options']['price_id']) ? $download['options']['price_id'] : null;
                $download_files = edd_get_download_files($id, $price_id);
                do_action('edd_download_history_row_start', $post->ID, $id);
                echo '<td class="edd_download_download_name">' . get_the_title($id) . '</td>';
                if (!edd_no_redownload()) {
                    echo '<td class="edd_download_download_files">';
                    if ($download_files) {
                        foreach ($download_files as $filekey => $file) {
                            $download_url = edd_get_download_file_url($purchase_data['key'], $purchase_data['email'], $filekey, $id);
                            echo '<div class="edd_download_file"><a href="' . esc_url($download_url) . '" class="edd_download_file_link">' . esc_html($file['name']) . '</a></div>';
                            do_action('edd_download_history_files', $filekey, $file, $id, $post->ID, $purchase_data);
                        }
                    } else {
                        _e('No downloadable files found.', 'edd');
                    }
                    echo '</td>';
                }
                // end if ! edd_no_redownload()
                do_action('edd_download_history_row_end', $post->ID, $id);
                echo '</tr>';
コード例 #2
0
 /** @see WP_Widget::widget */
 function widget($args, $instance)
 {
     extract($args);
     $title = apply_filters('widget_title', $instance['title']);
     global $user_ID, $edd_options;
     if (is_user_logged_in()) {
         $purchases = edd_get_users_purchases($user_ID);
         if ($purchases) {
             echo $before_widget;
             if ($title) {
                 echo $before_title . $title . $after_title;
             }
             foreach ($purchases as $purchase) {
                 $purchase_data = edd_get_payment_meta($purchase->ID);
                 $downloads = edd_get_payment_meta_downloads($purchase->ID);
                 if ($downloads) {
                     foreach ($downloads as $download) {
                         $id = isset($purchase_data['cart_details']) ? $download['id'] : $download;
                         $price_id = isset($download['options']['price_id']) ? $download['options']['price_id'] : null;
                         $download_files = edd_get_download_files($id, $price_id);
                         echo '<div class="edd-purchased-widget-purchase edd-purchased-widget-purchase-' . $purchase->ID . '" id="edd-purchased-widget-purchase-' . $id . '">';
                         echo '<div class="edd-purchased-widget-purchase-name">' . get_the_title($id) . '</div>';
                         echo '<ul class="edd-purchased-widget-file-list">';
                         if (!edd_no_redownload()) {
                             if ($download_files) {
                                 foreach ($download_files as $filekey => $file) {
                                     $download_url = edd_get_download_file_url($purchase_data['key'], $purchase_data['email'], $filekey, $id, $price_id);
                                     echo '<li class="edd-purchased-widget-file"><a href="' . $download_url . '" class="edd-purchased-widget-file-link">' . $file['name'] . '</a></li>';
                                 }
                             } else {
                                 echo '<li class="edd-purchased-widget-no-file">' . __('No downloadable files found.', 'edd');
                             }
                         }
                         echo '</ul>';
                         echo '</div>';
                     }
                 }
             }
         }
         echo $after_widget;
     }
 }