Skip to content

Commit

Permalink
Merge branch 'master' into feature/publishpress-pro
Browse files Browse the repository at this point in the history
  • Loading branch information
junaidbhura authored Jan 23, 2023
2 parents 366c175 + 441bdc5 commit 182c695
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 12 deletions.
4 changes: 4 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 Down
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ Sensitive credentials (license keys, tokens) are read from environment variables
## Supported Plugins

1. Advanced Custom Fields Pro
2. Gravity Forms / Add-Ons
3. Polylang Pro
4. PublishPress Pro
5. WP All Import / Export Pro / 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,6 +37,8 @@ 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>"
POLYLANG_PRO_KEY="<polylang_pro_license_key>"
POLYLANG_PRO_URL="<registered_url_for_polylang_pro>"
Expand All @@ -53,6 +56,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 @@ -205,6 +223,7 @@ Add the following to your composer.json file:
},
],
"require": {
"junaidbhura/acf-extended-pro": "*",
"junaidbhura/advanced-custom-fields-pro": "*",
"junaidbhura/gravityforms": "*",
"junaidbhura/gravityformspolls": "*",
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'];
}

}
16 changes: 13 additions & 3 deletions plugins/WpAiPro.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 @@ -98,11 +99,20 @@ public function getDownloadUrl() {
'url' => $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 '';
}

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

return '';
return $response['download_link'];
}

}

0 comments on commit 182c695

Please sign in to comment.