检索用户的管理栏显示首选项。
原型
_get_admin_bar_pref( string $context = 'front', int $user )
参数
$context
(string)
(Optional)
此首选项检查的上下文。默认为’前’。不再使用“管理员”偏好设置。
$user
(int)
(Optional)
要检查的用户的ID,当前用户的默认值为0。
返回值
(bool)
管理栏是否应该为此用户显示。
源文件
路径:wp-includes/admin-bar.php
<?php
...
function _get_admin_bar_pref( $context = 'front', $user = 0 ) {
$pref = get_user_option( "show_admin_bar_{$context}", $user );
if ( false === $pref )
return true;
return 'true' === $pref;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/_get_admin_bar_pref/