Skip to content

Commit

Permalink
WP All Import / Export support
Browse files Browse the repository at this point in the history
  • Loading branch information
junaidbhura committed Aug 9, 2018
1 parent 94a36f2 commit effab0c
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,16 @@ public function getDownloadUrl( PackageEvent $event ) {
$plugin = new Plugins\PolylangPro( $package->getPrettyVersion() );
break;

case 'junaidbhura/wp-all-import-pro':
case 'junaidbhura/wp-all-export-pro':
$plugin = new Plugins\WpAiPro( $package->getPrettyVersion(), str_replace( 'junaidbhura/', '', $package_name ) );
break;

default:
if ( 0 === strpos( $package_name, 'junaidbhura/gravityforms' ) ) {
$plugin = new Plugins\GravityForms( $package->getPrettyVersion(), str_replace( 'junaidbhura/', '', $package_name ) );
} elseif ( 0 === strpos( $package_name, 'junaidbhura/wpai-' ) ) {
$plugin = new Plugins\WpAiPro( $package->getPrettyVersion(), str_replace( 'junaidbhura/', '', $package_name ) );
}

}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "junaidbhura/composer-wp-pro-plugins",
"type": "composer-plugin",
"version": "1.0.3",
"version": "1.0.4",
"require": {
"vlucas/phpdotenv": "^2.4",
"composer-plugin-api": "^1.1"
Expand Down
88 changes: 88 additions & 0 deletions plugins/WpAiPro.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php
/**
* WP All Import / Export Pro Plugin.
*
* @package Junaidbhura\Composer\WPProPlugins\Plugins
*/

namespace Junaidbhura\Composer\WPProPlugins\Plugins;

use Junaidbhura\Composer\WPProPlugins\Http;

/**
* WpAiPro class.
*/
class WpAiPro {

/**
* 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 = 'wp-all-import-pro' ) {
$this->version = $version;
$this->slug = $slug;
}

/**
* Get the download URL for this plugin.
*
* @return string
*/
public function getDownloadUrl() {
if ( 'wp-all-export-pro' === $this->slug ) {
$license = getenv( 'WP_ALL_EXPORT_PRO_KEY' );
$url = getenv( 'WP_ALL_EXPORT_PRO_URL' );
$name = 'WP All Export';
} else {
$license = getenv( 'WP_ALL_IMPORT_PRO_KEY' );
$url = getenv( 'WP_ALL_IMPORT_PRO_URL' );

switch ( $this->slug ) {
case 'wpai-acf-add-on':
$name = 'ACF Add-On';
break;
case 'wpai-linkcloak-add-on':
$name = 'Link Cloaking Add-On';
break;
case 'wpai-user-add-on':
$name = 'User Import Add-On';
break;
case 'wpai-woocommerce-add-on':
$name = 'WooCommerce Add-On';
break;
default:
$name = 'WP All Import';
}
}

$http = new Http();
$response = json_decode( $http->post( 'https://www.wpallimport.com', array(
'edd_action' => 'get_version',
'license' => $license,
'item_name' => $name,
'url' => $url,
'version' => $this->version,
) ), true );
if ( ! empty( $response['download_link'] ) ) {
return $response['download_link'];
}
return '';
}

}

0 comments on commit effab0c

Please sign in to comment.