Skip to content

Commit

Permalink
Update admin/load.php, more graceful error exiting if user lacks perm…
Browse files Browse the repository at this point in the history
…issions to activate plugin.

Co-authored-by: Felix Arntz <[email protected]>
  • Loading branch information
10upsimon and felixarntz authored Nov 8, 2023
1 parent 0a20c0a commit 2246e74
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions admin/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,17 @@ function perflab_activate_plugin() {
// The plugin being activated.
$plugin = sanitize_text_field( $_GET['plugin'] );

if ( check_admin_referer( "perflab_activate_plugin_{$plugin}" ) && current_user_can( 'activate_plugin', $plugin ) ) {
// Activate the plugin in question and return to prior screen.
activate_plugins( $plugin );
$referer = wp_get_referer();
if ( wp_safe_redirect( $referer ) ) {
exit;
}
check_admin_referer( "perflab_activate_plugin_{$plugin}" );

if ( ! current_user_can( 'activate_plugin', $plugin ) ) {
wp_die( __( 'Sorry, you are not allowed to activate this plugin.', 'default' ) );
}

// Activate the plugin in question and return to prior screen.
activate_plugins( $plugin );
$referer = wp_get_referer();
if ( wp_safe_redirect( $referer ) ) {
exit;
}
}

Expand Down

0 comments on commit 2246e74

Please sign in to comment.