WPDev.one
Core Function
View Source on Trac ↗

activate_plugin()

activate_plugin( mixed $plugin, mixed $redirect = '', mixed $network_wide = false, mixed $silent = false )

Attempts activation of plugin in a "sandbox" and redirects on success.

Parameters 2 required

Name / Type Description
$plugin
string

Path to the plugin file relative to the plugins directory.

Required
$redirect
string

Optional. URL to redirect to.

bool

$network_wide Optional. Whether to enable the plugin for all sites in the network or just the current site. Multisite only. Default false.

Required
$silent
bool

Optional. Whether to prevent calling activation hooks. Default false.

Return Value

((null)
| WP_Error) Null on success, WP_Error on invalid file.

Function Information

Since Version
2.5.0
Source File
wp-admin/includes/plugin.php
Advertisement