Skip to content

Commit

Permalink
Merge pull request #1 from dwnload/feature/edd-slm-v2
Browse files Browse the repository at this point in the history
Updating PHP >= 8.0 - Version 2
  • Loading branch information
thefrosty committed Nov 15, 2023
2 parents 74885b4 + e927c86 commit 37bdf0e
Show file tree
Hide file tree
Showing 16 changed files with 2,900 additions and 1,538 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
.DS_Store
vendor
wordpress
3 changes: 3 additions & 0 deletions CHANGELONG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## 2.0.0 - 2023-11-15
- Bump min PHP version to 8.0.

## 1.4.0 - 2019-01-03
### Updated
- `thefrosty/wp-utilties` to v^1.3.1.
Expand Down
51 changes: 22 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
# Dwnload EDD Software License Manager [![Build Status](https://travis-ci.org/dwnload/EddSoftwareLicenseManager.svg?branch=master)](https://travis-ci.org/dwnload/EddSoftwareLicenseManager)
# EDD Software License Manager

[![PHP from Packagist](https://img.shields.io/packagist/php-v/dwnload/edd-software-license-manager.svg)]()
[![Latest Stable Version](https://img.shields.io/packagist/v/dwnload/edd-software-license-manager.svg)](https://packagist.org/packages/dwnload/edd-software-license-manager)
[![Total Downloads](https://img.shields.io/packagist/dt/dwnload/edd-software-license-manager.svg)](https://packagist.org/packages/dwnload/edd-software-license-manager)
[![License](https://img.shields.io/packagist/l/dwnload/edd-software-license-manager.svg)](https://packagist.org/packages/dwnload/edd-software-license-manager)
![Build Status](https://github.com/dwnload/WpSettingsApi/actions/workflows/main.yml/badge.svg)
[![codecov](https://codecov.io/gh/dwnload/WpSettingsApi//branch/develop/graph/badge.svg)](https://codecov.io/gh/dwnload/WpSettingsApi/)

A PHP class abstraction for managing WordPress plugin licenses and auto-updates that are sold on an Easy Digital Downloads store.

## Package Installation (via Composer)

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

```js
```json
{
"require": {
"dwnload/edd-software-license-manager": "^1.3.0"
"dwnload/edd-software-license-manager": "^2.0"
}
}
```
Expand All @@ -20,31 +28,16 @@ Now run:
### How to use this package

```php
use Dwnload\EddSoftwareLicenseManager\Edd;

// In the root of your plugin
$args = [
'api_url' => trailingslashit( https://plugingarden.dwnload.io ),
'plugin_file' => __FILE__,
'api_data' => [
'version' => (string) $version, // current version number
'license' => (string) $license_key, // license key (used get_option above to retrieve from DB)
'item_name' => 'Super Cool Plugin', // name of this plugin (matching your EDD Download title)
'item_id' => (int) 10,
'author' => 'Austin Passy', // author of this plugin
'beta' => (bool) isset( $use_beta ),
],
'item_id' => (int) 10,
'name' => plugin_basename( __FILE__ ),
'slug' => basename( __FILE__, '.php' ),
'version' => (string) $version,
'wp_override' => false,
'beta' => (bool) isset( $use_beta ),
$license = \get_option(\Dwnload\EddSoftwareLicenseManager\Edd\AbstractLicenceManager::LICENSE_SETTING, []);
$data = [
'license' => $license[$plugin_id]['license'] ?? '',
'item_name' => 'Custom Login Style Pack #1', // Name of this plugin (matching your EDD Download title).
'author' => 'Frosty Media',
'item_id' => (int),
'version' => '1.0.0',
];

if ( is_admin() ) {
( new Init() )
->add( new PluginUpdater( $args )
->initialize();
}
\TheFrosty\WpUtilities\Plugin\Plugin $plugin
->add(new Edd\LicenseManager($plugin, $data))
->add(new Edd\PluginUpdater('https://frosty.media/', __FILE__, $data))
->initialize();
```
34 changes: 15 additions & 19 deletions assets/css/licensemanager.css
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
h2 span.license-status {
background-color: whitesmoke;
border: 1px solid;
font-size: 90%;
padding: 4px 6px;
border-radius: 2px;
div.EddSoftwareLicenseManager .license-status {
}

h2 span.license-status.active {
background-color: #f6fef9;
border-color: #23d160;
color: #0e301a;
div.EddSoftwareLicenseManager .license-status.active {
color: #066226;
text-shadow: 1px 1px 1px rgba(20, 255, 0, 0.5);
}

h2 span.license-status.inactive {
background-color: #fffdf5;
border-color: #ffdd57;
color: #3b3108;
div.EddSoftwareLicenseManager .license-status.inactive {
color: #886d03;
text-shadow: 1px 1px 1px rgba(255, 215, 0, 0.5);
}

h2 span.license-status.expired,
h2 span.license-status.invalid {
background-color: #fff5f7;
border-color: #ff3860;
color: #cd0930;
div.EddSoftwareLicenseManager .license-status.expired,
div.EddSoftwareLicenseManager .license-status.invalid {
color: #990422;
text-shadow: 1px 1px 1px rgba(255, 37, 37, 0.5);
}

div.EddSoftwareLicenseManager hr {
visibility: hidden;
}

img.EddLicenseLoader {
Expand Down
71 changes: 38 additions & 33 deletions assets/js/licensemanager.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
/* global jQuery, ajaxurl, EddLicenseManager */
(function ($) {
"use strict";
'use strict'

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

$.ajax({
method: "POST",
url: ajaxurl,
data: {
action: EddLicenseManager.action,
license_key: $('input[name="'+ EddLicenseManager.license_attr +'"]').val(),
nonce: EddLicenseManager.nonce,
plugin_action: $this.prop('name')
},
beforeSend: function () {
$this.attr('disabled', true);
$('<img class="' + img + '" src="'+ EddLicenseManager.loading + '" height="16" width="16">').insertAfter($this);
},
success: function (response) {
if (typeof response.success !== 'undefined' && response.success) {
location.reload(true);
}
$this.attr('disabled', false);
$('img[class="'+ img +'"]').remove();
},
fail: function () {
window.alert('Unknown Error');
}
});
});
});
}(jQuery));
if ($this.attr('disabled') === 'disabled' || $element.val().length === 0) {
return
}

$.ajax({
method: 'POST',
url: ajaxurl,
data: {
action: EddLicenseManager.action,
license_key: $element.val(),
nonce: EddLicenseManager.nonce,
plugin_action: $this.data('action'),
plugin_id: $this.data('plugin_id')
},
beforeSend: function () {
$this.attr('disabled', true)
$('<img class="EddLicenseLoader" src="' + EddLicenseManager.loading + '" height="16" width="16">').insertAfter($this)
},
success: function (response) {
if (typeof response.success !== 'undefined' && response.success) {
$this.closest('form').submit()
}
$('img[class="EddLicenseLoader"]').remove()
},
fail: function (response) {
$this.attr('disabled', false)
window.alert(response)
}
})
})
})
}(jQuery))
34 changes: 27 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "dwnload/edd-software-license-manager",
"description": "A PHP class abstraction for managing WordPress plugin licenses and auto-updates that are sold on an Easy Digital Downloads store.",
"version": "1.4.0",
"license": "MIT",
"authors": [
{
Expand All @@ -11,15 +10,36 @@
"role": "Developer"
}
],
"config": {
"allow-plugins": {
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"roots/wordpress-core-installer": true
},
"optimize-autoloader": true,
"platform": {
"php": "8.0"
},
"preferred-install": "dist",
"sort-packages": true
},
"require": {
"composer/installers": "~1.0",
"dwnload/wp-settings-api": "^2.6.0",
"thefrosty/wp-utilities": "^1.3.1",
"php": ">=7.1"
"php": "^8.0",
"composer/installers": "~2.0",
"dwnload/wp-settings-api": "^3.9",
"thefrosty/wp-utilities": "^3.2"
},
"require-dev": {
"10up/wp_mock": "dev-dev",
"wp-coding-standards/wpcs": "^0.9.0"
"ext-simplexml": "*",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
"phpcompatibility/php-compatibility": "^9.3",
"phpunit/php-code-coverage": "^9",
"phpunit/phpunit": "^9",
"roots/wordpress": "^6.4",
"squizlabs/php_codesniffer": "^3.2",
"symfony/var-dumper": "^5.4 || ^6.2",
"wp-phpunit/wp-phpunit": "^6.3",
"yoast/phpunit-polyfills": "^2.0"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit 37bdf0e

Please sign in to comment.