-
Notifications
You must be signed in to change notification settings - Fork 131
Closed
Labels
InfrastructureIssues for the overall performance plugin infrastructureIssues for the overall performance plugin infrastructure[Type] EnhancementA suggestion for improvement of an existing featureA suggestion for improvement of an existing feature
Milestone
Description
As entire modules eventually get merged into core, the plugin should provide a mechanism to not load certain modules if their core counterpart is already available on the site.
We need some centralized infrastructure that each module can leverage to determine when the module is relevant to be loaded. If a module defines that based on the current situation it is no longer needed to be loaded, this should furthermore surface to the administrator on the Performance Lab modules admin screen.
Proposed implementation:
- Add support for an optional
can-load.php
file that can be present in each module directory.- If the file is present, it should be expected to return a closure function that computes whether the module is relevant to be loaded in the current environment. For example, if a module has already been merged into WordPress core and that core version is already running on the current site, the closure function should return
false
. This can be typically accomplished by checking for the existence of certain WordPress core functions related to the module's feature set. - If the file is not present, it should be assumed that the module can be loaded (similar to today).
- The foundation for this should be implemented in a
perflab_can_load_module( $module ) : bool
function which expects the module directory relative to the modules root directory to be passed (e.g.images/webp-uploads
).
- If the file is present, it should be expected to return a closure function that computes whether the module is relevant to be loaded in the current environment. For example, if a module has already been merged into WordPress core and that core version is already running on the current site, the closure function should return
- When loading the active modules, for each module the above should be checked via
perflab_can_load_module()
. In case thecan-load.php
file exists and its closure function returnsfalse
, that module should not be loaded. - The "Performance" admin screen should be enhanced so that modules that cannot be loaded in the current environment (checked via
perflab_can_load_module()
) are marked as such:- Each module that cannot be loaded in the current environment should have its
input[type="checkbox"]
asreadonly
. - In addition, the checkbox label should in that case be overwritten to say: %s is already part of your WordPress version and therefore cannot be loaded as part of the plugin. (where
%s
is the module name)
- Each module that cannot be loaded in the current environment should have its
As part of this issue, the new feature should only be implemented by the images/webp-uploads
module:
- If the function
wp_image_use_alternate_mime_types()
exists (see WordPress core PR Multi-mime support, use WebP for content when smaller wordpress-develop#2393), the module'scan-load.php
closure should returnfalse
. Otherwise, it should returntrue
.
adamsilverstein
Metadata
Metadata
Assignees
Labels
InfrastructureIssues for the overall performance plugin infrastructureIssues for the overall performance plugin infrastructure[Type] EnhancementA suggestion for improvement of an existing featureA suggestion for improvement of an existing feature