Opened 14 years ago
Last modified 6 years ago
#15906 new defect (bug)
validate_plugin needs all_plugins filter
Reported by: | wpmuguru | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Plugins | Keywords: | has-patch |
Focuses: | Cc: |
Description
If a plugin adds plugins to the plugin list in the plugin admin screens using the all_plugins filter, the added plugins will not validate. If the all_plugins filter is added to the validate function, then the plugin validates and activates fine.
Attachments (1)
Change History (10)
#2
@
14 years ago
If it was added to get_plugins, then both the $plugin_folder parameter & context (ex. plugin_editor) should be provided to the filter. So, I'm not sure that moving the filter there would provide any benefit.
#4
in reply to:
↑ 3
@
14 years ago
Replying to nacin:
We killed off the all_plugins filters in 3.0, I believe.
It's in https://core.trac.wordpress.org/browser/trunk/wp-admin/includes/class-wp-plugins-list-table.php#L47
as of R17228.
#9
@
9 years ago
I just stumbled over this one. Adding a plugin via all_plugins
can't be activated, because validate_plugin()
doesn't know the plugin.
The filter was moved to core in [12722], but was originally requested in https://mu.trac.wordpress.org/ticket/656. The reporter wanted to have the filter in `get_plugins()`, but it got added to the list table instead, see https://mu.trac.wordpress.org/changeset/1333/.
Adding the filter to get_plugins()
itself would be tricky because it already does plenty of work and also caching. I think adding the filter to each get_plugins()
call where it could make sense should be harmless. In this case it's only validate_plugin()
because I don't think that the plugin editor and the upgrade/install process are quite useful for custom plugins.
My current code is:
<?php add_filter( 'all_plugins', function( $plugins ) { $_gp_plugins = get_plugins( '/gp-plugins' ); // WP_PLUGIN_DIR . '/gp-plugins' // Fix plugin file path $gp_plugins = array(); foreach ( $_gp_plugins as $file => $data ) { $gp_plugins[ 'gp-plugins/' . $file ] = $data; } $plugins = array_merge( $plugins, $gp_plugins ); unset( $_gp_plugins ); return $plugins; } );
get_plugins()
function is used in several more places (e.g. in Plugin Editor). Shouldn't we useall_plugins
filter inget_plugins()
itself?