WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #43992, comment 5


Ignore:
Timestamp:
01/25/2019 09:34:52 PM (20 months ago)
Author:
afragen
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #43992, comment 5

    initial v1  
    1 This could be something as simple as the following.
    2 
    3 
    4 {{{
    5 add_filter(
    6         'plugin_action_links',
    7         function ( $actions, $plugin_file, $plugin_data ) {
    8                 $compatible_php = ( empty( $plugin_data['Requires PHP'] ) || version_compare( substr( phpversion(), 0, strlen( $plugin_data['Requires PHP'] ) ), $plugin_data['Requires PHP'], '>=' ) );
    9                 if ( ! $compatible_php ) {
    10                         unset( $actions['activate'] );
    11                 }
    12                 return $actions;
    13         },
    14         10,
    15         3
    16 );
    17 }}}
    18 
    19 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.
    20 
    21 I think it's going to be much more difficult to stop activation from an uploaded plugin via the upload panel.
    22 
    23 A more inclusive solution would likely require a filter hook into `wp-admin/includes/plugin.php` `validate_plugin()` that passes the plugin's headers.
    24 
    25 Just brain dumping.