I uploaded a plugin to the WordPress repository and some people enjoy the plugin. I use plugin.php
as the base name for my plugin.
Every time I change something, I would like to change the name of the main file to the name of the plugin. But if I would do that I think that the users would get the error "plugin disabled because it could not be found".
Is there a way to specify the new base name for a plugin so that I can rename my main php file?
I uploaded a plugin to the WordPress.org repository and some people enjoy the plugin. I use plugin.php
as the base name for my plugin.
Every time I change something, I would like to change the name of the main file to the name of the plugin. But if I would do that I think that the users would get the error "plugin disabled because it could not be found".
Is there a way to specify the new base name for a plugin so that I can rename my main php file?
Share Improve this question edited Feb 7, 2022 at 17:36 Tom J Nowell♦ 60.8k7 gold badges77 silver badges147 bronze badges asked Feb 7, 2022 at 16:58 MarcMarc 6979 silver badges28 bronze badges 1 |2 Answers
Reset to default 1There is no safe reliable way to do this, wether it is or is not on wordpress.org, and .org may get upset if you do this. You might also break automations on .org and on your customers sites.
Is there a way to specify the new base name for a plugin so that I can rename my main php file?
No there is no mechanism for this.
There is an ultra hacky workaround that will p*ss off all your users, break lots of things, but do the job for a minority of users who update regularly and are lucky.
The only "way" to do it would be to introduce a version of the plugin that has 2 main plugin files, and a filter to transfer from one to the other.
However:
- users will see 2 plugins listed when on this version
- users who don't update to this version or update to the next version will not be migrated
- security plugins may see this as an attack
- users may then reactivate the old plugin
- any filters users have made to auto-activate the plugin will be crippled, you will have broken their website
- any users who put your plugin in a non-standard place then include it with an
include
orrequire
will have their sites broken - the built in updater may upgrade the old plugin file to the newer version that has only your new basefile, get confused, and deactivate the plugin, or rollback the update assuming it had failed
- in theory your new base file is actually a brand new plugin, there may be consequences in terms of your plugins listing and how the WP updater handles it
The cost to doing this is extremely high, with a minimal chance of success, all to satisfy a personal preference. Expect lots of upset users and support burden.
It's a hacky task but I think it's a good one...
It's in the WP.org plugin guidelines to have the directory with the same name of the main plugin file.
Why? Because autoloading of translation (from WP4.7) is based on text-domain which need to be also the same.
You should contact plugin reviewer team at [email protected] to know if they have any guidelines for you.
plugin.php
is preferable as it's unambiguous, whereas the name of the plugin might be the main file, or it might be a class of that name, or it might be something else, etc – Tom J Nowell ♦ Commented Feb 7, 2022 at 17:27