_get_admin_bar_pref

函式
_get_admin_bar_pref ( $context = 'front', $user = 0 )
Access
Private
引數
  • (string) $context Context of this preference check. Defaults to 'front'. The 'admin' preference is no longer used.
    Required:
    Default: 'front'
  • (int) $user Optional. ID of the user to check, defaults to 0 for current user.
    Required:
返回值
  • (bool) Whether the admin bar should be showing for this user.
定義位置
相關方法
get_admin_page_parentget_admin_urlwp_admin_bar_renderwp_admin_bar_wp_menu_wp_admin_bar_init
引入
3.1.0
棄用
-

_get_admin_bar_pref: 這是一個用來獲取使用者對WordPress管理欄可見性的偏好的函式。它接收一個使用者ID作為引數,並返回使用者的偏好。

檢索使用者的管理欄顯示偏好。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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;
}

常見問題

FAQs
檢視更多 >