From 5b48bf389ec93e765845470332c95da738856c34 Mon Sep 17 00:00:00 2001 From: Anthony Martin Date: Tue, 20 Dec 2022 15:13:41 +0100 Subject: [PATCH 1/6] Add support for WPML (Main plugin and Add-Ons) --- Installer.php | 2 + README.md | 320 ++++++++++++++++++++++++++++++++++++++++++++++- plugins/WPML.php | 71 +++++++++++ 3 files changed, 392 insertions(+), 1 deletion(-) create mode 100644 plugins/WPML.php diff --git a/Installer.php b/Installer.php index afed0ab..c887d69 100644 --- a/Installer.php +++ b/Installer.php @@ -267,6 +267,8 @@ protected function getDownloadUrl( PackageInterface $package ) { $plugin = new Plugins\PublishPressPro( $package->getPrettyVersion(), $plugin_name ); } elseif ( 0 === strpos( $package_name, 'junaidbhura/wpai-' ) || 0 === strpos( $package_name, 'junaidbhura/wpae-' ) ) { $plugin = new Plugins\WpAiPro( $package->getPrettyVersion(), $plugin_name ); + } elseif ( 0 === strpos( $package_name, 'junaidbhura/wpml-' ) ) { + $plugin = new Plugins\WPML( $package->getPrettyVersion(), $plugin_name ); } } diff --git a/README.md b/README.md index 3861889..eb19405 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Sensitive credentials (license keys, tokens) are read from environment variables 1. PublishPress Pro 1. Advanced Custom Fields Extended Pro 1. WP All Import / Export Pro / Add-Ons +1. WPML ## Overview @@ -55,6 +56,8 @@ WP_ALL_IMPORT_PRO_KEY="" WP_ALL_IMPORT_PRO_URL="" WP_ALL_EXPORT_PRO_KEY="" WP_ALL_EXPORT_PRO_URL="" +WPML_USER_ID="" +WPML_KEY="" ``` Add the following to your composer.json file: @@ -241,6 +244,262 @@ Add the following to your composer.json file: } } }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-sitepress-multilingual-cms", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-string-translation", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-media-translation", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-woocommerce-multilingual", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-gravityforms-multilingual", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-contact-form-7-multilingual", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-ninja-forms", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-wpforms", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-buddypress-multilingual", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-acfml", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-all-import", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-mailchimp-for-wp", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-wp-seo-multilingual", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-types", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-sticky-links", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-cms-nav", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + { + "type": "package", + "package": { + "name": "junaidbhura/wpml-translation-management", + "version": "", + "type": "wordpress-plugin", + "dist": { + "type": "zip", + "url": "https://wpml.org/" + }, + "require": { + "junaidbhura/composer-wp-pro-plugins": "*" + } + } + }, + ], "require": { "junaidbhura/acf-extended-pro": "*", @@ -254,7 +513,24 @@ Add the following to your composer.json file: "junaidbhura/wp-all-export-pro": "*", "junaidbhura/wpai-acf-add-on": "*", "junaidbhura/wpae-acf-add-on": "*", - "junaidbhura/wpae-user-add-on-pro": "*" + "junaidbhura/wpae-user-add-on-pro": "*", + "junaidbhura/wpml-sitepress-multilingual-cms": "*", + "junaidbhura/wpml-string-translation": "*", + "junaidbhura/wpml-media-translation": "*", + "junaidbhura/wpml-woocommerce-multilingual": "*", + "junaidbhura/wpml-gravityforms-multilingual": "*", + "junaidbhura/wpml-contact-form-7-multilingual": "*", + "junaidbhura/wpml-ninja-forms": "*", + "junaidbhura/wpml-wpforms": "*", + "junaidbhura/wpml-buddypress-multilingual": "*", + "junaidbhura/wpml-acfml": "*", + "junaidbhura/wpml-all-import": "*", + "junaidbhura/wpml-mailchimp-for-wp": "*", + "junaidbhura/wpml-wp-seo-multilingual": "*", + "junaidbhura/wpml-types": "*", + "junaidbhura/wpml-sticky-links": "*", + "junaidbhura/wpml-cms-nav": "*", + "junaidbhura/wpml-translation-management": "*" }, ``` @@ -362,3 +638,45 @@ You can use any WP All Export Pro add-on by simply adding it's slug like so: For example: `junaidbhura/wpae-acf-add-on` + +### WPML Add-Ons + +You can use any WPML add-on by simply adding it's slug like so: + +`junaidbhura/` + +For example: + +`junaidbhura/wpml-sitepress-multilingual-cms` + +`junaidbhura/wpml-string-translation` + +`junaidbhura/wpml-media-translation` + +`junaidbhura/wpml-woocommerce-multilingual` + +`junaidbhura/wpml-gravityforms-multilingual` + +`junaidbhura/wpml-contact-form-7-multilingual` + +`junaidbhura/wpml-ninja-forms` + +`junaidbhura/wpml-wpforms` + +`junaidbhura/wpml-buddypress-multilingual` + +`junaidbhura/wpml-acfml` + +`junaidbhura/wpml-all-import` + +`junaidbhura/wpml-mailchimp-for-wp` + +`junaidbhura/wpml-wp-seo-multilingual` + +`junaidbhura/wpml-types` + +`junaidbhura/wpml-sticky-links` + +`junaidbhura/wpml-cms-nav` + +`junaidbhura/wpml-translation-management` diff --git a/plugins/WPML.php b/plugins/WPML.php new file mode 100644 index 0000000..0aa6018 --- /dev/null +++ b/plugins/WPML.php @@ -0,0 +1,71 @@ +version = $version; + $this->slug = $slug; + } + + /** + * Get the download URL for this plugin. + * + * @return string + */ + public function getDownloadUrl() { + $packages = [ + 'wpml-sitepress-multilingual-cms' => 6088, + 'wpml-string-translation' => 6092, + 'wpml-media-translation' => 7474, + 'wpml-woocommerce-multilingual' => 637370, + 'wpml-gravityforms-multilingual' => 8882, + 'wpml-contact-form-7-multilingual' => 3156699, + 'wpml-ninja-forms' => 5342487, + 'wpml-wpforms' => 5368995, + 'wpml-buddypress-multilingual' => 2216259, + 'wpml-acfml' => 1097589, + 'wpml-all-import' => 720221, + 'wpml-mailchimp-for-wp' => 1442229, + 'wpml-wp-seo-multilingual' => 3566177, + 'wpml-types' => 1385906, + 'wpml-sticky-links' => 6090, + 'wpml-cms-nav' => 6096, + 'wpml-translation-management' => 6094, + ]; + + if (array_key_exists($this->slug, $packages)) { + return 'https://wpml.org/?download='. $packages[$this->slug] .'&user_id='. getenv( 'WPML_USER_ID' ) .'&subscription_key='. getenv( 'WPML_KEY' ) .'&version=' . $this->version; + } + } + +} From cb4e2ca085941ce82e7e4acfb8a4d5b6f8e01cde Mon Sep 17 00:00:00 2001 From: Chauncey McAskill Date: Mon, 6 Mar 2023 16:02:28 -0500 Subject: [PATCH 2/6] Sort WPML add-ons and fix coding style Changed: - Sort WPML add-ons alphabetically. - README: Sort bullet list, repositories, and requirements. - README: Group WPML add-ons using an bullet list. - WPML: Use verbose array syntax and align values. - WPML: Fix the default slug to match the array key below. - WPML: Fix default add-on name in constructor. --- README.md | 117 +++++++++++++++++++---------------------------- plugins/WPML.php | 42 ++++++++--------- 2 files changed, 69 insertions(+), 90 deletions(-) diff --git a/README.md b/README.md index eb19405..66dff22 100644 --- a/README.md +++ b/README.md @@ -247,7 +247,7 @@ Add the following to your composer.json file: { "type": "package", "package": { - "name": "junaidbhura/wpml-sitepress-multilingual-cms", + "name": "junaidbhura/wpml-acfml", "version": "", "type": "wordpress-plugin", "dist": { @@ -262,7 +262,7 @@ Add the following to your composer.json file: { "type": "package", "package": { - "name": "junaidbhura/wpml-string-translation", + "name": "junaidbhura/wpml-all-import", "version": "", "type": "wordpress-plugin", "dist": { @@ -277,7 +277,7 @@ Add the following to your composer.json file: { "type": "package", "package": { - "name": "junaidbhura/wpml-media-translation", + "name": "junaidbhura/wpml-buddypress-multilingual", "version": "", "type": "wordpress-plugin", "dist": { @@ -292,7 +292,7 @@ Add the following to your composer.json file: { "type": "package", "package": { - "name": "junaidbhura/wpml-woocommerce-multilingual", + "name": "junaidbhura/wpml-cms-nav", "version": "", "type": "wordpress-plugin", "dist": { @@ -307,7 +307,7 @@ Add the following to your composer.json file: { "type": "package", "package": { - "name": "junaidbhura/wpml-gravityforms-multilingual", + "name": "junaidbhura/wpml-contact-form-7-multilingual", "version": "", "type": "wordpress-plugin", "dist": { @@ -322,7 +322,7 @@ Add the following to your composer.json file: { "type": "package", "package": { - "name": "junaidbhura/wpml-contact-form-7-multilingual", + "name": "junaidbhura/wpml-gravityforms-multilingual", "version": "", "type": "wordpress-plugin", "dist": { @@ -337,7 +337,7 @@ Add the following to your composer.json file: { "type": "package", "package": { - "name": "junaidbhura/wpml-ninja-forms", + "name": "junaidbhura/wpml-mailchimp-for-wp", "version": "", "type": "wordpress-plugin", "dist": { @@ -352,7 +352,7 @@ Add the following to your composer.json file: { "type": "package", "package": { - "name": "junaidbhura/wpml-wpforms", + "name": "junaidbhura/wpml-media-translation", "version": "", "type": "wordpress-plugin", "dist": { @@ -367,7 +367,7 @@ Add the following to your composer.json file: { "type": "package", "package": { - "name": "junaidbhura/wpml-buddypress-multilingual", + "name": "junaidbhura/wpml-ninja-forms", "version": "", "type": "wordpress-plugin", "dist": { @@ -382,7 +382,7 @@ Add the following to your composer.json file: { "type": "package", "package": { - "name": "junaidbhura/wpml-acfml", + "name": "junaidbhura/wpml-sitepress-multilingual-cms", "version": "", "type": "wordpress-plugin", "dist": { @@ -397,7 +397,7 @@ Add the following to your composer.json file: { "type": "package", "package": { - "name": "junaidbhura/wpml-all-import", + "name": "junaidbhura/wpml-sticky-links", "version": "", "type": "wordpress-plugin", "dist": { @@ -412,7 +412,7 @@ Add the following to your composer.json file: { "type": "package", "package": { - "name": "junaidbhura/wpml-mailchimp-for-wp", + "name": "junaidbhura/wpml-string-translation", "version": "", "type": "wordpress-plugin", "dist": { @@ -427,7 +427,7 @@ Add the following to your composer.json file: { "type": "package", "package": { - "name": "junaidbhura/wpml-wp-seo-multilingual", + "name": "junaidbhura/wpml-translation-management", "version": "", "type": "wordpress-plugin", "dist": { @@ -457,7 +457,7 @@ Add the following to your composer.json file: { "type": "package", "package": { - "name": "junaidbhura/wpml-sticky-links", + "name": "junaidbhura/wpml-woocommerce-multilingual", "version": "", "type": "wordpress-plugin", "dist": { @@ -472,7 +472,7 @@ Add the following to your composer.json file: { "type": "package", "package": { - "name": "junaidbhura/wpml-cms-nav", + "name": "junaidbhura/wpml-wp-seo-multilingual", "version": "", "type": "wordpress-plugin", "dist": { @@ -487,7 +487,7 @@ Add the following to your composer.json file: { "type": "package", "package": { - "name": "junaidbhura/wpml-translation-management", + "name": "junaidbhura/wpml-wpforms", "version": "", "type": "wordpress-plugin", "dist": { @@ -498,8 +498,7 @@ Add the following to your composer.json file: "junaidbhura/composer-wp-pro-plugins": "*" } } - }, - + } ], "require": { "junaidbhura/acf-extended-pro": "*", @@ -515,22 +514,22 @@ Add the following to your composer.json file: "junaidbhura/wpae-acf-add-on": "*", "junaidbhura/wpae-user-add-on-pro": "*", "junaidbhura/wpml-sitepress-multilingual-cms": "*", - "junaidbhura/wpml-string-translation": "*", - "junaidbhura/wpml-media-translation": "*", - "junaidbhura/wpml-woocommerce-multilingual": "*", - "junaidbhura/wpml-gravityforms-multilingual": "*", - "junaidbhura/wpml-contact-form-7-multilingual": "*", - "junaidbhura/wpml-ninja-forms": "*", - "junaidbhura/wpml-wpforms": "*", - "junaidbhura/wpml-buddypress-multilingual": "*", "junaidbhura/wpml-acfml": "*", "junaidbhura/wpml-all-import": "*", + "junaidbhura/wpml-buddypress-multilingual": "*", + "junaidbhura/wpml-cms-nav": "*", + "junaidbhura/wpml-contact-form-7-multilingual": "*", + "junaidbhura/wpml-gravityforms-multilingual": "*", "junaidbhura/wpml-mailchimp-for-wp": "*", - "junaidbhura/wpml-wp-seo-multilingual": "*", - "junaidbhura/wpml-types": "*", + "junaidbhura/wpml-media-translation": "*", + "junaidbhura/wpml-ninja-forms": "*", "junaidbhura/wpml-sticky-links": "*", - "junaidbhura/wpml-cms-nav": "*", - "junaidbhura/wpml-translation-management": "*" + "junaidbhura/wpml-string-translation": "*", + "junaidbhura/wpml-translation-management": "*", + "junaidbhura/wpml-types": "*", + "junaidbhura/wpml-woocommerce-multilingual": "*", + "junaidbhura/wpml-wp-seo-multilingual": "*", + "junaidbhura/wpml-wpforms": "*" }, ``` @@ -641,42 +640,22 @@ For example: ### WPML Add-Ons -You can use any WPML add-on by simply adding it's slug like so: - -`junaidbhura/` - -For example: - -`junaidbhura/wpml-sitepress-multilingual-cms` - -`junaidbhura/wpml-string-translation` - -`junaidbhura/wpml-media-translation` - -`junaidbhura/wpml-woocommerce-multilingual` - -`junaidbhura/wpml-gravityforms-multilingual` - -`junaidbhura/wpml-contact-form-7-multilingual` - -`junaidbhura/wpml-ninja-forms` - -`junaidbhura/wpml-wpforms` - -`junaidbhura/wpml-buddypress-multilingual` - -`junaidbhura/wpml-acfml` - -`junaidbhura/wpml-all-import` - -`junaidbhura/wpml-mailchimp-for-wp` - -`junaidbhura/wpml-wp-seo-multilingual` - -`junaidbhura/wpml-types` - -`junaidbhura/wpml-sticky-links` - -`junaidbhura/wpml-cms-nav` - -`junaidbhura/wpml-translation-management` +The following WPML plugins and add-ons are supported: + +* `junaidbhura/wpml-acfml` +* `junaidbhura/wpml-all-import` +* `junaidbhura/wpml-buddypress-multilingual` +* `junaidbhura/wpml-cms-nav` +* `junaidbhura/wpml-contact-form-7-multilingual` +* `junaidbhura/wpml-gravityforms-multilingual` +* `junaidbhura/wpml-mailchimp-for-wp` +* `junaidbhura/wpml-media-translation` +* `junaidbhura/wpml-ninja-forms` +* `junaidbhura/wpml-sitepress-multilingual-cms` +* `junaidbhura/wpml-sticky-links` +* `junaidbhura/wpml-string-translation` +* `junaidbhura/wpml-translation-management` +* `junaidbhura/wpml-types` +* `junaidbhura/wpml-woocommerce-multilingual` +* `junaidbhura/wpml-wp-seo-multilingual` +* `junaidbhura/wpml-wpforms` diff --git a/plugins/WPML.php b/plugins/WPML.php index 0aa6018..c4751bb 100644 --- a/plugins/WPML.php +++ b/plugins/WPML.php @@ -32,7 +32,7 @@ class WPML { * @param string $version * @param string $slug */ - public function __construct( $version = '', $slug = 'sitepress-multilingual-cms' ) { + public function __construct( $version = '', $slug = 'wpml-sitepress-multilingual-cms' ) { $this->version = $version; $this->slug = $slug; } @@ -43,28 +43,28 @@ public function __construct( $version = '', $slug = 'sitepress-multilingual-cms' * @return string */ public function getDownloadUrl() { - $packages = [ - 'wpml-sitepress-multilingual-cms' => 6088, - 'wpml-string-translation' => 6092, - 'wpml-media-translation' => 7474, - 'wpml-woocommerce-multilingual' => 637370, - 'wpml-gravityforms-multilingual' => 8882, + $packages = array( + 'wpml-acfml' => 1097589, + 'wpml-all-import' => 720221, + 'wpml-buddypress-multilingual' => 2216259, + 'wpml-cms-nav' => 6096, 'wpml-contact-form-7-multilingual' => 3156699, - 'wpml-ninja-forms' => 5342487, - 'wpml-wpforms' => 5368995, - 'wpml-buddypress-multilingual' => 2216259, - 'wpml-acfml' => 1097589, - 'wpml-all-import' => 720221, - 'wpml-mailchimp-for-wp' => 1442229, - 'wpml-wp-seo-multilingual' => 3566177, - 'wpml-types' => 1385906, - 'wpml-sticky-links' => 6090, - 'wpml-cms-nav' => 6096, - 'wpml-translation-management' => 6094, - ]; + 'wpml-gravityforms-multilingual' => 8882, + 'wpml-mailchimp-for-wp' => 1442229, + 'wpml-media-translation' => 7474, + 'wpml-ninja-forms' => 5342487, + 'wpml-sitepress-multilingual-cms' => 6088, + 'wpml-sticky-links' => 6090, + 'wpml-string-translation' => 6092, + 'wpml-translation-management' => 6094, + 'wpml-types' => 1385906, + 'wpml-woocommerce-multilingual' => 637370, + 'wpml-wp-seo-multilingual' => 3566177, + 'wpml-wpforms' => 5368995, + ); - if (array_key_exists($this->slug, $packages)) { - return 'https://wpml.org/?download='. $packages[$this->slug] .'&user_id='. getenv( 'WPML_USER_ID' ) .'&subscription_key='. getenv( 'WPML_KEY' ) .'&version=' . $this->version; + if ( array_key_exists( $this->slug, $packages ) ) { + return 'https://wpml.org/?download=' . $packages[ $this->slug ] . '&user_id=' . getenv( 'WPML_USER_ID' ) . '&subscription_key=' . getenv( 'WPML_KEY' ) . '&version=' . $this->version; } } From c61c70f8509e5fd740ca2b5db45e8504cd858f86 Mon Sep 17 00:00:00 2001 From: Chauncey McAskill Date: Mon, 6 Mar 2023 16:07:54 -0500 Subject: [PATCH 3/6] Fix class naming convention Changed: - Renamed the class and file name to `CamelCase` to reflect the other plugin class names. --- Installer.php | 2 +- plugins/WPML.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Installer.php b/Installer.php index c887d69..2a1b25f 100644 --- a/Installer.php +++ b/Installer.php @@ -268,7 +268,7 @@ protected function getDownloadUrl( PackageInterface $package ) { } elseif ( 0 === strpos( $package_name, 'junaidbhura/wpai-' ) || 0 === strpos( $package_name, 'junaidbhura/wpae-' ) ) { $plugin = new Plugins\WpAiPro( $package->getPrettyVersion(), $plugin_name ); } elseif ( 0 === strpos( $package_name, 'junaidbhura/wpml-' ) ) { - $plugin = new Plugins\WPML( $package->getPrettyVersion(), $plugin_name ); + $plugin = new Plugins\Wpml( $package->getPrettyVersion(), $plugin_name ); } } diff --git a/plugins/WPML.php b/plugins/WPML.php index c4751bb..2ea0ffa 100644 --- a/plugins/WPML.php +++ b/plugins/WPML.php @@ -1,6 +1,6 @@ Date: Mon, 6 Mar 2023 16:19:56 -0500 Subject: [PATCH 4/6] Update WPML instructions in README To match other support plugins with add-ons such as Gravity Forms where the main plugin and one add-on are illustrated in code samples. --- README.md | 249 ++---------------------------------------------------- 1 file changed, 6 insertions(+), 243 deletions(-) diff --git a/README.md b/README.md index 66dff22..d2634ed 100644 --- a/README.md +++ b/README.md @@ -244,141 +244,6 @@ Add the following to your composer.json file: } } }, - { - "type": "package", - "package": { - "name": "junaidbhura/wpml-acfml", - "version": "", - "type": "wordpress-plugin", - "dist": { - "type": "zip", - "url": "https://wpml.org/" - }, - "require": { - "junaidbhura/composer-wp-pro-plugins": "*" - } - } - }, - { - "type": "package", - "package": { - "name": "junaidbhura/wpml-all-import", - "version": "", - "type": "wordpress-plugin", - "dist": { - "type": "zip", - "url": "https://wpml.org/" - }, - "require": { - "junaidbhura/composer-wp-pro-plugins": "*" - } - } - }, - { - "type": "package", - "package": { - "name": "junaidbhura/wpml-buddypress-multilingual", - "version": "", - "type": "wordpress-plugin", - "dist": { - "type": "zip", - "url": "https://wpml.org/" - }, - "require": { - "junaidbhura/composer-wp-pro-plugins": "*" - } - } - }, - { - "type": "package", - "package": { - "name": "junaidbhura/wpml-cms-nav", - "version": "", - "type": "wordpress-plugin", - "dist": { - "type": "zip", - "url": "https://wpml.org/" - }, - "require": { - "junaidbhura/composer-wp-pro-plugins": "*" - } - } - }, - { - "type": "package", - "package": { - "name": "junaidbhura/wpml-contact-form-7-multilingual", - "version": "", - "type": "wordpress-plugin", - "dist": { - "type": "zip", - "url": "https://wpml.org/" - }, - "require": { - "junaidbhura/composer-wp-pro-plugins": "*" - } - } - }, - { - "type": "package", - "package": { - "name": "junaidbhura/wpml-gravityforms-multilingual", - "version": "", - "type": "wordpress-plugin", - "dist": { - "type": "zip", - "url": "https://wpml.org/" - }, - "require": { - "junaidbhura/composer-wp-pro-plugins": "*" - } - } - }, - { - "type": "package", - "package": { - "name": "junaidbhura/wpml-mailchimp-for-wp", - "version": "", - "type": "wordpress-plugin", - "dist": { - "type": "zip", - "url": "https://wpml.org/" - }, - "require": { - "junaidbhura/composer-wp-pro-plugins": "*" - } - } - }, - { - "type": "package", - "package": { - "name": "junaidbhura/wpml-media-translation", - "version": "", - "type": "wordpress-plugin", - "dist": { - "type": "zip", - "url": "https://wpml.org/" - }, - "require": { - "junaidbhura/composer-wp-pro-plugins": "*" - } - } - }, - { - "type": "package", - "package": { - "name": "junaidbhura/wpml-ninja-forms", - "version": "", - "type": "wordpress-plugin", - "dist": { - "type": "zip", - "url": "https://wpml.org/" - }, - "require": { - "junaidbhura/composer-wp-pro-plugins": "*" - } - } - }, { "type": "package", "package": { @@ -394,21 +259,6 @@ Add the following to your composer.json file: } } }, - { - "type": "package", - "package": { - "name": "junaidbhura/wpml-sticky-links", - "version": "", - "type": "wordpress-plugin", - "dist": { - "type": "zip", - "url": "https://wpml.org/" - }, - "require": { - "junaidbhura/composer-wp-pro-plugins": "*" - } - } - }, { "type": "package", "package": { @@ -423,81 +273,6 @@ Add the following to your composer.json file: "junaidbhura/composer-wp-pro-plugins": "*" } } - }, - { - "type": "package", - "package": { - "name": "junaidbhura/wpml-translation-management", - "version": "", - "type": "wordpress-plugin", - "dist": { - "type": "zip", - "url": "https://wpml.org/" - }, - "require": { - "junaidbhura/composer-wp-pro-plugins": "*" - } - } - }, - { - "type": "package", - "package": { - "name": "junaidbhura/wpml-types", - "version": "", - "type": "wordpress-plugin", - "dist": { - "type": "zip", - "url": "https://wpml.org/" - }, - "require": { - "junaidbhura/composer-wp-pro-plugins": "*" - } - } - }, - { - "type": "package", - "package": { - "name": "junaidbhura/wpml-woocommerce-multilingual", - "version": "", - "type": "wordpress-plugin", - "dist": { - "type": "zip", - "url": "https://wpml.org/" - }, - "require": { - "junaidbhura/composer-wp-pro-plugins": "*" - } - } - }, - { - "type": "package", - "package": { - "name": "junaidbhura/wpml-wp-seo-multilingual", - "version": "", - "type": "wordpress-plugin", - "dist": { - "type": "zip", - "url": "https://wpml.org/" - }, - "require": { - "junaidbhura/composer-wp-pro-plugins": "*" - } - } - }, - { - "type": "package", - "package": { - "name": "junaidbhura/wpml-wpforms", - "version": "", - "type": "wordpress-plugin", - "dist": { - "type": "zip", - "url": "https://wpml.org/" - }, - "require": { - "junaidbhura/composer-wp-pro-plugins": "*" - } - } } ], "require": { @@ -514,22 +289,7 @@ Add the following to your composer.json file: "junaidbhura/wpae-acf-add-on": "*", "junaidbhura/wpae-user-add-on-pro": "*", "junaidbhura/wpml-sitepress-multilingual-cms": "*", - "junaidbhura/wpml-acfml": "*", - "junaidbhura/wpml-all-import": "*", - "junaidbhura/wpml-buddypress-multilingual": "*", - "junaidbhura/wpml-cms-nav": "*", - "junaidbhura/wpml-contact-form-7-multilingual": "*", - "junaidbhura/wpml-gravityforms-multilingual": "*", - "junaidbhura/wpml-mailchimp-for-wp": "*", - "junaidbhura/wpml-media-translation": "*", - "junaidbhura/wpml-ninja-forms": "*", - "junaidbhura/wpml-sticky-links": "*", - "junaidbhura/wpml-string-translation": "*", - "junaidbhura/wpml-translation-management": "*", - "junaidbhura/wpml-types": "*", - "junaidbhura/wpml-woocommerce-multilingual": "*", - "junaidbhura/wpml-wp-seo-multilingual": "*", - "junaidbhura/wpml-wpforms": "*" + "junaidbhura/wpml-string-translation": "*" }, ``` @@ -640,7 +400,11 @@ For example: ### WPML Add-Ons -The following WPML plugins and add-ons are supported: +You can use any WPML add-on by simply adding it's slug like so: + +`junaidbhura/wpml-` + +The following add-ons are supported: * `junaidbhura/wpml-acfml` * `junaidbhura/wpml-all-import` @@ -651,7 +415,6 @@ The following WPML plugins and add-ons are supported: * `junaidbhura/wpml-mailchimp-for-wp` * `junaidbhura/wpml-media-translation` * `junaidbhura/wpml-ninja-forms` -* `junaidbhura/wpml-sitepress-multilingual-cms` * `junaidbhura/wpml-sticky-links` * `junaidbhura/wpml-string-translation` * `junaidbhura/wpml-translation-management` From 431b19eda076cbdb8fb1ef28a3056446ff80de25 Mon Sep 17 00:00:00 2001 From: Chauncey McAskill Date: Mon, 6 Mar 2023 18:01:39 -0500 Subject: [PATCH 5/6] Update WPML class to extend abstract plugin and throw exception if add-on is not supported. --- plugins/WPML.php | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/plugins/WPML.php b/plugins/WPML.php index 2ea0ffa..0990fc8 100644 --- a/plugins/WPML.php +++ b/plugins/WPML.php @@ -7,24 +7,12 @@ namespace Junaidbhura\Composer\WPProPlugins\Plugins; +use UnexpectedValueException; + /** * Wpml class. */ -class Wpml { - - /** - * 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 = ''; +class Wpml extends AbstractPlugin { /** * Wpml constructor. @@ -33,8 +21,7 @@ class Wpml { * @param string $slug */ public function __construct( $version = '', $slug = 'wpml-sitepress-multilingual-cms' ) { - $this->version = $version; - $this->slug = $slug; + parent::__construct( $version, $slug ); } /** @@ -63,9 +50,14 @@ public function getDownloadUrl() { 'wpml-wpforms' => 5368995, ); - if ( array_key_exists( $this->slug, $packages ) ) { - return 'https://wpml.org/?download=' . $packages[ $this->slug ] . '&user_id=' . getenv( 'WPML_USER_ID' ) . '&subscription_key=' . getenv( 'WPML_KEY' ) . '&version=' . $this->version; + if ( ! array_key_exists( $this->slug, $packages ) ) { + throw new UnexpectedValueException( sprintf( + 'Could not find a matching package for %s. Check the package spelling and that the package is supported', + 'junaidbhura/' . $this->slug + ) ); } + + return 'https://wpml.org/?download=' . $packages[ $this->slug ] . '&user_id=' . getenv( 'WPML_USER_ID' ) . '&subscription_key=' . getenv( 'WPML_KEY' ) . '&version=' . $this->version; } } From d5d1fe72168eb7f664162493df6b67fc982f9eb8 Mon Sep 17 00:00:00 2001 From: Chauncey McAskill Date: Mon, 6 Mar 2023 18:14:45 -0500 Subject: [PATCH 6/6] Fix indentation style Should be tabs instead of spaces. --- plugins/WPML.php | 74 ++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/plugins/WPML.php b/plugins/WPML.php index 0990fc8..b1ad222 100644 --- a/plugins/WPML.php +++ b/plugins/WPML.php @@ -14,15 +14,15 @@ */ class Wpml extends AbstractPlugin { - /** - * Wpml constructor. - * - * @param string $version - * @param string $slug - */ - public function __construct( $version = '', $slug = 'wpml-sitepress-multilingual-cms' ) { - parent::__construct( $version, $slug ); - } + /** + * Wpml constructor. + * + * @param string $version + * @param string $slug + */ + public function __construct( $version = '', $slug = 'wpml-sitepress-multilingual-cms' ) { + parent::__construct( $version, $slug ); + } /** * Get the download URL for this plugin. @@ -30,34 +30,34 @@ public function __construct( $version = '', $slug = 'wpml-sitepress-multilingual * @return string */ public function getDownloadUrl() { - $packages = array( - 'wpml-acfml' => 1097589, - 'wpml-all-import' => 720221, - 'wpml-buddypress-multilingual' => 2216259, - 'wpml-cms-nav' => 6096, - 'wpml-contact-form-7-multilingual' => 3156699, - 'wpml-gravityforms-multilingual' => 8882, - 'wpml-mailchimp-for-wp' => 1442229, - 'wpml-media-translation' => 7474, - 'wpml-ninja-forms' => 5342487, - 'wpml-sitepress-multilingual-cms' => 6088, - 'wpml-sticky-links' => 6090, - 'wpml-string-translation' => 6092, - 'wpml-translation-management' => 6094, - 'wpml-types' => 1385906, - 'wpml-woocommerce-multilingual' => 637370, - 'wpml-wp-seo-multilingual' => 3566177, - 'wpml-wpforms' => 5368995, - ); - - if ( ! array_key_exists( $this->slug, $packages ) ) { - throw new UnexpectedValueException( sprintf( - 'Could not find a matching package for %s. Check the package spelling and that the package is supported', - 'junaidbhura/' . $this->slug - ) ); - } - - return 'https://wpml.org/?download=' . $packages[ $this->slug ] . '&user_id=' . getenv( 'WPML_USER_ID' ) . '&subscription_key=' . getenv( 'WPML_KEY' ) . '&version=' . $this->version; + $packages = array( + 'wpml-acfml' => 1097589, + 'wpml-all-import' => 720221, + 'wpml-buddypress-multilingual' => 2216259, + 'wpml-cms-nav' => 6096, + 'wpml-contact-form-7-multilingual' => 3156699, + 'wpml-gravityforms-multilingual' => 8882, + 'wpml-mailchimp-for-wp' => 1442229, + 'wpml-media-translation' => 7474, + 'wpml-ninja-forms' => 5342487, + 'wpml-sitepress-multilingual-cms' => 6088, + 'wpml-sticky-links' => 6090, + 'wpml-string-translation' => 6092, + 'wpml-translation-management' => 6094, + 'wpml-types' => 1385906, + 'wpml-woocommerce-multilingual' => 637370, + 'wpml-wp-seo-multilingual' => 3566177, + 'wpml-wpforms' => 5368995, + ); + + if ( ! array_key_exists( $this->slug, $packages ) ) { + throw new UnexpectedValueException( sprintf( + 'Could not find a matching package for %s. Check the package spelling and that the package is supported', + 'junaidbhura/' . $this->slug + ) ); + } + + return 'https://wpml.org/?download=' . $packages[ $this->slug ] . '&user_id=' . getenv( 'WPML_USER_ID' ) . '&subscription_key=' . getenv( 'WPML_KEY' ) . '&version=' . $this->version; } }