html-order-download-permission.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3. exit;
  4. }
  5. ?>
  6. <div class="wc-metabox closed">
  7. <h3 class="fixed">
  8. <button type="button" data-permission_id="<?php echo esc_attr( $download->get_id() ); ?>" rel="<?php echo esc_attr( $download->get_product_id() ) . ',' . esc_attr( $download->get_download_id() ); ?>" class="revoke_access button"><?php esc_html_e( 'Revoke access', 'woocommerce' ); ?></button>
  9. <div class="handlediv" aria-label="<?php esc_attr_e( 'Click to toggle', 'woocommerce' ); ?>"></div>
  10. <strong>
  11. <?php
  12. printf(
  13. '#%s &mdash; %s &mdash; %s: %s &mdash; ',
  14. esc_html( $product->get_id() ),
  15. esc_html( apply_filters( 'woocommerce_admin_download_permissions_title', $product->get_name(), $download->get_product_id(), $download->get_order_id(), $download->get_order_key(), $download->get_download_id() ) ),
  16. esc_html( $file_count ),
  17. esc_html( wc_get_filename_from_url( $product->get_file_download_path( $download->get_download_id() ) ) )
  18. );
  19. printf( _n( 'Downloaded %s time', 'Downloaded %s times', $download->get_download_count(), 'woocommerce' ), esc_html( $download->get_download_count() ) )
  20. ?>
  21. </strong>
  22. </h3>
  23. <table cellpadding="0" cellspacing="0" class="wc-metabox-content">
  24. <tbody>
  25. <tr>
  26. <td>
  27. <label><?php esc_html_e( 'Downloads remaining', 'woocommerce' ); ?></label>
  28. <input type="hidden" name="permission_id[<?php echo esc_attr( $loop ); ?>]" value="<?php echo esc_attr( $download->get_id() ); ?>" />
  29. <input type="number" step="1" min="0" class="short" name="downloads_remaining[<?php echo esc_attr( $loop ); ?>]" value="<?php echo esc_attr( $download->get_downloads_remaining() ); ?>" placeholder="<?php esc_attr_e( 'Unlimited', 'woocommerce' ); ?>" />
  30. </td>
  31. <td>
  32. <label><?php esc_html_e( 'Access expires', 'woocommerce' ); ?></label>
  33. <input type="text" class="short date-picker" name="access_expires[<?php echo esc_attr( $loop ); ?>]" value="<?php echo ! is_null( $download->get_access_expires() ) ? esc_attr( date_i18n( 'Y-m-d', $download->get_access_expires()->getTimestamp() ) ) : ''; ?>" maxlength="10" placeholder="<?php esc_attr_e( 'Never', 'woocommerce' ); ?>" pattern="<?php echo esc_attr( apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ) ); ?>" />
  34. </td>
  35. <td>
  36. <label><?php esc_html_e( 'Customer download link', 'woocommerce' ); ?></label>
  37. <?php
  38. $download_link = add_query_arg(
  39. array(
  40. 'download_file' => $download->get_product_id(),
  41. 'order' => $download->get_order_key(),
  42. 'email' => urlencode( $download->get_user_email() ),
  43. 'key' => $download->get_download_id(),
  44. ), trailingslashit( home_url() )
  45. );
  46. ?>
  47. <a id="copy-download-link" class="button" href="<?php echo esc_url( $download_link ); ?>" data-tip="<?php esc_attr_e( 'Copied!', 'woocommerce' ); ?>" data-tip-failed="<?php esc_attr_e( 'Copying to clipboard failed. You should be able to right-click the button and copy.', 'woocommerce' ); ?>"><?php esc_html_e( 'Copy link', 'woocommerce' ); ?></a>
  48. </td>
  49. <td>
  50. <label><?php esc_html_e( 'Customer download log', 'woocommerce' ); ?></label>
  51. <?php
  52. $report_url = add_query_arg(
  53. 'permission_id',
  54. rawurlencode( $download->get_id() ),
  55. admin_url( 'admin.php?page=wc-reports&tab=orders&report=downloads' )
  56. );
  57. echo '<a class="button" href="' . esc_url( $report_url ) . '">';
  58. esc_html_e( 'View report', 'woocommerce' );
  59. echo '</a>';
  60. ?>
  61. </td>
  62. </tr>
  63. </tbody>
  64. </table>
  65. </div>