file_mod_allowed
云策文档标注
概述
file_mod_allowed 是一个 WordPress 过滤器,用于控制是否允许文件修改操作。它基于 DISALLOW_FILE_MODS 常量定义,并可通过上下文参数进行更细粒度的控制。
关键要点
- 过滤器名称:file_mod_allowed
- 参数:$file_mod_allowed(布尔值,表示是否允许文件修改)和 $context(字符串,表示使用上下文)
- 默认行为:如果 DISALLOW_FILE_MODS 常量未定义或为 false,则允许文件修改
- 引入版本:WordPress 4.8.0
- 相关函数:wp_is_file_mod_allowed() 用于确定是否允许文件修改
注意事项
- 上下文参数 $context 在某些情况下可能具有误导性,例如 capability_update_core 上下文不仅用于检查核心文件,还用于检查主题和插件
原文内容
Filters whether file modifications are allowed.
Parameters
$file_mod_allowedbool-
Whether file modifications are allowed.
$contextstring-
The usage context.
Source
return apply_filters( 'file_mod_allowed', ! defined( 'DISALLOW_FILE_MODS' ) || ! DISALLOW_FILE_MODS, $context );
Changelog
| Version | Description |
|---|---|
| 4.8.0 | Introduced. |
Skip to note 2 content
Cameron Jones
When using this filter, the
capability_update_corecontext is misleading, as it is being passed not just when checking core files, but also when checking themes and plugins.