diff --git a/Installer.php b/Installer.php index ec97a3b..399e511 100644 --- a/Installer.php +++ b/Installer.php @@ -260,6 +260,8 @@ protected function getDownloadUrl( PackageInterface $package ) { 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/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 ) ); } diff --git a/README.md b/README.md index 01db5f8..df17848 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,11 @@ Sensitive credentials (license keys, tokens) are read from environment variables ## Supported Plugins 1. Advanced Custom Fields Pro -2. Advanced Custom Fields Extended Pro -3. Gravity Forms / Add-Ons -4. Polylang 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 @@ -41,6 +42,10 @@ ACFE_PRO_URL="" GRAVITY_FORMS_KEY="" POLYLANG_PRO_KEY="" POLYLANG_PRO_URL="" +PUBLISHPRESS_PRO_KEY="" +PUBLISHPRESS_PRO_URL="" +PUBLISHPRESS__PRO_KEY="" +PUBLISHPRESS__PRO_URL="" WP_ALL_IMPORT_PRO_KEY="" WP_ALL_IMPORT_PRO_URL="" WP_ALL_EXPORT_PRO_KEY="" @@ -126,6 +131,21 @@ Add the following to your composer.json file: } } }, + { + "type": "package", + "package": { + "name": "junaidbhura/publishpress-planner-pro", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://publishpress.com/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, { "type": "package", "package": { @@ -208,6 +228,7 @@ Add the following to your composer.json file: "junaidbhura/gravityforms": "*", "junaidbhura/gravityformspolls": "*", "junaidbhura/polylang-pro": "*", + "junaidbhura/publishpress-planner-pro": "*", "junaidbhura/wp-all-import-pro": "*", "junaidbhura/wp-all-export-pro": "*", "junaidbhura/wpai-acf-add-on": "*", @@ -228,6 +249,25 @@ For example: Here's a list of all Gravity Forms add-on slugs: [https://docs.gravityforms.com/gravity-forms-add-on-slugs/](https://docs.gravityforms.com/gravity-forms-add-on-slugs/) +### PublishPress Pro Plugins + +You can use any PublishPress Pro plugins by simply adding it's slug like so: + +`junaidbhura/` + +The following plugins are supported: + +| Package name | Environment variables | +|:------------------------------------------- |:-------------------------------------------- | +| `junaidbhura/publishpress-authors-pro` | `PUBLISHPRESS_AUTHORS_PRO_` | +| `junaidbhura/publishpress-blocks-pro` | `PUBLISHPRESS_BLOCKS_PRO_` | +| `junaidbhura/publishpress-capabilities-pro` | `PUBLISHPRESS_CAPABILITIES_PRO_` | +| `junaidbhura/publishpress-checklists-pro` | `PUBLISHPRESS_CHECKLISTS_PRO_` | +| `junaidbhura/publishpress-permissions-pro` | `PUBLISHPRESS_PERMISSIONS_PRO_` | +| `junaidbhura/publishpress-planner-pro` | `PUBLISHPRESS_PLANNER_PRO_` | +| `junaidbhura/publishpress-revisions-pro` | `PUBLISHPRESS_REVISIONS_PRO_` | +| `junaidbhura/publishpress-series-pro` | `PUBLISHPRESS_SERIES_PRO_` | + ### WP All Import Pro Add-Ons You can use any WP All Import Pro add-on by simply adding it's slug like so: diff --git a/plugins/PublishPressPro.php b/plugins/PublishPressPro.php new file mode 100644 index 0000000..827f855 --- /dev/null +++ b/plugins/PublishPressPro.php @@ -0,0 +1,137 @@ +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']; + } + +}