wpseek.com
WordPress开发者和主题制作者的搜索引擎
activate_plugins › WordPress Function
Since2.6.0
已弃用n/a
› activate_plugins ( $plugins, $redirect = '', $network_wide = false, $silent = false )
参数: (4) |
|
返回: |
|
定义在: |
|
文档: |
Activates 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.Related Functions: activate_plugin, deactivate_plugins, wp_ajax_activate_plugin, deactivated_plugins_notice, activate_sitewide_plugin
源码
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; }