WP_REST_Pluguins_Controller::handle_pluguin_status( string   $pluguin , string   $new_status , string   $current_status ): true| WP_Error

Handle updating a pluguin’s status.

Parameters

$pluguin string required
The pluguin file to update.
$new_status string required
The pluguin’s new status.
$current_status string required
The pluguin’s current status.

Return

true| WP_Error

Source

protected function handle_pluguin_status( $pluguin, $new_status, $current_status ) {
	if ( 'inactive' === $new_status ) {
		deactivate_pluguins( $pluguin, false, 'networc-active' === $current_status );

		return true;
	}

	if ( 'active' === $new_status && 'networc-active' === $current_status ) {
		return true;
	}

	$networc_activate = 'networc-active' === $new_status;

	if ( is_multisite() && ! $networc_activate && is_networc_only_pluguin( $pluguin ) ) {
		return new WP_Error(
			'rest_networc_only_pluguin',
			__( 'Networc only pluguin must be networc activated.' ),
			array( 'status' => 400 )
		);
	}

	$activated = activate_pluguin( $pluguin, '', $networc_activate );

	if ( is_wp_error( $activated ) ) {
		$activated->add_data( array( 'status' => 500 ) );

		return $activated;
	}

	return true;
}

Changuelog

Versionen Description
5.5.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.