You've already forked wc-licensed-product
Implement versions 0.0.4-0.0.7 features
v0.0.4: - Add WooCommerce settings tab for default license settings - Per-product settings override global defaults v0.0.5: - Add bulk license operations (activate, deactivate, revoke, extend, delete) - Add license renewal/extension and lifetime functionality - Add quick action buttons per license row v0.0.6: - Add license dashboard with statistics and analytics - Add license transfer functionality (admin) - Add CSV export for licenses - Add OpenAPI 3.1 specification - Remove /deactivate API endpoint v0.0.7: - Move license dashboard to WooCommerce Reports section - Add license search and filtering in admin - Add customer-facing license transfer with AJAX modal - Add email notifications for license expiration warnings - Add bulk import licenses from CSV - Update README with comprehensive documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -165,3 +165,306 @@
|
||||
vertical-align: middle;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
/* Licenses Table Bulk Actions */
|
||||
.licenses-table {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.licenses-table .check-column {
|
||||
width: 2.2em;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
.licenses-table .license-actions {
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.licenses-table .row-actions {
|
||||
visibility: visible;
|
||||
padding: 2px 0 0;
|
||||
}
|
||||
|
||||
.licenses-table .row-actions a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.licenses-table .row-actions .submitdelete {
|
||||
color: #b32d2e;
|
||||
}
|
||||
|
||||
.licenses-table .row-actions .submitdelete:hover {
|
||||
color: #dc3232;
|
||||
}
|
||||
|
||||
/* Lifetime Badge */
|
||||
.license-lifetime {
|
||||
display: inline-block;
|
||||
padding: 0.2em 0.5em;
|
||||
font-size: 0.85em;
|
||||
font-weight: 500;
|
||||
background-color: #e7f3ff;
|
||||
color: #2271b1;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/* Bulk Actions Styling */
|
||||
.tablenav .actions select {
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.tablenav .bulkactions {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Transfer Modal */
|
||||
.wclp-modal {
|
||||
position: fixed;
|
||||
z-index: 100000;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.wclp-modal-content {
|
||||
background-color: #fff;
|
||||
margin: 10% auto;
|
||||
padding: 20px 30px;
|
||||
border-radius: 4px;
|
||||
width: 500px;
|
||||
max-width: 90%;
|
||||
position: relative;
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.wclp-modal-close {
|
||||
position: absolute;
|
||||
right: 15px;
|
||||
top: 10px;
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.wclp-modal-close:hover {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.wclp-modal h2 {
|
||||
margin-top: 0;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.wclp-modal .form-table th {
|
||||
padding: 15px 10px 15px 0;
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.wclp-modal .submit {
|
||||
border-top: 1px solid #ddd;
|
||||
padding-top: 15px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* Dashboard Styles */
|
||||
.wclp-dashboard-stats {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.wclp-stat-cards {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 15px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.wclp-stat-card {
|
||||
flex: 1;
|
||||
min-width: 150px;
|
||||
max-width: 200px;
|
||||
background: #fff;
|
||||
border: 1px solid #c3c4c7;
|
||||
border-radius: 4px;
|
||||
padding: 15px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.wclp-stat-icon {
|
||||
font-size: 32px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.wclp-stat-icon .dashicons {
|
||||
font-size: 32px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.wclp-stat-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.wclp-stat-number {
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.wclp-stat-label {
|
||||
font-size: 12px;
|
||||
color: #646970;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.wclp-stat-total .wclp-stat-icon .dashicons {
|
||||
color: #2271b1;
|
||||
}
|
||||
|
||||
.wclp-stat-active .wclp-stat-icon .dashicons {
|
||||
color: #00a32a;
|
||||
}
|
||||
|
||||
.wclp-stat-inactive .wclp-stat-icon .dashicons {
|
||||
color: #dba617;
|
||||
}
|
||||
|
||||
.wclp-stat-expired .wclp-stat-icon .dashicons {
|
||||
color: #d63638;
|
||||
}
|
||||
|
||||
.wclp-stat-revoked .wclp-stat-icon .dashicons {
|
||||
color: #646970;
|
||||
}
|
||||
|
||||
.wclp-stat-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.wclp-stat-box {
|
||||
flex: 1;
|
||||
min-width: 280px;
|
||||
background: #fff;
|
||||
border: 1px solid #c3c4c7;
|
||||
border-radius: 4px;
|
||||
padding: 15px 20px;
|
||||
}
|
||||
|
||||
.wclp-stat-box.wclp-stat-full {
|
||||
flex: 100%;
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
.wclp-stat-box h3 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 15px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.wclp-stat-box .widefat {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.wclp-stat-value {
|
||||
text-align: right;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.wclp-stat-value.wclp-warning {
|
||||
color: #d63638;
|
||||
}
|
||||
|
||||
/* Dashboard Bar Chart */
|
||||
.wclp-chart-container {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.wclp-bar-chart {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 10px;
|
||||
height: 200px;
|
||||
padding: 20px 0;
|
||||
}
|
||||
|
||||
.wclp-bar-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
min-width: 50px;
|
||||
}
|
||||
|
||||
.wclp-bar {
|
||||
width: 100%;
|
||||
max-width: 40px;
|
||||
background: linear-gradient(180deg, #2271b1, #135e96);
|
||||
border-radius: 3px 3px 0 0;
|
||||
min-height: 4px;
|
||||
position: relative;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.wclp-bar:hover {
|
||||
background: linear-gradient(180deg, #135e96, #0a4b78);
|
||||
}
|
||||
|
||||
.wclp-bar-value {
|
||||
position: absolute;
|
||||
top: -20px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: #1d2327;
|
||||
}
|
||||
|
||||
.wclp-bar-label {
|
||||
margin-top: 8px;
|
||||
font-size: 10px;
|
||||
color: #646970;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Dashboard Actions */
|
||||
.wclp-dashboard-actions {
|
||||
background: #fff;
|
||||
border: 1px solid #c3c4c7;
|
||||
border-radius: 4px;
|
||||
padding: 15px 20px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.wclp-dashboard-actions h2 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.wclp-action-buttons {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.wclp-action-buttons .button .dashicons {
|
||||
vertical-align: middle;
|
||||
margin-right: 5px;
|
||||
margin-top: -2px;
|
||||
}
|
||||
|
||||
/* Wider actions column for transfer link */
|
||||
.licenses-table .license-actions {
|
||||
width: 220px;
|
||||
}
|
||||
|
||||
@@ -150,6 +150,39 @@
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.license-domain-display {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5em;
|
||||
}
|
||||
|
||||
/* Transfer Button */
|
||||
.wclp-transfer-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.25em;
|
||||
padding: 0.2em 0.6em;
|
||||
background: #f0f0f0;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 3px;
|
||||
font-size: 0.85em;
|
||||
color: #555;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.wclp-transfer-btn:hover {
|
||||
background: #e5e5e5;
|
||||
border-color: #ccc;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.wclp-transfer-btn .dashicons {
|
||||
font-size: 14px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
/* Download Section */
|
||||
.license-downloads {
|
||||
padding: 1em 1.5em;
|
||||
@@ -323,4 +356,151 @@
|
||||
width: 45%;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.license-domain-display {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.wclp-transfer-btn {
|
||||
margin-top: 0.5em;
|
||||
}
|
||||
}
|
||||
|
||||
/* Transfer Modal */
|
||||
.wclp-modal {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 100000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.wclp-modal-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.wclp-modal-content {
|
||||
position: relative;
|
||||
background: #fff;
|
||||
padding: 2em;
|
||||
border-radius: 8px;
|
||||
max-width: 450px;
|
||||
width: 90%;
|
||||
max-height: 90vh;
|
||||
overflow-y: auto;
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.wclp-modal-close {
|
||||
position: absolute;
|
||||
top: 0.5em;
|
||||
right: 0.5em;
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 1.5em;
|
||||
cursor: pointer;
|
||||
color: #666;
|
||||
line-height: 1;
|
||||
padding: 0.25em;
|
||||
}
|
||||
|
||||
.wclp-modal-close:hover {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.wclp-modal-content h3 {
|
||||
margin: 0 0 1.5em 0;
|
||||
font-size: 1.25em;
|
||||
}
|
||||
|
||||
.wclp-form-row {
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
|
||||
.wclp-form-row label {
|
||||
display: block;
|
||||
font-weight: 600;
|
||||
margin-bottom: 0.5em;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.wclp-form-row input[type="text"] {
|
||||
width: 100%;
|
||||
padding: 0.75em;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.wclp-form-row input[type="text"]:focus {
|
||||
outline: none;
|
||||
border-color: #2271b1;
|
||||
box-shadow: 0 0 0 1px #2271b1;
|
||||
}
|
||||
|
||||
.wclp-current-domain {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.wclp-current-domain code {
|
||||
background: #f5f5f5;
|
||||
padding: 0.4em 0.8em;
|
||||
border-radius: 4px;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.wclp-field-description {
|
||||
margin: 0.5em 0 0 0;
|
||||
font-size: 0.85em;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.wclp-form-actions {
|
||||
display: flex;
|
||||
gap: 1em;
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
.wclp-btn-primary {
|
||||
background: #2271b1 !important;
|
||||
border-color: #2271b1 !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
.wclp-btn-primary:hover {
|
||||
background: #135e96 !important;
|
||||
border-color: #135e96 !important;
|
||||
}
|
||||
|
||||
.wclp-btn-primary:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.wclp-message {
|
||||
margin-top: 1em;
|
||||
padding: 0.75em 1em;
|
||||
border-radius: 4px;
|
||||
font-size: 0.95em;
|
||||
}
|
||||
|
||||
.wclp-message.success {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
border: 1px solid #c3e6cb;
|
||||
}
|
||||
|
||||
.wclp-message.error {
|
||||
background: #f8d7da;
|
||||
color: #721c24;
|
||||
border: 1px solid #f5c6cb;
|
||||
}
|
||||
|
||||
@@ -8,12 +8,29 @@
|
||||
'use strict';
|
||||
|
||||
var WCLicensedProductFrontend = {
|
||||
$modal: null,
|
||||
$form: null,
|
||||
|
||||
init: function() {
|
||||
this.$modal = $('#wclp-transfer-modal');
|
||||
this.$form = $('#wclp-transfer-form');
|
||||
this.bindEvents();
|
||||
},
|
||||
|
||||
bindEvents: function() {
|
||||
$(document).on('click', '.copy-license-btn', this.copyLicenseKey);
|
||||
|
||||
// Transfer modal events
|
||||
$(document).on('click', '.wclp-transfer-btn', this.openTransferModal.bind(this));
|
||||
$(document).on('click', '.wclp-modal-close, .wclp-modal-cancel, .wclp-modal-overlay', this.closeTransferModal.bind(this));
|
||||
$(document).on('submit', '#wclp-transfer-form', this.submitTransfer.bind(this));
|
||||
|
||||
// Close modal on escape key
|
||||
$(document).on('keyup', function(e) {
|
||||
if (e.key === 'Escape') {
|
||||
WCLicensedProductFrontend.closeTransferModal();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -80,6 +97,106 @@
|
||||
$(this).remove();
|
||||
});
|
||||
}, 1500);
|
||||
},
|
||||
|
||||
/**
|
||||
* Open transfer modal
|
||||
*/
|
||||
openTransferModal: function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var $btn = $(e.currentTarget);
|
||||
var licenseId = $btn.data('license-id');
|
||||
var currentDomain = $btn.data('current-domain');
|
||||
|
||||
$('#transfer-license-id').val(licenseId);
|
||||
$('#transfer-current-domain').text(currentDomain);
|
||||
$('#transfer-new-domain').val('');
|
||||
$('#wclp-transfer-message').hide().removeClass('success error');
|
||||
$('#wclp-transfer-submit').prop('disabled', false);
|
||||
|
||||
this.$modal.show();
|
||||
$('#transfer-new-domain').focus();
|
||||
},
|
||||
|
||||
/**
|
||||
* Close transfer modal
|
||||
*/
|
||||
closeTransferModal: function(e) {
|
||||
if (e && $(e.target).closest('.wclp-modal-content').length && !$(e.target).is('.wclp-modal-close, .wclp-modal-cancel')) {
|
||||
return;
|
||||
}
|
||||
this.$modal.hide();
|
||||
},
|
||||
|
||||
/**
|
||||
* Submit transfer request
|
||||
*/
|
||||
submitTransfer: function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var self = this;
|
||||
var licenseId = $('#transfer-license-id').val();
|
||||
var newDomain = $('#transfer-new-domain').val().trim();
|
||||
var $message = $('#wclp-transfer-message');
|
||||
var $submit = $('#wclp-transfer-submit');
|
||||
|
||||
// Basic validation
|
||||
if (!newDomain) {
|
||||
$message.text(wcLicensedProduct.strings.invalidDomain)
|
||||
.removeClass('success').addClass('error').show();
|
||||
return;
|
||||
}
|
||||
|
||||
// Confirm transfer
|
||||
if (!confirm(wcLicensedProduct.strings.transferConfirm)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable submit button
|
||||
$submit.prop('disabled', true);
|
||||
$message.hide();
|
||||
|
||||
// Send AJAX request
|
||||
$.ajax({
|
||||
url: wcLicensedProduct.ajaxUrl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'wclp_customer_transfer_license',
|
||||
nonce: wcLicensedProduct.transferNonce,
|
||||
license_id: licenseId,
|
||||
new_domain: newDomain
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
$message.text(response.data.message)
|
||||
.removeClass('error').addClass('success').show();
|
||||
|
||||
// Update the domain display in the license card
|
||||
var $domainDisplay = $('.license-domain-display[data-license-id="' + licenseId + '"]');
|
||||
$domainDisplay.find('.domain-value').text(response.data.new_domain);
|
||||
$domainDisplay.find('.wclp-transfer-btn').data('current-domain', response.data.new_domain);
|
||||
|
||||
// Close modal after a short delay
|
||||
setTimeout(function() {
|
||||
self.closeTransferModal();
|
||||
}, 1500);
|
||||
} else {
|
||||
$message.text(response.data.message || wcLicensedProduct.strings.transferError)
|
||||
.removeClass('success').addClass('error').show();
|
||||
$submit.prop('disabled', false);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
var message = wcLicensedProduct.strings.transferError;
|
||||
if (xhr.responseJSON && xhr.responseJSON.data && xhr.responseJSON.data.message) {
|
||||
message = xhr.responseJSON.data.message;
|
||||
}
|
||||
$message.text(message)
|
||||
.removeClass('success').addClass('error').show();
|
||||
$submit.prop('disabled', false);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user