[wp-trac] [WordPress Trac] #43992: Prevent activation of a plugin if its required PHP version is too high
WordPress Trac
noreply at wordpress.org
Thu Dec 20 04:50:12 UTC 2018
#43992: Prevent activation of a plugin if its required PHP version is too high
-------------------------------------------------+-------------------------
Reporter: flixos90 | Owner: (none)
Type: task (blessed) | Status: new
Priority: normal | Milestone: 5.1
Component: Plugins | Version:
Severity: major | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses:
servehappy dev-feedback |
-------------------------------------------------+-------------------------
Comment (by afragen):
This could be something as simple as the following.
{{{
add_filter(
'plugin_action_links',
function ( $actions, $plugin_file, $plugin_data ) {
$compatible_php = ( empty( $plugin_data['Requires PHP'] )
|| version_compare( substr( phpversion(), 0, strlen(
$plugin_data['Requires PHP'] ) ), $plugin_data['Requires PHP'], '>=' ) );
if ( ! $compatible_php ) {
unset( $actions['activate'] );
}
return $actions;
},
10,
3
);
}}}
This needs an extra plugin header {{{Requires PHP}}} and if no header is
present will allow activation. This is only for the plugins.php page.
I think it's going to be much more difficult to stop activation from an
uploaded plugin via the upload panel.
A more inclusive solution would likely require a filter hook into `wp-
admin/includes/plugin.php` `validate_plugin()` that passes the plugin's
headers.
Just brain dumping.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43992#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list