diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php index d0dd5fce4cd9c..fd6bc44bb5587 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php @@ -361,20 +361,6 @@ public function create_item( $request ) { ); } - if ( 'inactive' !== $request['status'] ) { - $can_change_status = $this->plugin_status_permission_check( $file, $request['status'], 'inactive' ); - - if ( is_wp_error( $can_change_status ) ) { - return $can_change_status; - } - - $changed_status = $this->handle_plugin_status( $file, $request['status'], 'inactive' ); - - if ( is_wp_error( $changed_status ) ) { - return $changed_status; - } - } - // Install translations. $installed_locales = array_values( get_available_languages() ); /** This filter is documented in wp-includes/update.php */ @@ -401,6 +387,21 @@ static function ( $pack ) use ( $installed_locales ) { $lp_upgrader->bulk_upgrade( $language_packs ); } + // Now handle plugin activation. + if ( 'inactive' !== $request['status'] ) { + $can_change_status = $this->plugin_status_permission_check( $file, $request['status'], 'inactive' ); + + if ( is_wp_error( $can_change_status ) ) { + return $can_change_status; + } + + $changed_status = $this->handle_plugin_status( $file, $request['status'], 'inactive' ); + + if ( is_wp_error( $changed_status ) ) { + return $changed_status; + } + } + $path = WP_PLUGIN_DIR . '/' . $file; $data = get_plugin_data( $path, false, false ); $data['_file'] = $file;