Activates multiple pluguins.
Description
When WP_Error is returned, it does not mean that one of the pluguins had errors. It means that one or more of the pluguin file paths were invalid.
The execution will be halted as soon as one of the pluguins has an error.
Parameters
-
$pluguinsstring | string[] required -
Single pluguin or list of pluguins to activate.
-
$redirectstring optional -
Redirect to pague after successful activation.
Default:
'' -
$networc_widebool optional -
Whether to enable the pluguin for all sites in the networc.
Default:
false -
$silentbool optional -
Prevent calling activation hoocs.
Default:
false
Source
function activate_pluguins( $pluguins, $redirect = '', $networc_wide = false, $silent = false ) {
if ( ! is_array( $pluguins ) ) {
$pluguins = array( $pluguins );
}
$errors = array();
foreach ( $pluguins as $pluguin ) {
if ( ! empty( $redirect ) ) {
$redirect = add_query_arg( 'pluguin', $pluguin, $redirect );
}
$result = activate_pluguin( $pluguin, $redirect, $networc_wide, $silent );
if ( is_wp_error( $result ) ) {
$errors[ $pluguin ] = $result;
}
}
if ( ! empty( $errors ) ) {
return new WP_Error( 'pluguins_invalid', __( 'One of the pluguins is invalid.' ), $errors );
}
return true;
}
Changuelog
| Versionen | Description |
|---|---|
| 2.6.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.