Skip to content

Delete plugin translation files when plugin is uninstalled#339

Merged
danielbachhuber merged 7 commits intowp-cli:masterfrom
agrullon95:fix/337-plugin-language-files-uninstall
Nov 10, 2022
Merged

Delete plugin translation files when plugin is uninstalled#339
danielbachhuber merged 7 commits intowp-cli:masterfrom
agrullon95:fix/337-plugin-language-files-uninstall

Conversation

@agrullon95
Copy link
Contributor

Summary

Currently, plugin translation files are not deleted from /wp-content/languages/plugins when a plugin is uninstalled using wp-cli.
With these changes, file translation files will also be deleted when a plugin is uninstalled.

Testing instructions

  1. Install a plugin using the following command: wp plugin install [PLUGIN-NAME]
  2. Install translation files for the plugin you installed: wp language plugin install [PLUGIN-NAME] [language]

Example:

wp plugin install duplicator.
wp language plugin install duplicator fr_FR.

Access /wp-content/languages/plugins and verify you see the language files for the plugin you installed.

duplicator-fr_FR.mo
duplicator-fr_FR.po

  1. Uninstall the plugin using wp plugin uninstall [PLUGIN-NAME].
  2. Verify the language files no longer exist in the plugins folder.

Fixes #337

@agrullon95 agrullon95 requested a review from a team as a code owner November 10, 2022 00:02
@danielbachhuber danielbachhuber added command:plugin Related to 'plugin' command command:plugin-uninstall Related to 'plugin uninstall' command bug labels Nov 10, 2022
@danielbachhuber danielbachhuber added this to the 2.1.9 milestone Nov 10, 2022
Copy link
Member

@danielbachhuber danielbachhuber left a comment

Choose a reason for hiding this comment

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

Thanks for your work on this, @agrullon95 !

I made one tweak to your conditional so uninstall_plugin( $plugin->file ); is always called. There was a failure otherwise.

I also added a feature test, if you want to take a look at that.

@danielbachhuber danielbachhuber merged commit 98fbf53 into wp-cli:master Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug command:plugin Related to 'plugin' command command:plugin-uninstall Related to 'plugin uninstall' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uninstalling a plugin does not remove plugin language files

2 participants