Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for WPML (plugin / add-ons) #42

Closed
wants to merge 3 commits into from
Closed

Add support for WPML (plugin / add-ons) #42

wants to merge 3 commits into from

Conversation

Spidlace
Copy link

@Spidlace Spidlace commented Dec 20, 2022

Checklist:

  • I've read the Contributing page.
  • I've created an issue and referenced it here.
  • My code is tested.
  • My code follows the WordPress code style.
  • My code has proper inline documentation.

Description

Add support for WPML plugin and add-ons

plugins/WPML.php Outdated
'wpml-translation-management' => 6094,
];

if (in_array($this->slug, $packages)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in_array should be replaced with array_key_exists

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, my bad!
It's modified! :-)

Copy link

@MouseEatsCat MouseEatsCat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this on a project with several WPML add-ons and it seems to work well!

Copy link
Contributor

@mcaskill mcaskill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature is much appreciated.

I have not tested it myself yet but I propose a few minor changes to match the coding style of the rest of the package.

Comment on lines +2 to +6
/**
* ACF Pro Plugin.
*
* @package Junaidbhura\Composer\WPProPlugins\Plugins
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change file block comment to reflect WPML plugin.

Suggested change
/**
* ACF Pro Plugin.
*
* @package Junaidbhura\Composer\WPProPlugins\Plugins
*/
/**
* WPML Plugin.
*
* @package Junaidbhura\Composer\WPProPlugins\Plugins
*/

Comment on lines +10 to +13
/**
* AcfPro class.
*/
class WPML {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change class block comment to reflect WPML plugin.

Rename the class and file name to CamelCase to reflect the other plugin class names.

Suggested change
/**
* AcfPro class.
*/
class WPML {
/**
* Wpml class.
*/
class Wpml {

Comment on lines +29 to +34
/**
* WpAiPro constructor.
*
* @param string $version
* @param string $slug
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change method block comment to reflect WPML plugin.

Suggested change
/**
* WpAiPro constructor.
*
* @param string $version
* @param string $slug
*/
/**
* Wpml constructor.
*
* @param string $version
* @param string $slug
*/

Comment on lines +46 to +64
$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,
];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to verbose array syntax and aligned array values to match coding style other classes.

Suggested change
$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,
];
$packages = array(
'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,
);

Comment on lines +66 to +68
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;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added spacing to match coding style other classes.

Suggested change
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;
}

@junaidbhura
Copy link
Owner

Thanks everyone, happy new year!

Hey @Spidlace could you please implement the suggestions from @mcaskill ?

I'll be happy to merge it in once done. I'll make some minor updates once merged. I don't have an API key, @mcaskill have you verified this as working?

@mcaskill
Copy link
Contributor

mcaskill commented Jan 2, 2023

[…] I don't have an API key, @mcaskill have you verified this as working?

My colleague, @MouseEatsCat, and I have tried it.

@junaidbhura
Copy link
Owner

Okay excellent @mcaskill - will wait for @Spidlace to implement the suggestions before merging it in

* @param string $version
* @param string $slug
*/
public function __construct( $version = '', $slug = 'sitepress-multilingual-cms' ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the default slug to match the array key below.

Suggested change
public function __construct( $version = '', $slug = 'sitepress-multilingual-cms' ) {
public function __construct( $version = '', $slug = 'wpml-sitepress-multilingual-cms' ) {

Copy link
Contributor

@mcaskill mcaskill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that the Wpml.php file is using spaces instead of tabs. That should also be fixed.

Comment on lines +508 to +548
### WPML Add-Ons

You can use any WPML add-on by simply adding it's slug like so:

`junaidbhura/<plugin-slug>`

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`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is derived from from WP All Import/Export Pro and both should be rephrased to highlight the fact that only specific add-ons of each plugin are supported. The section should be phrase as so:

Suggested change
### WPML Add-Ons
You can use any WPML add-on by simply adding it's slug like so:
`junaidbhura/<plugin-slug>`
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`
### WPML Add-Ons
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`

Comment on lines +443 to 445
},

],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix JSON syntax.

Suggested change
},
],
}
],

@mcaskill
Copy link
Contributor

mcaskill commented Feb 1, 2023

Hi @Spidlace,

I hope you are doing well.

Will you be able to work on requested changes any time soon?
Alternatively, if your branch could add me as a contributor, I can make the changes for you.

Thanks and take care,

@mcaskill
Copy link
Contributor

mcaskill commented Mar 6, 2023

I've merged my suggestions in my fork, including some alleviation to the WPML code samples in the README.

I could create a separate pull request if we want to merge this feature sooner.

@junaidbhura
Copy link
Owner

@mcaskill Shall we close this PR in favour and maybe you could create a new PR instead?

@junaidbhura
Copy link
Owner

Closing in favour of #53

@junaidbhura junaidbhura closed this Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants