Skip to content

Commit

Permalink
Merge branch 'master' into feature/ninja-forms-addons
Browse files Browse the repository at this point in the history
  • Loading branch information
junaidbhura authored Jan 23, 2023
2 parents 9ad2d4d + 583ff37 commit bb2f436
Show file tree
Hide file tree
Showing 7 changed files with 300 additions and 12 deletions.
6 changes: 6 additions & 0 deletions Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ protected function getDownloadUrl( PackageInterface $package ) {
$package_name = $package->getName();

switch ( $package_name ) {
case 'junaidbhura/acf-extended-pro':
$plugin = new Plugins\AcfExtendedPro( $package->getPrettyVersion() );
break;

case 'junaidbhura/advanced-custom-fields-pro':
$plugin = new Plugins\AcfPro( $package->getPrettyVersion() );
break;
Expand All @@ -258,6 +262,8 @@ protected function getDownloadUrl( PackageInterface $package ) {
$plugin = new Plugins\GravityForms( $package->getPrettyVersion(), str_replace( 'junaidbhura/', '', $package_name ) );
} elseif ( 0 === strpos( $package_name, 'junaidbhura/ninja-forms-' ) ) {
$plugin = new Plugins\NinjaForms( $package->getPrettyVersion(), str_replace( 'junaidbhura/', '', $package_name ) );
} elseif ( 0 === strpos( $package_name, 'junaidbhura/publishpress-' ) ) {
$plugin = new Plugins\PublishPressPro( $package->getPrettyVersion(), str_replace( 'junaidbhura/', '', $package_name ) );
} elseif ( 0 === strpos( $package_name, 'junaidbhura/wpai-' ) || 0 === strpos( $package_name, 'junaidbhura/wpae-' ) ) {
$plugin = new Plugins\WpAiPro( $package->getPrettyVersion(), str_replace( 'junaidbhura/', '', $package_name ) );
}
Expand Down
67 changes: 63 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ Sensitive credentials (license keys, tokens) are read from environment variables
## Supported Plugins

1. Advanced Custom Fields Pro
2. Gravity Forms / Add-Ons
3. Ninja Forms Add-Ons
4. Polylang Pro
5. WP All Import / Export Pro / Add-Ons
1. Ninja Forms Add-Ons
1. Gravity Forms / Add-Ons
1. Polylang Pro
1. PublishPress Pro
1. Advanced Custom Fields Extended Pro
1. WP All Import / Export Pro / Add-Ons

## Overview

Expand All @@ -36,13 +38,19 @@ Create a `.env` file in the root of your WordPress site, where the `composer.jso

```
ACF_PRO_KEY="<acf_pro_license_key>"
ACFE_PRO_KEY="<acf_extended_pro_license_key>"
ACFE_PRO_URL="<registered_url_for_acf_extended_pro>"
GRAVITY_FORMS_KEY="<gravity_forms_license_key>"
NINJA_FORMS_KEY="<ninja_forms_membership_license_key>"
NINJA_FORMS_URL="<registered_url_for_ninja_forms_membership>"
NINJA_FORMS_<addon_slug>_KEY="<ninja_forms_addon_license_key>"
NINJA_FORMS_<addon_slug>_URL="<registered_url_for_ninja_forms_addon>"
POLYLANG_PRO_KEY="<polylang_pro_license_key>"
POLYLANG_PRO_URL="<registered_url_for_polylang_pro>"
PUBLISHPRESS_PRO_KEY="<publishpress_pro_membership_license_key>"
PUBLISHPRESS_PRO_URL="<registered_url_for_publishpress_pro_membership>"
PUBLISHPRESS_<plugin_slug>_PRO_KEY="<publishpress_pro_license_key>"
PUBLISHPRESS_<plugin_slug>_PRO_URL="<registered_url_for_publishpress_pro>"
WP_ALL_IMPORT_PRO_KEY="<wp_all_import_license_key>"
WP_ALL_IMPORT_PRO_URL="<registered_url_for_wpai_pro>"
WP_ALL_EXPORT_PRO_KEY="<wp_all_export_license_key>"
Expand All @@ -53,6 +61,21 @@ Add the following to your composer.json file:

```json
"repositories": [
{
"type": "package",
"package": {
"name": "junaidbhura/acf-extended-pro",
"version": "<version_number>",
"type": "wordpress-plugin",
"dist": {
"type": "zip",
"url": "https://www.acf-extended.com/"
},
"require": {
"junaidbhura/composer-wp-pro-plugins": "*"
}
}
},
{
"type": "package",
"package": {
Expand Down Expand Up @@ -128,6 +151,21 @@ Add the following to your composer.json file:
}
}
},
{
"type": "package",
"package": {
"name": "junaidbhura/publishpress-planner-pro",
"version": "<version_number>",
"type": "wordpress-plugin",
"dist": {
"type": "zip",
"url": "https://publishpress.com/"
},
"require": {
"junaidbhura/composer-wp-pro-plugins": "*"
}
}
},
{
"type": "package",
"package": {
Expand Down Expand Up @@ -205,11 +243,13 @@ Add the following to your composer.json file:
},
],
"require": {
"junaidbhura/acf-extended-pro": "*",
"junaidbhura/advanced-custom-fields-pro": "*",
"junaidbhura/gravityforms": "*",
"junaidbhura/gravityformspolls": "*",
"junaidbhura/ninja-forms-uploads": "*",
"junaidbhura/polylang-pro": "*",
"junaidbhura/publishpress-planner-pro": "*",
"junaidbhura/wp-all-import-pro": "*",
"junaidbhura/wp-all-export-pro": "*",
"junaidbhura/wpai-acf-add-on": "*",
Expand Down Expand Up @@ -283,6 +323,25 @@ The following add-ons are supported:
| `junaidbhura/ninja-forms-zapier` | `NINJA_FORMS_ZAPIER_<key_or_url>` |
| `junaidbhura/ninja-forms-zoho` | `NINJA_FORMS_ZOHO_<key_or_url>` |

### PublishPress Pro Plugins

You can use any PublishPress Pro plugins by simply adding it's slug like so:

`junaidbhura/<plugin-slug>`

The following plugins are supported:

| Package name | Environment variables |
|:------------------------------------------- |:-------------------------------------------- |
| `junaidbhura/publishpress-authors-pro` | `PUBLISHPRESS_AUTHORS_PRO_<key_or_url>` |
| `junaidbhura/publishpress-blocks-pro` | `PUBLISHPRESS_BLOCKS_PRO_<key_or_url>` |
| `junaidbhura/publishpress-capabilities-pro` | `PUBLISHPRESS_CAPABILITIES_PRO_<key_or_url>` |
| `junaidbhura/publishpress-checklists-pro` | `PUBLISHPRESS_CHECKLISTS_PRO_<key_or_url>` |
| `junaidbhura/publishpress-permissions-pro` | `PUBLISHPRESS_PERMISSIONS_PRO_<key_or_url>` |
| `junaidbhura/publishpress-planner-pro` | `PUBLISHPRESS_PLANNER_PRO_<key_or_url>` |
| `junaidbhura/publishpress-revisions-pro` | `PUBLISHPRESS_REVISIONS_PRO_<key_or_url>` |
| `junaidbhura/publishpress-series-pro` | `PUBLISHPRESS_SERIES_PRO_<key_or_url>` |

### WP All Import Pro Add-Ons

You can use any WP All Import Pro add-on by simply adding it's slug like so:
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"type": "composer-plugin",
"license": "MIT",
"require": {
"vlucas/phpdotenv": "^3.0 || ^4.0 || ^5.0",
"composer-plugin-api": "^1.0 || ^2.0"
"composer-plugin-api": "^1.0 || ^2.0",
"composer/semver": "^1.0 || ^2.0 || ^3.0",
"vlucas/phpdotenv": "^3.0 || ^4.0 || ^5.0"
},
"authors": [
{
Expand Down
64 changes: 64 additions & 0 deletions plugins/AcfExtendedPro.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* ACF Extended Pro Plugin.
*
* @package Junaidbhura\Composer\WPProPlugins\Plugins
*/

namespace Junaidbhura\Composer\WPProPlugins\Plugins;

use Composer\Semver\Semver;
use Junaidbhura\Composer\WPProPlugins\Http;

/**
* AcfExtendedPro class.
*/
class AcfExtendedPro {

/**
* The version number of the plugin to download.
*
* @var string Version number.
*/
protected $version = '';

/**
* AcfExtendedPro constructor.
*
* @param string $version
*/
public function __construct( $version = '' ) {
$this->version = $version;
}

/**
* Get the download URL for this plugin.
*
* @return string
*/
public function getDownloadUrl() {
$http = new Http();
$response = json_decode( $http->post( 'https://acf-extended.com', array(
'edd_action' => 'get_version',
'license' => getenv( 'ACFE_PRO_KEY' ),
'item_name' => 'ACF Extended Pro',
'url' => getenv( 'ACFE_PRO_URL' ),
'version' => $this->version,
) ), true );

if ( empty( $response['download_link'] ) ) {
return '';
}

if ( empty( $response['new_version'] ) ) {
return '';
}

if ( ! Semver::satisfies( $response['new_version'], $this->version ) ) {
return '';
}

return $response['download_link'];
}

}
17 changes: 14 additions & 3 deletions plugins/PolylangPro.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Junaidbhura\Composer\WPProPlugins\Plugins;

use Composer\Semver\Semver;
use Junaidbhura\Composer\WPProPlugins\Http;

/**
Expand Down Expand Up @@ -44,10 +45,20 @@ public function getDownloadUrl() {
'url' => getenv( 'POLYLANG_PRO_URL' ),
'version' => $this->version,
) ), true );
if ( ! empty( $response['download_link'] ) ) {
return $response['download_link'];

if ( empty( $response['download_link'] ) ) {
return '';
}

if ( empty( $response['new_version'] ) ) {
return '';
}
return '';

if ( ! Semver::satisfies( $response['new_version'], $this->version ) ) {
return '';
}

return $response['download_link'];
}

}
137 changes: 137 additions & 0 deletions plugins/PublishPressPro.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?php
/**
* PublishPress Pro Plugin.
*
* @package Junaidbhura\Composer\WPProPlugins\Plugins
*/

namespace Junaidbhura\Composer\WPProPlugins\Plugins;

use Composer\Semver\Semver;
use Junaidbhura\Composer\WPProPlugins\Http;

/**
* PublishPressPro class.
*/
class PublishPressPro {

/**
* The version number of the plugin to download.
*
* @var string Version number.
*/
protected $version = '';

/**
* The slug of which plugin to download.
*
* @var string Plugin slug.
*/
protected $slug = '';

/**
* WpAiPro constructor.
*
* @param string $version
* @param string $slug
*/
public function __construct( $version = '', $slug = 'publishpress-planner-pro' ) {
$this->version = $version;
$this->slug = $slug;
}

/**
* Get the download URL for this plugin.
*
* @return string
*/
public function getDownloadUrl() {
$id = 0;
$env = null;
/**
* Membership licensing.
*/
$license = ( getenv( 'PUBLISHPRESS_PRO_KEY' ) ?: null );
$url = ( getenv( 'PUBLISHPRESS_PRO_URL' ) ?: null );

/**
* List of official plugins as of 2023-01-20.
*/
switch ( $this->slug ) {
case 'publishpress-authors-pro':
$id = 7203;
$env = 'AUTHORS';
break;

case 'publishpress-blocks-pro':
$id = 98972;
$env = 'BLOCKS';
break;

case 'publishpress-capabilities-pro':
$id = 44811;
$env = 'CAPABILITIES';
break;

case 'publishpress-checklists-pro':
$id = 6465;
$env = 'CHECKLISTS';
break;

case 'publishpress-permissions-pro':
$id = 34506;
$env = 'PERMISSIONS';
break;

case 'publishpress-planner-pro':
$id = 49742;
$env = 'PLANNER';
break;

case 'publishpress-revisions-pro':
$id = 40280;
$env = 'REVISIONS';
break;

case 'publishpress-series-pro':
$id = 110550;
$env = 'SERIES';
break;

default:
return '';
}

if ( $env ) {
/**
* Use add-on licensing if available, otherwise use membership licensing.
*/
$license = ( getenv( "PUBLISHPRESS_{$env}_PRO_KEY" ) ?: $license );
$url = ( getenv( "PUBLISHPRESS_{$env}_PRO_URL" ) ?: $url );
}

$http = new Http();
$response = json_decode( $http->get( 'https://publishpress.com', array(
'edd_action' => 'get_version',
'license' => $license,
'item_id' => $id,
'url' => $url,
'version' => $this->version,
) ), true );

if ( empty( $response['download_link'] ) ) {
return '';
}

if ( empty( $response['new_version'] ) ) {
return '';
}

if ( ! Semver::satisfies( $response['new_version'], $this->version ) ) {
return '';
}

return $response['download_link'];
}

}
Loading

0 comments on commit bb2f436

Please sign in to comment.