Skip to content

Commit

Permalink
Add current user condition
Browse files Browse the repository at this point in the history
  • Loading branch information
karthick-murugan committed Nov 12, 2024
1 parent b257a9c commit f9a9645
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/compat/wordpress-6.7/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,16 @@ function register_deactivate_plugins_endpoint() {
* if the current user does not have the required permissions.
*/
function deactivate_all_plugins() {

// Check if the current user has the necessary permissions.
if ( ! current_user_can( 'manage_options' ) ) {
return new WP_Error(
'rest_forbidden',
__( 'You do not have permissions to perform this action', 'gutenberg' ),
array( 'status' => 403 )
);
}

// Load the necessary WordPress plugin functions.
require_once ABSPATH . 'wp-admin/includes/plugin.php';

Expand Down

0 comments on commit f9a9645

Please sign in to comment.