Skip to content

Commit 37bdf0e

Browse files
authored
Merge pull request #1 from dwnload/feature/edd-slm-v2
Updating PHP >= 8.0 - Version 2
2 parents 74885b4 + e927c86 commit 37bdf0e

16 files changed

+2900
-1538
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea
22
.DS_Store
33
vendor
4+
wordpress

CHANGELONG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## 2.0.0 - 2023-11-15
8+
- Bump min PHP version to 8.0.
9+
710
## 1.4.0 - 2019-01-03
811
### Updated
912
- `thefrosty/wp-utilties` to v^1.3.1.

README.md

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
# Dwnload EDD Software License Manager [![Build Status](https://travis-ci.org/dwnload/EddSoftwareLicenseManager.svg?branch=master)](https://travis-ci.org/dwnload/EddSoftwareLicenseManager)
1+
# EDD Software License Manager
2+
3+
[![PHP from Packagist](https://img.shields.io/packagist/php-v/dwnload/edd-software-license-manager.svg)]()
4+
[![Latest Stable Version](https://img.shields.io/packagist/v/dwnload/edd-software-license-manager.svg)](https://packagist.org/packages/dwnload/edd-software-license-manager)
5+
[![Total Downloads](https://img.shields.io/packagist/dt/dwnload/edd-software-license-manager.svg)](https://packagist.org/packages/dwnload/edd-software-license-manager)
6+
[![License](https://img.shields.io/packagist/l/dwnload/edd-software-license-manager.svg)](https://packagist.org/packages/dwnload/edd-software-license-manager)
7+
![Build Status](https://github.com/dwnload/WpSettingsApi/actions/workflows/main.yml/badge.svg)
8+
[![codecov](https://codecov.io/gh/dwnload/WpSettingsApi//branch/develop/graph/badge.svg)](https://codecov.io/gh/dwnload/WpSettingsApi/)
9+
210
A PHP class abstraction for managing WordPress plugin licenses and auto-updates that are sold on an Easy Digital Downloads store.
311

412
## Package Installation (via Composer)
513

614
To install this package, edit your `composer.json` file:
715

8-
```js
16+
```json
917
{
1018
"require": {
11-
"dwnload/edd-software-license-manager": "^1.3.0"
19+
"dwnload/edd-software-license-manager": "^2.0"
1220
}
1321
}
1422
```
@@ -20,31 +28,16 @@ Now run:
2028
### How to use this package
2129

2230
```php
23-
use Dwnload\EddSoftwareLicenseManager\Edd;
24-
25-
// In the root of your plugin
26-
$args = [
27-
'api_url' => trailingslashit( https://plugingarden.dwnload.io ),
28-
'plugin_file' => __FILE__,
29-
'api_data' => [
30-
'version' => (string) $version, // current version number
31-
'license' => (string) $license_key, // license key (used get_option above to retrieve from DB)
32-
'item_name' => 'Super Cool Plugin', // name of this plugin (matching your EDD Download title)
33-
'item_id' => (int) 10,
34-
'author' => 'Austin Passy', // author of this plugin
35-
'beta' => (bool) isset( $use_beta ),
36-
],
37-
'item_id' => (int) 10,
38-
'name' => plugin_basename( __FILE__ ),
39-
'slug' => basename( __FILE__, '.php' ),
40-
'version' => (string) $version,
41-
'wp_override' => false,
42-
'beta' => (bool) isset( $use_beta ),
31+
$license = \get_option(\Dwnload\EddSoftwareLicenseManager\Edd\AbstractLicenceManager::LICENSE_SETTING, []);
32+
$data = [
33+
'license' => $license[$plugin_id]['license'] ?? '',
34+
'item_name' => 'Custom Login Style Pack #1', // Name of this plugin (matching your EDD Download title).
35+
'author' => 'Frosty Media',
36+
'item_id' => (int),
37+
'version' => '1.0.0',
4338
];
44-
45-
if ( is_admin() ) {
46-
( new Init() )
47-
->add( new PluginUpdater( $args )
48-
->initialize();
49-
}
39+
\TheFrosty\WpUtilities\Plugin\Plugin $plugin
40+
->add(new Edd\LicenseManager($plugin, $data))
41+
->add(new Edd\PluginUpdater('https://frosty.media/', __FILE__, $data))
42+
->initialize();
5043
```

assets/css/licensemanager.css

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
1-
h2 span.license-status {
2-
background-color: whitesmoke;
3-
border: 1px solid;
4-
font-size: 90%;
5-
padding: 4px 6px;
6-
border-radius: 2px;
1+
div.EddSoftwareLicenseManager .license-status {
72
}
83

9-
h2 span.license-status.active {
10-
background-color: #f6fef9;
11-
border-color: #23d160;
12-
color: #0e301a;
4+
div.EddSoftwareLicenseManager .license-status.active {
5+
color: #066226;
6+
text-shadow: 1px 1px 1px rgba(20, 255, 0, 0.5);
137
}
148

15-
h2 span.license-status.inactive {
16-
background-color: #fffdf5;
17-
border-color: #ffdd57;
18-
color: #3b3108;
9+
div.EddSoftwareLicenseManager .license-status.inactive {
10+
color: #886d03;
11+
text-shadow: 1px 1px 1px rgba(255, 215, 0, 0.5);
1912
}
2013

21-
h2 span.license-status.expired,
22-
h2 span.license-status.invalid {
23-
background-color: #fff5f7;
24-
border-color: #ff3860;
25-
color: #cd0930;
14+
div.EddSoftwareLicenseManager .license-status.expired,
15+
div.EddSoftwareLicenseManager .license-status.invalid {
16+
color: #990422;
17+
text-shadow: 1px 1px 1px rgba(255, 37, 37, 0.5);
18+
}
19+
20+
div.EddSoftwareLicenseManager hr {
21+
visibility: hidden;
2622
}
2723

2824
img.EddLicenseLoader {

assets/js/licensemanager.js

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,42 @@
11
/* global jQuery, ajaxurl, EddLicenseManager */
22
(function ($) {
3-
"use strict";
3+
'use strict'
44

5-
$(document).ready(function () {
6-
$('input#EddSoftwareLicenseManagerButton').on('click', function (e) {
7-
e.preventDefault();
8-
var $this = $(this),
9-
img = 'EddLicenseLoader';
5+
$(document).ready(function () {
6+
$('a[id^="EddSoftwareLicenseManagerButton"]:not(:disabled)').on('click', function (e) {
7+
e.preventDefault()
8+
const $this = $(this)
9+
const $element = $('input[name$="[' + $this.data('plugin_id') + ']"]')
1010

11-
$.ajax({
12-
method: "POST",
13-
url: ajaxurl,
14-
data: {
15-
action: EddLicenseManager.action,
16-
license_key: $('input[name="'+ EddLicenseManager.license_attr +'"]').val(),
17-
nonce: EddLicenseManager.nonce,
18-
plugin_action: $this.prop('name')
19-
},
20-
beforeSend: function () {
21-
$this.attr('disabled', true);
22-
$('<img class="' + img + '" src="'+ EddLicenseManager.loading + '" height="16" width="16">').insertAfter($this);
23-
},
24-
success: function (response) {
25-
if (typeof response.success !== 'undefined' && response.success) {
26-
location.reload(true);
27-
}
28-
$this.attr('disabled', false);
29-
$('img[class="'+ img +'"]').remove();
30-
},
31-
fail: function () {
32-
window.alert('Unknown Error');
33-
}
34-
});
35-
});
36-
});
37-
}(jQuery));
11+
if ($this.attr('disabled') === 'disabled' || $element.val().length === 0) {
12+
return
13+
}
14+
15+
$.ajax({
16+
method: 'POST',
17+
url: ajaxurl,
18+
data: {
19+
action: EddLicenseManager.action,
20+
license_key: $element.val(),
21+
nonce: EddLicenseManager.nonce,
22+
plugin_action: $this.data('action'),
23+
plugin_id: $this.data('plugin_id')
24+
},
25+
beforeSend: function () {
26+
$this.attr('disabled', true)
27+
$('<img class="EddLicenseLoader" src="' + EddLicenseManager.loading + '" height="16" width="16">').insertAfter($this)
28+
},
29+
success: function (response) {
30+
if (typeof response.success !== 'undefined' && response.success) {
31+
$this.closest('form').submit()
32+
}
33+
$('img[class="EddLicenseLoader"]').remove()
34+
},
35+
fail: function (response) {
36+
$this.attr('disabled', false)
37+
window.alert(response)
38+
}
39+
})
40+
})
41+
})
42+
}(jQuery))

composer.json

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "dwnload/edd-software-license-manager",
33
"description": "A PHP class abstraction for managing WordPress plugin licenses and auto-updates that are sold on an Easy Digital Downloads store.",
4-
"version": "1.4.0",
54
"license": "MIT",
65
"authors": [
76
{
@@ -11,15 +10,36 @@
1110
"role": "Developer"
1211
}
1312
],
13+
"config": {
14+
"allow-plugins": {
15+
"composer/installers": true,
16+
"dealerdirect/phpcodesniffer-composer-installer": true,
17+
"roots/wordpress-core-installer": true
18+
},
19+
"optimize-autoloader": true,
20+
"platform": {
21+
"php": "8.0"
22+
},
23+
"preferred-install": "dist",
24+
"sort-packages": true
25+
},
1426
"require": {
15-
"composer/installers": "~1.0",
16-
"dwnload/wp-settings-api": "^2.6.0",
17-
"thefrosty/wp-utilities": "^1.3.1",
18-
"php": ">=7.1"
27+
"php": "^8.0",
28+
"composer/installers": "~2.0",
29+
"dwnload/wp-settings-api": "^3.9",
30+
"thefrosty/wp-utilities": "^3.2"
1931
},
2032
"require-dev": {
21-
"10up/wp_mock": "dev-dev",
22-
"wp-coding-standards/wpcs": "^0.9.0"
33+
"ext-simplexml": "*",
34+
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
35+
"phpcompatibility/php-compatibility": "^9.3",
36+
"phpunit/php-code-coverage": "^9",
37+
"phpunit/phpunit": "^9",
38+
"roots/wordpress": "^6.4",
39+
"squizlabs/php_codesniffer": "^3.2",
40+
"symfony/var-dumper": "^5.4 || ^6.2",
41+
"wp-phpunit/wp-phpunit": "^6.3",
42+
"yoast/phpunit-polyfills": "^2.0"
2343
},
2444
"autoload": {
2545
"psr-4": {

0 commit comments

Comments
 (0)