Opened 23 months ago
Last modified 15 months ago
#57220 new enhancement
New plugin header for requiring network installation
Reported by: | petitphp | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Plugins | Keywords: | has-patch has-unit-tests |
Focuses: | multisite | Cc: |
Description
There is currently no way for developers to mark a plugin as “only working on a multisite installation”. If such a requirement is necessary, the plugin has to run a check during the plugin initialization and stop its execution (and maybe show an error notice to the user).
Alternatively, users have no obvious way to know is a plugin explicitly require a multisite to work.
WordPress provides a “Network” header for plugins which allow plugins to specify if they should be activated at the network level when use in a multisite, but it doesn’t stop activation on non-multisite installations.
This proposal is for adding a new header Requires Network
to allow plugins to specifically require a multisite installation to be activated.
<?php /** * Plugin Name: My Custom Plugin * Description: A plugin requiring a network installation to work. * Plugin URI: https://example.com * Version: 1.0.0 * Requires Network: true */
The new header is complementary to the existing Network
header and not meant to replace it.
After a quick look in the core, I think implementing this header would also involve other parts of the WordPress ecosystem :
- WP.org plugin API: include a flag “requires_network” to allow plugin install table to support the new requirement,
- WP-CLI: plugin install/activate commands need to support the new requirement
Attachments (2)
Change History (9)
This ticket was mentioned in PR #3717 on WordPress/wordpress-develop by @petitphp.
23 months ago
#2
- Keywords has-patch has-unit-tests added
Implementation of the new Requires Network
plugin header.
Changes from this PR only touch parts of the admin UI that relies on data from get_plugin_data
.
Other parts of the admin that use the response from the WP.org plugin API were not updated.
Trac ticket: https://core.trac.wordpress.org/ticket/57220
This ticket was mentioned in Slack in #core-multisite by petitphp. View the logs.
23 months ago
#4
@
23 months ago
Can you provide more information on why this header is needed and what problem is trying to solve here. Feels like Network
covers a lot of this.
#5
@
23 months ago
- Summary changed from New plugin header for requirering network installation to New plugin header for requiring network installation
The goal of this ticket is to give developers a way to flag a plugin as "multisite only" and to have the WordPress admin react accordingly.
Currently, for a plugin built around multisite features, it's not possible to prevent users to activate it on a "single site" installation. The developer has to add safeguards to stop the plugin initialization, maybe warn the user with a notice and/or deactivate it.
The Network
header is a first step to force users to activate a plugin at the network level in a multisite installation, but it'll not stop users from activating it on a single site instance, hence this proposal.
I agree that this proposal is very niche and only apply to a limited set of plugins.
#6
@
21 months ago
I think this is typically the kind of small feature that you might think is not that important or useful but I would say it's definitely a good step forward in order to have a better general Multisite experience for the end user.
On the positive sides, it doesn't require that much code in Core, and it helps providing more information for both plugin creators and plugin users.
Furthermore, the patch looks solid to me, with some filters and good implementation.
#7
@
15 months ago
The sister headers for required PHP and core versions are there to prevent undefined function errors and save plugin authors from endless use of if ( function_exists( 'etc' ) )
. I believe there is a ticket somewhere that proposes to load multisite functions all the time, and if it were solved, it seems there would no longer be a need for this ticket.
Admin UI mockup for the new "Requires Network" plugin header.