Automattic\WooCommerce\Admin\API
MarketingOverview::activate_plugin
Return installed marketing extensions data.
Method of the class: MarketingOverview{}
No Hooks.
Returns
\WP_Error|\WP_REST_Response.
Usage
$MarketingOverview = new MarketingOverview(); $MarketingOverview->activate_plugin( $request );
- $request(WP_REST_Request) (required)
- Request data.
MarketingOverview::activate_plugin() MarketingOverview::activate plugin code WC 10.8.1
public function activate_plugin( $request ) {
$plugin_slug = $request->get_param( 'plugin' );
if ( ! PluginsHelper::is_plugin_installed( $plugin_slug ) ) {
return new \WP_Error( 'woocommerce_rest_invalid_plugin', __( 'Invalid plugin.', 'woocommerce' ), 404 );
}
$result = activate_plugin( PluginsHelper::get_plugin_path_from_slug( $plugin_slug ) );
if ( ! is_null( $result ) ) {
return new \WP_Error( 'woocommerce_rest_invalid_plugin', __( 'The plugin could not be activated.', 'woocommerce' ), 500 );
}
// IMPORTANT - Don't return the active plugins data here.
// Instead we will get that data in a separate request to ensure they are loaded.
return rest_ensure_response(
array(
'status' => 'success',
)
);
}