maybe_disable_automattic_widgets()
云策文档标注
概述
maybe_disable_automattic_widgets() 函数用于禁用已合并到核心的 Automattic widgets 插件。它通过检查并移除活动插件列表中的 widgets.php 来实现。
关键要点
- 函数 maybe_disable_automattic_widgets() 在 WordPress 2.2.0 版本引入。
- 它遍历活动插件列表,查找并移除 widgets.php 插件。
- 使用 __get_option() 获取活动插件,update_option() 更新选项。
代码示例
function maybe_disable_automattic_widgets() {
$plugins = __get_option( 'active_plugins' );
foreach ( (array) $plugins as $plugin ) {
if ( 'widgets.php' === basename( $plugin ) ) {
array_splice( $plugins, array_search( $plugin, $plugins, true ), 1 );
update_option( 'active_plugins', $plugins );
break;
}
}
}
原文内容
Disables the Automattic widgets plugin, which was merged into core.
Source
function maybe_disable_automattic_widgets() {
$plugins = __get_option( 'active_plugins' );
foreach ( (array) $plugins as $plugin ) {
if ( 'widgets.php' === basename( $plugin ) ) {
array_splice( $plugins, array_search( $plugin, $plugins, true ), 1 );
update_option( 'active_plugins', $plugins );
break;
}
}
}
Changelog
| Version | Description |
|---|---|
| 2.2.0 | Introduced. |