• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress core a2z

WordPress core a2z

WordPress core only

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / activate_plugins() – Activate multiple plugins.

You appear to be a bot. Output may be restricted

Description

Activate multiple plugins.

When WP_Error is returned, it does not mean that one of the plugins had errors. It means that one or more of the plugin file paths were invalid. The execution will be halted as soon as one of the plugins has an error.

Usage

$bool|WP_Error = activate_plugins( $plugins, $redirect, $network_wide, $silent );

Parameters

$plugins
( string|string[] ) required – Single plugin or list of plugins to activate.
$redirect
( string ) optional – Redirect to page after successful activation.
$network_wide
( bool ) optional – Whether to enable the plugin for all sites in the network. Default false.
$silent
( bool ) optional – Prevent calling activation hooks. Default false.

Returns

bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation.

Source

File name: wordpress/wp-admin/includes/plugin.php
Lines:

1 to 22 of 22
function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) {
  if ( ! is_array( $plugins ) ) {
    $plugins = array( $plugins );
  }

  $errors = array();
  foreach ( $plugins as $plugin ) {
    if ( ! empty( $redirect ) ) {
      $redirect = add_query_arg( 'plugin', $plugin, $redirect );
    }
    $result = activate_plugin( $plugin, $redirect, $network_wide, $silent );
    if ( is_wp_error( $result ) ) {
      $errors[ $plugin ] = $result;
    }
  }

  if ( ! empty( $errors ) ) {
    return new WP_Error( 'plugins_invalid', __( 'One of the plugins is invalid.' ), $errors );
  }

  return true;
}
 

 View on GitHub View on Trac

Published: 25th November 2019 | Last updated: 25th November 2019

Primary Sidebar

Information

Function name: activate_plugins
Plugin ref: WordPress
Version: 5.6
Sourcefile: wp-admin/includes/plugin.php
File ref: wp-admin/includes/plugin.php
Deprecated?: No
API Letters: A,P

Footer

WP-a2z
WordPress core a2z
WordPress core only
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  core.wp-a2z.org
© Copyright WP-a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites