Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




activate_plugins [ WordPress Function ]

activate_plugins ( $plugins, $redirect = '', $network_wide = false, $silent = false )
Parameters:
  • (string|array) $plugins
  • (string) $redirect Redirect to page after successful activation.
  • (bool) $network_wide Whether to enable the plugin for all sites in the network.
  • (bool) $silent Prevent calling activation hooks. Default is false.
Returns:
  • (bool|WP_Error) True when finished or WP_Error if there were errors during a plugin activation.
Defined at:



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 plugins file path was invalid.

The execution will be halted as soon as one of the plugins has an error.

Source


<?php
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;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics