WP_REST_Plugins_Controller::handle_plugin_status() WordPress Method
This method is responsible for handling the plugin status. It is called when the user clicks on the "activate" or "deactivate" link for a plugin. If the user does not have the required capability, this method will return an error.
WP_REST_Plugins_Controller::handle_plugin_status( string $plugin, string $new_status, string $current_status ) #
Handle updating a plugin’s status.
Parameters
- $plugin
(string)(Required)The plugin file to update.
- $new_status
(string)(Required)The plugin's new status.
- $current_status
(string)(Required)The plugin's current status.
Return
(true|WP_Error)
Source
File: wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.php
protected function handle_plugin_status( $plugin, $new_status, $current_status ) { if ( 'inactive' === $new_status ) { deactivate_plugins( $plugin, false, 'network-active' === $current_status ); return true; } if ( 'active' === $new_status && 'network-active' === $current_status ) { return true; } $network_activate = 'network-active' === $new_status; if ( is_multisite() && ! $network_activate && is_network_only_plugin( $plugin ) ) { return new WP_Error( 'rest_network_only_plugin', __( 'Network only plugin must be network activated.' ), array( 'status' => 400 ) ); } $activated = activate_plugin( $plugin, '', $network_activate ); if ( is_wp_error( $activated ) ) { $activated->add_data( array( 'status' => 500 ) ); return $activated; } return true; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.5.0 | Introduced. |