Make sure that WPML is actually active before your try to access its API. The plugin dies with a fatal error otherwise.
Separate object creation and class declaration: Move the class WPML2MLP_Importer to a separate file.
Use existing instances. There is no need to recreate instances of Mlp_Site_Relations or Mlp_Content_Relations, they are provided by MultilingualPress.
We will introduce unit and integration tests for MultilingualPress and its extensions soon. Please make your code ready for that:
Do not use singletons.
Do not register hook callbacks (add_action() and add_filter()) in constructors, this is not testable.
Try to limit the cyclomatic complexity to 5, the NPath complexity to 50. The PHP Mess Detector is very useful for such checks (usable in PhpStorm via Composer).
Add the hook to the doc block of callback handlers to make the code easier to understand. Example:
/**
* Adds the menu option to the settings
*
* @wp-hook network_admin_menu
*/
public function add_menu_option() {
}
Add an admin notice with a link to the settings page after activation.
The settings page is not clear: Yes/no options should be expressed with checkboxes, not with radio buttons. What happens when the user selects no? Please make that clear, or use just two different submit buttons. The user should never have to guess.
In WPML2MLP_Importer::run_import(), move the POST handling to a separate method or class, make sure you do not import everything again after a page reload. Use admin-post.php as form action, and redirect the user back to the settings page when you are done. For the export, see this instruction.
Why is there a class for zip files in the plugin? WordPress comes with PclZip, can we use that instead?
Hi,
the following notes are the result of a short review. They are in no particular order.
mlp_
is reserved for the main plugin.WPML2MLP_Importer
to a separate file.Mlp_Site_Relations
orMlp_Content_Relations
, they are provided by MultilingualPress.add_action()
andadd_filter()
) in constructors, this is not testable._e( 'WPML 2 MLP' )
is not translatable.WPML2MLP_Importer::run_import()
, move thePOST
handling to a separate method or class, make sure you do not import everything again after a page reload. Useadmin-post.php
as form action, and redirect the user back to the settings page when you are done. For the export, see this instruction.PclZip
, can we use that instead?