wp_maybe_grant_site_health_caps

函数


wp_maybe_grant_site_health_caps ( $allcaps, $caps, $args, $user )
参数
  • (bool[])
    $allcaps
    An array of all the user’s capabilities.
    Required:
  • (string[])
    $caps
    Required primitive capabilities for the requested capability.
    Required:
  • (array)
    $args
    { Arguments that accompany the requested capability check. @type string $0 Requested capability. @type int $1 Concerned user ID. @type mixed …$2 Optional second and further parameters, typically object ID. }
    Required:
  • (WP_User)
    $user
    The user object.
    Required:
返回值
  • (bool[]) Filtered array of the user’s capabilities.
定义位置
  • wp-includes/capabilities.php
    , line 1251
引入
5.2.2
弃用

Filters the user capabilities to grant the ‘view_site_health_checks’ capabilities as necessary.

function wp_maybe_grant_site_health_caps( $allcaps, $caps, $args, $user ) {
	if ( ! empty( $allcaps['install_plugins'] ) && ( ! is_multisite() || is_super_admin( $user->ID ) ) ) {
		$allcaps['view_site_health_checks'] = true;
	}

	return $allcaps;
}