wp_is_php_version_acceptable
云策文档标注
概述
wp_is_php_version_acceptable 是一个 WordPress 过滤器,用于控制活动 PHP 版本是否被 WordPress 视为可接受。它允许开发者自定义 PHP 版本检查的严格性,但只能加强限制,不能放宽。
关键要点
- 此过滤器用于过滤 PHP 版本是否可接受,返回 false 会在管理员仪表板中触发 PHP 版本警告。
- 过滤器仅在 wordpress.org Serve Happy API 认为 PHP 版本可接受时运行,确保只能使检查更严格,而不能放宽。
- 参数包括 $is_acceptable(布尔值,默认 true)和 $version(字符串,PHP 版本)。
- 在 wp_check_php_version() 函数中使用,用于检查用户是否需要更新 PHP。
- 自 WordPress 5.1.1 版本引入。
原文内容
Filters whether the active PHP version is considered acceptable by WordPress.
Description
Returning false will trigger a PHP version warning to show up in the admin dashboard to administrators.
This filter is only run if the wordpress.org Serve Happy API considers the PHP version acceptable, ensuring that this filter can only make this check stricter, but not loosen it.
Parameters
$is_acceptablebool-
Whether the PHP version is considered acceptable. Default true.
$versionstring-
PHP version checked.
Source
$response['is_acceptable'] = (bool) apply_filters( 'wp_is_php_version_acceptable', true, $version );
Changelog
| Version | Description |
|---|---|
| 5.1.1 | Introduced. |